11e4e1b8273b3f73fcf4c2946e3009ef94991f6b
[ghc-hetmet.git] / ghc / includes / Makefile
1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.22 2003/09/04 09:56: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 = 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 $(TargetPlatform_CPP)" >> $@
47         @echo "#define BuildPlatform_TYPE  $(BuildPlatform_CPP)" >> $@
48         @echo >> $@
49         @echo "#define $(HostPlatform_CPP)_HOST         1" >> $@
50         @echo "#define $(TargetPlatform_CPP)_TARGET     1" >> $@
51         @echo "#define $(BuildPlatform_CPP)_BUILD       1" >> $@
52         @echo >> $@
53         @echo "#define $(HostArch_CPP)_HOST_ARCH        1" >> $@
54         @echo "#define $(TargetArch_CPP)_TARGET_ARCH    1" >> $@
55         @echo "#define $(BuildArch_CPP)_BUILD_ARCH      1" >> $@
56         @echo "#define HOST_ARCH                        \"$(HostArch_CPP)\"" >> $@
57         @echo "#define TARGET_ARCH                      \"$(TargetArch_CPP)\"" >> $@
58         @echo "#define BUILD_ARCH                       \"$(BuildArch_CPP)\"" >> $@
59         @echo >> $@
60         @echo "#define $(HostOS_CPP)_HOST_OS            1" >> $@
61         @echo "#define $(TargetOS_CPP)_TARGET_OS        1" >> $@  
62         @echo "#define $(BuildOS_CPP)_BUILD_OS          1" >> $@
63         @echo "#define HOST_OS                          \"$(HostOS_CPP)\"" >> $@
64         @echo "#define TARGET_OS                        \"$(TargetOS_CPP)\"" >> $@
65         @echo "#define BUILD_OS                         \"$(BuildOS_CPP)\"" >> $@
66 ifeq "$(HostOS_CPP)" "irix"
67         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS           " >> $@  
68         @echo "#define $(IRIX_MAJOR)_TARGET_OS          1" >> $@  
69         @echo "#endif                                    " >> $@  
70 endif
71         @echo >> $@
72         @echo "#define $(HostVendor_CPP)_HOST_VENDOR    1" >> $@
73         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
74         @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR  1" >> $@
75         @cat $(FPTOOLS_TOP)/mk/$@ >> $@
76         @echo "#endif /* __FPTOOLS_CONFIG_H__ */"          >> $@
77         @echo "Done."
78
79 # ---------------------------------------------------------------------------
80 # Make DerivedConstants.h for the compiler
81
82 all :: DerivedConstants.h
83
84 mkDerivedConstants.c : $(H_CONFIG)
85
86 mkDerivedConstantsHdr : mkDerivedConstants.o
87         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
88
89 DerivedConstants.h : mkDerivedConstantsHdr
90         ./mkDerivedConstantsHdr >DerivedConstants.h
91
92 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
93
94 # ---------------------------------------------------------------------------
95 # Make NativeDefs.h for the NCG
96
97 all :: NativeDefs.h
98
99 mkNativeHdr.o : DerivedConstants.h
100
101 mkNativeHdr : mkNativeHdr.o
102         $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkNativeHdr.o
103
104 NativeDefs.h : mkNativeHdr
105         ./mkNativeHdr >NativeDefs.h
106
107 CLEAN_FILES += mkNativeHdr$(exeext) NativeDefs.h
108
109 # ---------------------------------------------------------------------------
110 # boot setup:
111 #
112 # Need config.h to make dependencies in the runtime system source.
113 #
114 boot :: all
115
116 #
117 # Install all header files
118 #
119 # Hackily set the install destination here:
120 #
121 # Note: we keep per-platform copies of all the include files
122 # (ditto for interface files). This is not *really* needed, but
123 # it gives (perhaps) a cleaner binary dist structure..might change.
124 #
125 override datadir:=$(libdir)/include
126 INSTALL_DATAS += $(H_FILES) $(H_CONFIG)
127
128 #
129 # `make clean' settings:
130 #
131 CLEAN_FILES += $(H_CONFIG)
132
133 #
134 # Finally, slurp in the standard targets.
135 #
136 include $(TOP)/mk/target.mk