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
21 # All header files are in includes/{one of these subdirectories}
23 includes_H_SUBDIRS += .
24 includes_H_SUBDIRS += rts
25 includes_H_SUBDIRS += rts/prof
26 includes_H_SUBDIRS += rts/storage
27 includes_H_SUBDIRS += stg
29 includes_H_FILES := $(wildcard $(patsubst %,includes/%/*.h,$(includes_H_SUBDIRS)))
30 # This isn't necessary, but it makes the paths look a little prettier
31 includes_H_FILES := $(subst /./,/,$(includes_H_FILES))
36 ifeq "$(GhcUnregisterised)" "YES"
37 includes_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
40 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
41 includes_CC_OPTS += -DTABLES_NEXT_TO_CODE
44 includes_CC_OPTS += -Iincludes -Irts
46 ifneq "$(GhcWithSMP)" "YES"
47 includes_CC_OPTS += -DNOSMP
50 # The fptools configure script creates the configuration header file and puts it
51 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
52 # definitions to avoid clashes), prepending some make variables specifying cpp
55 ifneq "$(BINDIST)" "YES"
57 ifeq "$(PORTING_HOST)" "YES"
59 $(includes_H_CONFIG) :
60 @echo "*** Cross-compiling: please copy $(includes_H_CONFIG) from the target system"
65 $(includes_H_CONFIG) : mk/config.h mk/config.mk includes/ghc.mk
66 @echo "Creating $@..."
67 @echo "#ifndef __GHCAUTOCONF_H__" >$@
68 @echo "#define __GHCAUTOCONF_H__" >>$@
69 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
70 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' mk/config.h >> $@
71 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
76 $(includes_H_PLATFORM) : includes/Makefile
78 @echo "Creating $@..."
79 @echo "#ifndef __GHCPLATFORM_H__" >$@
80 @echo "#define __GHCPLATFORM_H__" >>$@
82 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
83 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
85 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
86 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
88 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
89 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
90 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
91 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
93 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
94 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
95 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
96 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
97 ifeq "$(HostOS_CPP)" "irix"
98 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
99 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
103 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
104 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
105 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
106 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
108 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
109 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
110 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
111 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
112 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
113 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
114 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
115 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
117 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
122 # ---------------------------------------------------------------------------
123 # Make DerivedConstants.h for the compiler
125 includes_DERIVEDCONSTANTS = includes/DerivedConstants.h
127 ifeq "$(PORTING_HOST)" "YES"
130 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
135 includes_dist-derivedconstants_C_SRCS = mkDerivedConstants.c
136 includes_dist-derivedconstants_PROG = mkDerivedConstants$(exeext)
138 $(eval $(call build-prog,includes,dist-derivedconstants,0))
140 $(includes_dist-derivedconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_FILES) $$(rts_H_FILES)
141 includes/dist-derivedconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
143 ifneq "$(BINDIST)" "YES"
144 $(includes_DERIVEDCONSTANTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext)
150 # -----------------------------------------------------------------------------
153 includes_GHCCONSTANTS = includes/GHCConstants.h
155 ifeq "$(PORTING_HOST)" "YES"
157 $(includes_GHCCONSTANTS) :
158 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
163 includes_dist-ghcconstants_C_SRCS = mkDerivedConstants.c
164 includes_dist-ghcconstants_PROG = mkGHCConstants$(exeext)
165 includes_dist-ghcconstants_CC_OPTS = -DGEN_HASKELL
167 $(eval $(call build-prog,includes,dist-ghcconstants,0))
169 ifneq "$(BINDIST)" "YES"
170 $(includes_dist-ghcconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_FILES) $$(rts_H_FILES)
172 includes/dist-ghcconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
174 $(includes_GHCCONSTANTS) : $(INPLACE_BIN)/mkGHCConstants$(exeext)
180 # ---------------------------------------------------------------------------
181 # Install all header files
183 $(eval $(call clean-target,includes,,\
184 $(includes_H_CONFIG) $(includes_H_PLATFORM) \
185 $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS)))
187 $(eval $(call all-target,includes,,\
188 $(includes_H_CONFIG) $(includes_H_PLATFORM) \
189 $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS)))
191 install: install_includes
193 .PHONY: install_includes
195 $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)")
196 $(foreach d,$(includes_H_SUBDIRS), \
197 $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)/$d") && \
198 $(call INSTALL_HEADER,$(INSTALL_OPTS),includes/$d/*.h,"$(DESTDIR)$(ghcheaderdir)/$d/") && \
200 $(call INSTALL_HEADER,$(INSTALL_OPTS),$(includes_H_CONFIG) $(includes_H_PLATFORM),"$(DESTDIR)$(ghcheaderdir)/")