[project @ 2003-03-21 15:45:56 by sof]
[ghc-hetmet.git] / ghc / includes / Makefile
1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.21 2003/03/21 15:45:56 sof 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 = config.h
24
25 boot :: gmp.h
26
27 all :: $(H_CONFIG) NativeDefs.h
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 
34 # and puts it in fptools/mk/config.h. We copy it down to here, prepending
35 # some make variables specifying cpp platform variables.
36 #
37 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
38
39 $(H_CONFIG) :
40         @echo "Creating $@..."
41         @$(RM) $@
42         @echo "#ifndef __FPTOOLS_CONFIG_H__"  >$@
43         @echo "#define __FPTOOLS_CONFIG_H__" >>$@
44         @echo >> $@
45         @echo "#define HostPlatform_TYPE   $(HostPlatform_CPP)" >> $@
46         @echo "#define TargetPlatform_TYPE $(HostPlatform_CPP)" >> $@
47         @echo "#define BuildPlatform_TYPE  $(HostPlatform_CPP)" >> $@
48         @echo >> $@
49         @echo "#define $(HostPlatform_CPP)_HOST         1" >> $@
50         @echo "#define $(HostPlatform_CPP)_TARGET       1" >> $@
51         @echo "#define $(HostPlatform_CPP)_BUILD        1" >> $@
52         @echo >> $@
53         @echo "#define $(HostArch_CPP)_HOST_ARCH        1" >> $@
54         @echo "#define $(HostArch_CPP)_TARGET_ARCH      1" >> $@
55         @echo "#define $(HostArch_CPP)_BUILD_ARCH       1" >> $@
56         @echo "#define HOST_ARCH                        \"$(HostArch_CPP)\"" >> $@
57         @echo >> $@
58         @echo "#define $(HostOS_CPP)_HOST_OS            1" >> $@
59         @echo "#define $(HostOS_CPP)_TARGET_OS          1" >> $@  
60         @echo "#define $(HostOS_CPP)_BUILD_OS           1" >> $@
61         @echo "#define HOST_OS                          \"$(HostOS_CPP)\"" >> $@
62 ifeq "$(HostOS_CPP)" "irix"
63         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS           " >> $@  
64         @echo "#define $(IRIX_MAJOR)_TARGET_OS          1" >> $@  
65         @echo "#endif                                    " >> $@  
66 endif
67         @echo >> $@
68         @echo "#define $(HostVendor_CPP)_HOST_VENDOR    1" >> $@
69         @echo "#define $(HostVendor_CPP)_TARGET_VENDOR  1" >> $@
70         @echo "#define $(HostVendor_CPP)_BUILD_VENDOR   1" >> $@
71         @cat $(FPTOOLS_TOP)/mk/$@ >> $@
72         @echo "#endif /* __FPTOOLS_CONFIG_H__ */"          >> $@
73         @echo "Done."
74
75 # ---------------------------------------------------------------------------
76 # Make DerivedConstants.h for the compiler
77
78 all :: DerivedConstants.h
79
80 mkDerivedConstants.c : $(H_CONFIG)
81
82 mkDerivedConstantsHdr : mkDerivedConstants.o
83         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
84
85 DerivedConstants.h : mkDerivedConstantsHdr
86         ./mkDerivedConstantsHdr >DerivedConstants.h
87
88 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
89
90 # ---------------------------------------------------------------------------
91 # Make NativeDefs.h for the NCG
92
93 all :: NativeDefs.h
94
95 mkNativeHdr.o : DerivedConstants.h
96
97 mkNativeHdr : mkNativeHdr.o
98         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkNativeHdr.o
99
100 NativeDefs.h : mkNativeHdr
101         ./mkNativeHdr >NativeDefs.h
102
103 CLEAN_FILES += mkNativeHdr$(exeext) NativeDefs.h
104
105 # ---------------------------------------------------------------------------
106 # boot setup:
107 #
108 # Need config.h to make dependencies in the runtime system source.
109 #
110 boot :: all
111
112 #
113 # Install all header files
114 #
115 # Hackily set the install destination here:
116 #
117 # Note: we keep per-platform copies of all the include files
118 # (ditto for interface files). This is not *really* needed, but
119 # it gives (perhaps) a cleaner binary dist structure..might change.
120 #
121 override datadir:=$(libdir)/include
122 INSTALL_DATAS += $(H_FILES) $(H_CONFIG)
123
124 #
125 # `make clean' settings:
126 #
127 CLEAN_FILES += $(H_CONFIG)
128
129 #
130 # Finally, slurp in the standard targets.
131 #
132 include $(TOP)/mk/target.mk