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