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