[project @ 2002-05-01 17:51:02 by sof]
[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 # The fptools mk setup defines a set of standard names which are used
74 # by the standard targets provided by mk. One example of this is the
75 # use of standard names for specifying what files to compile, their
76 # intermediate/object code, and the name of the final
77 # executable. Based on the settings of these variables, the standard
78 # targets will generate/expand rules that automatically compile and
79 # link your program.
80 #
81 # The general rules:
82 #
83 #   SRCS - sources, might be prefixed to indicate what type of source
84 #          they are.
85 #   OBJS - object files (possibly prefixed).
86 #
87 #   PROG - name of final executable
88 #
89 # We attempt to automatically devine the list of sources $(SRCS) to
90 # compile by looking in the current directory (and possibly other
91 # directories which may be specified by setting the $(ALL_DIRS)
92 # variable).  This is complicated by the fact that some files are
93 # derived from other files: eg. .hsc files give rise to -hsc.c and
94 # -hsc.h files, .ly files give rise to .hs files, and .hs files give
95 # rise to .hc files sometimes.
96
97 # So we figure out the sources in three stages: first figure out what
98 # sources we can find (this is $(ALL_SRCS)).  Then figure out all the
99 # "derived" sources (eg. A.hsc generates A.hs and A_hsc.c), and
100 # finally put all these together and remove duplicates (GNU make's
101 # handy sort function does the duplicate removing).
102
103 # HS_SRCS:   list of Haskell modules you want to compile.
104 #             (also use by depend rule).
105 # HS_OBJS:   list of corresponding object files
106 # HS_PROG:   program that is ultimately linked.
107 # HS_IFACES: list of interface files generated
108 #             (caveat: assuming no funny use of -hisuf and that
109 #               file name and module name match)
110
111 ALL_SRCS    = $(wildcard $(patsubst ./%, %,  \
112                    $(patsubst %,%/*.hs,   . $(ALL_DIRS)) \
113                    $(patsubst %,%/*.lhs,  . $(ALL_DIRS)) \
114                    $(patsubst %,%/*.y,    . $(ALL_DIRS)) \
115                    $(patsubst %,%/*.ly,   . $(ALL_DIRS)) \
116                    $(patsubst %,%/*.c,    . $(ALL_DIRS)) \
117                    $(patsubst %,%/*.hc,   . $(ALL_DIRS)) \
118                    $(patsubst %,%/*.S,    . $(ALL_DIRS)) \
119                    $(patsubst %,%/*.prl,  . $(ALL_DIRS)) \
120                    $(patsubst %,%/*.lprl, . $(ALL_DIRS)) \
121                    $(patsubst %,%/*.lit,  . $(ALL_DIRS)) \
122                    $(patsubst %,%/*.verb, . $(ALL_DIRS)) \
123                    $(patsubst %,%/*.hsc,  . $(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 HSC_SRCS      = $(filter %.hsc, $(PRE_SRCS))
136 HAPPY_Y_SRCS  = $(filter %.y,   $(PRE_SRCS))
137 HAPPY_LY_SRCS = $(filter %.ly,   $(PRE_SRCS))
138 HAPPY_SRCS    = $(HAPPY_Y_SRCS) $(HAPPY_LY_SRCS)
139
140 DERIVED_HSC_SRCS      = $(patsubst %.hsc, %.hs, $(HSC_SRCS)) \
141                         $(patsubst %.hsc, %_hsc.c, $(HSC_SRCS)) \
142                         $(patsubst %.hsc, %_hsc.h, $(HSC_SRCS)) \
143                         $(patsubst %.hsc, %.hc, $(HSC_SRCS))
144
145 DERIVED_HAPPY_SRCS    = $(patsubst %.y,   %.hs, $(HAPPY_Y_SRCS)) \
146                         $(patsubst %.ly,  %.hs, $(HAPPY_LY_SRCS))
147
148 DERIVED_HC_SRCS       = $(patsubst %.hs,  %.hc, $(PRE_HS_SRCS)) \
149                         $(patsubst %.lhs, %.hc, $(PRE_LHS_SRCS))
150
151 DERIVED_SRCS          = $(DERIVED_HSC_SRCS) \
152                         $(DERIVED_HAPPY_SRCS) \
153                         $(DERIVED_HC_SRCS)
154
155 # EXCLUDED_SRCS can be set in the Makefile, otherwise it defaults to empty.
156 EXCLUDED_HSC_SRCS      = $(filter %.hsc, $(EXCLUDED_SRCS))
157 EXCLUDED_HAPPY_Y_SRCS  = $(filter %.y,   $(EXCLUDED_SRCS))
158 EXCLUDED_HAPPY_LY_SRCS = $(filter %.ly,  $(EXCLUDED_SRCS))
159 EXCLUDED_HAPPY_SRCS   = $(EXCLUDED_HAPPY_Y_SRCS) $(EXCLUDED_HAPPY_LY_SRCS)
160 EXCLUDED_HS_SRCS      = $(filter %.hs,  $(EXCLUDED_SRCS))
161 EXCLUDED_LHS_SRCS     = $(filter %.lhs, $(EXCLUDED_SRCS))
162 EXCLUDED_DERIVED_SRCS = $(patsubst %.hsc, %.hs, $(EXCLUDED_HSC_SRCS)) \
163                         $(patsubst %.hsc, %_hsc.h, $(EXCLUDED_HSC_SRCS)) \
164                         $(patsubst %.hsc, %_hsc.c, $(EXCLUDED_HSC_SRCS)) \
165                         $(patsubst %.hsc, %.hc, $(EXCLUDED_HSC_SRCS)) \
166                         $(patsubst %.y,   %.hs, $(EXCLUDED_HAPPY_Y_SRCS)) \
167                         $(patsubst %.ly,  %.hs, $(EXCLUDED_HAPPY_LY_SRCS)) \
168                         $(patsubst %.hs,  %.hc, $(EXCLUDED_HS_SRCS)) \
169                         $(patsubst %.lhs, %.hc, $(EXCLUDED_LHS_SRCS)) \
170                         $(patsubst %.hs,  %_stub.c, $(EXCLUDED_HS_SRCS)) \
171                         $(patsubst %.lhs, %_stub.c, $(EXCLUDED_LHS_SRCS))
172
173 # Exclude _hsc.c files; they get built as part of the cbits library,
174 # not part of the main library
175
176 CLOSED_EXCLUDED_SRCS  = $(sort $(EXCLUDED_SRCS) $(EXCLUDED_DERIVED_SRCS))
177
178 SRCS        = $(filter-out $(CLOSED_EXCLUDED_SRCS), \
179                 $(sort $(PRE_SRCS) $(DERIVED_SRCS)))
180
181 HS_SRCS     = $(filter %.lhs %.hs, $(sort $(SRCS) $(BOOT_SRCS)))
182 HS_OBJS     = $(addsuffix .$(way_)o,$(basename $(HS_SRCS)))
183 HS_IFACES   = $(addsuffix .$(way_)hi,$(basename $(HS_SRCS)))
184
185 HSC_C_OBJS  = $(addsuffix _hsc.$(way_)o,$(basename $(filter %.hsc,$(SRCS))))
186
187 EXTRA_OBJS  = $(addsuffix .$(way_)o,$(basename $(EXTRA_SRCS)))
188
189 # Always remove $(EXCLUDED_C_SRCS) from C_SRCS
190 EXCLUDED_C_SRCS = $(patsubst %.lhs, %_stub.c, $(HS_SRCS)) \
191                   $(patsubst %.hs,  %_stub.c, $(HS_SRCS))
192
193
194 C_SRCS      = $(filter-out $(EXCLUDED_C_SRCS),$(filter %.c,$(SRCS)))
195 C_OBJS      = $(addsuffix .$(way_)o,$(basename $(C_SRCS)))
196
197 # SCRIPT_SRCS:  list of raw script files (in literate form)
198 # SCRIPT_OBJS:  de-litted scripts
199 SCRIPT_SRCS = $(filter %.lprl,$(SRCS))
200 SCRIPT_OBJS = $(addsuffix .prl,$(basename $(SCRIPT_SRCS)))
201
202 OBJS        = $(HS_OBJS) $(C_OBJS) $(SCRIPT_OBJS)
203
204 # The default is for $(LIBOBJS) to be the same as $(OBJS)
205 LIBOBJS     = $(OBJS)
206
207 #
208 # Note that as long as you use the standard variables for setting
209 # which C & Haskell programs you want to work on, you don't have
210 # to set any of the clean variables - the default should do the Right
211 # Thing.
212 #
213
214 #------------------------------------------------------------------
215 #
216 # make depend defaults
217 #
218 # The default set of files for the dependency generators to work on
219 # is just their source equivalents.
220 #
221
222 ifneq "$(BootingFromHc)" "YES"
223 MKDEPENDHS_SRCS=$(HS_SRCS)
224 else
225 MKDEPENDHS_SRCS=
226 endif
227
228 MKDEPENDC_SRCS=$(C_SRCS)
229
230 #------------------------------------------------------------------
231 #
232 # make TAGS defaults
233 #
234 # The default set of files for the dependency generators to work on
235 # is just their source equivalents.
236 #
237 TAGS_HS_SRCS=$(HS_SRCS)
238 TAGS_C_SRCS=$(C_SRCS)
239
240 #------------------------------------------------------------------
241 # Clean file make-variables.
242 #
243 # The following three variables are used to control
244 # what gets removed when doing `make clean'
245 #
246 # MOSTLYCLEAN_FILES   object code etc., but not stuff
247 #                     that is slow to recompile and/or stable
248 #
249 # CLEAN_FILES  all files that are created by running make.
250 #
251 # MAINTAINER_CLEAN_FILES also clean out machine-generated files
252 #                        that may require extra tools to create.
253 #
254 #
255 MOSTLY_CLEAN_FILES += $(HS_OBJS) $(C_OBJS) $(HSC_C_OBJS)
256 CLEAN_FILES        += $(HS_PROG) $(C_PROG) $(SCRIPT_PROG) $(SCRIPT_LINK) \
257                       $(PROG) $(LIBRARY) $(HS_IFACES) a.out \
258                       $(DERIVED_HSC_SRCS)
259
260 # Don't clean the .hc files if we're bootstrapping
261 ifneq "$(BootingFromHc)" "YES"
262 CLEAN_FILES += $(DERIVED_HC_SRCS)
263 endif
264
265 DIST_CLEAN_FILES        += .depend *.hp *.prof
266
267 MAINTAINER_CLEAN_FILES  += $(BOOT_SRCS) $(DERIVED_HAPPY_SRCS)
268
269 #
270 # `Standard' set of files to clean out.
271 #
272 MOSTLY_CLEAN_FILES += \
273  *.CKP *.ln *.BAK *.bak .*.bak *.o core a.out errs ,* *.a .emacs_*  \
274  tags TAGS *.ind *.ilg *.idx *.idx-prev *.aux *.aux-prev *.dvi *.log \
275  *.toc *.lot *.lof *.blg *.cb *_stub.c *_stub.h *.raw_s *.a.list
276
277 #------------------------------------------------------------------
278 #
279 # Distribution setup
280 #
281 # Following variables are used for creating source and binary distributions:
282 #
283 #  SRC_DIST_NAME && BIN_DIST_NAME  -- the package names
284 #
285 #  SRC_DIST_FILES = list of extra files to include from a build tree into a source
286 #                   distribution
287 #
288 #  SRC_DIST_DIR  = what the current directory in the source/build tree
289 #                  maps to in the source distrib. tree being created.
290 #
291 SRC_DIST_NAME=$(ProjectNameShort)-$(ProjectVersion)
292
293 #
294 # Binary distributions proceeds as follows:
295 #
296 # Fromthe top of a build tree, you do `make binary-dist'. The
297 # canned rule for this  (in target.mk) will then do a binary
298 # install to a temporary directory before packaging it all up.
299 # The following variables guide the binary-dist:
300 #
301 #  BIN_DIST_TMPDIR= the absolute path to where the temporary directory
302 #                   structure of a binary distribution should be created.
303 #                   [Default: toplevel from which you issue `make binary-dist']
304 #  BIN_DIST_NAME=   what to call the thing.
305 #
306 #  BIN_DIST_DIRS=   at the toplevel, list of directories to descend into when
307 #                   building the distribution tree.
308 #
309 #  An extra directory variable that is set during bin-dists is $(bindist_top), giving
310 #  the abs. path to the root of the binary installation tree. (useful when punting
311 #  stuff like README and ANNOUNCE into a distrib, for instance)
312 #
313 #  The layout of a binary distribution is described in the
314 #  installation documentation.
315 #
316
317
318 # Directory in which DLLs are dumped so as not to get picked up by running
319 # programs (e.g. ghc or hsc) that run in the build tree
320
321 DLL_PEN = $(FPTOOLS_TOP)/dll
322