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
18 SRC_CC_OPTS += -I. -I../rts
21 # Header file built from the configure script's findings
23 H_CONFIG = ghcautoconf.h
24 H_PLATFORM = ghcplatform.h
28 all :: $(H_CONFIG) $(H_PLATFORM)
30 # gmp.h is copied from the GMP directory
31 gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h
34 # The fptools configure script creates the configuration header file and puts it
35 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
36 # definitions to avoid clashes), prepending some make variables specifying cpp
39 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
42 @echo "*** Cross-compiling: please copy $(H_CONFIG) from the target system"
47 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
49 $(H_CONFIG) : Makefile
50 @echo "#ifndef __GHCAUTOCONF_H__" >$@
51 @echo "#define __GHCAUTOCONF_H__" >>$@
52 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
53 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
54 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
59 $(H_PLATFORM) : Makefile
60 @echo "Creating $@..."
62 @echo "#ifndef __GHCPLATFORM_H__" >$@
63 @echo "#define __GHCPLATFORM_H__" >>$@
65 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
66 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
68 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
69 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
71 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
72 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
73 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
74 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
76 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
77 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
78 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
79 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
80 ifeq "$(HostOS_CPP)" "irix"
81 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
82 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
86 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
87 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
88 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
89 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
91 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
92 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
93 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
94 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
95 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
96 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
97 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
98 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
100 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
103 # ---------------------------------------------------------------------------
104 # Make DerivedConstants.h for the compiler
106 all :: DerivedConstants.h
108 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
111 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
116 mkDerivedConstants.c : $(H_CONFIG)
118 mkDerivedConstantsHdr : mkDerivedConstants.o
119 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
121 DerivedConstants.h : mkDerivedConstantsHdr
122 ./mkDerivedConstantsHdr >$@
126 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
128 # -----------------------------------------------------------------------------
131 all :: GHCConstants.h
133 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
136 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
141 mkGHCConstants : mkGHCConstants.o
142 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
144 mkGHCConstants.o : mkDerivedConstants.c
145 $(CC) -o $@ $(CC_OPTS) -c $< -DGEN_HASKELL
147 GHCConstants.h : mkGHCConstants
152 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
154 # ---------------------------------------------------------------------------
157 # Need config.h to make dependencies in the runtime system source.
162 # Install all header files
164 # Hackily set the install destination here:
166 # Note: we keep per-platform copies of all the include files
167 # (ditto for interface files). This is not *really* needed, but
168 # it gives (perhaps) a cleaner binary dist structure..might change.
170 override datadir:=$(libdir)/include
171 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
174 # `make clean' settings:
176 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
179 # Finally, slurp in the standard targets.
181 include $(TOP)/mk/target.mk