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