1 # -----------------------------------------------------------------------------
4 include $(TOP)/mk/boilerplate.mk
9 H_FILES = $(filter-out gmp.h,$(wildcard *.h)) gmp.h
12 # Options -- if we're building unregisterised, add a couple of -D's
14 ifeq "$(GhcUnregisterised)" "YES"
15 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
19 # Header file built from the configure script's findings
21 H_CONFIG = ghcautoconf.h
22 H_PLATFORM = ghcplatform.h
26 all :: $(H_CONFIG) $(H_PLATFORM)
28 # gmp.h is copied from the GMP directory
29 gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h
32 # The fptools configure script creates the configuration header file and puts it
33 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
34 # definitions to avoid clashes), prepending some make variables specifying cpp
37 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
40 @echo "*** Cross-compiling: please copy $(H_CONFIG) from the target system"
45 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
47 $(H_CONFIG) : Makefile
48 @echo "#ifndef __GHCAUTOCONF_H__" >$@
49 @echo "#define __GHCAUTOCONF_H__" >>$@
50 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
51 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
52 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
57 $(H_PLATFORM) : Makefile
58 @echo "Creating $@..."
60 @echo "#ifndef __GHCPLATFORM_H__" >$@
61 @echo "#define __GHCPLATFORM_H__" >>$@
63 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
64 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
66 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
67 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
69 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
70 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
71 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
72 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
74 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
75 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
76 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
77 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
78 ifeq "$(HostOS_CPP)" "irix"
79 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
80 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
84 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
85 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
86 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
87 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
89 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
90 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
91 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
92 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
93 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
94 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
95 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
96 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
98 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
101 # ---------------------------------------------------------------------------
102 # Make DerivedConstants.h for the compiler
104 all :: DerivedConstants.h
106 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
109 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
114 mkDerivedConstants.c : $(H_CONFIG)
116 mkDerivedConstantsHdr : mkDerivedConstants.o
117 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
119 DerivedConstants.h : mkDerivedConstantsHdr
120 ./mkDerivedConstantsHdr >$@
124 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
126 # -----------------------------------------------------------------------------
129 all :: GHCConstants.h
131 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
134 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
139 mkGHCConstants : mkGHCConstants.o
140 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
142 mkGHCConstants.o : mkDerivedConstants.c
143 $(CC) -o $@ -c $< -DGEN_HASKELL
145 GHCConstants.h : mkGHCConstants
150 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
152 # ---------------------------------------------------------------------------
155 # Need config.h to make dependencies in the runtime system source.
160 # Install all header files
162 # Hackily set the install destination here:
164 # Note: we keep per-platform copies of all the include files
165 # (ditto for interface files). This is not *really* needed, but
166 # it gives (perhaps) a cleaner binary dist structure..might change.
168 override datadir:=$(libdir)/include
169 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
172 # `make clean' settings:
174 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
177 # Finally, slurp in the standard targets.
179 include $(TOP)/mk/target.mk