1 # -----------------------------------------------------------------------------
4 include $(TOP)/mk/boilerplate.mk
7 # Header files built from the configure script's findings
9 H_CONFIG = ghcautoconf.h
10 H_PLATFORM = ghcplatform.h
15 H_FILES = $(filter-out $(H_CONFIG) $(H_PLATFORM),$(wildcard *.h))
17 ifneq "$(DOING_BIN_DIST)" "YES"
22 ifeq "$(GhcUnregisterised)" "YES"
23 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
26 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
27 SRC_CC_OPTS += -DTABLES_NEXT_TO_CODE
30 SRC_CC_OPTS += -I. -I../rts
31 ifeq "$(HaveLibGmp)" "YES"
32 ifneq "$(GMP_INCLUDE_DIRS)" ""
33 SRC_CC_OPTS += -I$(GMP_INCLUDE_DIRS)
36 SRC_CC_OPTS += -I../gmp/gmpbuild
39 ifneq "$(GhcWithSMP)" "YES"
40 SRC_CC_OPTS += -DNOSMP
43 all :: $(H_CONFIG) $(H_PLATFORM)
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
50 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
53 @echo "*** Cross-compiling: please copy $(H_CONFIG) from the target system"
58 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
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__ */" >> $@
71 $(H_PLATFORM) : Makefile
72 @echo "Creating $@..."
74 @echo "#ifndef __GHCPLATFORM_H__" >$@
75 @echo "#define __GHCPLATFORM_H__" >>$@
77 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
78 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
80 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
81 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
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)\"" >> $@
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" >> $@
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)\"" >> $@
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" >> $@
112 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
115 # ---------------------------------------------------------------------------
116 # Make DerivedConstants.h for the compiler
118 all :: DerivedConstants.h
120 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
123 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
128 mkDerivedConstants.c : $(H_CONFIG) $(H_PLATFORM)
130 mkDerivedConstantsHdr : mkDerivedConstants.o
131 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
133 DerivedConstants.h : mkDerivedConstantsHdr
134 ./mkDerivedConstantsHdr >$@
138 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
140 # -----------------------------------------------------------------------------
143 all :: GHCConstants.h
145 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
148 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
153 mkGHCConstants : mkGHCConstants.o
154 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
156 mkGHCConstants.o : mkDerivedConstants.c
157 $(CC) -o $@ $(CC_OPTS) -c $< -DGEN_HASKELL
159 GHCConstants.h : mkGHCConstants
164 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
168 # ---------------------------------------------------------------------------
172 # Install all header files
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.
178 INSTALL_HEADERS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
180 BINDIST_EXTRAS += $(INSTALL_HEADERS)
181 include $(TOP)/mk/bindist.mk
184 # `make clean' settings:
186 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
189 # Finally, slurp in the standard targets.
191 include $(TOP)/mk/target.mk
193 # We need DerivedConstants.h in order to make dependencies in the RTS
194 # sources, so 'make boot' here should behave like 'make all'.
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").