]> andersk Git - moira.git/blame - util/imake.includes/Imake.rules
Programmer: Win Treese
[moira.git] / util / imake.includes / Imake.rules
CommitLineData
2e387221 1/**/# $Source$
2/**/# $Author$
3/**/# $Header$
4/**/#
5
b9be51ef 6#ifdef __STDC__
7#define concat(x,y) x##y
8#define concat3(x,y,z) x##y##z
9#define concat4(w,x,y,z) w##x##y##z
10#define requote(x) #x
11#else
df897414 12#define concat(x,y)x/**/y
13#define concat3(x,y,z)x/**/y/**/z
14#define concat4(w,x,y,z)w/**/x/**/y/**/z
b9be51ef 15#define requote(x) "x"
16#endif
17
df897414 18#ifdef PROFILED_LIBS
b9be51ef 19/*
20 * Rule for building objects in libraries.
21 */
22
23#define library_obj_rule() @@\
24.c.o: @@\
df897414 25 $(CC) PROF_FLAG -c $(CFLAGS) $*.c @@\
b9be51ef 26 -$(LD) -X -r -o profiled/$*.o $*.o @@\
27 $(CC) -c $(CFLAGS) $*.c @@\
28 -$(LD) -x -r -o a.out $*.o @@\
29 $(MV) a.out $*.o
30
31/*
32 * cc -R breaks profiling with -p on 4.3BSD on the VAX
33 * (and probably elsewhere), so we don't do it for the profiled version.
34 */
35
36#define library_ro_object(cfile) @@\
37concat(cfile,.o): concat(cfile,.c) @@\
df897414 38 $(CC) PROF_FLAG -c $(CFLAGS) concat(cfile,.c) @@\
b9be51ef 39 -$(LD) -X -r -o profiled/$*.o $*.o @@\
40 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
41 -$(LD) -x -r -o a.out $*.o @@\
42 $(MV) a.out $*.o
43
44#define library_asm_object(ofile,sfile) @@\
45ofile: sfile @@\
46 $(CP) sfile x.c @@\
47 $(CPP) -DPROF x.c | $(AS) - @@\
48 -$(LD) -X -r -o profiled/$*.o a.out @@\
49 $(CPP) x.c | $(AS) - @@\
50 -$(LD) -x -r -o $*.o a.out @@\
51 $(RM) a.out x.c
52
53#define install_library_target(libname,objs,srcs,lintlibs) @@\
54 @@\
55all:: concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
56all:: concat3(llib-l,libname,.ln) @@\
57 @@\
58concat3(lib,libname,.a): objs @@\
59 $(ARCHIVE) $@ objs @@\
60 $(RANLIB) $@ @@\
61 @@\
62concat3(lib,libname,_p.a): objs @@\
63 cd profiled; $(ARCHIVE) ../$@ objs @@\
64 $(RANLIB) $@ @@\
65 @@\
2e387221 66lint:: concat3(llib-l,libname,.ln) @@\
b9be51ef 67 @@\
68concat3(llib-l,libname,.ln): srcs @@\
f9d599c8 69 $(LINT) concat(-C,libname) $(LINTFLAGS) srcs lintlibs @@\
b9be51ef 70 @@\
71clean:: @@\
72 $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
73 $(RM) concat3(llib-l,libname,.ln) @@\
74 $(RM) objs @@\
df897414 75 $(RM) profiled/?*.o @@\
b9be51ef 76 @@\
77install:: @@\
93fe6c95 78 $(INSTALLRAW) -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
f9d599c8 79 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
93fe6c95 80 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
81 $(INSTALLRAW) -m 644 concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
f9d599c8 82 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
93fe6c95 83 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
f9d599c8 84 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\
b9be51ef 85
df897414 86#else /* !PROFILED_LIBS */
87/*
88 * Rule for building objects in libraries.
89 */
90
91#define library_obj_rule() @@\
92.c.o: @@\
93 $(CC) -c $(CFLAGS) $*.c @@\
94 -$(LD) -x -r -o a.out $*.o @@\
95 $(MV) a.out $*.o
96
97#define library_ro_object(cfile) @@\
98concat(cfile,.o): concat(cfile,.c) @@\
99 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
100 -$(LD) -x -r -o a.out $*.o @@\
101 $(MV) a.out $*.o
102
103#define library_asm_object(ofile,sfile) @@\
104ofile: sfile @@\
105 $(CPP) x.c | $(AS) - @@\
106 -$(LD) -x -r -o $*.o a.out @@\
107 $(RM) a.out x.c
108
109#define install_library_target(libname,objs,srcs,lintlibs) @@\
110 @@\
111all:: concat3(lib,libname,.a) @@\
112all:: concat3(llib-l,libname,.ln) @@\
113 @@\
114concat3(lib,libname,.a): objs @@\
115 $(ARCHIVE) $@ objs @@\
116 $(RANLIB) $@ @@\
117 @@\
118lint:: concat3(llib-l,libname,.ln) @@\
119 @@\
120concat3(llib-l,libname,.ln): srcs @@\
f9d599c8 121 $(LINT) concat(-C,libname) $(LINTFLAGS) srcs lintlibs @@\
df897414 122 @@\
123clean:: @@\
124 $(RM) concat3(lib,libname,.a) @@\
125 $(RM) concat3(llib-l,libname,.ln) @@\
126 $(RM) objs @@\
127 @@\
128install:: @@\
93fe6c95 129 $(INSTALLRAW) -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
df897414 130 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
93fe6c95 131 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
f9d599c8 132 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBBDIR)/,llib-l,libname,.ln) @@\
df897414 133
134#endif /* PROFILED_LIBS */
135
b9be51ef 136/*
137 * Rule for building utilities (binaries which don't get installed)
138 */
b9be51ef 139#define genutil(pgm,objs,localdeps,syslibs) @@\
140all:: pgm @@\
141 @@\
142pgm: objs localdeps @@\
143 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
144 @@\
145clean:: @@\
146 $(RM) pgm objs @@\
147
148/*
149 * Rule for building "generator" programs.
150 */
151
152#define generate(file,pgm,libs) @@\
153 @@\
154pgm: concat(pgm,.c) libs @@\
155 $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\
156 @@\
157file: pgm @@\
7caabe5f 158 ./pgm file @@\
b9be51ef 159 @@\
160clean:: @@\
161 $(RM) file pgm concat(pgm,.o)
162
163#define generate_depend(file,pgm,libs) @@\
164 generate(file,pgm,libs) @@\
165 @@\
166depend:: file
167
168
169/*
170 * Rule for building test programs (something which is not installed)
171 */
172
173#define test(pgm,locallibs,syslibs) @@\
174 @@\
175all:: pgm @@\
176 @@\
177pgm: concat(pgm,.c) locallibs @@\
178 $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\
179 @@\
180clean:: @@\
181 $(RM) pgm concat(pgm,.o) @@\
182
7caabe5f 183/*
184 * Rule for compileing files with "et"
185 */
186
df897414 187#ifdef PROFILED_LIBS
188#define comp_et_prof(tbl) @@\
189concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
190 $(COMPILE_ET) concat(tbl,.et) -n @@\
191 $(CC) -c PROF_FLAG concat(tbl,.et.c) @@\
192 $(MV) concat(tbl,.et.o) concat3(profiled/,tbl,.o) @@\
193 $(COMPILE_ET) concat(tbl,.et) @@\
7caabe5f 194clean:: @@\
195 $(RM) concat(src,.o) concat(src,.h) @@\
df897414 196depend:: concat(src,.h)
197#else /* !PROFILED_LIBS */
198#define comp_et_prof(tbl) comp_et(tbl)
199#endif /* PROFILED_LIBS */
200
201#define comp_et(tbl) @@\
202concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
203 $(COMPILE_ET) concat(tbl,.et) @@\
204clean:: @@\
205 $(RM) concat(src,.o) concat(src,.h)
7caabe5f 206
207#define comp_et_depend(src) @@\
208 comp_et(src) @@\
209 @@\
df897414 210depend:: concat(src,.h)
7caabe5f 211
b9be51ef 212/*
213 * Rule for building some random object module
214 */
215
216#define host_simple_object(obj,src) @@\
217obj: src @@\
218 $(HCC) $(HCFLAGS) -c src @@\
219 @@\
220clean:: @@\
221 $(RM) obj @@\
222
223#define ro_object(obj,src) @@\
224obj: src @@\
225 $(CCRO) $(CFLAGS) -c src @@\
226 @@\
227clean:: @@\
228 $(RM) obj @@\
229
2e387221 230/*
231 * Rule for building some random object module with compile flags and
232 * other dependendcies
233 */
234
235#define host_flag_object(obj,src,flags,localdeps) @@\
236obj: src localdeps @@\
237 $(HCC) $(HCFLAGS) flags -c src @@\
238 @@\
239clean:: @@\
240 $(RM) obj @@\
241
242#define ro_flag_object(obj,src,flags,localdeps) @@\
243obj: src localdeps @@\
244 $(CCRO) $(CFLAGS) flags -c src @@\
245 @@\
246clean:: @@\
247 $(RM) obj @@\
248
249/*
250 * Rule for building some random object module with compile flags, an
251 * intermediate output, and some other dependencies
252 */
253
254#define host_cplx_object(obj,interim,src,flags,localdeps) @@\
7caabe5f 255obj: interim src localdeps @@\
2e387221 256 $(HCC) $(HCFLAGS) flags -c src @@\
257 $(MV) interim obj @@\
258 @@\
259clean:: @@\
260 $(RM) obj @@\
261
262#define ro_cplx_object(obj,interim,src,flags,localdeps) @@\
7caabe5f 263obj: src localdeps interim @@\
2e387221 264 $(CCRO) $(CFLAGS) flags -c src @@\
265 $(MV) interim obj @@\
266 @@\
267clean:: @@\
268 $(RM) obj @@\
269
b9be51ef 270/*
271 * Rule for building a program which is to be installed:
272 */
273
274#define program(pgm,objs,localdeps,syslibs,installdir) @@\
275all:: pgm @@\
276 @@\
7caabe5f 277pgm: localdeps objs @@\
278 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
b9be51ef 279 @@\
280install:: @@\
2e387221 281 $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\
282 @@\
283clean:: @@\
284 $(RM) pgm objs @@\
285
286/*
287 * Rule for building a program which is to be installed setuid root:
288 */
289
290#define suidprogram(pgm,objs,localdeps,syslibs,installdir) @@\
291all:: pgm @@\
292 @@\
293pgm: objs localdeps @@\
f9d599c8 294 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
2e387221 295 @@\
296install:: @@\
297 $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm @@\
b9be51ef 298 @@\
299clean:: @@\
300 $(RM) pgm objs @@\
301
302/*
303 * Rule for building a specially installed program
304 */
305
306#define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\
307all:: pgm @@\
308 @@\
309pgm: objs localdeps @@\
f9d599c8 310 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
b9be51ef 311 @@\
312install:: @@\
2e387221 313 $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\
b9be51ef 314 @@\
315clean:: @@\
316 $(RM) pgm objs @@\
317
318/*
2e387221 319 * Rule for installing man pages. Section installing into should match
320 * suffix, or the man page won't show up when using man(1).
b9be51ef 321 */
322
323#define manpage(section,page) @@\
324all:: @@\
325install:: page @@\
28580807 326 $(INSTALLFILE) page concat4(${DESTDIR}${MANDIR}/man,section,/,`basename page`) @@\
b9be51ef 327
328/*
2e387221 329 * Rule for building makefile dependencies.
b9be51ef 330 */
331
332#define depend_target() @@\
333depend:: $(SRCS) @@\
2e387221 334 @echo "### Now computing dependencies" @@\
b9be51ef 335 @$(DEPEND) -s "# DO NOT DELETE" $(CFLAGS) $(SRCS) @@\
336
337#define clean_target() @@\
338clean:: @@\
339 $(RM) *~ \#* *.bak $(TAGSFILE)
340
341#define tags_target() @@\
342tags:: @@\
343 $(TAGGER) *.c *.h
344
345#define makefile_target() @@\
346Makefile:: @@\
347 -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\
348 $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\
349
350#define foreach_subdirs(name,subdirs) @@\
351name:: @@\
352 @for d in subdirs; \ @@\
353 do \ @@\
354 (cd $$d; echo "### Making" name "in" `pwd`; \ @@\
7caabe5f 355 $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \ @@\
b9be51ef 356 echo "### Done with" `pwd`); \ @@\
357 done
358
359#define print_target() @@\
360print:: ${CODE} @@\
361 ${LPR} ${CODE}
362
363#define src_target() @@\
364src:: ${CODE} @@\
365 @@\
366${CODE}: @@\
719b9402 367 $(RM) $@ @@\
b9be51ef 368 -$(LN) ${SRCDIR}/$@ $@
369
370#define do_subdirs_no_imakefile(subdirs) @@\
371 foreach_subdirs(all, subdirs) @@\
372 foreach_subdirs(install, subdirs) @@\
373 foreach_subdirs(clean, subdirs) @@\
374 foreach_subdirs(depend, subdirs) @@\
375 foreach_subdirs(tags, subdirs) @@\
376 foreach_subdirs(print, subdirs) @@\
377 foreach_subdirs(src, subdirs) @@\
378
379#define do_subdirs(subdirs) @@\
380 do_subdirs_no_imakefile(subdirs) @@\
381 @@\
382Makefiles:: @@\
383 @echo "### Making Makefiles in" `pwd` @@\
384 @for d in subdirs; \ @@\
385 do \ @@\
386 (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\
387 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
388 NEWTOP=../$(BUILDTOP) \ @@\
389 BUILDTOP=../$(BUILDTOP) \ @@\
390 -f ../Makefile \ @@\
391 Makefile; \ @@\
392 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
393 NEWTOP=../$(BUILDTOP) \ @@\
394 Makefiles; \ @@\
395 echo "### Done with" `pwd`); \ @@\
396 done
397
398
399
This page took 0.109847 seconds and 5 git commands to generate.