[project @ 2004-08-13 10:42:34 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 #  INSTALL_IFACES   (installed in $(ifacedir))
26 #
27 # see target.mk for more information.
28 #
29
30 #
31 # Setting user/group ownership for the installed entities
32 #
33 # this stuff about "who" does the installing doesn't have make vars
34 # as it is not intended to be run-time changeable.
35 #
36 ifneq "$(OWNER)" ""
37 INSTALL_OWNER   = -o $(OWNER)
38 else
39 INSTALL_OWNER   =
40 endif
41
42 ifneq "$(GROUP)" ""
43 INSTALL_GROUP   = -g $(GROUP)
44 else
45 INSTALL_GROUP   =
46 endif
47
48 SRC_INSTALL_OPTS += $(INSTALL_OWNER) $(INSTALL_GROUP)
49
50 #
51 # Invocations of `install' for the four different classes
52 # of targets:
53 #
54
55 INSTALL_PROGRAM = $(INSTALL) -m 755
56 INSTALL_SCRIPT  = $(INSTALL) -m 755
57 INSTALL_SHLIB   = $(INSTALL) -m 755
58 INSTALL_DATA    = $(INSTALL) -m 644
59 INSTALL_DIR     = $(FPTOOLS_TOP)/glafp-utils/mkdirhier/mkdirhier
60
61 #
62 # The install variables does not have any defaults,
63 # what files to install have to be specified in the Makefiles.
64 #
65
66 #################################################################################
67 #
68 #               Standard variable names
69 #
70 #################################################################################
71 # The fptools mk setup defines a set of standard names which are used
72 # by the standard targets provided by mk. One example of this is the
73 # use of standard names for specifying what files to compile, their
74 # intermediate/object code, and the name of the final
75 # executable. Based on the settings of these variables, the standard
76 # targets will generate/expand rules that automatically compile and
77 # link your program.
78 #
79 # The general rules:
80 #
81 #   SRCS - sources, might be prefixed to indicate what type of source
82 #          they are.
83 #   OBJS - object files (possibly prefixed).
84 #
85 #   PROG - name of final executable
86 #
87 # We attempt to automatically devine the list of sources $(SRCS) to
88 # compile by looking in the current directory (and possibly other
89 # directories which may be specified by setting the $(ALL_DIRS)
90 # variable).  This is complicated by the fact that some files are
91 # derived from other files: eg. .hsc files give rise to -hsc.c and
92 # -hsc.h files, .ly files give rise to .hs files, and .hs files give
93 # rise to .hc files sometimes.
94
95 # So we figure out the sources in three stages: first figure out what
96 # sources we can find (this is $(ALL_SRCS)).  Then figure out all the
97 # "derived" sources (eg. A.hsc generates A.hs and A_hsc.c), and
98 # finally put all these together and remove duplicates (GNU make's
99 # handy sort function does the duplicate removing).
100
101 # HS_SRCS:   list of Haskell modules you want to compile.
102 #             (also use by depend rule).
103 # HS_OBJS:   list of corresponding object files
104 # HS_PROG:   program that is ultimately linked.
105 # HS_IFACES: list of interface files generated
106 #             (caveat: assuming no funny use of -hisuf and that
107 #               file name and module name match)
108
109 ALL_SRCS    = $(wildcard $(patsubst ./%, %,  \
110                    $(patsubst %,%/*.hs,   . $(ALL_DIRS)) \
111                    $(patsubst %,%/*.lhs,  . $(ALL_DIRS)) \
112                    $(patsubst %,%/*.y,    . $(ALL_DIRS)) \
113                    $(patsubst %,%/*.ly,   . $(ALL_DIRS)) \
114                    $(patsubst %,%/*.x,    . $(ALL_DIRS)) \
115                    $(patsubst %,%/*.c,    . $(ALL_DIRS)) \
116                    $(patsubst %,%/*.hc,   . $(ALL_DIRS)) \
117                    $(patsubst %,%/*.S,    . $(ALL_DIRS)) \
118                    $(patsubst %,%/*.prl,  . $(ALL_DIRS)) \
119                    $(patsubst %,%/*.lprl, . $(ALL_DIRS)) \
120                    $(patsubst %,%/*.lit,  . $(ALL_DIRS)) \
121                    $(patsubst %,%/*.verb, . $(ALL_DIRS)) \
122                    $(patsubst %,%/*.hsc,  . $(ALL_DIRS)) \
123                    $(patsubst %,%/*.gc,   . $(ALL_DIRS)) \
124                )) $(EXTRA_SRCS)
125
126 # ALL_SRCS is computed once and for all into PRE_SRCS at the top of
127 # target.mk.  Otherwise, we end up re-computing ALL_SRCS every time it
128 # is expanded (it is used in several variables below, and these
129 # variables are used in several others, etc.), which can really slow
130 # down make.
131
132 PRE_HS_SRCS  = $(filter %.hs,  $(PRE_SRCS))
133 PRE_LHS_SRCS = $(filter %.lhs, $(PRE_SRCS))
134
135 GC_SRCS       = $(filter %.gc,  $(PRE_SRCS))
136 HSC_SRCS      = $(filter %.hsc, $(PRE_SRCS))
137 HAPPY_Y_SRCS  = $(filter %.y,   $(PRE_SRCS))
138 HAPPY_LY_SRCS = $(filter %.ly,   $(PRE_SRCS))
139 HAPPY_SRCS    = $(HAPPY_Y_SRCS) $(HAPPY_LY_SRCS)
140 ALEX_SRCS     = $(filter %.x,   $(PRE_SRCS))
141
142 DERIVED_GC_SRCS       = $(patsubst %.gc, %.hs, $(GC_SRCS)) \
143                         $(patsubst %.gc, %_stub_ffi.c, $(GC_SRCS)) \
144                         $(patsubst %.gc, %_stub_ffi.h, $(GC_SRCS))
145
146 DERIVED_HSC_SRCS      = $(patsubst %.hsc, %.hs, $(HSC_SRCS)) \
147                         $(patsubst %.hsc, %_hsc.c, $(HSC_SRCS)) \
148                         $(patsubst %.hsc, %_hsc.h, $(HSC_SRCS)) \
149                         $(patsubst %.hsc, %.hc, $(HSC_SRCS))
150
151 DERIVED_HAPPY_SRCS    = $(patsubst %.y,   %.hs, $(HAPPY_Y_SRCS)) \
152                         $(patsubst %.ly,  %.hs, $(HAPPY_LY_SRCS))
153
154 DERIVED_ALEX_SRCS     = $(patsubst %.x,   %.hs, $(ALEX_SRCS))
155
156 DERIVED_HC_SRCS       = $(patsubst %.hs,  %.hc, $(PRE_HS_SRCS)) \
157                         $(patsubst %.lhs, %.hc, $(PRE_LHS_SRCS))
158
159 DERIVED_SRCS          = $(DERIVED_GC_SRCS) \
160                         $(DERIVED_HSC_SRCS) \
161                         $(DERIVED_HAPPY_SRCS) \
162                         $(DERIVED_ALEX_SRCS) \
163                         $(DERIVED_HC_SRCS)
164
165 # EXCLUDED_SRCS can be set in the Makefile, otherwise it defaults to empty.
166 EXCLUDED_GC_SRCS       = $(filter %.gc,  $(EXCLUDED_SRCS))
167 EXCLUDED_HSC_SRCS      = $(filter %.hsc, $(EXCLUDED_SRCS))
168 EXCLUDED_HAPPY_Y_SRCS  = $(filter %.y,   $(EXCLUDED_SRCS))
169 EXCLUDED_HAPPY_LY_SRCS = $(filter %.ly,  $(EXCLUDED_SRCS))
170 EXCLUDED_HAPPY_SRCS   = $(EXCLUDED_HAPPY_Y_SRCS) $(EXCLUDED_HAPPY_LY_SRCS)
171 EXCLUDED_ALEX_SRCS    = $(filter %.x,   $(EXCLUDED_SRCS))
172 EXCLUDED_HS_SRCS      = $(filter %.hs,  $(EXCLUDED_SRCS))
173 EXCLUDED_LHS_SRCS     = $(filter %.lhs, $(EXCLUDED_SRCS))
174 EXCLUDED_DERIVED_SRCS = $(patsubst %.hsc, %.hs, $(EXCLUDED_HSC_SRCS)) \
175                         $(patsubst %.hsc, %_hsc.h, $(EXCLUDED_HSC_SRCS)) \
176                         $(patsubst %.hsc, %_hsc.c, $(EXCLUDED_HSC_SRCS)) \
177                         $(patsubst %.hsc, %.hc, $(EXCLUDED_HSC_SRCS)) \
178                         $(patsubst %.gc,  %_stub_ffi.c, $(EXCLUDED_GC_SRCS)) \
179                         $(patsubst %.gc,  %_stub_ffi.h, $(EXCLUDED_GC_SRCS)) \
180                         $(patsubst %.y,   %.hs, $(EXCLUDED_HAPPY_Y_SRCS)) \
181                         $(patsubst %.ly,  %.hs, $(EXCLUDED_HAPPY_LY_SRCS)) \
182                         $(patsubst %.x,   %.hs, $(EXCLUDED_ALEX_SRCS)) \
183                         $(patsubst %.hs,  %.hc, $(EXCLUDED_HS_SRCS)) \
184                         $(patsubst %.lhs, %.hc, $(EXCLUDED_LHS_SRCS)) \
185                         $(patsubst %.hs,  %_stub.c, $(EXCLUDED_HS_SRCS)) \
186                         $(patsubst %.lhs, %_stub.c, $(EXCLUDED_LHS_SRCS))
187
188 # Exclude _hsc.c files; they get built as part of the cbits library,
189 # not part of the main library
190
191 CLOSED_EXCLUDED_SRCS  = $(sort $(EXCLUDED_SRCS) $(EXCLUDED_DERIVED_SRCS))
192
193 SRCS        = $(filter-out $(CLOSED_EXCLUDED_SRCS), \
194                 $(sort $(PRE_SRCS) $(DERIVED_SRCS)))
195
196 HS_SRCS     = $(filter %.lhs %.hs, $(sort $(SRCS) $(BOOT_SRCS)))
197 HS_OBJS     = $(addsuffix .$(way_)o,$(basename $(HS_SRCS)))
198 HS_IFACES   = $(addsuffix .$(way_)hi,$(basename $(HS_SRCS)))
199
200 GC_C_OBJS   = $(addsuffix _stub_ffi.$(way_)o,$(basename $(filter %.gc,$(SRCS))))
201 HSC_C_OBJS  = $(addsuffix _hsc.$(way_)o,$(basename $(filter %.hsc,$(SRCS))))
202
203 ifeq "$(BootingFromHc)" "NO"
204 # We don't want to build the _stub.c files ourselves, unless we're
205 # bootstrapping from .hc files.
206 EXCLUDED_C_SRCS = $(patsubst %.lhs, %_stub.c, $(HS_SRCS)) \
207                   $(patsubst %.hs,  %_stub.c, $(HS_SRCS)) \
208                   $(patsubst %.gc, %_stub_ffi.c, $(GC_SRCS)) \
209                   $(patsubst %.gc, %_stub_ffi.h, $(GC_SRCS))
210 endif
211
212 # These are droppings from hsc2hs - ignore them if we see them.
213 EXCLUDED_C_SRCS += $(patsubst %.hsc, %_hsc_make.c, $(HSC_SRCS))
214
215 C_SRCS      = $(filter-out $(EXCLUDED_C_SRCS),$(filter %.c,$(SRCS)))
216 C_OBJS      = $(addsuffix .$(way_)o,$(basename $(C_SRCS)))
217
218 # SCRIPT_SRCS:  list of raw script files (in literate form)
219 # SCRIPT_OBJS:  de-litted scripts
220 SCRIPT_SRCS = $(filter %.lprl,$(SRCS))
221 SCRIPT_OBJS = $(addsuffix .prl,$(basename $(SCRIPT_SRCS)))
222
223 OBJS        = $(HS_OBJS) $(C_OBJS) $(GC_C_OBJS) 
224
225 # The default is for $(LIBOBJS) to be the same as $(OBJS)
226 LIBOBJS     = $(OBJS)
227
228 #
229 # Note that as long as you use the standard variables for setting
230 # which C & Haskell programs you want to work on, you don't have
231 # to set any of the clean variables - the default should do the Right
232 # Thing.
233 #
234
235 #------------------------------------------------------------------
236 #
237 # make depend defaults
238 #
239 # The default set of files for the dependency generators to work on
240 # is just their source equivalents.
241 #
242
243 ifneq "$(BootingFromHc)" "YES"
244 MKDEPENDHS_SRCS=$(HS_SRCS)
245 else
246 MKDEPENDHS_SRCS=
247 endif
248
249 MKDEPENDC_SRCS=$(C_SRCS)
250
251 #------------------------------------------------------------------
252 #
253 # make TAGS defaults
254 #
255 # The default set of files for the TAGS file generators to work on
256 # is just their source equivalents.
257 #
258 TAGS_HS_SRCS=$(HS_SRCS)
259 TAGS_C_SRCS=$(C_SRCS)
260
261 #------------------------------------------------------------------
262 # Clean file make-variables.
263 #
264 # The following three variables are used to control
265 # what gets removed when doing `make clean'
266 #
267 # MOSTLYCLEAN_FILES   object code etc., but not stuff
268 #                     that is slow to recompile and/or stable
269 #
270 # CLEAN_FILES  all files that are created by running make.
271 #
272 # MAINTAINER_CLEAN_FILES also clean out machine-generated files
273 #                        that may require extra tools to create.
274 #
275 #
276 # NOTE: $(SCRIPT_OBJS) is not in MOSTLY_CLEAN_FILES, because in some
277 # places in the tree it appears that we have source files in $(SCRIPT_OBJS).
278 # Specifically glafp-utils/mkdependC/mkdependC.prl and others in ghc/driver and
279 # possibly others elsewhere in the tree.  ToDo: fix this properly.
280 MOSTLY_CLEAN_FILES += $(HS_OBJS) $(C_OBJS) $(HSC_C_OBJS) $(GC_C_OBJS)
281 CLEAN_FILES        += $(HS_PROG) $(C_PROG) $(SCRIPT_PROG) $(SCRIPT_LINK) \
282                       $(PROG) $(LIBRARY) a.out \
283                       $(DERIVED_HSC_SRCS) \
284                       $(DERIVED_GC_SRCS) \
285                       $(patsubst %,%/*.$(way_)hi, . $(ALL_DIRS))
286
287 # we delete *all* the .hi files we can find, rather than just
288 # $(HS_IFACES), because stale interfaces left around by modules which
289 # don't exist any more can screw up the build.
290
291 # Don't clean the .hc files if we're bootstrapping
292 ifneq "$(BootingFromHc)" "YES"
293 CLEAN_FILES += $(DERIVED_HC_SRCS)
294 endif
295
296 DIST_CLEAN_FILES        += .depend* *.hp *.prof
297
298 MAINTAINER_CLEAN_FILES  += $(BOOT_SRCS) $(DERIVED_HAPPY_SRCS) $(DERIVED_ALEX_SRCS)
299
300 #
301 # `Standard' set of files to clean out.
302 #
303 MOSTLY_CLEAN_FILES += \
304  *.CKP *.ln *.BAK *.bak .*.bak *.o core a.out errs ,* *.a .emacs_*  \
305  tags TAGS *.ind *.ilg *.idx *.idx-prev *.aux *.aux-prev *.dvi *.log \
306  *.toc *.lot *.lof *.blg *.cb *_stub.c *_stub.h *.raw_s *.a.list
307
308 #------------------------------------------------------------------
309 #
310 # Distribution setup
311 #
312 # Following variables are used for creating source and binary distributions:
313 #
314 #  SRC_DIST_NAME && BIN_DIST_NAME  -- the package names
315 #
316 #  SRC_DIST_FILES = list of extra files to include from a build tree into a source
317 #                   distribution
318 #
319 #  SRC_DIST_DIR  = what the current directory in the source/build tree
320 #                  maps to in the source distrib. tree being created.
321 #
322 SRC_DIST_NAME=$(ProjectNameShort)-$(ProjectVersion)
323
324 #
325 # Binary distributions proceeds as follows:
326 #
327 # Fromthe top of a build tree, you do `make binary-dist'. The
328 # canned rule for this  (in target.mk) will then do a binary
329 # install to a temporary directory before packaging it all up.
330 # The following variables guide the binary-dist:
331 #
332 #  BIN_DIST_TMPDIR= the absolute path to where the temporary directory
333 #                   structure of a binary distribution should be created.
334 #                   [Default: toplevel from which you issue `make binary-dist']
335 #  BIN_DIST_NAME=   what to call the thing.
336 #
337 #  BIN_DIST_DIRS=   at the toplevel, list of directories to descend into when
338 #                   building the distribution tree.
339 #
340 #  An extra directory variable that is set during bin-dists is $(bindist_top), giving
341 #  the abs. path to the root of the binary installation tree. (useful when punting
342 #  stuff like README and ANNOUNCE into a distrib, for instance)
343 #
344 #  The layout of a binary distribution is described in the
345 #  installation documentation.
346 #
347
348
349 # Directory in which DLLs are dumped so as not to get picked up by running
350 # programs (e.g. ghc or hsc) that run in the build tree
351
352 DLL_PEN = $(FPTOOLS_TOP)/dll
353