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 %,%/*.hs-boot, . $(ALL_DIRS)) \
57 $(patsubst %,%/*.lhs-boot, . $(ALL_DIRS)) \
58 $(patsubst %,%/*.y, . $(ALL_DIRS)) \
59 $(patsubst %,%/*.ly, . $(ALL_DIRS)) \
60 $(patsubst %,%/*.x, . $(ALL_DIRS)) \
61 $(patsubst %,%/*.c, . $(ALL_DIRS)) \
62 $(patsubst %,%/*.hc, . $(ALL_DIRS)) \
63 $(patsubst %,%/*.S, . $(ALL_DIRS)) \
64 $(patsubst %,%/*.prl, . $(ALL_DIRS)) \
65 $(patsubst %,%/*.lprl, . $(ALL_DIRS)) \
66 $(patsubst %,%/*.lit, . $(ALL_DIRS)) \
67 $(patsubst %,%/*.verb, . $(ALL_DIRS)) \
68 $(patsubst %,%/*.hsc, . $(ALL_DIRS)) \
69 $(patsubst %,%/*.gc, . $(ALL_DIRS)) \
72 # ALL_SRCS is computed once and for all into PRE_SRCS at the top of
73 # target.mk. Otherwise, we end up re-computing ALL_SRCS every time it
74 # is expanded (it is used in several variables below, and these
75 # variables are used in several others, etc.), which can really slow
78 PRE_HS_SRCS = $(filter %.hs, $(PRE_SRCS))
79 PRE_LHS_SRCS = $(filter %.lhs, $(PRE_SRCS))
81 PRE_HS_BOOT_SRCS = $(filter %.hs-boot, $(PRE_SRCS)) \
82 $(filter %.lhs-boot, $(PRE_SRCS))
84 GC_SRCS = $(filter %.gc, $(PRE_SRCS))
85 HSC_SRCS = $(filter %.hsc, $(PRE_SRCS))
86 HAPPY_Y_SRCS = $(filter %.y, $(PRE_SRCS))
87 HAPPY_LY_SRCS = $(filter %.ly, $(PRE_SRCS))
88 HAPPY_SRCS = $(HAPPY_Y_SRCS) $(HAPPY_LY_SRCS)
89 ALEX_SRCS = $(filter %.x, $(PRE_SRCS))
91 DERIVED_GC_SRCS = $(patsubst %.gc, %.hs, $(GC_SRCS)) \
92 $(patsubst %.gc, %_stub_ffi.c, $(GC_SRCS)) \
93 $(patsubst %.gc, %_stub_ffi.h, $(GC_SRCS))
95 DERIVED_HSC_SRCS = $(patsubst %.hsc, %.hs, $(HSC_SRCS)) \
96 $(patsubst %.hsc, %_hsc.c, $(HSC_SRCS)) \
97 $(patsubst %.hsc, %_hsc.h, $(HSC_SRCS)) \
98 $(patsubst %.hsc, %.hc, $(HSC_SRCS))
100 DERIVED_HAPPY_SRCS = $(patsubst %.y, %.hs, $(HAPPY_Y_SRCS)) \
101 $(patsubst %.ly, %.hs, $(HAPPY_LY_SRCS))
103 DERIVED_ALEX_SRCS = $(patsubst %.x, %.hs, $(ALEX_SRCS))
105 DERIVED_HC_SRCS = $(patsubst %.hs, %.hc, $(PRE_HS_SRCS)) \
106 $(patsubst %.lhs, %.hc, $(PRE_LHS_SRCS))
108 DERIVED_SRCS = $(DERIVED_GC_SRCS) \
109 $(DERIVED_HSC_SRCS) \
110 $(DERIVED_HAPPY_SRCS) \
111 $(DERIVED_ALEX_SRCS) \
114 # EXCLUDED_SRCS can be set in the Makefile, otherwise it defaults to empty.
115 EXCLUDED_GC_SRCS = $(filter %.gc, $(EXCLUDED_SRCS))
116 EXCLUDED_HSC_SRCS = $(filter %.hsc, $(EXCLUDED_SRCS))
117 EXCLUDED_HAPPY_Y_SRCS = $(filter %.y, $(EXCLUDED_SRCS))
118 EXCLUDED_HAPPY_LY_SRCS = $(filter %.ly, $(EXCLUDED_SRCS))
119 EXCLUDED_HAPPY_SRCS = $(EXCLUDED_HAPPY_Y_SRCS) $(EXCLUDED_HAPPY_LY_SRCS)
120 EXCLUDED_ALEX_SRCS = $(filter %.x, $(EXCLUDED_SRCS))
121 EXCLUDED_HS_SRCS = $(filter %.hs, $(EXCLUDED_SRCS))
122 EXCLUDED_LHS_SRCS = $(filter %.lhs, $(EXCLUDED_SRCS))
123 EXCLUDED_DERIVED_SRCS = $(patsubst %.hsc, %.hs, $(EXCLUDED_HSC_SRCS)) \
124 $(patsubst %.hsc, %_hsc.h, $(EXCLUDED_HSC_SRCS)) \
125 $(patsubst %.hsc, %_hsc.c, $(EXCLUDED_HSC_SRCS)) \
126 $(patsubst %.hsc, %.hc, $(EXCLUDED_HSC_SRCS)) \
127 $(patsubst %.gc, %_stub_ffi.c, $(EXCLUDED_GC_SRCS)) \
128 $(patsubst %.gc, %_stub_ffi.h, $(EXCLUDED_GC_SRCS)) \
129 $(patsubst %.y, %.hs, $(EXCLUDED_HAPPY_Y_SRCS)) \
130 $(patsubst %.ly, %.hs, $(EXCLUDED_HAPPY_LY_SRCS)) \
131 $(patsubst %.x, %.hs, $(EXCLUDED_ALEX_SRCS)) \
132 $(patsubst %.hs, %.hc, $(EXCLUDED_HS_SRCS)) \
133 $(patsubst %.lhs, %.hc, $(EXCLUDED_LHS_SRCS)) \
134 $(patsubst %.hs, %_stub.c, $(EXCLUDED_HS_SRCS)) \
135 $(patsubst %.lhs, %_stub.c, $(EXCLUDED_LHS_SRCS))
137 # Exclude _hsc.c files; they get built as part of the cbits library,
138 # not part of the main library
140 CLOSED_EXCLUDED_SRCS = $(sort $(EXCLUDED_SRCS) $(EXCLUDED_DERIVED_SRCS))
142 SRCS = $(filter-out $(CLOSED_EXCLUDED_SRCS), \
143 $(sort $(PRE_SRCS) $(DERIVED_SRCS)))
145 HS_SRCS = $(filter %.lhs %.hs, $(sort $(SRCS) $(BOOT_SRCS)))
146 HS_OBJS = $(addsuffix .$(way_)o,$(basename $(HS_SRCS)))
147 HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(HS_SRCS)))
149 HI_BOOTS = $(patsubst %.hs-boot, %.$(way_)hi-boot, \
150 $(patsubst %.lhs-boot, %.$(way_)hi-boot, $(PRE_HS_BOOT_SRCS)))
152 O_BOOTS = $(patsubst %.hs-boot, %.$(way_)o-boot, \
153 $(patsubst %.lhs-boot, %.$(way_)o-boot, $(PRE_HS_BOOT_SRCS)))
155 GC_C_OBJS = $(addsuffix _stub_ffi.$(way_)o,$(basename $(filter %.gc,$(SRCS))))
156 HSC_C_OBJS = $(addsuffix _hsc.$(way_)o,$(basename $(filter %.hsc,$(SRCS))))
158 ifeq "$(BootingFromHc)" "NO"
159 # We don't want to build the _stub.c files ourselves, unless we're
160 # bootstrapping from .hc files.
161 EXCLUDED_C_SRCS = $(patsubst %.lhs, %_stub.c, $(HS_SRCS)) \
162 $(patsubst %.hs, %_stub.c, $(HS_SRCS)) \
163 $(patsubst %.gc, %_stub_ffi.c, $(GC_SRCS)) \
164 $(patsubst %.gc, %_stub_ffi.h, $(GC_SRCS))
167 # These are droppings from hsc2hs - ignore them if we see them.
168 EXCLUDED_C_SRCS += $(patsubst %.hsc, %_hsc_make.c, $(HSC_SRCS))
170 C_SRCS = $(filter-out $(EXCLUDED_C_SRCS),$(filter %.c %.S,$(SRCS)))
171 C_OBJS = $(addsuffix .$(way_)o,$(basename $(C_SRCS)))
173 # SCRIPT_SRCS: list of raw script files (in literate form)
174 # SCRIPT_OBJS: de-litted scripts
175 SCRIPT_SRCS = $(filter %.lprl,$(SRCS))
176 SCRIPT_OBJS = $(addsuffix .prl,$(basename $(SCRIPT_SRCS)))
178 OBJS = $(HS_OBJS) $(C_OBJS) $(GC_C_OBJS)
180 # The default is for $(LIBOBJS) to be the same as $(OBJS)
184 # Note that as long as you use the standard variables for setting
185 # which C & Haskell programs you want to work on, you don't have
186 # to set any of the clean variables - the default should do the Right
190 #------------------------------------------------------------------
192 # make depend defaults
194 # The default set of files for the dependency generators to work on
195 # is just their source equivalents.
198 ifneq "$(BootingFromHc)" "YES"
199 MKDEPENDHS_SRCS=$(HS_SRCS)
204 MKDEPENDC_SRCS=$(C_SRCS)
206 #------------------------------------------------------------------
210 # The default set of files for the TAGS file generators to work on
211 # is just their source equivalents.
213 TAGS_HS_SRCS=$(HS_SRCS)
214 TAGS_C_SRCS=$(C_SRCS)
216 #------------------------------------------------------------------
217 # Clean file make-variables.
219 # The following three variables are used to control
220 # what gets removed when doing `make clean'
222 # MOSTLYCLEAN_FILES object code etc., but not stuff
223 # that is slow to recompile and/or stable
225 # CLEAN_FILES all files that are created by running make.
227 # MAINTAINER_CLEAN_FILES also clean out machine-generated files
228 # that may require extra tools to create.
231 # NOTE: $(SCRIPT_OBJS) is not in MOSTLY_CLEAN_FILES, because in some
232 # places in the tree it appears that we have source files in $(SCRIPT_OBJS).
233 # Specifically glafp-utils/mkdependC/mkdependC.prl and others in driver/ and
234 # possibly others elsewhere in the tree. ToDo: fix this properly.
235 MOSTLY_CLEAN_FILES += $(HS_OBJS) $(C_OBJS) $(HSC_C_OBJS) $(GC_C_OBJS)
236 CLEAN_FILES += $(HS_PROG) $(C_PROG) $(SCRIPT_PROG) $(SCRIPT_LINK) \
237 $(PROG) $(LIBRARY) a.out \
238 $(DERIVED_HSC_SRCS) \
240 $(patsubst %,%/*.$(way_)hi, . $(ALL_DIRS)) \
241 $(HI_BOOTS) $(O_BOOTS)
243 # we delete *all* the .hi files we can find, rather than just
244 # $(HS_IFACES), because stale interfaces left around by modules which
245 # don't exist any more can screw up the build.
247 # Don't clean the .hc files if we're bootstrapping
248 ifneq "$(BootingFromHc)" "YES"
249 CLEAN_FILES += $(DERIVED_HC_SRCS)
252 DIST_CLEAN_FILES += .depend* *.hp *.prof
254 MAINTAINER_CLEAN_FILES += $(BOOT_SRCS) $(DERIVED_HAPPY_SRCS) $(DERIVED_ALEX_SRCS)
257 # `Standard' set of files to clean out.
259 MOSTLY_CLEAN_FILES += \
260 *.CKP *.ln *.BAK *.bak .*.bak *.o core a.out errs ,* *.a .emacs_* \
261 tags TAGS *.ind *.ilg *.idx *.idx-prev *.aux *.aux-prev *.dvi *.log \
262 *.toc *.lot *.lof *.blg *.cb *_stub.c *_stub.h *.raw_s *.a.list
264 #------------------------------------------------------------------
266 # Directory in which DLLs are dumped so as not to get picked up by running
267 # programs (e.g. ghc or hsc) that run in the build tree
269 DLL_PEN = $(FPTOOLS_TOP)/dll
271 #------------------------------------------------------------------
273 # Stylesheet for HTML generated from DocBook XML
276 FPTOOLS_CSS = fptools.css
277 FPTOOLS_CSS_ABS = $(FPTOOLS_TOP)/mk/$(FPTOOLS_CSS)