1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.26 2005/01/28 12:55:51 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 = ghcautoconf.h
24 H_PLATFORM = ghcplatform.h
28 all :: $(H_CONFIG) $(H_PLATFORM)
30 # gmp.h is copied from the GMP directory
31 gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h
34 # The fptools configure script creates the configuration header file and puts it
35 # in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
36 # definitions to avoid clashes), prepending some make variables specifying cpp
39 $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
41 $(H_CONFIG) : Makefile
42 @echo "#ifndef __GHCAUTOCONF_H__" >$@
43 @echo "#define __GHCAUTOCONF_H__" >>$@
44 # Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'.
45 @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@
46 @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@
49 $(H_PLATFORM) : Makefile
50 @echo "Creating $@..."
52 @echo "#ifndef __GHCPLATFORM_H__" >$@
53 @echo "#define __GHCPLATFORM_H__" >>$@
55 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
56 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
58 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
59 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
61 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
62 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
63 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
64 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
66 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
67 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
68 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
69 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
70 ifeq "$(HostOS_CPP)" "irix"
71 @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@
72 @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@
76 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
77 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
78 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
79 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
81 @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
82 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
83 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
84 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
85 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
86 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
87 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
88 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
90 @echo "#endif /* __GHCPLATFORM_H__ */" >> $@
93 # ---------------------------------------------------------------------------
94 # Make DerivedConstants.h for the compiler
96 all :: DerivedConstants.h
98 mkDerivedConstants.c : $(H_CONFIG)
100 mkDerivedConstantsHdr : mkDerivedConstants.o
101 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
103 DerivedConstants.h : mkDerivedConstantsHdr
104 ./mkDerivedConstantsHdr >$@
106 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
108 # -----------------------------------------------------------------------------
111 all :: GHCConstants.h
113 mkGHCConstants.c : $(H_CONFIG)
115 mkGHCConstants : mkGHCConstants.o
116 $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
118 mkGHCConstants.o : mkDerivedConstants.c
119 $(CC) -o $@ -c $< -DGEN_HASKELL
121 GHCConstants.h : mkGHCConstants
124 CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
126 # ---------------------------------------------------------------------------
129 # Need config.h to make dependencies in the runtime system source.
134 # Install all header files
136 # Hackily set the install destination here:
138 # Note: we keep per-platform copies of all the include files
139 # (ditto for interface files). This is not *really* needed, but
140 # it gives (perhaps) a cleaner binary dist structure..might change.
142 override datadir:=$(libdir)/include
143 INSTALL_DATAS += $(H_FILES) $(H_CONFIG)
146 # `make clean' settings:
148 CLEAN_FILES += $(H_CONFIG)
151 # Finally, slurp in the standard targets.
153 include $(TOP)/mk/target.mk