1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.23 2004/08/13 13:09:18 simonmar Exp $
6 include $(TOP)/mk/boilerplate.mk
11 H_FILES = $(filter-out gmp.h,$(wildcard *.h)) gmp.h
14 # Options -- if we're building unregisterised, add a couple of -D's
16 ifeq "$(GhcUnregisterised)" "YES"
17 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
21 # Header file built from the configure script's findings
23 H_CONFIG = ghcconfig.h
29 # gmp.h is copied from the GMP directory
30 gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h
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.
37 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
40 @echo "Creating $@..."
42 @echo "#ifndef __GHCCONFIG_H__" >$@
43 @echo "#define __GHCCONFIG_H__" >>$@
45 @echo "#define HostPlatform_TYPE $(HostPlatform_CPP)" >> $@
46 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
47 @echo "#define BuildPlatform_TYPE $(BuildPlatform_CPP)" >> $@
49 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
50 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
51 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
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)\"" >> $@
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" >> $@
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/config.h >> $@
76 @echo "#endif /* __GHCCONFIG_H__ */" >> $@
79 # ---------------------------------------------------------------------------
80 # Make DerivedConstants.h for the compiler
82 all :: DerivedConstants.h
84 mkDerivedConstants.c : $(H_CONFIG)
86 mkDerivedConstantsHdr : mkDerivedConstants.o
87 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
89 DerivedConstants.h : mkDerivedConstantsHdr
90 ./mkDerivedConstantsHdr >$@
92 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
94 # -----------------------------------------------------------------------------
99 mkGHCConstants.c : $(H_CONFIG)
101 mkGHCConstants : mkGHCConstants.o
102 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
104 mkGHCConstants.o : mkDerivedConstants.c
105 $(CC) -o $@ -c $< -DGEN_HASKELL
107 GHCConstants.h : mkGHCConstants
110 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
112 # ---------------------------------------------------------------------------
115 # Need config.h to make dependencies in the runtime system source.
120 # Install all header files
122 # Hackily set the install destination here:
124 # Note: we keep per-platform copies of all the include files
125 # (ditto for interface files). This is not *really* needed, but
126 # it gives (perhaps) a cleaner binary dist structure..might change.
128 override datadir:=$(libdir)/include
129 INSTALL_DATAS += $(H_FILES) $(H_CONFIG)
132 # `make clean' settings:
134 CLEAN_FILES += $(H_CONFIG)
137 # Finally, slurp in the standard targets.
139 include $(TOP)/mk/target.mk