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