Partially fix GHCi when unregisterised
[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 "$(GhcWithNoRegs)" "YES"
15 SRC_CC_OPTS += -DNO_REGS
16 endif
17
18 ifeq "$(GhcWithMiniInterpreter)" "YES"
19 SRC_CC_OPTS += -DUSE_MINIINTERPRETER
20 endif
21
22 ifeq "$(GhcWithTablesNextToCode)" "YES"
23 SRC_CC_OPTS += -DTABLES_NEXT_TO_CODE
24 endif
25
26 SRC_CC_OPTS += -I. -I../rts
27
28 ifneq "$(GhcWithSMP)" "YES"
29 SRC_CC_OPTS += -DNOSMP
30 endif
31
32 #
33 # Header file built from the configure script's findings
34 #
35 H_CONFIG   = ghcautoconf.h
36 H_PLATFORM = ghcplatform.h
37
38 boot :: gmp.h
39
40 all :: $(H_CONFIG) $(H_PLATFORM)
41
42 # gmp.h is copied from the GMP directory
43 gmp.h : $(FPTOOLS_TOP)/rts/gmp/gmp.h
44         $(CP) $< $@
45
46 # The fptools configure script creates the configuration header file and puts it
47 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
48 # definitions to avoid clashes), prepending some make variables specifying cpp
49 # platform variables.
50
51 ifneq "$(TARGETPLATFORM)"  "$(HOSTPLATFORM)"
52
53 $(H_CONFIG) :
54         @echo "*** Cross-compiling: please copy $(H_CONFIG) from the target system"
55         @exit 1
56
57 else
58
59 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
60
61 $(H_CONFIG) : Makefile
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 # ---------------------------------------------------------------------------
167 # boot setup:
168 #
169 # Need config.h to make dependencies in the runtime system source.
170 #
171 boot :: all
172
173 #
174 # Install all header files
175 #
176 # Hackily set the install destination here:
177 #
178 # Note: we keep per-platform copies of all the include files
179 # (ditto for interface files). This is not *really* needed, but
180 # it gives (perhaps) a cleaner binary dist structure..might change.
181 #
182 override datadir:=$(libdir)/include
183 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
184
185 #
186 # `make clean' settings:
187 #
188 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
189
190 #
191 # Finally, slurp in the standard targets.
192 #
193 include $(TOP)/mk/target.mk