cd5a8f24822065d263b22f7b427b88c9af830308
[ghc-hetmet.git] / ghc / includes / Makefile
1 #
2 # ghc/includes
3 #
4
5 TOP = ..
6 include $(TOP)/mk/boilerplate.mk
7
8 #
9 # Just to make sure, no ways stuff in here, please.
10 #
11 override WAYS=
12
13 # De-litted header files
14 LH_FILES=$(wildcard *.lh)
15
16 DELIT_H_FILES = $(patsubst %.lh, %.h, $(LH_FILES))
17
18 #
19 # Header file built from the configure script's findings
20 #
21 H_CONFIG = config.h
22
23
24 # Everything else
25 H_FILES = stgdefs.h rtsdefs.h StgDirections.h StgMachDeps.h error.h \
26   ieee-flpt.h gmp.h LLC.h HLC.h
27
28 ALL_FILES = $(DELIT_H_FILES) $(H_FILES)
29 ifeq ($(GhcWithNativeCodeGen),YES)
30 ALL_FILES += $(TARGETPLATFORM).h
31 endif
32
33
34 #
35 # The fptools configure script creates the configuration header file 
36 # and puts it in fptools/mk/config.h. We copy it down to here, prepending
37 # some make variables specifying cpp platform variables.
38 #
39 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h
40
41 $(H_CONFIG) :
42         @echo "Creating $@..."
43         @$(RM) $@
44         @echo "#define HostPlatform_TYPE   $(HostPlatform_CPP)"  > $@
45         @echo "#define TargetPlatform_TYPE $(HostPlatform_CPP)" >> $@
46         @echo "#define BuildPlatform_TYPE  $(HostPlatform_CPP)" >> $@
47         @echo >> $@
48         @echo "#define $(HostPlatform_CPP)_HOST         1" >> $@
49         @echo "#define $(HostPlatform_CPP)_TARGET       1" >> $@
50         @echo "#define $(HostPlatform_CPP)_BUILD        1" >> $@
51         @echo >> $@
52         @echo "#define $(HostArch_CPP)_HOST_ARCH        1" >> $@
53         @echo "#define $(HostArch_CPP)_TARGET_ARCH      1" >> $@
54         @echo "#define $(HostArch_CPP)_BUILD_ARCH       1" >> $@
55         @echo >> $@
56         @echo "#define $(HostOS_CPP)_HOST_OS            1" >> $@
57         @echo "#define $(HostOS_CPP)_TARGET_OS          1" >> $@  
58         @echo "#ifndef $(HostPlaform_GNU)_TARGET_OS      " >> $@  
59         @echo "#define $(HostPlaform_GNU)_TARGET_OS     1" >> $@  
60         @echo "#endif                                    " >> $@  
61         @echo "#define $(HostOS_CPP)_BUILD_OS           1" >> $@
62         @echo >> $@
63         @echo "#define $(HostVendor_CPP)_HOST_VENDOR    1" >> $@
64         @echo "#define $(HostVendor_CPP)_TARGET_VENDOR  1" >> $@
65         @echo "#define $(HostVendor_CPP)_BUILD_VENDOR   1" >> $@
66         @cat $(FPTOOLS_TOP)/mk/$@ >> $@
67         @echo "Done."
68
69 $(TARGETPLATFORM).h : mkNativeHdr
70         $(RM) $@
71         ./mkNativeHdr > $@ || ( rm $@ && exit 1 )
72
73 #
74 # Building mkNativeHdr using the Haskell compiler
75 # to do it (ghc really).
76 #
77 mkNativeHdr : $(HLIT) $(HFILES) mkNativeHdr.c
78         $(HC) -c mkNativeHdr.c
79         $(CC) $(CFLAGS) -o mkNativeHdr mkNativeHdr.c
80
81 all :: $(H_CONFIG) $(ALL_FILES)
82
83 #
84 # boot setup:
85 #
86 # When building the dependencies in runtime/ , lib/ we need to get
87 # at the de-litted versions of includes/, hence we arrange the
88 # `depend' target to depend on `all'.
89 #
90 boot :: all
91
92 #
93 # Install all header files
94 #
95 # Hackily set the install destination here:
96 #
97 # Note: we keep per-platform copies of all the include files
98 # (ditto for interface files). This is not *really* needed, but
99 # it gives (perhaps) a cleaner binary dist structure..might change.
100 #
101 override datadir:=$(libdir)/includes
102 INSTALL_DATAS += $(DELIT_H_FILES) $(H_FILES) $(TARGETPLATFORM).h $(H_CONFIG)
103
104 #
105 # `make clean' settings:
106 #
107 CLEAN_FILES += $(DELIT_H_FILES) $(H_CONFIG) mkNativeHdr.o mkNativeHdr
108
109 ifeq ($(GhcWithNativeCodeGen),YES)
110 CLEAN_FILES += $(TARGETPLATFORM).h
111 endif
112
113 #
114 # Finally, slurp in the standard targets.
115 #
116 include $(TOP)/mk/target.mk