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