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