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 gmp.h $(H_CONFIG) $(H_PLATFORM),$(wildcard *.h)) gmp.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
32 ifneq "$(GhcWithSMP)" "YES"
33 SRC_CC_OPTS += -DNOSMP
38 all :: $(H_CONFIG) $(H_PLATFORM)
40 # gmp.h is copied from the GMP directory
41 gmp.h : $(FPTOOLS_TOP)/rts/gmp/gmp.h
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
49 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
52 @echo "*** Cross-compiling: please copy $(H_CONFIG) from the target system"
57 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
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__ */" >> $@
70 $(H_PLATFORM) : Makefile
71 @echo "Creating $@..."
73 @echo "#ifndef __GHCPLATFORM_H__" >$@
74 @echo "#define __GHCPLATFORM_H__" >>$@
76 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
77 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
79 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
80 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
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)\"" >> $@
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" >> $@
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)\"" >> $@
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" >> $@
111 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
114 # ---------------------------------------------------------------------------
115 # Make DerivedConstants.h for the compiler
117 all :: DerivedConstants.h
119 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
122 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
127 mkDerivedConstants.c : $(H_CONFIG) $(H_PLATFORM)
129 mkDerivedConstantsHdr : mkDerivedConstants.o
130 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
132 DerivedConstants.h : mkDerivedConstantsHdr
133 ./mkDerivedConstantsHdr >$@
137 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
139 # -----------------------------------------------------------------------------
142 all :: GHCConstants.h
144 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
147 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
152 mkGHCConstants : mkGHCConstants.o
153 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
155 mkGHCConstants.o : mkDerivedConstants.c
156 $(CC) -o $@ $(CC_OPTS) -c $< -DGEN_HASKELL
158 GHCConstants.h : mkGHCConstants
163 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
167 # ---------------------------------------------------------------------------
171 # Install all header files
173 # Hackily set the install destination here:
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.
179 override datadir:=$(libdir)/include
180 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
183 $(INSTALL_DIR) $(BIN_DIST_DIR)/includes
184 $(INSTALL_DATA) Makefile $(BIN_DIST_DIR)/includes/
185 $(INSTALL_DATA) $(INSTALL_DATAS) $(BIN_DIST_DIR)/includes/
188 # `make clean' settings:
190 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
193 # Finally, slurp in the standard targets.
195 include $(TOP)/mk/target.mk
197 # We need DerivedConstants.h in order to make dependencies in the RTS
198 # sources, so 'make boot' here should behave like 'make all'.
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").