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 concat5(v,w,x,y,z) v##w##x##y##z
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
16 #define concat5(v,w,x,y,z)v/**/w/**/x/**/y/**/z
17 #define requote(x) "x"
22 * Rule for building objects in libraries.
25 #define library_obj_rule() @@\
27 $(CC) PROF_FLAG -c $(CFLAGS) $*.c @@\
28 -$(LD) -X -r -o profiled/$*.o $*.o @@\
29 $(CC) -c $(CFLAGS) $*.c @@\
30 -$(LD) -x -r -o a.out $*.o @@\
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.
38 #define library_ro_object(cfile) @@\
39 concat(cfile,.o): concat(cfile,.c) @@\
40 $(CC) PROF_FLAG -c $(CFLAGS) concat(cfile,.c) @@\
41 -$(LD) -X -r -o profiled/$*.o $*.o @@\
42 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
43 -$(LD) -x -r -o a.out $*.o @@\
46 #define library_asm_object(ofile,sfile) @@\
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 @@\
55 #define install_library_target(libname,objs,srcs,lintlibs) @@\
57 all:: concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
58 all:: concat3(llib-l,libname,.ln) @@\
60 concat3(lib,libname,.a): objs @@\
61 $(ARCHIVE) $@ objs @@\
64 concat3(lib,libname,_p.a): objs @@\
65 cd profiled; $(ARCHIVE) ../$@ objs @@\
68 lint:: concat3(llib-l,libname,.ln) @@\
70 concat3(llib-l,libname,.ln): srcs @@\
71 $(LINT) concat(-C,libname) $(LINTFLAGS) srcs lintlibs @@\
74 $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
75 $(RM) concat3(llib-l,libname,.ln) @@\
77 $(RM) profiled/?*.o @@\
80 $(INSTALLRAW) -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
81 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
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) @@\
84 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
85 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
86 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\
88 #else /* !PROFILED_LIBS */
90 * Rule for building objects in libraries.
93 #define library_obj_rule() @@\
95 $(CC) -c $(CFLAGS) $*.c @@\
96 -$(LD) -x -r -o a.out $*.o @@\
99 #define library_ro_object(cfile) @@\
100 concat(cfile,.o): concat(cfile,.c) @@\
101 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
102 -$(LD) -x -r -o a.out $*.o @@\
105 #define library_asm_object(ofile,sfile) @@\
107 $(CPP) x.c | $(AS) - @@\
108 -$(LD) -x -r -o $*.o a.out @@\
111 #define install_library_target(libname,objs,srcs,lintlibs) @@\
113 all:: concat3(lib,libname,.a) @@\
114 all:: concat3(llib-l,libname,.ln) @@\
116 concat3(lib,libname,.a): objs @@\
117 $(ARCHIVE) $@ objs @@\
120 lint:: concat3(llib-l,libname,.ln) @@\
122 concat3(llib-l,libname,.ln): srcs @@\
123 $(LINT) concat(-C,libname) $(LINTFLAGS) srcs lintlibs @@\
126 $(RM) concat3(lib,libname,.a) @@\
127 $(RM) concat3(llib-l,libname,.ln) @@\
131 $(INSTALLRAW) -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
132 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
133 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
134 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBBDIR)/,llib-l,libname,.ln) @@\
136 #endif /* PROFILED_LIBS */
139 * Rule for building utilities (binaries which don't get installed)
141 #define genutil(pgm,objs,localdeps,syslibs) @@\
144 pgm: objs localdeps @@\
145 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
151 * Rule for building "generator" programs.
154 #define generate(file,pgm,libs) @@\
156 pgm: concat(pgm,.c) libs @@\
157 $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\
163 $(RM) file pgm concat(pgm,.o)
165 #define generate_depend(file,pgm,libs) @@\
166 generate(file,pgm,libs) @@\
172 * Rule for building test programs (something which is not installed)
175 #define test(pgm,locallibs,syslibs) @@\
179 pgm: concat(pgm,.c) locallibs @@\
180 $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\
183 $(RM) pgm concat(pgm,.o) @@\
186 * Rule for compileing files with "et"
190 #define comp_et_prof(tbl) @@\
191 concat(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) @@\
197 $(RM) concat(src,.o) concat(src,.h) @@\
198 depend:: concat(src,.h)
199 #else /* !PROFILED_LIBS */
200 #define comp_et_prof(tbl) comp_et(tbl)
201 #endif /* PROFILED_LIBS */
203 #define comp_et(tbl) @@\
204 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
205 $(COMPILE_ET) concat(tbl,.et) @@\
207 $(RM) concat(src,.o) concat(src,.h)
209 #define comp_et_depend(src) @@\
212 depend:: concat(src,.h)
215 * Rule for building some random object module
218 #define host_simple_object(obj,src) @@\
220 $(HCC) $(HCFLAGS) -c src @@\
225 #define ro_object(obj,src) @@\
227 $(CCRO) $(CFLAGS) -c src @@\
233 * Rule for building some random object module with compile flags and
234 * other dependendcies
237 #define host_flag_object(obj,src,flags,localdeps) @@\
238 obj: src localdeps @@\
239 $(HCC) $(HCFLAGS) flags -c src @@\
244 #define ro_flag_object(obj,src,flags,localdeps) @@\
245 obj: src localdeps @@\
246 $(CCRO) $(CFLAGS) flags -c src @@\
252 * Rule for building some random object module with compile flags, an
253 * intermediate output, and some other dependencies
256 #define host_cplx_object(obj,interim,src,flags,localdeps) @@\
257 obj: interim src localdeps @@\
258 $(HCC) $(HCFLAGS) flags -c src @@\
259 $(MV) interim obj @@\
264 #define ro_cplx_object(obj,interim,src,flags,localdeps) @@\
265 obj: src localdeps interim @@\
266 $(CCRO) $(CFLAGS) flags -c src @@\
267 $(MV) interim obj @@\
273 * Rule for building a program which is to be installed:
276 #define program(pgm,objs,localdeps,syslibs,installdir) @@\
279 pgm: localdeps objs @@\
280 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
283 $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\
289 * Rule for building a program which is to be installed setuid root:
292 #define suidprogram(pgm,objs,localdeps,syslibs,installdir) @@\
295 pgm: objs localdeps @@\
296 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
299 $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm @@\
305 * Rule for building a specially installed program
308 #define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\
311 pgm: objs localdeps @@\
312 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
315 $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\
321 * Special rule for building and installing a Berkeley r-command
322 * We need to preserve the original copies upon installation.
325 #define ucbprogram(pgm,objs,localdeps,syslibs,installdir) @@\
328 pgm: objs localdeps @@\
329 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
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) @@\
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).
345 #define manpage(section,page) @@\
348 $(INSTALLFILE) page concat4(${DESTDIR}${MANDIR}/man,section,/,`basename page`) @@\
351 * Rule for building makefile dependencies.
354 #define depend_target() @@\
356 @echo "### Now computing dependencies" @@\
357 @$(DEPEND) -s "# DO NOT DELETE" $(CFLAGS) $(SRCS) @@\
359 #define clean_target() @@\
361 $(RM) *~ \#* *.bak $(TAGSFILE)
363 #define tags_target() @@\
367 #define makefile_target() @@\
369 -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\
370 $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\
372 #define foreach_subdirs(name,subdirs) @@\
374 @for d in subdirs; \ @@\
376 (cd $$d; echo "### Making" name "in" `pwd`; \ @@\
377 $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \ @@\
378 echo "### Done with" `pwd`); \ @@\
381 #define print_target() @@\
385 #define src_target() @@\
390 -$(LN) ${SRCDIR}/$@ $@
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) @@\
401 #define do_subdirs(subdirs) @@\
402 do_subdirs_no_imakefile(subdirs) @@\
405 @echo "### Making Makefiles in" `pwd` @@\
406 @for d in subdirs; \ @@\
408 (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\
409 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
410 NEWTOP=../$(BUILDTOP) \ @@\
411 BUILDTOP=../$(BUILDTOP) \ @@\
414 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
415 NEWTOP=../$(BUILDTOP) \ @@\
417 echo "### Done with" `pwd`); \ @@\