[project @ 2002-01-30 12:11:35 by simonmar]
[ghc-hetmet.git] / mk / paths.mk
1 #################################################################################
2 #
3 #                           paths.mk
4 #
5 #       This file defines Make variables for standard directories
6 #       and file lists
7 #
8 #################################################################################
9
10
11 #-----------------------------------------------------------------
12 #
13 # Installation setup
14 #
15
16 #-----------------------------------------------------------------------------
17 # install configuration
18 #
19 # The install standard target is guided by the following four variables
20 #
21 #  INSTALL_PROGS    (installed in $(bindir))
22 #  INSTALL_LIBS     (installed in $(libdir))
23 #  INSTALL_LIBEXECS (installed in $(libexecdir))
24 #  INSTALL_DATAS    (installed in $(datadir))
25 #
26 # see target.mk for more information.
27 #
28
29 #
30 # Setting user/group ownership for the installed entities
31 #
32 # this stuff about "who" does the installing doesn't have make vars
33 # as it is not intended to be run-time changeable.
34 #
35 ifneq "$(OWNER)" ""
36 INSTALL_OWNER   = -o $(OWNER)
37 else
38 INSTALL_OWNER   =
39 endif
40
41 ifneq "$(GROUP)" ""
42 INSTALL_GROUP   = -g $(GROUP)
43 else
44 INSTALL_GROUP   =
45 endif
46
47 SRC_INSTALL_OPTS += $(INSTALL_OWNER) $(INSTALL_GROUP)
48
49 #
50 # Invocations of `install' for the four different classes
51 # of targets:
52 #
53
54 INSTALL_PROGRAM = $(INSTALL) -m 755
55 INSTALL_SCRIPT  = $(INSTALL) -m 755
56 INSTALL_SHLIB   = $(INSTALL) -m 755
57 INSTALL_DATA    = $(INSTALL) -m 644
58 INSTALL_DIR     = $(FPTOOLS_TOP)/glafp-utils/mkdirhier/mkdirhier
59
60 #
61 # The install variables does not have any defaults,
62 # what files to install have to be specified in the Makefiles.
63 #
64 #INSTALL_PROGS += $(HS_PROG) $(C_PROG)
65 #INSTALL_LIBS  += $(LIBRARY)
66 #INSTALL_DATAS += $(HS_IFACES)
67
68 #################################################################################
69 #
70 #               Standard variable names
71 #
72 #################################################################################
73
74 #
75 # The fptools mk setup defines a set of standard names which are used by the standard
76 # targets provided by mk. One example of this is the use of standard names
77 # for specifying what files to compile, their intermediate/object code, and
78 # the name of the final executable. Based on the settings of these variables, the
79 # standard targets will generate/expand rules that automatically compile and
80 # link your program.
81 #
82 # The general rules:
83 #
84 #   SRCS - sources, might be prefixed to indicate what type of source
85 #          they are.
86 #   OBJS - object files (possibly prefixed).
87 #
88 #   PROG - name of final executable
89
90 # We attempt to automatically devine the list of sources $(SRCS) to
91 # compile by looking in the current directory.  This is complicated by
92 # the fact that a .hsc file gives rise to a .hs file (which needs to
93 # be automatically included in $(SRCS)), but the .hs file might
94 # already be present in the current directory and we don't want to
95 # compile it twice.
96
97 # So we figure out the sources in three stages: first figure out
98 # what's in the current directory (this is $(PRE_SRCS)).  Then figure
99 # out all the "derived" sources (eg. A.hsc generates A.hs and
100 # A_hsc.c), and finally put all these together and remove duplicates
101 # (GNU make's handy sort function does the duplicate removing).
102 #
103 # BOOT_SRCS: list of machine generated Haskell modules.
104 # HS_SRCS:   list of Haskell modules you want to compile.
105 #             (also use by depend rule).
106 # HS_OBJS:   list of corresponding object files
107 # HS_PROG:   program that is ultimately linked.
108 # HS_IFACES: list of interface files generated
109 #             (caveat: assuming no funny use of -hisuf and that
110 #               file name and module name match)
111
112 # NB. use := rather than = here, otherwise the wildcard will get re-computed
113 # every time PRE_SRCS is expanded (this happens a lot).
114 PRE_SRCS    := $(wildcard $(patsubst ./%, %,  \
115                    $(patsubst %,%/*.hs,   . $(ALL_DIRS)) \
116                    $(patsubst %,%/*.lhs,  . $(ALL_DIRS)) \
117                    $(patsubst %,%/*.y,    . $(ALL_DIRS)) \
118                    $(patsubst %,%/*.c,    . $(ALL_DIRS)) \
119                    $(patsubst %,%/*.hc,   . $(ALL_DIRS)) \
120                    $(patsubst %,%/*.S,    . $(ALL_DIRS)) \
121                    $(patsubst %,%/*.prl,  . $(ALL_DIRS)) \
122                    $(patsubst %,%/*.lprl, . $(ALL_DIRS)) \
123                    $(patsubst %,%/*.lit,  . $(ALL_DIRS)) \
124                    $(patsubst %,%/*.verb, . $(ALL_DIRS)) \
125                    $(patsubst %,%/*.hsc,  . $(ALL_DIRS)) \
126                ))
127
128 PRE_HS_SRCS  = $(filter %.hs,  $(PRE_SRCS))
129 PRE_LHS_SRCS = $(filter %.lhs, $(PRE_SRCS))
130
131 HSC_SRCS     = $(filter %.hsc, $(PRE_SRCS))
132 HAPPY_SRCS   = $(filter %.y,   $(PRE_SRCS))
133
134 DERIVED_SRCS = $(patsubst %.hsc, %.hs, $(HSC_SRCS)) \
135                $(patsubst %.hsc, %_hsc.c, $(HSC_SRCS)) \
136                $(patsubst %.hsc, %_hsc.h, $(HSC_SRCS)) \
137                $(patsubst %.y, %.hs, $(HAPPY_SRCS)) \
138                $(patsubst %.hs, %.hc, $(PRE_HS_SRCS)) \
139                $(patsubst %.lhs, %.hc, $(PRE_LHS_SRCS))
140
141 # EXCLUDED_SRCS can be set in the Makefile, otherwise it defaults to empty.
142 EXCLUDED_HSC_SRCS     = $(filter %.hsc, $(EXCLUDED_SRCS))
143 EXCLUDED_HAPPY_SRCS   = $(filter %.y,   $(EXCLUDED_SRCS))
144 EXCLUDED_HS_SRCS      = $(filter %.hs,  $(EXCLUDED_SRCS))
145 EXCLUDED_LHS_SRCS     = $(filter %.lhs, $(EXCLUDED_SRCS))
146 EXCLUDED_DERIVED_SRCS = $(patsubst %.hsc, %.hs, $(EXCLUDED_HSC_SRCS)) \
147                         $(patsubst %.hsc, %_hsc.h, $(EXCLUDED_HSC_SRCS)) \
148                         $(patsubst %.hsc, %_hsc.c, $(EXCLUDED_HSC_SRCS)) \
149                         $(patsubst %.y, %.hs, $(EXCLUDED_HAPPY_SRCS)) \
150                         $(patsubst %.hs, %.hc, $(EXCLUDED_HS_SRCS)) \
151                         $(patsubst %.lhs, %.hc, $(EXCLUDED_LHS_SRCS))
152 # Exclude _hsc.c files; they get built as part of the cbits library,
153 # not part of the main library
154
155 CLOSED_EXCLUDED_SRCS  = $(sort $(EXCLUDED_SRCS) $(EXCLUDED_DERIVED_SRCS))
156
157 SRCS        = $(filter-out $(CLOSED_EXCLUDED_SRCS), \
158                 $(sort $(PRE_SRCS) $(DERIVED_SRCS)))
159
160 HS_SRCS     = $(filter %.lhs %.hs, $(sort $(SRCS) $(BOOT_SRCS)))
161 HS_OBJS     = $(addsuffix .$(way_)o,$(basename $(HS_SRCS)))
162 HS_IFACES   = $(addsuffix .$(way_)hi,$(basename $(HS_SRCS)))
163
164 HSC_C_OBJS  = $(addsuffix _hsc.$(way_)o,$(basename $(filter %.hsc,$(SRCS))))
165
166 C_SRCS      = $(filter %.c,$(SRCS))
167 C_OBJS      = $(addsuffix .$(way_)o,$(basename $(C_SRCS)))
168
169 # SCRIPT_SRCS:  list of raw script files (in literate form)
170 # SCRIPT_OBJS:  de-litted scripts
171 SCRIPT_SRCS=$(filter %.lprl,$(SRCS))
172 SCRIPT_OBJS=$(addsuffix .prl,$(basename $(SCRIPT_SRCS)))
173
174 OBJS=$(HS_OBJS) $(C_OBJS) $(SCRIPT_OBJS)
175
176 #
177 # Note that as long as you use the standard variables for setting
178 # which C & Haskell programs you want to work on, you don't have
179 # to set any of the clean variables - the default should do the Right
180 # Thing.
181 #
182
183 #------------------------------------------------------------------
184 #
185 # make depend defaults
186 #
187 # The default set of files for the dependency generators to work on
188 # is just their source equivalents.
189 #
190
191 ifneq "$(BootingFromHc)" "YES"
192 MKDEPENDHS_SRCS=$(HS_SRCS)
193 else
194 MKDEPENDHS_SRCS=
195 endif
196
197 MKDEPENDC_SRCS=$(C_SRCS)
198
199 #------------------------------------------------------------------
200 #
201 # make TAGS defaults
202 #
203 # The default set of files for the dependency generators to work on
204 # is just their source equivalents.
205 #
206 TAGS_HS_SRCS=$(HS_SRCS)
207 TAGS_C_SRCS=$(C_SRCS)
208
209 #------------------------------------------------------------------
210 # Clean file make-variables.
211 #
212 # The following three variables are used to control
213 # what gets removed when doing `make clean'
214 #
215 # MOSTLYCLEAN_FILES   object code etc., but not stuff
216 #                     that is slow to recompile and/or stable
217 #
218 # CLEAN_FILES  all files that are created by running make.
219 #
220 # MAINTAINER_CLEAN_FILES also clean out machine-generated files
221 #                        that may require extra tools to create.
222 #
223 #
224 MOSTLY_CLEAN_FILES += $(HS_OBJS) $(C_OBJS) $(HSC_C_OBJS)
225 CLEAN_FILES        += $(HS_PROG) $(C_PROG) $(SCRIPT_PROG) $(SCRIPT_LINK) \
226                       $(PROG) $(LIBRARY) $(HS_IFACES) a.out \
227                       $(CLEAN_DERIVED_SRCS)
228
229 # Don't clean the .hc files if we're bootstrapping
230 ifneq "$(BootingFromHc)" "YES"
231 CLEAN_DERIVED_SRCS = $(filter-out %.hc, $(DERIVED_SRCS))
232 else
233 CLEAN_DERIVED_SRCS = $(DERIVED_SRCS)
234 endif
235
236 DIST_CLEAN_FILES += .depend
237 MAINTAINER_CLEAN_FILES += $(BOOT_SRCS)
238
239 #
240 # `Standard' set of files to clean out.
241 #
242 MOSTLY_CLEAN_FILES += \
243  *.CKP *.ln *.BAK *.bak .*.bak *.o core a.out errs ,* *.a .emacs_*  \
244  tags TAGS *.ind *.ilg *.idx *.idx-prev *.aux *.aux-prev *.dvi *.log \
245  *.toc *.lot *.lof *.blg *.cb *_stub.c *_stub.h *.raw_s *.a.list
246
247 #------------------------------------------------------------------
248 #
249 # Distribution setup
250 #
251 # Following variables are used for creating source and binary distributions:
252 #
253 #  SRC_DIST_NAME && BIN_DIST_NAME  -- the package names
254 #
255 #  SRC_DIST_FILES = list of extra files to include from a build tree into a source
256 #                   distribution
257 #
258 #  SRC_DIST_DIR  = what the current directory in the source/build tree
259 #                  maps to in the source distrib. tree being created.
260 #
261 SRC_DIST_NAME=$(ProjectNameShort)-$(ProjectVersion)
262
263 #
264 # Binary distributions proceeds as follows:
265 #
266 # Fromthe top of a build tree, you do `make binary-dist'. The
267 # canned rule for this  (in target.mk) will then do a binary
268 # install to a temporary directory before packaging it all up.
269 # The following variables guide the binary-dist:
270 #
271 #  BIN_DIST_TMPDIR= the absolute path to where the temporary directory
272 #                   structure of a binary distribution should be created.
273 #                   [Default: toplevel from which you issue `make binary-dist']
274 #  BIN_DIST_NAME=   what to call the thing.
275 #
276 #  BIN_DIST_DIRS=   at the toplevel, list of directories to descend into when
277 #                   building the distribution tree.
278 #
279 #  An extra directory variable that is set during bin-dists is $(bindist_top), giving
280 #  the abs. path to the root of the binary installation tree. (useful when punting
281 #  stuff like README and ANNOUNCE into a distrib, for instance)
282 #
283 #  The layout of a binary distribution is described in the
284 #  installation documentation.
285 #
286
287
288 # Directory in which DLLs are dumped so as not to get picked up by running
289 # programs (e.g. ghc or hsc) that run in the build tree
290
291 DLL_PEN = $(FPTOOLS_TOP)/dll
292