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 "Creating $@..."
59 @echo "#ifndef __GHCAUTOCONF_H__" >$@
60 @echo "#define __GHCAUTOCONF_H__" >>$@
61 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
62 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
63 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
68 $(H_PLATFORM) : Makefile
69 @echo "Creating $@..."
71 @echo "#ifndef __GHCPLATFORM_H__" >$@
72 @echo "#define __GHCPLATFORM_H__" >>$@
74 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
75 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
77 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
78 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
80 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
81 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
82 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
83 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
85 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
86 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
87 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
88 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
89 ifeq "$(HostOS_CPP)" "irix"
90 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
91 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
95 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
96 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
97 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
98 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
100 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
101 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
102 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
103 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
104 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
105 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
106 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
107 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
109 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
112 # ---------------------------------------------------------------------------
113 # Make DerivedConstants.h for the compiler
115 all :: DerivedConstants.h
117 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
120 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
125 mkDerivedConstants.c : $(H_CONFIG) $(H_PLATFORM)
127 mkDerivedConstantsHdr : mkDerivedConstants.o
128 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
130 DerivedConstants.h : mkDerivedConstantsHdr
131 ./mkDerivedConstantsHdr >$@
135 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
137 # -----------------------------------------------------------------------------
140 all :: GHCConstants.h
142 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
145 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
150 mkGHCConstants : mkGHCConstants.o
151 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
153 mkGHCConstants.o : mkDerivedConstants.c
154 $(CC) -o $@ $(CC_OPTS) -c $< -DGEN_HASKELL
156 GHCConstants.h : mkGHCConstants
161 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
163 # ---------------------------------------------------------------------------
167 # Install all header files
169 # Hackily set the install destination here:
171 # Note: we keep per-platform copies of all the include files
172 # (ditto for interface files). This is not *really* needed, but
173 # it gives (perhaps) a cleaner binary dist structure..might change.
175 override datadir:=$(libdir)/include
176 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
179 # `make clean' settings:
181 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
184 # Finally, slurp in the standard targets.
186 include $(TOP)/mk/target.mk
188 # We need DerivedConstants.h in order to make dependencies in the RTS
189 # sources, so 'make boot' here should behave like 'make all'.
191 # However, note that we should do this only *after* 'make boot' has
192 # created .depend in here; otherwise an out-of-date .depend file can
193 # prevent 'make boot' from working, requiring manual removal of
194 # .depend (see #1095). This is why the following target comes *after*
195 # target.mk is included above (target.mk contains "boot :: depend").