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 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
39 $(H_CONFIG) : Makefile
40 @echo "#ifndef __GHCAUTOCONF_H__" >$@
41 @echo "#define __GHCAUTOCONF_H__" >>$@
42 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
43 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
44 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
47 $(H_PLATFORM) : Makefile
48 @echo "Creating $@..."
50 @echo "#ifndef __GHCPLATFORM_H__" >$@
51 @echo "#define __GHCPLATFORM_H__" >>$@
53 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
54 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
56 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
57 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
59 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
60 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
61 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
62 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
64 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
65 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
66 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
67 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
68 ifeq "$(HostOS_CPP)" "irix"
69 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
70 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
74 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
75 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
76 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
77 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
79 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
80 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
81 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
82 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
83 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
84 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
85 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
86 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
88 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
91 # ---------------------------------------------------------------------------
92 # Make DerivedConstants.h for the compiler
94 all :: DerivedConstants.h
96 mkDerivedConstants.c : $(H_CONFIG)
98 mkDerivedConstantsHdr : mkDerivedConstants.o
99 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
101 DerivedConstants.h : mkDerivedConstantsHdr
102 ./mkDerivedConstantsHdr >$@
104 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
106 # -----------------------------------------------------------------------------
109 all :: GHCConstants.h
111 mkGHCConstants : mkGHCConstants.o
112 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
114 mkGHCConstants.o : mkDerivedConstants.c
115 $(CC) -o $@ -c $< -DGEN_HASKELL
117 GHCConstants.h : mkGHCConstants
120 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
122 # ---------------------------------------------------------------------------
125 # Need config.h to make dependencies in the runtime system source.
130 # Install all header files
132 # Hackily set the install destination here:
134 # Note: we keep per-platform copies of all the include files
135 # (ditto for interface files). This is not *really* needed, but
136 # it gives (perhaps) a cleaner binary dist structure..might change.
138 override datadir:=$(libdir)/include
139 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
142 # `make clean' settings:
144 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
147 # Finally, slurp in the standard targets.
149 include $(TOP)/mk/target.mk