[project @ 2000-05-25 13:11:17 by panne]
[ghc-hetmet.git] / ghc / driver / Makefile
1 #-----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.31 2000/05/25 13:11:17 panne Exp $
3
4 # We create two driver scripts: 
5 #       - one to run in-place in the build tree for building libraries
6 #       - one wired to the install locations for later installation
7 #
8 # the installation script is built first, and we invoke make recursively
9 # to build the in-place version.
10
11 TOP=..
12 CURRENT_DIR=ghc/driver
13 include $(TOP)/mk/boilerplate.mk
14
15 INSTALLING=1
16
17 DYN_LOADABLE_BITS = \
18         ghc-asm.prl \
19         ghc-consist.prl \
20         ghc-split.prl
21
22 INSTALLED_SCRIPT_PROG  = ghc-$(ProjectVersion)
23 INPLACE_SCRIPT_PROG    = ghc-inplace
24
25 ifeq "$(INSTALLING)" "1"
26 TOP_PWD         := $(prefix)
27 SCRIPT_PROG     =  $(INSTALLED_SCRIPT_PROG)
28 SCRIPT_LINK     =  ghc
29 else
30 TOP_PWD         := $(FPTOOLS_TOP_ABS)
31 SCRIPT_PROG     =  $(INPLACE_SCRIPT_PROG)
32 endif
33
34 SCRIPT_OBJS = ghc.prl
35  
36 INTERP=perl
37
38 #
39 # The driver needs to know the options and names for 
40 # all possible ways, so we magically generate the
41 # the make variable names for them here.
42 #
43
44 USER_WAY_NAMES = $(foreach way,$(USER_WAYS),WAY_$(way)_NAME)
45 USER_WAY_OPTS  = $(foreach way,$(USER_WAYS),WAY_$(way)_REAL_OPTS)
46
47 SCRIPT_SUBST_VARS := \
48   INSTALLING \
49   ProjectName ProjectVersion ProjectVersionInt \
50   HscMajorVersion HscMinorVersion CcMajorVersion CcMinorVersion \
51   CURRENT_DIR HOSTPLATFORM TARGETPLATFORM \
52   GHC_LIB_DIR GHC_RUNTIME_DIR GHC_INCLUDE_DIR \
53   GHC_OPT_HILEV_ASM GhcWithNativeCodeGen LeadingUnderscore\
54   GHC_UNLIT GHC_HSCPP GHC_MKDEPENDHS GHC_HSC GHC_SYSMAN EnableWin32DLLs \
55   CP RM CONTEXT_DIFF LibGmp GhcWithRegisterised LibsReadline \
56   $(USER_WAY_NAMES) $(USER_WAY_OPTS)
57
58 #
59 # When creating a binary distribution, we prefix the driver script
60 # with a short msg about what variables need to be set to get the
61 # script going. 
62 #
63
64 ifeq "$(BIN_DIST)" "1"
65 SCRIPT_PREFIX_FILES=prefix.txt
66 else
67 SCRIPT_SUBST_VARS += libdir includedir libexecdir datadir bindir TMPDIR TOP_PWD
68 endif
69
70 all :: $(DYN_LOADABLE_BITS)
71
72 # don't recurse on 'make install'
73 #
74 ifeq "$(INSTALLING)" "1"
75 all clean distclean mostlyclean maintainer-clean ::
76         $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
77 endif
78
79 #
80 # Install setup:
81 #   the driver goes in $(bindir), the perl script helpers
82 #   in $(libdir)
83 #
84 # ToDo: allow different install name for driver?
85 #
86 INSTALL_SCRIPTS += $(SCRIPT_PROG)
87 INSTALL_LIBS    += $(DYN_LOADABLE_BITS)
88
89 #
90 # depend setup: other directories need the driver script to compute
91 # their dependencies, so `depend' is simply an alias for `all' here.
92 depend :: all
93
94 #
95 # Clean up
96 #
97 CLEAN_FILES += $(SCRIPT_OBJS) $(SCRIPT_LINK) $(DYN_LOADABLE_BITS) ghc-[0-9].*
98
99 #
100 # Source distribution
101 #
102 SRC_DEST_FILES=$(patsubst %.prl,%.lprl,$(DYN_LOADABLE_BITS)) ghc.lprl ordering-passes test_mangler
103
104 include $(TOP)/mk/target.mk
105
106 ghc.prl : $(TOP)/mk/version.mk
107
108 #
109 # Another hack (hmm..I can see a pattern developing here :-)
110 # In ghc/driver, we create a symlink from ghc-<whatever-version> to
111 # ghc, but we don't want this included in a source distribution.
112 # We `solve' this by removing `ghc' from the dist tree here.
113 dist ::
114         @echo "Patching dist tree: removing $(SRC_DIST_DIR)/ghc symlink"
115         $(RM) $(SRC_DIST_DIR)/ghc