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
20 ifneq "$(GhcWithSMP)" "YES"
21 SRC_CC_OPTS += -DNOSMP
25 # Header file built from the configure script's findings
27 H_CONFIG = ghcautoconf.h
28 H_PLATFORM = ghcplatform.h
32 all :: $(H_CONFIG) $(H_PLATFORM)
34 # gmp.h is copied from the GMP directory
35 gmp.h : $(FPTOOLS_TOP)/rts/gmp/gmp.h
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 "#ifndef __GHCAUTOCONF_H__" >$@
55 @echo "#define __GHCAUTOCONF_H__" >>$@
56 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
57 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
58 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
63 $(H_PLATFORM) : Makefile
64 @echo "Creating $@..."
66 @echo "#ifndef __GHCPLATFORM_H__" >$@
67 @echo "#define __GHCPLATFORM_H__" >>$@
69 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
70 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
72 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
73 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
75 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
76 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
77 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
78 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
80 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
81 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
82 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
83 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
84 ifeq "$(HostOS_CPP)" "irix"
85 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
86 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
90 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
91 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
92 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
93 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
95 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
96 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
97 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
98 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
99 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
100 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
101 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
102 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
104 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
107 # ---------------------------------------------------------------------------
108 # Make DerivedConstants.h for the compiler
110 all :: DerivedConstants.h
112 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
115 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
120 mkDerivedConstants.c : $(H_CONFIG) $(H_PLATFORM)
122 mkDerivedConstantsHdr : mkDerivedConstants.o
123 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
125 DerivedConstants.h : mkDerivedConstantsHdr
126 ./mkDerivedConstantsHdr >$@
130 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
132 # -----------------------------------------------------------------------------
135 all :: GHCConstants.h
137 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
140 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
145 mkGHCConstants : mkGHCConstants.o
146 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
148 mkGHCConstants.o : mkDerivedConstants.c
149 $(CC) -o $@ $(CC_OPTS) -c $< -DGEN_HASKELL
151 GHCConstants.h : mkGHCConstants
156 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
158 # ---------------------------------------------------------------------------
161 # Need config.h to make dependencies in the runtime system source.
166 # Install all header files
168 # Hackily set the install destination here:
170 # Note: we keep per-platform copies of all the include files
171 # (ditto for interface files). This is not *really* needed, but
172 # it gives (perhaps) a cleaner binary dist structure..might change.
174 override datadir:=$(libdir)/include
175 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
178 # `make clean' settings:
180 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
183 # Finally, slurp in the standard targets.
185 include $(TOP)/mk/target.mk