6e8636e2a96aeae76809f9c7a26aa06d0227ddb3
[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 # In main/Signals we need to distinguish between irix5 and irix6,
36 # so we suitably mangle HostOS_FULL to get at the major version.
37 # (A hack, for sure - ToDo: consider systematically adding more
38 # fine-grained OS info to this Makefile/configure soup )
39
40 ifeq "$(HostOS_CPP)" "irix"
41 IRIX_MAJOR = $(shell echo $(HostOS_Full) | sed 's/\(irix[^.]*\).*$$/\1/' )
42 endif
43
44 #
45 # The fptools configure script creates the configuration header file 
46 # and puts it in fptools/mk/config.h. We copy it down to here, prepending
47 # some make variables specifying cpp platform variables.
48 #
49 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h
50
51 $(H_CONFIG) :
52         @echo "Creating $@..."
53         @$(RM) $@
54         @echo "#define HostPlatform_TYPE   $(HostPlatform_CPP)"  > $@
55         @echo "#define TargetPlatform_TYPE $(HostPlatform_CPP)" >> $@
56         @echo "#define BuildPlatform_TYPE  $(HostPlatform_CPP)" >> $@
57         @echo >> $@
58         @echo "#define $(HostPlatform_CPP)_HOST         1" >> $@
59         @echo "#define $(HostPlatform_CPP)_TARGET       1" >> $@
60         @echo "#define $(HostPlatform_CPP)_BUILD        1" >> $@
61         @echo >> $@
62         @echo "#define $(HostArch_CPP)_HOST_ARCH        1" >> $@
63         @echo "#define $(HostArch_CPP)_TARGET_ARCH      1" >> $@
64         @echo "#define $(HostArch_CPP)_BUILD_ARCH       1" >> $@
65         @echo >> $@
66         @echo "#define $(HostOS_CPP)_HOST_OS            1" >> $@
67         @echo "#define $(HostOS_CPP)_TARGET_OS          1" >> $@  
68         @echo "#define $(HostOS_CPP)_BUILD_OS           1" >> $@
69 ifeq "$(HostOS_CPP)" "irix"
70         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS           " >> $@  
71         @echo "#define $(IRIX_MAJOR)_TARGET_OS          1" >> $@  
72         @echo "#endif                                    " >> $@  
73 endif
74         @echo >> $@
75         @echo "#define $(HostVendor_CPP)_HOST_VENDOR    1" >> $@
76         @echo "#define $(HostVendor_CPP)_TARGET_VENDOR  1" >> $@
77         @echo "#define $(HostVendor_CPP)_BUILD_VENDOR   1" >> $@
78         @cat $(FPTOOLS_TOP)/mk/$@ >> $@
79         @echo "Done."
80
81 $(TARGETPLATFORM).h : mkNativeHdr
82         $(RM) $@
83         ./mkNativeHdr > $@ || ( rm $@ && exit 1 )
84
85 #
86 # Building mkNativeHdr using the Haskell compiler
87 # to do it (ghc really).
88 #
89 mkNativeHdr : $(HLIT) $(HFILES) mkNativeHdr.c
90         $(HC) -c mkNativeHdr.c
91         $(CC) $(CFLAGS) -o mkNativeHdr mkNativeHdr.c
92
93 all :: $(H_CONFIG) $(ALL_FILES)
94
95 #
96 # boot setup:
97 #
98 # When building the dependencies in runtime/ , lib/ we need to get
99 # at the de-litted versions of includes/, hence we arrange the
100 # `depend' target to depend on `all'.
101 #
102 boot :: all
103
104 #
105 # Install all header files
106 #
107 # Hackily set the install destination here:
108 #
109 # Note: we keep per-platform copies of all the include files
110 # (ditto for interface files). This is not *really* needed, but
111 # it gives (perhaps) a cleaner binary dist structure..might change.
112 #
113 override datadir:=$(libdir)/includes
114 INSTALL_DATAS += $(DELIT_H_FILES) $(H_FILES) $(TARGETPLATFORM).h $(H_CONFIG)
115
116 #
117 # `make clean' settings:
118 #
119 CLEAN_FILES += $(DELIT_H_FILES) $(H_CONFIG) mkNativeHdr.o mkNativeHdr
120
121 ifeq ($(GhcWithNativeCodeGen),YES)
122 CLEAN_FILES += $(TARGETPLATFORM).h
123 endif
124
125 #
126 # Finally, slurp in the standard targets.
127 #
128 include $(TOP)/mk/target.mk