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 -I../gmp/gmpbuild
32 ifneq "$(GhcWithSMP)" "YES"
33 SRC_CC_OPTS += -DNOSMP
36 all :: $(H_CONFIG) $(H_PLATFORM)
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
43 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
46 @echo "*** Cross-compiling: please copy $(H_CONFIG) from the target system"
51 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
53 $(H_CONFIG) : Makefile
54 @echo "Creating $@..."
55 @echo "#ifndef __GHCAUTOCONF_H__" >$@
56 @echo "#define __GHCAUTOCONF_H__" >>$@
57 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
58 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
59 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
64 $(H_PLATFORM) : Makefile
65 @echo "Creating $@..."
67 @echo "#ifndef __GHCPLATFORM_H__" >$@
68 @echo "#define __GHCPLATFORM_H__" >>$@
70 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
71 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
73 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
74 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
76 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
77 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
78 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
79 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
81 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
82 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
83 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
84 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
85 ifeq "$(HostOS_CPP)" "irix"
86 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
87 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
91 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
92 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
93 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
94 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
96 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
97 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
98 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
99 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
100 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
101 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
102 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
103 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
105 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
108 # ---------------------------------------------------------------------------
109 # Make DerivedConstants.h for the compiler
111 all :: DerivedConstants.h
113 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
116 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
121 mkDerivedConstants.c : $(H_CONFIG) $(H_PLATFORM)
123 mkDerivedConstantsHdr : mkDerivedConstants.o
124 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
126 DerivedConstants.h : mkDerivedConstantsHdr
127 ./mkDerivedConstantsHdr >$@
131 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
133 # -----------------------------------------------------------------------------
136 all :: GHCConstants.h
138 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
141 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
146 mkGHCConstants : mkGHCConstants.o
147 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
149 mkGHCConstants.o : mkDerivedConstants.c
150 $(CC) -o $@ $(CC_OPTS) -c $< -DGEN_HASKELL
152 GHCConstants.h : mkGHCConstants
157 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
161 # ---------------------------------------------------------------------------
165 # Install all header files
167 # Hackily set the install destination here:
169 # Note: we keep per-platform copies of all the include files
170 # (ditto for interface files). This is not *really* needed, but
171 # it gives (perhaps) a cleaner binary dist structure..might change.
173 override datadir:=$(libdir)/include
174 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
177 $(INSTALL_DIR) $(BIN_DIST_DIR)/includes
178 $(INSTALL_DATA) Makefile $(BIN_DIST_DIR)/includes/
179 $(INSTALL_DATA) $(INSTALL_DATAS) $(BIN_DIST_DIR)/includes/
182 # `make clean' settings:
184 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
187 # Finally, slurp in the standard targets.
189 include $(TOP)/mk/target.mk
191 # We need DerivedConstants.h in order to make dependencies in the RTS
192 # sources, so 'make boot' here should behave like 'make all'.
194 # However, note that we should do this only *after* 'make boot' has
195 # created .depend in here; otherwise an out-of-date .depend file can
196 # prevent 'make boot' from working, requiring manual removal of
197 # .depend (see #1095). This is why the following target comes *after*
198 # target.mk is included above (target.mk contains "boot :: depend").