1 ################################################################################
5 # This file defines Make variables for standard directories
8 ################################################################################
10 ################################################################################
12 # Standard variable names
14 ################################################################################
15 # The fptools mk setup defines a set of standard names which are used
16 # by the standard targets provided by mk. One example of this is the
17 # use of standard names for specifying what files to compile, their
18 # intermediate/object code, and the name of the final
19 # executable. Based on the settings of these variables, the standard
20 # targets will generate/expand rules that automatically compile and
25 # SRCS - sources, might be prefixed to indicate what type of source
27 # OBJS - object files (possibly prefixed).
29 # PROG - name of final executable
31 # We attempt to automatically devine the list of sources $(SRCS) to
32 # compile by looking in the current directory (and possibly other
33 # directories which may be specified by setting the $(ALL_DIRS)
34 # variable). This is complicated by the fact that some files are
35 # derived from other files: eg. .hsc files give rise to -hsc.c and
36 # -hsc.h files, .ly files give rise to .hs files, and .hs files give
37 # rise to .hc files sometimes.
39 # So we figure out the sources in three stages: first figure out what
40 # sources we can find (this is $(ALL_SRCS)). Then figure out all the
41 # "derived" sources (eg. A.hsc generates A.hs and A_hsc.c), and
42 # finally put all these together and remove duplicates (GNU make's
43 # handy sort function does the duplicate removing).
45 # HS_SRCS: list of Haskell modules you want to compile.
46 # (also use by depend rule).
47 # HS_OBJS: list of corresponding object files
48 # HS_PROG: program that is ultimately linked.
49 # HS_IFACES: list of interface files generated
50 # (caveat: assuming no funny use of -hisuf and that
51 # file name and module name match)
53 ALL_SRCS = $(wildcard $(patsubst ./%, %, \
54 $(patsubst %,%/*.hs, . $(ALL_DIRS)) \
55 $(patsubst %,%/*.lhs, . $(ALL_DIRS)) \
56 $(patsubst %,%/*.y, . $(ALL_DIRS)) \
57 $(patsubst %,%/*.ly, . $(ALL_DIRS)) \
58 $(patsubst %,%/*.x, . $(ALL_DIRS)) \
59 $(patsubst %,%/*.c, . $(ALL_DIRS)) \
60 $(patsubst %,%/*.hc, . $(ALL_DIRS)) \
61 $(patsubst %,%/*.S, . $(ALL_DIRS)) \
62 $(patsubst %,%/*.prl, . $(ALL_DIRS)) \
63 $(patsubst %,%/*.lprl, . $(ALL_DIRS)) \
64 $(patsubst %,%/*.lit, . $(ALL_DIRS)) \
65 $(patsubst %,%/*.verb, . $(ALL_DIRS)) \
66 $(patsubst %,%/*.hsc, . $(ALL_DIRS)) \
67 $(patsubst %,%/*.gc, . $(ALL_DIRS)) \
70 # ALL_SRCS is computed once and for all into PRE_SRCS at the top of
71 # target.mk. Otherwise, we end up re-computing ALL_SRCS every time it
72 # is expanded (it is used in several variables below, and these
73 # variables are used in several others, etc.), which can really slow
76 PRE_HS_SRCS = $(filter %.hs, $(PRE_SRCS))
77 PRE_LHS_SRCS = $(filter %.lhs, $(PRE_SRCS))
79 GC_SRCS = $(filter %.gc, $(PRE_SRCS))
80 HSC_SRCS = $(filter %.hsc, $(PRE_SRCS))
81 HAPPY_Y_SRCS = $(filter %.y, $(PRE_SRCS))
82 HAPPY_LY_SRCS = $(filter %.ly, $(PRE_SRCS))
83 HAPPY_SRCS = $(HAPPY_Y_SRCS) $(HAPPY_LY_SRCS)
84 ALEX_SRCS = $(filter %.x, $(PRE_SRCS))
86 DERIVED_GC_SRCS = $(patsubst %.gc, %.hs, $(GC_SRCS)) \
87 $(patsubst %.gc, %_stub_ffi.c, $(GC_SRCS)) \
88 $(patsubst %.gc, %_stub_ffi.h, $(GC_SRCS))
90 DERIVED_HSC_SRCS = $(patsubst %.hsc, %.hs, $(HSC_SRCS)) \
91 $(patsubst %.hsc, %_hsc.c, $(HSC_SRCS)) \
92 $(patsubst %.hsc, %_hsc.h, $(HSC_SRCS)) \
93 $(patsubst %.hsc, %.hc, $(HSC_SRCS))
95 DERIVED_HAPPY_SRCS = $(patsubst %.y, %.hs, $(HAPPY_Y_SRCS)) \
96 $(patsubst %.ly, %.hs, $(HAPPY_LY_SRCS))
98 DERIVED_ALEX_SRCS = $(patsubst %.x, %.hs, $(ALEX_SRCS))
100 DERIVED_HC_SRCS = $(patsubst %.hs, %.hc, $(PRE_HS_SRCS)) \
101 $(patsubst %.lhs, %.hc, $(PRE_LHS_SRCS))
103 DERIVED_SRCS = $(DERIVED_GC_SRCS) \
104 $(DERIVED_HSC_SRCS) \
105 $(DERIVED_HAPPY_SRCS) \
106 $(DERIVED_ALEX_SRCS) \
109 # EXCLUDED_SRCS can be set in the Makefile, otherwise it defaults to empty.
110 EXCLUDED_GC_SRCS = $(filter %.gc, $(EXCLUDED_SRCS))
111 EXCLUDED_HSC_SRCS = $(filter %.hsc, $(EXCLUDED_SRCS))
112 EXCLUDED_HAPPY_Y_SRCS = $(filter %.y, $(EXCLUDED_SRCS))
113 EXCLUDED_HAPPY_LY_SRCS = $(filter %.ly, $(EXCLUDED_SRCS))
114 EXCLUDED_HAPPY_SRCS = $(EXCLUDED_HAPPY_Y_SRCS) $(EXCLUDED_HAPPY_LY_SRCS)
115 EXCLUDED_ALEX_SRCS = $(filter %.x, $(EXCLUDED_SRCS))
116 EXCLUDED_HS_SRCS = $(filter %.hs, $(EXCLUDED_SRCS))
117 EXCLUDED_LHS_SRCS = $(filter %.lhs, $(EXCLUDED_SRCS))
118 EXCLUDED_DERIVED_SRCS = $(patsubst %.hsc, %.hs, $(EXCLUDED_HSC_SRCS)) \
119 $(patsubst %.hsc, %_hsc.h, $(EXCLUDED_HSC_SRCS)) \
120 $(patsubst %.hsc, %_hsc.c, $(EXCLUDED_HSC_SRCS)) \
121 $(patsubst %.hsc, %.hc, $(EXCLUDED_HSC_SRCS)) \
122 $(patsubst %.gc, %_stub_ffi.c, $(EXCLUDED_GC_SRCS)) \
123 $(patsubst %.gc, %_stub_ffi.h, $(EXCLUDED_GC_SRCS)) \
124 $(patsubst %.y, %.hs, $(EXCLUDED_HAPPY_Y_SRCS)) \
125 $(patsubst %.ly, %.hs, $(EXCLUDED_HAPPY_LY_SRCS)) \
126 $(patsubst %.x, %.hs, $(EXCLUDED_ALEX_SRCS)) \
127 $(patsubst %.hs, %.hc, $(EXCLUDED_HS_SRCS)) \
128 $(patsubst %.lhs, %.hc, $(EXCLUDED_LHS_SRCS)) \
129 $(patsubst %.hs, %_stub.c, $(EXCLUDED_HS_SRCS)) \
130 $(patsubst %.lhs, %_stub.c, $(EXCLUDED_LHS_SRCS))
132 # Exclude _hsc.c files; they get built as part of the cbits library,
133 # not part of the main library
135 CLOSED_EXCLUDED_SRCS = $(sort $(EXCLUDED_SRCS) $(EXCLUDED_DERIVED_SRCS))
137 SRCS = $(filter-out $(CLOSED_EXCLUDED_SRCS), \
138 $(sort $(PRE_SRCS) $(DERIVED_SRCS)))
140 HS_SRCS = $(filter %.lhs %.hs, $(sort $(SRCS) $(BOOT_SRCS)))
141 HS_OBJS = $(addsuffix .$(way_)o,$(basename $(HS_SRCS)))
142 HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(HS_SRCS)))
144 GC_C_OBJS = $(addsuffix _stub_ffi.$(way_)o,$(basename $(filter %.gc,$(SRCS))))
145 HSC_C_OBJS = $(addsuffix _hsc.$(way_)o,$(basename $(filter %.hsc,$(SRCS))))
147 ifeq "$(BootingFromHc)" "NO"
148 # We don't want to build the _stub.c files ourselves, unless we're
149 # bootstrapping from .hc files.
150 EXCLUDED_C_SRCS = $(patsubst %.lhs, %_stub.c, $(HS_SRCS)) \
151 $(patsubst %.hs, %_stub.c, $(HS_SRCS)) \
152 $(patsubst %.gc, %_stub_ffi.c, $(GC_SRCS)) \
153 $(patsubst %.gc, %_stub_ffi.h, $(GC_SRCS))
156 # These are droppings from hsc2hs - ignore them if we see them.
157 EXCLUDED_C_SRCS += $(patsubst %.hsc, %_hsc_make.c, $(HSC_SRCS))
159 C_SRCS = $(filter-out $(EXCLUDED_C_SRCS),$(filter %.c,$(SRCS)))
160 C_OBJS = $(addsuffix .$(way_)o,$(basename $(C_SRCS)))
162 # SCRIPT_SRCS: list of raw script files (in literate form)
163 # SCRIPT_OBJS: de-litted scripts
164 SCRIPT_SRCS = $(filter %.lprl,$(SRCS))
165 SCRIPT_OBJS = $(addsuffix .prl,$(basename $(SCRIPT_SRCS)))
167 OBJS = $(HS_OBJS) $(C_OBJS) $(GC_C_OBJS)
169 # The default is for $(LIBOBJS) to be the same as $(OBJS)
173 # Note that as long as you use the standard variables for setting
174 # which C & Haskell programs you want to work on, you don't have
175 # to set any of the clean variables - the default should do the Right
179 #------------------------------------------------------------------
181 # make depend defaults
183 # The default set of files for the dependency generators to work on
184 # is just their source equivalents.
187 ifneq "$(BootingFromHc)" "YES"
188 MKDEPENDHS_SRCS=$(HS_SRCS)
193 MKDEPENDC_SRCS=$(C_SRCS)
195 #------------------------------------------------------------------
199 # The default set of files for the TAGS file generators to work on
200 # is just their source equivalents.
202 TAGS_HS_SRCS=$(HS_SRCS)
203 TAGS_C_SRCS=$(C_SRCS)
205 #------------------------------------------------------------------
206 # Clean file make-variables.
208 # The following three variables are used to control
209 # what gets removed when doing `make clean'
211 # MOSTLYCLEAN_FILES object code etc., but not stuff
212 # that is slow to recompile and/or stable
214 # CLEAN_FILES all files that are created by running make.
216 # MAINTAINER_CLEAN_FILES also clean out machine-generated files
217 # that may require extra tools to create.
220 # NOTE: $(SCRIPT_OBJS) is not in MOSTLY_CLEAN_FILES, because in some
221 # places in the tree it appears that we have source files in $(SCRIPT_OBJS).
222 # Specifically glafp-utils/mkdependC/mkdependC.prl and others in ghc/driver and
223 # possibly others elsewhere in the tree. ToDo: fix this properly.
224 MOSTLY_CLEAN_FILES += $(HS_OBJS) $(C_OBJS) $(HSC_C_OBJS) $(GC_C_OBJS)
225 CLEAN_FILES += $(HS_PROG) $(C_PROG) $(SCRIPT_PROG) $(SCRIPT_LINK) \
226 $(PROG) $(LIBRARY) a.out \
227 $(DERIVED_HSC_SRCS) \
229 $(patsubst %,%/*.$(way_)hi, . $(ALL_DIRS))
231 # we delete *all* the .hi files we can find, rather than just
232 # $(HS_IFACES), because stale interfaces left around by modules which
233 # don't exist any more can screw up the build.
235 # Don't clean the .hc files if we're bootstrapping
236 ifneq "$(BootingFromHc)" "YES"
237 CLEAN_FILES += $(DERIVED_HC_SRCS)
240 DIST_CLEAN_FILES += .depend* *.hp *.prof
242 MAINTAINER_CLEAN_FILES += $(BOOT_SRCS) $(DERIVED_HAPPY_SRCS) $(DERIVED_ALEX_SRCS)
245 # `Standard' set of files to clean out.
247 MOSTLY_CLEAN_FILES += \
248 *.CKP *.ln *.BAK *.bak .*.bak *.o core a.out errs ,* *.a .emacs_* \
249 tags TAGS *.ind *.ilg *.idx *.idx-prev *.aux *.aux-prev *.dvi *.log \
250 *.toc *.lot *.lof *.blg *.cb *_stub.c *_stub.h *.raw_s *.a.list
252 #------------------------------------------------------------------
256 # Following variables are used for creating source and binary distributions:
258 # SRC_DIST_NAME && BIN_DIST_NAME -- the package names
260 # SRC_DIST_FILES = list of extra files to include from a build tree into a source
263 # SRC_DIST_DIR = what the current directory in the source/build tree
264 # maps to in the source distrib. tree being created.
266 SRC_DIST_NAME=$(ProjectNameShort)-$(ProjectVersion)
269 # Binary distributions proceeds as follows:
271 # Fromthe top of a build tree, you do `make binary-dist'. The
272 # canned rule for this (in target.mk) will then do a binary
273 # install to a temporary directory before packaging it all up.
274 # The following variables guide the binary-dist:
276 # BIN_DIST_TMPDIR= the absolute path to where the temporary directory
277 # structure of a binary distribution should be created.
278 # [Default: toplevel from which you issue `make binary-dist']
279 # BIN_DIST_NAME= what to call the thing.
281 # BIN_DIST_DIRS= at the toplevel, list of directories to descend into when
282 # building the distribution tree.
284 # An extra directory variable that is set during bin-dists is $(bindist_top), giving
285 # the abs. path to the root of the binary installation tree. (useful when punting
286 # stuff like README and ANNOUNCE into a distrib, for instance)
288 # The layout of a binary distribution is described in the
289 # installation documentation.
293 # Directory in which DLLs are dumped so as not to get picked up by running
294 # programs (e.g. ghc or hsc) that run in the build tree
296 DLL_PEN = $(FPTOOLS_TOP)/dll
298 #------------------------------------------------------------------
300 # Stylesheet for HTML generated from DocBook XML
303 FPTOOLS_CSS = fptools.css
304 FPTOOLS_CSS_ABS = $(FPTOOLS_TOP)/mk/$(FPTOOLS_CSS)