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
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
15 #define requote(x) "x"
20 * Rule for building objects in libraries.
23 #define library_obj_rule() @@\
25 $(CC) PROF_FLAG -c $(CFLAGS) $*.c @@\
26 -$(LD) -X -r -o profiled/$*.o $*.o @@\
27 $(CC) -c $(CFLAGS) $*.c @@\
28 -$(LD) -x -r -o a.out $*.o @@\
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.
36 #define library_ro_object(cfile) @@\
37 concat(cfile,.o): concat(cfile,.c) @@\
38 $(CC) PROF_FLAG -c $(CFLAGS) concat(cfile,.c) @@\
39 -$(LD) -X -r -o profiled/$*.o $*.o @@\
40 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
41 -$(LD) -x -r -o a.out $*.o @@\
44 #define library_asm_object(ofile,sfile) @@\
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 @@\
53 #define install_library_target(libname,objs,srcs,lintlibs) @@\
55 all:: concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
56 all:: concat3(llib-l,libname,.ln) @@\
58 concat3(lib,libname,.a): objs @@\
59 $(ARCHIVE) $@ objs @@\
62 concat3(lib,libname,_p.a): objs @@\
63 cd profiled; $(ARCHIVE) ../$@ objs @@\
66 lint:: concat3(llib-l,libname,.ln) @@\
68 concat3(llib-l,libname,.ln): srcs @@\
69 $(LINT) concat(-C,libname) $(LINTFLAGS) srcs lintlibs @@\
72 $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
73 $(RM) concat3(llib-l,libname,.ln) @@\
75 $(RM) profiled/?*.o @@\
78 $(INSTALLFILE) concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
79 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
80 $(INSTALLFILE) concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
81 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
82 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\
84 #else /* !PROFILED_LIBS */
86 * Rule for building objects in libraries.
89 #define library_obj_rule() @@\
91 $(CC) -c $(CFLAGS) $*.c @@\
92 -$(LD) -x -r -o a.out $*.o @@\
95 #define library_ro_object(cfile) @@\
96 concat(cfile,.o): concat(cfile,.c) @@\
97 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
98 -$(LD) -x -r -o a.out $*.o @@\
101 #define library_asm_object(ofile,sfile) @@\
103 $(CPP) x.c | $(AS) - @@\
104 -$(LD) -x -r -o $*.o a.out @@\
107 #define install_library_target(libname,objs,srcs,lintlibs) @@\
109 all:: concat3(lib,libname,.a) @@\
110 all:: concat3(llib-l,libname,.ln) @@\
112 concat3(lib,libname,.a): objs @@\
113 $(ARCHIVE) $@ objs @@\
116 lint:: concat3(llib-l,libname,.ln) @@\
118 concat3(llib-l,libname,.ln): srcs @@\
119 $(LINT) concat(-C,libname) $(LINTFLAGS) srcs lintlibs @@\
122 $(RM) concat3(lib,libname,.a) @@\
123 $(RM) concat3(llib-l,libname,.ln) @@\
127 $(INSTALLFILE) concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
128 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
129 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBBDIR)/,llib-l,libname,.ln) @@\
131 #endif /* PROFILED_LIBS */
134 * Rule for building utilities (binaries which don't get installed)
136 #define genutil(pgm,objs,localdeps,syslibs) @@\
139 pgm: objs localdeps @@\
140 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
146 * Rule for building "generator" programs.
149 #define generate(file,pgm,libs) @@\
151 pgm: concat(pgm,.c) libs @@\
152 $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\
158 $(RM) file pgm concat(pgm,.o)
160 #define generate_depend(file,pgm,libs) @@\
161 generate(file,pgm,libs) @@\
167 * Rule for building test programs (something which is not installed)
170 #define test(pgm,locallibs,syslibs) @@\
174 pgm: concat(pgm,.c) locallibs @@\
175 $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\
178 $(RM) pgm concat(pgm,.o) @@\
181 * Rule for compileing files with "et"
185 #define comp_et_prof(tbl) @@\
186 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
187 $(COMPILE_ET) concat(tbl,.et) -n @@\
188 $(CC) -c PROF_FLAG concat(tbl,.et.c) @@\
189 $(MV) concat(tbl,.et.o) concat3(profiled/,tbl,.o) @@\
190 $(COMPILE_ET) concat(tbl,.et) @@\
192 $(RM) concat(src,.o) concat(src,.h) @@\
193 depend:: concat(src,.h)
194 #else /* !PROFILED_LIBS */
195 #define comp_et_prof(tbl) comp_et(tbl)
196 #endif /* PROFILED_LIBS */
198 #define comp_et(tbl) @@\
199 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
200 $(COMPILE_ET) concat(tbl,.et) @@\
202 $(RM) concat(src,.o) concat(src,.h)
204 #define comp_et_depend(src) @@\
207 depend:: concat(src,.h)
210 * Rule for building some random object module
213 #define host_simple_object(obj,src) @@\
215 $(HCC) $(HCFLAGS) -c src @@\
220 #define ro_object(obj,src) @@\
222 $(CCRO) $(CFLAGS) -c src @@\
228 * Rule for building some random object module with compile flags and
229 * other dependendcies
232 #define host_flag_object(obj,src,flags,localdeps) @@\
233 obj: src localdeps @@\
234 $(HCC) $(HCFLAGS) flags -c src @@\
239 #define ro_flag_object(obj,src,flags,localdeps) @@\
240 obj: src localdeps @@\
241 $(CCRO) $(CFLAGS) flags -c src @@\
247 * Rule for building some random object module with compile flags, an
248 * intermediate output, and some other dependencies
251 #define host_cplx_object(obj,interim,src,flags,localdeps) @@\
252 obj: interim src localdeps @@\
253 $(HCC) $(HCFLAGS) flags -c src @@\
254 $(MV) interim obj @@\
259 #define ro_cplx_object(obj,interim,src,flags,localdeps) @@\
260 obj: src localdeps interim @@\
261 $(CCRO) $(CFLAGS) flags -c src @@\
262 $(MV) interim obj @@\
268 * Rule for building a program which is to be installed:
271 #define program(pgm,objs,localdeps,syslibs,installdir) @@\
274 pgm: localdeps objs @@\
275 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
278 $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\
284 * Rule for building a program which is to be installed setuid root:
287 #define suidprogram(pgm,objs,localdeps,syslibs,installdir) @@\
290 pgm: objs localdeps @@\
291 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
294 $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm @@\
300 * Rule for building a specially installed program
303 #define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\
306 pgm: objs localdeps @@\
307 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
310 $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\
316 * Rule for installing man pages. Section installing into should match
317 * suffix, or the man page won't show up when using man(1).
320 #define manpage(section,page) @@\
323 $(INSTALLFILE) page concat3(${DESTDIR}${MANDIR}/man,section,/`basename page`) @@\
326 * Rule for building makefile dependencies.
329 #define depend_target() @@\
331 @echo "### Now computing dependencies" @@\
332 @$(DEPEND) -s "# DO NOT DELETE" $(CFLAGS) $(SRCS) @@\
334 #define clean_target() @@\
336 $(RM) *~ \#* *.bak $(TAGSFILE)
338 #define tags_target() @@\
342 #define makefile_target() @@\
344 -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\
345 $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\
347 #define foreach_subdirs(name,subdirs) @@\
349 @for d in subdirs; \ @@\
351 (cd $$d; echo "### Making" name "in" `pwd`; \ @@\
352 $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \ @@\
353 echo "### Done with" `pwd`); \ @@\
356 #define print_target() @@\
360 #define src_target() @@\
364 -$(LN) ${SRCDIR}/$@ $@
366 #define do_subdirs_no_imakefile(subdirs) @@\
367 foreach_subdirs(all, subdirs) @@\
368 foreach_subdirs(install, subdirs) @@\
369 foreach_subdirs(clean, subdirs) @@\
370 foreach_subdirs(depend, subdirs) @@\
371 foreach_subdirs(tags, subdirs) @@\
372 foreach_subdirs(print, subdirs) @@\
373 foreach_subdirs(src, subdirs) @@\
375 #define do_subdirs(subdirs) @@\
376 do_subdirs_no_imakefile(subdirs) @@\
379 @echo "### Making Makefiles in" `pwd` @@\
380 @for d in subdirs; \ @@\
382 (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\
383 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
384 NEWTOP=../$(BUILDTOP) \ @@\
385 BUILDTOP=../$(BUILDTOP) \ @@\
388 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
389 NEWTOP=../$(BUILDTOP) \ @@\
391 echo "### Done with" `pwd`); \ @@\