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)))
34 ifeq "$(GhcUnregisterised)" "YES"
35 includes_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
38 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
39 includes_CC_OPTS += -DTABLES_NEXT_TO_CODE
42 includes_CC_OPTS += -Iincludes -Irts
44 ifneq "$(GhcWithSMP)" "YES"
45 includes_CC_OPTS += -DNOSMP
48 # The fptools configure script creates the configuration header file and puts it
49 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
50 # definitions to avoid clashes), prepending some make variables specifying cpp
53 ifneq "$(BINDIST)" "YES"
55 ifeq "$(PORTING_HOST)" "YES"
57 $(includes_H_CONFIG) :
58 @echo "*** Cross-compiling: please copy $(includes_H_CONFIG) from the target system"
63 $(includes_H_CONFIG) : mk/config.h mk/config.mk includes/ghc.mk
64 @echo "Creating $@..."
65 @echo "#ifndef __GHCAUTOCONF_H__" >$@
66 @echo "#define __GHCAUTOCONF_H__" >>$@
67 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
68 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' mk/config.h >> $@
69 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
74 $(includes_H_PLATFORM) : includes/Makefile
76 @echo "Creating $@..."
77 @echo "#ifndef __GHCPLATFORM_H__" >$@
78 @echo "#define __GHCPLATFORM_H__" >>$@
80 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
81 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
83 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
84 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
86 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
87 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
88 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
89 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
91 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
92 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
93 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
94 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
95 ifeq "$(HostOS_CPP)" "irix"
96 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
97 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
101 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
102 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
103 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
104 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
106 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
107 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
108 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
109 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
110 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
111 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
112 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
113 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
115 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
120 # ---------------------------------------------------------------------------
121 # Make DerivedConstants.h for the compiler
123 includes_DERIVEDCONSTANTS = includes/DerivedConstants.h
125 ifeq "$(PORTING_HOST)" "YES"
128 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
133 includes_dist-derivedconstants_C_SRCS = mkDerivedConstants.c
134 includes_dist-derivedconstants_PROG = mkDerivedConstants$(exeext)
136 $(eval $(call build-prog,includes,dist-derivedconstants,0))
138 $(includes_dist-derivedconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_FILES) $$(rts_H_FILES)
139 includes/dist-derivedconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
141 ifneq "$(BINDIST)" "YES"
142 $(includes_DERIVEDCONSTANTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext)
148 # -----------------------------------------------------------------------------
151 includes_GHCCONSTANTS = includes/GHCConstants.h
153 ifeq "$(PORTING_HOST)" "YES"
155 $(includes_GHCCONSTANTS) :
156 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
161 includes_dist-ghcconstants_C_SRCS = mkDerivedConstants.c
162 includes_dist-ghcconstants_PROG = mkGHCConstants$(exeext)
163 includes_dist-ghcconstants_CC_OPTS = -DGEN_HASKELL
165 $(eval $(call build-prog,includes,dist-ghcconstants,0))
167 ifneq "$(BINDIST)" "YES"
168 $(includes_dist-ghcconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_FILES) $$(rts_H_FILES)
170 includes/dist-ghcconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
172 $(includes_GHCCONSTANTS) : $(INPLACE_BIN)/mkGHCConstants$(exeext)
178 # ---------------------------------------------------------------------------
179 # Install all header files
181 $(eval $(call clean-target,includes,,\
182 $(includes_H_CONFIG) $(includes_H_PLATFORM) \
183 $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS)))
185 $(eval $(call all-target,includes,,\
186 $(includes_H_CONFIG) $(includes_H_PLATFORM) \
187 $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS)))
189 install: install_includes
191 .PHONY: install_includes
193 $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)")
194 $(foreach d,$(includes_H_SUBDIRS), \
195 $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)/$d") && \
196 $(call INSTALL_HEADER,$(INSTALL_OPTS),includes/$d/*.h,"$(DESTDIR)$(ghcheaderdir)/$d/") && \
198 $(call INSTALL_HEADER,$(INSTALL_OPTS),$(includes_H_CONFIG) $(includes_H_PLATFORM),"$(DESTDIR)$(ghcheaderdir)/")