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