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