[project @ 2001-06-06 12:24:00 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 three different classes
51 # of targets:
52 #
53
54 INSTALL_PROGRAM = $(INSTALL) -m 755
55 INSTALL_SCRIPT  = $(INSTALL) -m 755
56 INSTALL_DATA    = $(INSTALL) -m 644
57 INSTALL_DIR     = $(FPTOOLS_TOP)/glafp-utils/mkdirhier/mkdirhier
58
59 #
60 # The install variables does not have any defaults,
61 # what files to install have to be specified in the Makefiles.
62
63 #INSTALL_PROGS += $(HS_PROG) $(C_PROG)
64 #INSTALL_LIBS  += $(LIBRARY)
65 #INSTALL_DATAS += $(HS_IFACES)
66
67 #################################################################################
68 #
69 #               Standard variable names
70 #
71 #################################################################################
72
73 #
74 # The fptools mk setup defines a set of standard names which are used by the standard
75 # targets provided by mk. One example of this is the use of standard names
76 # for specifying what files to compile, their intermediate/object code, and
77 # the name of the final executable. Based on the settings of these variables, the
78 # standard 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.  This is complicated by
91 # the fact that a .hsc file gives rise to a .hs file (which needs to
92 # be automatically included in $(SRCS)), but the .hs file might
93 # already be present in the current directory and we don't want to
94 # compile it twice.
95
96 # So we figure out the sources in three stages: first figure out
97 # what's in the current directory (this is $(PRE_SRCS)).  Then figure
98 # out all the "derived" sources (eg. A.hsc generates A.hs and
99 # A_hsc.c), and finally put all these together and remove duplicates
100 # (GNU make's handy sort function does the duplicate removing).
101 #
102 # BOOT_SRCS: list of machine generated Haskell modules.
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 PRE_SRCS    = $(wildcard *.lhs *.hs *.c *.prl *.lprl *.lit *.verb *.hsc)
112
113 HSC_SRCS     = $(filter %.hsc, $(PRE_SRCS))
114 DERIVED_SRCS = $(patsubst %.hsc, %.hs, $(HSC_SRCS)) \
115                $(patsubst %.hsc, %_hsc.c, $(HSC_SRCS)) \
116                $(patsubst %.hsc, %_hsc.h, $(HSC_SRCS))
117
118 # EXCLUDED_SRCS can be set in the Makefile, otherwise it defaults to empty.
119 EXCLUDED_DERIVED_SRCS = $(patsubst %.hsc,%.hs %_hsc.c, \
120                             $(filter %.hsc, $(EXCLUDED_SRCS)))
121 CLOSED_EXCLUDED_SRCS  = $(sort $(EXCLUDED_SRCS) $(EXCLUDED_DERIVED_SRCS))
122
123 SRCS        = $(filter-out $(CLOSED_EXCLUDED_SRCS), \
124                 $(sort $(PRE_SRCS) $(DERIVED_SRCS)))
125
126 HS_SRCS     = $(filter %.lhs %.hs %.hc,$(sort $(SRCS) $(BOOT_SRCS)))
127 HS_OBJS     = $(addsuffix .$(way_)o,$(basename $(HS_SRCS)))
128 HS_HCS      = $(addsuffix .$(way_)hc,$(basename $(HS_SRCS)))
129 HS_SS       = $(addsuffix .$(way_)s,$(basename $(HS_SRCS)))
130 HS_IFACES   = $(addsuffix .$(way_)hi,$(basename $(HS_SRCS)))
131
132 HSC_C_OBJS  = $(patsubst %_hsc.c,%_hsc.o,$(SRCS))
133
134 C_SRCS      = $(filter %.c,$(SRCS)) 
135 C_OBJS      = $(addsuffix .$(way_)o,$(basename $(C_SRCS)))
136
137 # SCRIPT_SRCS:  list of raw script files (in literate form)
138 # SCRIPT_OBJS:  de-litted scripts
139 SCRIPT_SRCS=$(filter %.lprl,$(SRCS))
140 SCRIPT_OBJS=$(addsuffix .prl,$(basename $(SCRIPT_SRCS)))
141
142 OBJS=$(HS_OBJS) $(C_OBJS) $(SCRIPT_OBJS)
143
144 #
145 # Note that as long as you use the standard variables for setting
146 # which C & Haskell programs you want to work on, you don't have
147 # to set any of the clean variables - the default should do the Right
148 # Thing.
149 #
150
151 #------------------------------------------------------------------
152 #
153 # make depend defaults
154 #
155 # The default set of files for the dependency generators to work on
156 # is just their source equivalents.
157
158
159 ifneq "$(BootingFromHc)" "YES"
160 MKDEPENDHS_SRCS=$(HS_SRCS)
161 else
162 MKDEPENDHS_SRCS=
163 endif
164
165 MKDEPENDC_SRCS=$(C_SRCS) 
166
167 #------------------------------------------------------------------
168 #
169 # make TAGS defaults
170 #
171 # The default set of files for the dependency generators to work on
172 # is just their source equivalents.
173
174 TAGS_HS_SRCS=$(HS_SRCS)
175 TAGS_C_SRCS=$(C_SRCS)
176
177 #------------------------------------------------------------------
178 # Clean file make-variables.
179 #
180 # The following three variables are used to control
181 # what gets removed when doing `make clean' 
182 #
183 # MOSTLYCLEAN_FILES   object code etc., but not stuff
184 #                     that is slow to recompile and/or stable
185 #
186 # CLEAN_FILES  all files that are created by running make.
187 #
188 # MAINTAINER_CLEAN_FILES also clean out machine-generated files
189 #                        that may require extra tools to create.
190 #
191 #
192 MOSTLY_CLEAN_FILES += $(HS_OBJS) $(C_OBJS)
193 CLEAN_FILES        += $(HS_PROG) $(C_PROG) $(SCRIPT_PROG) $(SCRIPT_LINK) \
194                       $(PROG) $(LIBRARY) $(HS_IFACES) $(HS_SS) a.out \
195                       $(DERIVED_SRCS)
196
197 # Don't clean the .hc files if we're bootstrapping
198 ifneq "$(BootingFromHc)" "YES"
199 CLEAN_FILES += $(HS_HCS)
200 endif
201
202 DIST_CLEAN_FILES += .depend
203 MAINTAINER_CLEAN_FILES += $(BOOT_SRCS)
204
205 #
206 # `Standard' set of files to clean out.
207 #
208 MOSTLY_CLEAN_FILES += \
209  *.CKP *.ln *.BAK *.bak .*.bak *.o *core a.out errs ,* *.a .emacs_*  \
210  tags TAGS *.ind *.ilg *.idx *.idx-prev *.aux *.aux-prev *.dvi *.log \
211  *.toc *.lot *.lof *.blg *.cb *_stub.c *_stub.h *.raw_s
212
213 #------------------------------------------------------------------
214 #
215 # Distribution setup
216
217 # Following variables are used for creating source and binary distributions:
218 #
219 #  SRC_DIST_NAME && BIN_DIST_NAME  -- the package names
220 #
221 #  SRC_DIST_FILES = list of extra files to include from a build tree into a source
222 #                   distribution
223 #  
224 #  SRC_DIST_DIR  = what the current directory in the source/build tree
225 #                  maps to in the source distrib. tree being created.
226 #
227 SRC_DIST_NAME=$(ProjectNameShort)-$(ProjectVersion)
228
229 #
230 # Binary distributions proceeds as follows:
231 #
232 # Fromthe top of a build tree, you do `make binary-dist'. The
233 # canned rule for this  (in target.mk) will then do a binary
234 # install to a temporary directory before packaging it all up.
235 # The following variables guide the binary-dist:
236 #
237 #  BIN_DIST_TMPDIR= the absolute path to where the temporary directory
238 #                   structure of a binary distribution should be created.
239 #                   [Default: toplevel from which you issue `make binary-dist']
240 #  BIN_DIST_NAME=   what to call the thing.
241 #
242 #  BIN_DIST_DIRS=   at the toplevel, list of directories to descend into when
243 #                   building the distribution tree.
244 #  
245 #  An extra directory variable that is set during bin-dists is $(bindist_top), giving
246 #  the abs. path to the root of the binary installation tree. (useful when punting
247 #  stuff like README and ANNOUNCE into a distrib, for instance)
248 #
249 #  The layout of a binary distribution is described in the
250 #  installation documentation.
251 #
252
253
254 # Directory in which DLLs are dumped so as not to get picked up by running
255 # programs (e.g. ghc or hsc) that run in the build tree
256
257 DLL_PEN = $(FPTOOLS_TOP)/dll
258