1 # -----------------------------------------------------------------------------
4 include $(TOP)/mk/boilerplate.mk
9 H_FILES = $(filter-out gmp.h,$(wildcard *.h)) gmp.h
14 ifeq "$(GhcUnregisterised)" "YES"
15 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
18 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
19 SRC_CC_OPTS += -DTABLES_NEXT_TO_CODE
22 SRC_CC_OPTS += -I. -I../rts
24 ifneq "$(GhcWithSMP)" "YES"
25 SRC_CC_OPTS += -DNOSMP
29 # Header file built from the configure script's findings
31 H_CONFIG = ghcautoconf.h
32 H_PLATFORM = ghcplatform.h
36 all :: $(H_CONFIG) $(H_PLATFORM)
38 # gmp.h is copied from the GMP directory
39 gmp.h : $(FPTOOLS_TOP)/rts/gmp/gmp.h
42 # The fptools configure script creates the configuration header file and puts it
43 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
44 # definitions to avoid clashes), prepending some make variables specifying cpp
47 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
50 @echo "*** Cross-compiling: please copy $(H_CONFIG) from the target system"
55 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
57 $(H_CONFIG) : Makefile
58 @echo "#ifndef __GHCAUTOCONF_H__" >$@
59 @echo "#define __GHCAUTOCONF_H__" >>$@
60 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
61 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
62 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
67 $(H_PLATFORM) : Makefile
68 @echo "Creating $@..."
70 @echo "#ifndef __GHCPLATFORM_H__" >$@
71 @echo "#define __GHCPLATFORM_H__" >>$@
73 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
74 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
76 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
77 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
79 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
80 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
81 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
82 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
84 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
85 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
86 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
87 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
88 ifeq "$(HostOS_CPP)" "irix"
89 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
90 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
94 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
95 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
96 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
97 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
99 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
100 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
101 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
102 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
103 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
104 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
105 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
106 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
108 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
111 # ---------------------------------------------------------------------------
112 # Make DerivedConstants.h for the compiler
114 all :: DerivedConstants.h
116 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
119 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
124 mkDerivedConstants.c : $(H_CONFIG) $(H_PLATFORM)
126 mkDerivedConstantsHdr : mkDerivedConstants.o
127 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
129 DerivedConstants.h : mkDerivedConstantsHdr
130 ./mkDerivedConstantsHdr >$@
134 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
136 # -----------------------------------------------------------------------------
139 all :: GHCConstants.h
141 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
144 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
149 mkGHCConstants : mkGHCConstants.o
150 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
152 mkGHCConstants.o : mkDerivedConstants.c
153 $(CC) -o $@ $(CC_OPTS) -c $< -DGEN_HASKELL
155 GHCConstants.h : mkGHCConstants
160 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
162 # ---------------------------------------------------------------------------
165 # Need config.h to make dependencies in the runtime system source.
170 # Install all header files
172 # Hackily set the install destination here:
174 # Note: we keep per-platform copies of all the include files
175 # (ditto for interface files). This is not *really* needed, but
176 # it gives (perhaps) a cleaner binary dist structure..might change.
178 override datadir:=$(libdir)/include
179 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
182 # `make clean' settings:
184 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
187 # Finally, slurp in the standard targets.
189 include $(TOP)/mk/target.mk