Draw STG F and D registers from the same pool of available SSE registers on x86-64.
[ghc.git] / includes / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
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
10 #
11 # -----------------------------------------------------------------------------
12
13 #
14 # Header files built from the configure script's findings
15 #
16 # XXX: these should go in includes/dist/build?
17 includes_H_CONFIG = includes/ghcautoconf.h
18 includes_H_PLATFORM = includes/ghcplatform.h
19
20 #
21 # All header files are in includes/{one of these subdirectories}
22 #
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
28
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))
32
33 #
34 # Options
35 #
36 ifeq "$(GhcUnregisterised)" "YES"
37 includes_CC_OPTS += -DUSE_MINIINTERPRETER
38 endif
39
40 includes_CC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
41 includes_CC_OPTS += -Irts
42
43 ifneq "$(GhcWithSMP)" "YES"
44 includes_CC_OPTS += -DNOSMP
45 endif
46
47 ifeq "$(DYNAMIC_BY_DEFAULT)" "YES"
48 includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT
49 endif
50
51 ifneq "$(BINDIST)" "YES"
52
53 ifeq "$(PORTING_HOST)" "YES"
54
55 $(includes_H_CONFIG) :
56 @echo "*** Cross-compiling: please copy $(includes_H_CONFIG) from the target system"
57 @exit 1
58
59 else
60
61 $(includes_H_CONFIG) : mk/config.h mk/config.mk includes/ghc.mk | $$(dir $$@)/.
62 @echo "Creating $@..."
63 @echo "#ifndef __GHCAUTOCONF_H__" >$@
64 @echo "#define __GHCAUTOCONF_H__" >>$@
65 #
66 # Copy the contents of mk/config.h, turning '#define PACKAGE_FOO
67 # "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes.
68 #
69 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' mk/config.h >> $@
70 #
71 # Tack on some extra config information from the build system
72 #
73 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
74 @echo >> $@
75 @echo "#define TABLES_NEXT_TO_CODE 1" >> $@
76 endif
77 #
78 ifeq "$(CC_LLVM_BACKEND)" "1"
79 @echo >> $@
80 @echo "#define llvm_CC_FLAVOR 1" >> $@
81 endif
82 #
83 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
84 @echo "Done."
85
86 endif
87
88 $(includes_H_PLATFORM) : includes/Makefile | $$(dir $$@)/.
89 $(call removeFiles,$@)
90 @echo "Creating $@..."
91 @echo "#ifndef __GHCPLATFORM_H__" >$@
92 @echo "#define __GHCPLATFORM_H__" >>$@
93 @echo >> $@
94 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
95 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
96 @echo >> $@
97 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
98 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
99 @echo >> $@
100 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
101 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
102 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
103 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
104 @echo >> $@
105 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
106 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
107 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
108 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
109 ifeq "$(HostOS_CPP)" "irix"
110 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
111 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
112 @echo "#endif" >> $@
113 endif
114 @echo >> $@
115 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
116 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
117 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
118 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
119 @echo >> $@
120 @echo "/* These TARGET macros are for backwards compatibility... DO NOT USE! */" >> $@
121 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
122 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
123 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
124 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
125 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
126 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
127 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
128 ifeq "$(GhcUnregisterised)" "YES"
129 @echo "#define UnregisterisedCompiler 1" >> $@
130 endif
131 @echo >> $@
132 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
133 @echo "Done."
134
135 endif
136
137 # ---------------------------------------------------------------------------
138 # Make DerivedConstants.h for the compiler
139
140 includes_DERIVEDCONSTANTS = includes/dist-derivedconstants/header/DerivedConstants.h
141 includes_GHCCONSTANTS_HASKELL_TYPE = includes/dist-derivedconstants/header/GHCConstantsHaskellType.hs
142 includes_GHCCONSTANTS_HASKELL_VALUE = includes/dist-derivedconstants/header/platformConstants
143 includes_GHCCONSTANTS_HASKELL_WRAPPERS = includes/dist-derivedconstants/header/GHCConstantsHaskellWrappers.hs
144 includes_GHCCONSTANTS_HASKELL_EXPORTS = includes/dist-derivedconstants/header/GHCConstantsHaskellExports.hs
145
146 INSTALL_LIBS += includes/dist-derivedconstants/header/platformConstants
147
148 ifeq "$(PORTING_HOST)-$(AlienScript)" "YES-"
149
150 DerivedConstants.h :
151 @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
152 @exit 1
153
154 else
155
156 includes_dist-derivedconstants_C_SRCS = mkDerivedConstants.c
157 includes_dist-derivedconstants_PROG = mkDerivedConstants$(exeext)
158 includes_dist-derivedconstants_INSTALL_INPLACE = YES
159
160 $(eval $(call build-prog,includes,dist-derivedconstants,0))
161
162 $(includes_dist-derivedconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_FILES) $$(rts_H_FILES)
163 includes/dist-derivedconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
164
165 ifneq "$(AlienScript)" ""
166 $(INPLACE_BIN)/mkDerivedConstants$(exeext): includes/$(includes_dist-derivedconstants_C_SRCS) | $$(dir $$@)/.
167 $(WhatGccIsCalled) -o $@ $< $(CFLAGS) $(includes_CC_OPTS)
168 endif
169
170 ifneq "$(BINDIST)" "YES"
171 $(includes_DERIVEDCONSTANTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
172 ifeq "$(AlienScript)" ""
173 ./$< >$@
174 else
175 $(AlienScript) run ./$< >$@
176 endif
177
178 $(includes_GHCCONSTANTS_HASKELL_TYPE) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
179 ifeq "$(AlienScript)" ""
180 ./$< --gen-haskell-type >$@
181 else
182 $(AlienScript) run ./$< --gen-haskell-type >$@
183 endif
184
185 $(includes_GHCCONSTANTS_HASKELL_VALUE) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
186 ifeq "$(AlienScript)" ""
187 ./$< --gen-haskell-value >$@
188 else
189 $(AlienScript) run ./$< --gen-haskell-value >$@
190 endif
191
192 $(includes_GHCCONSTANTS_HASKELL_WRAPPERS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
193 ifeq "$(AlienScript)" ""
194 ./$< --gen-haskell-wrappers >$@
195 else
196 $(AlienScript) run ./$< --gen-haskell-wrappers >$@
197 endif
198
199 $(includes_GHCCONSTANTS_HASKELL_EXPORTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
200 ifeq "$(AlienScript)" ""
201 ./$< --gen-haskell-exports >$@
202 else
203 $(AlienScript) run ./$< --gen-haskell-exports >$@
204 endif
205 endif
206
207 endif
208
209 # ---------------------------------------------------------------------------
210 # Install all header files
211
212 $(eval $(call clean-target,includes,,\
213 $(includes_H_CONFIG) $(includes_H_PLATFORM) \
214 $(includes_GHCCONSTANTS_HASKELL_TYPE) $(includes_GHCCONSTANTS_HASKELL_VALUE) $(includes_DERIVEDCONSTANTS)))
215
216 $(eval $(call all-target,includes,,\
217 $(includes_H_CONFIG) $(includes_H_PLATFORM) \
218 $(includes_GHCCONSTANTS_HASKELL_TYPE) $(includes_GHCCONSTANTS_HASKELL_VALUE) $(includes_DERIVEDCONSTANTS)))
219
220 install: install_includes
221
222 .PHONY: install_includes
223 install_includes :
224 $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)")
225 $(foreach d,$(includes_H_SUBDIRS), \
226 $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)/$d") && \
227 $(call INSTALL_HEADER,$(INSTALL_OPTS),includes/$d/*.h,"$(DESTDIR)$(ghcheaderdir)/$d/") && \
228 ) true
229 $(call INSTALL_HEADER,$(INSTALL_OPTS),$(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_DERIVEDCONSTANTS),"$(DESTDIR)$(ghcheaderdir)/")
230