fix a dependency: Makefile -> includes/Makefile
[ghc-hetmet.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
22 #
23 includes_H_FILES = $(filter-out $(includes_H_CONFIG) $(includes_H_PLATFORM),$(wildcard includes/*.h))
24
25 #
26 # Options
27 #
28 ifeq "$(GhcUnregisterised)" "YES"
29 includes_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
30 endif
31
32 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
33 includes_CC_OPTS += -DTABLES_NEXT_TO_CODE
34 endif
35
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)
40 endif
41 else
42 includes_CC_OPTS += -Igmp/gmpbuild
43 endif
44
45 ifneq "$(GhcWithSMP)" "YES"
46 includes_CC_OPTS += -DNOSMP
47 endif
48
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
52 # platform variables.
53
54 ifneq "$(BINDIST)" "YES"
55
56 ifneq "$(TARGETPLATFORM)"  "$(HOSTPLATFORM)"
57
58 $(includes_H_CONFIG) :
59         @echo "*** Cross-compiling: please copy $(includes_H_CONFIG) from the target system"
60         @exit 1
61
62 else
63
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__ */"          >> $@
71         @echo "Done."
72
73 endif
74
75 $(includes_H_PLATFORM) : includes/Makefile
76         $(RM) $@
77         @echo "Creating $@..."
78         @echo "#ifndef __GHCPLATFORM_H__"  >$@
79         @echo "#define __GHCPLATFORM_H__" >>$@
80         @echo >> $@
81         @echo "#define BuildPlatform_TYPE  $(HostPlatform_CPP)" >> $@
82         @echo "#define HostPlatform_TYPE   $(TargetPlatform_CPP)" >> $@
83         @echo >> $@
84         @echo "#define $(HostPlatform_CPP)_BUILD  1" >> $@
85         @echo "#define $(TargetPlatform_CPP)_HOST  1" >> $@
86         @echo >> $@
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)\"" >> $@
91         @echo >> $@
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" >> $@  
99         @echo "#endif" >> $@  
100 endif
101         @echo >> $@
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)\"" >> $@
106         @echo >> $@
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" >> $@
115         @echo >> $@
116         @echo "#endif /* __GHCPLATFORM_H__ */"          >> $@
117         @echo "Done."
118
119 endif
120
121 # ---------------------------------------------------------------------------
122 # Make DerivedConstants.h for the compiler
123
124 includes_DERIVEDCONSTANTS = includes/DerivedConstants.h
125
126 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
127
128 DerivedConstants.h :
129         @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
130         @exit 1
131
132 else
133
134 includes_dist-derivedconstants_C_SRCS = mkDerivedConstants.c
135 includes_dist-derivedconstants_PROG   = mkDerivedConstants$(exeext)
136
137 $(eval $(call build-prog,includes,dist-derivedconstants,0))
138
139 $(includes_dist-derivedconstants_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM)
140 includes/dist-derivedconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
141
142 ifneq "$(BINDIST)" "YES"
143 $(includes_DERIVEDCONSTANTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext)
144         ./$< >$@
145 endif
146
147 endif
148
149 # -----------------------------------------------------------------------------
150 #
151
152 includes_GHCCONSTANTS = includes/GHCConstants.h
153
154 ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
155
156 $(includes_GHCCONSTANTS) :
157         @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
158         @exit 1
159
160 else
161
162 includes_dist-ghcconstants_C_SRCS = mkDerivedConstants.c
163 includes_dist-ghcconstants_PROG   = mkGHCConstants$(exeext)
164 includes_dist-ghcconstants_CC_OPTS = -DGEN_HASKELL
165
166 $(eval $(call build-prog,includes,dist-ghcconstants,0))
167
168 ifneq "$(BINDIST)" "YES"
169 $(includes_dist-ghcconstants_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM)
170
171 includes/dist-ghcconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
172
173 $(includes_GHCCONSTANTS) : $(INPLACE_BIN)/mkGHCConstants$(exeext)
174         ./$< >$@
175 endif
176
177 endif
178
179 # ---------------------------------------------------------------------------
180 # Install all header files
181
182 INSTALL_HEADERS += $(includes_H_FILES) $(includes_H_CONFIG) $(includes_H_PLATFORM)
183
184 $(eval $(call clean-target,includes,,\
185   $(includes_H_CONFIG) $(includes_H_PLATFORM) \
186   $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS)))
187
188 $(eval $(call all-target,includes,,\
189   $(includes_H_CONFIG) $(includes_H_PLATFORM) \
190   $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS)))
191