1 # -----------------------------------------------------------------------------
3 # (c) 2009 The University of Glasgow
5 # This file is part of the GHC build system.
7 # To understand how the build system works and how to modify it, see
8 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
11 # -----------------------------------------------------------------------------
14 # Header files built from the configure script's findings
16 # XXX: these should go in includes/dist/build?
17 includes_H_CONFIG = includes/ghcautoconf.h
18 includes_H_PLATFORM = includes/ghcplatform.h
23 includes_H_FILES = $(filter-out $(includes_H_CONFIG) $(includes_H_PLATFORM),$(wildcard includes/*.h))
28 ifeq "$(GhcUnregisterised)" "YES"
29 includes_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
32 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
33 includes_CC_OPTS += -DTABLES_NEXT_TO_CODE
36 includes_CC_OPTS += -Iincludes -Irts -Irts/parallel
37 ifeq "$(HaveLibGmp)" "YES"
38 ifneq "$(GMP_INCLUDE_DIRS)" ""
39 includes_CC_OPTS += -I$(GMP_INCLUDE_DIRS)
42 includes_CC_OPTS += -Igmp/gmpbuild
45 ifneq "$(GhcWithSMP)" "YES"
46 includes_CC_OPTS += -DNOSMP
49 # The fptools configure script creates the configuration header file and puts it
50 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
51 # definitions to avoid clashes), prepending some make variables specifying cpp
54 ifneq "$(BINDIST)" "YES"
56 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
58 $(includes_H_CONFIG) :
59 @echo "*** Cross-compiling: please copy $(includes_H_CONFIG) from the target system"
64 $(includes_H_CONFIG) : mk/config.h mk/config.mk includes/ghc.mk
65 @echo "Creating $@..."
66 @echo "#ifndef __GHCAUTOCONF_H__" >$@
67 @echo "#define __GHCAUTOCONF_H__" >>$@
68 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
69 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' mk/config.h >> $@
70 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
75 $(includes_H_PLATFORM) : includes/Makefile
77 @echo "Creating $@..."
78 @echo "#ifndef __GHCPLATFORM_H__" >$@
79 @echo "#define __GHCPLATFORM_H__" >>$@
81 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
82 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
84 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
85 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
87 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
88 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
89 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
90 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
92 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
93 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
94 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
95 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
96 ifeq "$(HostOS_CPP)" "irix"
97 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
98 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
102 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
103 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
104 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
105 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
107 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
108 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
109 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
110 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
111 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
112 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
113 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
114 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
116 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
121 # ---------------------------------------------------------------------------
122 # Make DerivedConstants.h for the compiler
124 includes_DERIVEDCONSTANTS = includes/DerivedConstants.h
126 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
129 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
134 includes_dist-derivedconstants_C_SRCS = mkDerivedConstants.c
135 includes_dist-derivedconstants_PROG = mkDerivedConstants$(exeext)
137 $(eval $(call build-prog,includes,dist-derivedconstants,0))
139 $(includes_dist-derivedconstants_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM)
140 includes/dist-derivedconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
142 ifneq "$(BINDIST)" "YES"
143 $(includes_DERIVEDCONSTANTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext)
149 # -----------------------------------------------------------------------------
152 includes_GHCCONSTANTS = includes/GHCConstants.h
154 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
156 $(includes_GHCCONSTANTS) :
157 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
162 includes_dist-ghcconstants_C_SRCS = mkDerivedConstants.c
163 includes_dist-ghcconstants_PROG = mkGHCConstants$(exeext)
164 includes_dist-ghcconstants_CC_OPTS = -DGEN_HASKELL
166 $(eval $(call build-prog,includes,dist-ghcconstants,0))
168 ifneq "$(BINDIST)" "YES"
169 $(includes_dist-ghcconstants_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM)
171 includes/dist-ghcconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
173 $(includes_GHCCONSTANTS) : $(INPLACE_BIN)/mkGHCConstants$(exeext)
179 # ---------------------------------------------------------------------------
180 # Install all header files
182 INSTALL_HEADERS += $(includes_H_FILES) $(includes_H_CONFIG) $(includes_H_PLATFORM)
184 $(eval $(call clean-target,includes,,\
185 $(includes_H_CONFIG) $(includes_H_PLATFORM) \
186 $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS)))
188 $(eval $(call all-target,includes,,\
189 $(includes_H_CONFIG) $(includes_H_PLATFORM) \
190 $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS)))