[project @ 2004-11-16 10:00:10 by simonmar]
[ghc-hetmet.git] / ghc / includes / Makefile
1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.25 2004/10/08 10:16:14 ross 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 = ghcconfig.h
24
25 boot :: gmp.h
26
27 all :: $(H_CONFIG)
28
29 # gmp.h is copied from the GMP directory
30 gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h
31         $(CP) $< $@
32
33 # The fptools configure script creates the configuration header file and puts it
34 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
35 # definitions to avoid clashes), prepending some make variables specifying cpp
36 # platform variables.
37
38 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
39
40 $(H_CONFIG) :
41         @echo "Creating $@..."
42         @$(RM) $@
43         @echo "#ifndef __GHCCONFIG_H__"  >$@
44         @echo "#define __GHCCONFIG_H__" >>$@
45         @echo >> $@
46         @echo "#define HostPlatform_TYPE   $(HostPlatform_CPP)" >> $@
47         @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
48         @echo "#define BuildPlatform_TYPE  $(BuildPlatform_CPP)" >> $@
49         @echo >> $@
50         @echo "#define $(HostPlatform_CPP)_HOST         1" >> $@
51         @echo "#define $(TargetPlatform_CPP)_TARGET     1" >> $@
52         @echo "#define $(BuildPlatform_CPP)_BUILD       1" >> $@
53         @echo >> $@
54         @echo "#define $(HostArch_CPP)_HOST_ARCH        1" >> $@
55         @echo "#define $(TargetArch_CPP)_TARGET_ARCH    1" >> $@
56         @echo "#define $(BuildArch_CPP)_BUILD_ARCH      1" >> $@
57         @echo "#define HOST_ARCH                        \"$(HostArch_CPP)\"" >> $@
58         @echo "#define TARGET_ARCH                      \"$(TargetArch_CPP)\"" >> $@
59         @echo "#define BUILD_ARCH                       \"$(BuildArch_CPP)\"" >> $@
60         @echo >> $@
61         @echo "#define $(HostOS_CPP)_HOST_OS            1" >> $@
62         @echo "#define $(TargetOS_CPP)_TARGET_OS        1" >> $@  
63         @echo "#define $(BuildOS_CPP)_BUILD_OS          1" >> $@
64         @echo "#define HOST_OS                          \"$(HostOS_CPP)\"" >> $@
65         @echo "#define TARGET_OS                        \"$(TargetOS_CPP)\"" >> $@
66         @echo "#define BUILD_OS                         \"$(BuildOS_CPP)\"" >> $@
67 ifeq "$(HostOS_CPP)" "irix"
68         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS           " >> $@  
69         @echo "#define $(IRIX_MAJOR)_TARGET_OS          1" >> $@  
70         @echo "#endif                                    " >> $@  
71 endif
72         @echo >> $@
73         @echo "#define $(HostVendor_CPP)_HOST_VENDOR    1" >> $@
74         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
75         @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR  1" >> $@
76 #       Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
77         @sed 's,^\([     ]*\)#[  ]*define[       ][      ]*\(PACKAGE_[A-Z]*\)[   ][     ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
78         @echo "#endif /* __GHCCONFIG_H__ */"          >> $@
79         @echo "Done."
80
81 # ---------------------------------------------------------------------------
82 # Make DerivedConstants.h for the compiler
83
84 all :: DerivedConstants.h
85
86 mkDerivedConstants.c : $(H_CONFIG)
87
88 mkDerivedConstantsHdr : mkDerivedConstants.o
89         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
90
91 DerivedConstants.h : mkDerivedConstantsHdr
92         ./mkDerivedConstantsHdr >$@
93
94 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
95
96 # -----------------------------------------------------------------------------
97 #
98
99 all :: GHCConstants.h
100
101 mkGHCConstants.c : $(H_CONFIG)
102
103 mkGHCConstants : mkGHCConstants.o
104         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
105
106 mkGHCConstants.o : mkDerivedConstants.c
107         $(CC) -o $@ -c $<  -DGEN_HASKELL
108
109 GHCConstants.h : mkGHCConstants
110         ./mkGHCConstants >$@
111
112 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
113
114 # ---------------------------------------------------------------------------
115 # boot setup:
116 #
117 # Need config.h to make dependencies in the runtime system source.
118 #
119 boot :: all
120
121 #
122 # Install all header files
123 #
124 # Hackily set the install destination here:
125 #
126 # Note: we keep per-platform copies of all the include files
127 # (ditto for interface files). This is not *really* needed, but
128 # it gives (perhaps) a cleaner binary dist structure..might change.
129 #
130 override datadir:=$(libdir)/include
131 INSTALL_DATAS += $(H_FILES) $(H_CONFIG)
132
133 #
134 # `make clean' settings:
135 #
136 CLEAN_FILES += $(H_CONFIG)
137
138 #
139 # Finally, slurp in the standard targets.
140 #
141 include $(TOP)/mk/target.mk