[project @ 2005-03-02 09:48:16 by simonmar]
[ghc-hetmet.git] / ghc / includes / Makefile
1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.28 2005/03/02 09:48:16 simonmar Exp $
3 #
4
5 TOP = ..
6 include $(TOP)/mk/boilerplate.mk
7
8 #
9 # All header files
10 #
11 H_FILES = $(filter-out gmp.h,$(wildcard *.h)) gmp.h
12
13 #
14 # Options -- if we're building unregisterised, add a couple of -D's
15 #
16 ifeq "$(GhcUnregisterised)" "YES"
17 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
18 endif
19
20 #
21 # Header file built from the configure script's findings
22 #
23 H_CONFIG   = ghcautoconf.h
24 H_PLATFORM = ghcplatform.h
25
26 boot :: gmp.h
27
28 all :: $(H_CONFIG) $(H_PLATFORM)
29
30 # gmp.h is copied from the GMP directory
31 gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h
32         $(CP) $< $@
33
34 # The fptools configure script creates the configuration header file and puts it
35 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
36 # definitions to avoid clashes), prepending some make variables specifying cpp
37 # platform variables.
38
39 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
40
41 $(H_CONFIG) : Makefile
42         @echo "#ifndef __GHCAUTOCONF_H__"  >$@
43         @echo "#define __GHCAUTOCONF_H__" >>$@
44 #       Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
45         @sed 's,^\([     ]*\)#[  ]*define[       ][      ]*\(PACKAGE_[A-Z]*\)[   ][     ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
46         @echo "#endif /* __GHCAUTOCONF_H__ */"          >> $@
47         @echo "Done."
48
49 $(H_PLATFORM) : Makefile
50         @echo "Creating $@..."
51         @$(RM) $@
52         @echo "#ifndef __GHCPLATFORM_H__"  >$@
53         @echo "#define __GHCPLATFORM_H__" >>$@
54         @echo >> $@
55         @echo "#define BuildPlatform_TYPE  $(HostPlatform_CPP)" >> $@
56         @echo "#define HostPlatform_TYPE   $(TargetPlatform_CPP)" >> $@
57         @echo >> $@
58         @echo "#define $(HostPlatform_CPP)_BUILD  1" >> $@
59         @echo "#define $(TargetPlatform_CPP)_HOST  1" >> $@
60         @echo >> $@
61         @echo "#define $(HostArch_CPP)_BUILD_ARCH  1" >> $@
62         @echo "#define $(TargetArch_CPP)_HOST_ARCH  1" >> $@
63         @echo "#define BUILD_ARCH  \"$(HostArch_CPP)\"" >> $@
64         @echo "#define HOST_ARCH  \"$(TargetArch_CPP)\"" >> $@
65         @echo >> $@
66         @echo "#define $(HostOS_CPP)_BUILD_OS  1" >> $@
67         @echo "#define $(TargetOS_CPP)_HOST_OS  1" >> $@
68         @echo "#define BUILD_OS  \"$(HostOS_CPP)\"" >> $@
69         @echo "#define HOST_OS  \"$(TargetOS_CPP)\"" >> $@
70 ifeq "$(HostOS_CPP)" "irix"
71         @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@  
72         @echo "#define $(IRIX_MAJOR)_HOST_OS  1" >> $@  
73         @echo "#endif" >> $@  
74 endif
75         @echo >> $@
76         @echo "#define $(HostVendor_CPP)_BUILD_VENDOR  1" >> $@
77         @echo "#define $(TargetVendor_CPP)_HOST_VENDOR  1" >> $@
78         @echo "#define BUILD_VENDOR  \"$(HostVendor_CPP)\"" >> $@
79         @echo "#define HOST_VENDOR  \"$(TargetVendor_CPP)\"" >> $@
80         @echo >> $@
81         @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
82         @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
83         @echo "#define $(TargetPlatform_CPP)_TARGET  1" >> $@
84         @echo "#define $(TargetArch_CPP)_TARGET_ARCH  1" >> $@
85         @echo "#define TARGET_ARCH  \"$(TargetArch_CPP)\"" >> $@
86         @echo "#define $(TargetOS_CPP)_TARGET_OS  1" >> $@  
87         @echo "#define TARGET_OS  \"$(TargetOS_CPP)\"" >> $@
88         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
89         @echo >> $@
90         @echo "#endif /* __GHCPLATFORM_H__ */"          >> $@
91         @echo "Done."
92
93 # ---------------------------------------------------------------------------
94 # Make DerivedConstants.h for the compiler
95
96 all :: DerivedConstants.h
97
98 mkDerivedConstants.c : $(H_CONFIG)
99
100 mkDerivedConstantsHdr : mkDerivedConstants.o
101         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
102
103 DerivedConstants.h : mkDerivedConstantsHdr
104         ./mkDerivedConstantsHdr >$@
105
106 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
107
108 # -----------------------------------------------------------------------------
109 #
110
111 all :: GHCConstants.h
112
113 mkGHCConstants.c : $(H_CONFIG)
114
115 mkGHCConstants : mkGHCConstants.o
116         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
117
118 mkGHCConstants.o : mkDerivedConstants.c
119         $(CC) -o $@ -c $<  -DGEN_HASKELL
120
121 GHCConstants.h : mkGHCConstants
122         ./mkGHCConstants >$@
123
124 CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
125
126 # ---------------------------------------------------------------------------
127 # boot setup:
128 #
129 # Need config.h to make dependencies in the runtime system source.
130 #
131 boot :: all
132
133 #
134 # Install all header files
135 #
136 # Hackily set the install destination here:
137 #
138 # Note: we keep per-platform copies of all the include files
139 # (ditto for interface files). This is not *really* needed, but
140 # it gives (perhaps) a cleaner binary dist structure..might change.
141 #
142 override datadir:=$(libdir)/include
143 INSTALL_DATAS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
144
145 #
146 # `make clean' settings:
147 #
148 CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
149
150 #
151 # Finally, slurp in the standard targets.
152 #
153 include $(TOP)/mk/target.mk