Massive patch for the first months work adding System FC to GHC #15
[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 -- if we're building unregisterised, add a couple of -D's
13 #
14 ifeq "$(GhcUnregisterised)" "YES"
15 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
16 endif
17
18 SRC_CC_OPTS += -I. -I../rts
19
20 ifneq "$(GhcWithSMP)" "YES"
21 SRC_CC_OPTS += -DNOSMP
22 endif
23
24 #
25 # Header file built from the configure script's findings
26 #
27 H_CONFIG   = ghcautoconf.h
28 H_PLATFORM = ghcplatform.h
29
30 boot :: gmp.h
31
32 all :: $(H_CONFIG) $(H_PLATFORM)
33
34 # gmp.h is copied from the GMP directory
35 gmp.h : $(FPTOOLS_TOP)/rts/gmp/gmp.h
36         $(CP) $< $@
37
38 # The fptools configure script creates the configuration header file and puts it
39 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
40 # definitions to avoid clashes), prepending some make variables specifying cpp
41 # platform variables.
42
43 ifneq "$(TARGETPLATFORM)"  "$(HOSTPLATFORM)"
44
45 $(H_CONFIG) :
46         @echo "*** Cross-compiling: please copy $(H_CONFIG) from the target system"
47         @exit 1
48
49 else
50
51 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
52
53 $(H_CONFIG) : Makefile
54         @echo "#ifndef __GHCAUTOCONF_H__"  >$@
55         @echo "#define __GHCAUTOCONF_H__" >>$@
56 #       Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
57         @sed 's,^\([     ]*\)#[  ]*define[       ][      ]*\(PACKAGE_[A-Z]*\)[   ][     ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
58         @echo "#endif /* __GHCAUTOCONF_H__ */"          >> $@
59         @echo "Done."
60
61 endif
62
63 $(H_PLATFORM) : Makefile
64         @echo "Creating $@..."
65         @$(RM) $@
66         @echo "#ifndef __GHCPLATFORM_H__"  >$@
67         @echo "#define __GHCPLATFORM_H__" >>$@
68         @echo >> $@
69         @echo "#define BuildPlatform_TYPE  $(HostPlatform_CPP)" >> $@
70         @echo "#define HostPlatform_TYPE   $(TargetPlatform_CPP)" >> $@
71         @echo >> $@
72         @echo "#define $(HostPlatform_CPP)_BUILD  1" >> $@
73         @echo "#define $(TargetPlatform_CPP)_HOST  1" >> $@
74         @echo >> $@
75         @echo "#define $(HostArch_CPP)_BUILD_ARCH  1" >> $@
76         @echo "#define $(TargetArch_CPP)_HOST_ARCH  1" >> $@
77         @echo "#define BUILD_ARCH  \"$(HostArch_CPP)\"" >> $@
78         @echo "#define HOST_ARCH  \"$(TargetArch_CPP)\"" >> $@
79         @echo >> $@
80         @echo "#define $(HostOS_CPP)_BUILD_OS  1" >> $@
81         @echo "#define $(TargetOS_CPP)_HOST_OS  1" >> $@
82         @echo "#define BUILD_OS  \"$(HostOS_CPP)\"" >> $@
83         @echo "#define HOST_OS  \"$(TargetOS_CPP)\"" >> $@
84 ifeq "$(HostOS_CPP)" "irix"
85         @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@  
86         @echo "#define $(IRIX_MAJOR)_HOST_OS  1" >> $@  
87         @echo "#endif" >> $@  
88 endif
89         @echo >> $@
90         @echo "#define $(HostVendor_CPP)_BUILD_VENDOR  1" >> $@
91         @echo "#define $(TargetVendor_CPP)_HOST_VENDOR  1" >> $@
92         @echo "#define BUILD_VENDOR  \"$(HostVendor_CPP)\"" >> $@
93         @echo "#define HOST_VENDOR  \"$(TargetVendor_CPP)\"" >> $@
94         @echo >> $@
95         @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
96         @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
97         @echo "#define $(TargetPlatform_CPP)_TARGET  1" >> $@
98         @echo "#define $(TargetArch_CPP)_TARGET_ARCH  1" >> $@
99         @echo "#define TARGET_ARCH  \"$(TargetArch_CPP)\"" >> $@
100         @echo "#define $(TargetOS_CPP)_TARGET_OS  1" >> $@  
101         @echo "#define TARGET_OS  \"$(TargetOS_CPP)\"" >> $@
102         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
103         @echo >> $@
104         @echo "#endif /* __GHCPLATFORM_H__ */"          >> $@
105         @echo "Done."
106
107 # ---------------------------------------------------------------------------
108 # Make DerivedConstants.h for the compiler
109
110 all :: DerivedConstants.h
111
112 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
113
114 DerivedConstants.h :
115         @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
116         @exit 1
117
118 else
119
120 mkDerivedConstants.c : $(H_CONFIG) $(H_PLATFORM)
121
122 mkDerivedConstantsHdr : mkDerivedConstants.o
123         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
124
125 DerivedConstants.h : mkDerivedConstantsHdr
126         ./mkDerivedConstantsHdr >$@
127
128 endif
129
130 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
131
132 # -----------------------------------------------------------------------------
133 #
134
135 all :: GHCConstants.h
136
137 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
138
139 GHCConstants.h :
140         @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
141         @exit 1
142
143 else
144
145 mkGHCConstants : mkGHCConstants.o
146         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
147
148 mkGHCConstants.o : mkDerivedConstants.c
149         $(CC) -o $@ $(CC_OPTS) -c $<  -DGEN_HASKELL
150
151 GHCConstants.h : mkGHCConstants
152         ./mkGHCConstants >$@
153
154 endif
155
156 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
157
158 # ---------------------------------------------------------------------------
159 # boot setup:
160 #
161 # Need config.h to make dependencies in the runtime system source.
162 #
163 boot :: all
164
165 #
166 # Install all header files
167 #
168 # Hackily set the install destination here:
169 #
170 # Note: we keep per-platform copies of all the include files
171 # (ditto for interface files). This is not *really* needed, but
172 # it gives (perhaps) a cleaner binary dist structure..might change.
173 #
174 override datadir:=$(libdir)/include
175 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
176
177 #
178 # `make clean' settings:
179 #
180 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
181
182 #
183 # Finally, slurp in the standard targets.
184 #
185 include $(TOP)/mk/target.mk