Add extra WARN test
[ghc-hetmet.git] / includes / Makefile
1 # -----------------------------------------------------------------------------
2
3 TOP = ..
4 include $(TOP)/mk/boilerplate.mk
5
6 #
7 # Header files built from the configure script's findings
8 #
9 H_CONFIG   = ghcautoconf.h
10 H_PLATFORM = ghcplatform.h
11
12 #
13 # All header files
14 #
15 H_FILES = $(filter-out $(H_CONFIG) $(H_PLATFORM),$(wildcard *.h))
16
17 ifneq "$(DOING_BIN_DIST)" "YES"
18
19 #
20 # Options
21 #
22 ifeq "$(GhcUnregisterised)" "YES"
23 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
24 endif
25
26 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
27 SRC_CC_OPTS += -DTABLES_NEXT_TO_CODE
28 endif
29
30 SRC_CC_OPTS += -I. -I../rts
31 ifeq "$(HaveLibGmp)" "YES"
32 ifneq "$(GMP_INCLUDE_DIRS)" ""
33 SRC_CC_OPTS += -I$(GMP_INCLUDE_DIRS)
34 endif
35 else
36 SRC_CC_OPTS += -I../gmp/gmpbuild
37 endif
38
39 ifneq "$(GhcWithSMP)" "YES"
40 SRC_CC_OPTS += -DNOSMP
41 endif
42
43 all :: $(H_CONFIG) $(H_PLATFORM)
44
45 # The fptools configure script creates the configuration header file and puts it
46 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
47 # definitions to avoid clashes), prepending some make variables specifying cpp
48 # platform variables.
49
50 ifneq "$(TARGETPLATFORM)"  "$(HOSTPLATFORM)"
51
52 $(H_CONFIG) :
53         @echo "*** Cross-compiling: please copy $(H_CONFIG) from the target system"
54         @exit 1
55
56 else
57
58 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
59
60 $(H_CONFIG) : Makefile
61         @echo "Creating $@..."
62         @echo "#ifndef __GHCAUTOCONF_H__"  >$@
63         @echo "#define __GHCAUTOCONF_H__" >>$@
64 #       Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
65         @sed 's,^\([     ]*\)#[  ]*define[       ][      ]*\(PACKAGE_[A-Z]*\)[   ][     ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
66         @echo "#endif /* __GHCAUTOCONF_H__ */"          >> $@
67         @echo "Done."
68
69 endif
70
71 $(H_PLATFORM) : Makefile
72         @echo "Creating $@..."
73         @$(RM) $@
74         @echo "#ifndef __GHCPLATFORM_H__"  >$@
75         @echo "#define __GHCPLATFORM_H__" >>$@
76         @echo >> $@
77         @echo "#define BuildPlatform_TYPE  $(HostPlatform_CPP)" >> $@
78         @echo "#define HostPlatform_TYPE   $(TargetPlatform_CPP)" >> $@
79         @echo >> $@
80         @echo "#define $(HostPlatform_CPP)_BUILD  1" >> $@
81         @echo "#define $(TargetPlatform_CPP)_HOST  1" >> $@
82         @echo >> $@
83         @echo "#define $(HostArch_CPP)_BUILD_ARCH  1" >> $@
84         @echo "#define $(TargetArch_CPP)_HOST_ARCH  1" >> $@
85         @echo "#define BUILD_ARCH  \"$(HostArch_CPP)\"" >> $@
86         @echo "#define HOST_ARCH  \"$(TargetArch_CPP)\"" >> $@
87         @echo >> $@
88         @echo "#define $(HostOS_CPP)_BUILD_OS  1" >> $@
89         @echo "#define $(TargetOS_CPP)_HOST_OS  1" >> $@
90         @echo "#define BUILD_OS  \"$(HostOS_CPP)\"" >> $@
91         @echo "#define HOST_OS  \"$(TargetOS_CPP)\"" >> $@
92 ifeq "$(HostOS_CPP)" "irix"
93         @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@  
94         @echo "#define $(IRIX_MAJOR)_HOST_OS  1" >> $@  
95         @echo "#endif" >> $@  
96 endif
97         @echo >> $@
98         @echo "#define $(HostVendor_CPP)_BUILD_VENDOR  1" >> $@
99         @echo "#define $(TargetVendor_CPP)_HOST_VENDOR  1" >> $@
100         @echo "#define BUILD_VENDOR  \"$(HostVendor_CPP)\"" >> $@
101         @echo "#define HOST_VENDOR  \"$(TargetVendor_CPP)\"" >> $@
102         @echo >> $@
103         @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
104         @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
105         @echo "#define $(TargetPlatform_CPP)_TARGET  1" >> $@
106         @echo "#define $(TargetArch_CPP)_TARGET_ARCH  1" >> $@
107         @echo "#define TARGET_ARCH  \"$(TargetArch_CPP)\"" >> $@
108         @echo "#define $(TargetOS_CPP)_TARGET_OS  1" >> $@  
109         @echo "#define TARGET_OS  \"$(TargetOS_CPP)\"" >> $@
110         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
111         @echo >> $@
112         @echo "#endif /* __GHCPLATFORM_H__ */"          >> $@
113         @echo "Done."
114
115 # ---------------------------------------------------------------------------
116 # Make DerivedConstants.h for the compiler
117
118 all :: DerivedConstants.h
119
120 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
121
122 DerivedConstants.h :
123         @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
124         @exit 1
125
126 else
127
128 mkDerivedConstants.c : $(H_CONFIG) $(H_PLATFORM)
129
130 mkDerivedConstantsHdr : mkDerivedConstants.o
131         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
132
133 DerivedConstants.h : mkDerivedConstantsHdr
134         ./mkDerivedConstantsHdr >$@
135
136 endif
137
138 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
139
140 # -----------------------------------------------------------------------------
141 #
142
143 all :: GHCConstants.h
144
145 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
146
147 GHCConstants.h :
148         @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
149         @exit 1
150
151 else
152
153 mkGHCConstants : mkGHCConstants.o
154         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
155
156 mkGHCConstants.o : mkDerivedConstants.c
157         $(CC) -o $@ $(CC_OPTS) -c $<  -DGEN_HASKELL
158
159 GHCConstants.h : mkGHCConstants
160         ./mkGHCConstants >$@
161
162 endif
163
164 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
165
166 endif
167
168 # ---------------------------------------------------------------------------
169 # boot setup:
170 #
171 #
172 # Install all header files
173 #
174 # Note: we keep per-platform copies of all the include files
175 # (ditto for interface files). This is not *really* needed, but
176 # it gives (perhaps) a cleaner binary dist structure..might change.
177 #
178 INSTALL_HEADERS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
179
180 BINDIST_EXTRAS += $(INSTALL_HEADERS)
181 include $(TOP)/mk/bindist.mk
182
183 #
184 # `make clean' settings:
185 #
186 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
187
188 #
189 # Finally, slurp in the standard targets.
190 #
191 include $(TOP)/mk/target.mk
192
193 # We need DerivedConstants.h in order to make dependencies in the RTS
194 # sources, so 'make boot' here should behave like 'make all'.
195 #
196 # However, note that we should do this only *after* 'make boot' has
197 # created .depend in here; otherwise an out-of-date .depend file can
198 # prevent 'make boot' from working, requiring manual removal of
199 # .depend (see #1095).  This is why the following target comes *after*
200 # target.mk is included above (target.mk contains "boot :: depend").
201 #
202 boot :: all