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 @@\
63 $(ARCHIVE) $@ objs @@\
66 concat3(lib,libname,_p.a): objs @@\
69 cd profiled; $(ARCHIVE) ../$@ objs @@\
72 lint:: concat3(llib-l,libname,.ln) @@\
74 concat3(llib-l,libname,.ln): srcs @@\
75 $(LINT) concat($(LINTLIBFLAG),libname) $(LINTFLAGS) srcs lintlibs @@\
78 $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
79 $(RM) concat3(llib-l,libname,.ln) @@\
81 $(RM) profiled/?*.o @@\
84 $(INSTALLRAW) -c -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
85 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
86 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
87 $(INSTALLRAW) -c -m 644 concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
88 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
89 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
90 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\
92 #else /* !PROFILED_LIBS */
94 * Rule for building objects in libraries.
97 #define library_obj_rule() @@\
99 $(CC) -c $(CFLAGS) $*.c @@\
100 -$(LD) -x -r -o a.out $*.o @@\
103 #define library_ro_object(cfile) @@\
104 concat(cfile,.o): concat(cfile,.c) @@\
105 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
106 -$(LD) -x -r -o a.out $*.o @@\
109 #define library_asm_object(ofile,sfile) @@\
111 $(CPP) x.c | $(AS) - @@\
112 -$(LD) -x -r -o $*.o a.out @@\
115 #define install_library_target(libname,objs,srcs,lintlibs) @@\
117 all:: concat3(lib,libname,.a) @@\
118 all:: concat3(llib-l,libname,.ln) @@\
120 concat3(lib,libname,.a): objs @@\
123 $(ARCHIVE) $@ objs @@\
126 lint:: concat3(llib-l,libname,.ln) @@\
128 concat3(llib-l,libname,.ln): srcs @@\
129 $(LINT) concat($(LINTLIBFLAG),libname) $(LINTFLAGS) srcs lintlibs @@\
132 $(RM) concat3(lib,libname,.a) @@\
133 $(RM) concat3(llib-l,libname,.ln) @@\
137 $(INSTALLRAW) -c -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
138 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
139 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
140 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\
142 #endif /* PROFILED_LIBS */
145 * Rule for building utilities (binaries which don't get installed)
147 #define genutil(pgm,objs,localdeps,syslibs) @@\
150 pgm: objs localdeps @@\
151 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
157 * Rule for building "generator" programs.
160 #define generate(file,pgm,libs) @@\
162 pgm: concat(pgm,.c) libs @@\
163 $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\
169 $(RM) file pgm concat(pgm,.o)
171 #define generate_depend(file,pgm,libs) @@\
172 generate(file,pgm,libs) @@\
178 * Rule for building test programs (something which is not installed)
181 #define test(pgm,locallibs,syslibs) @@\
185 pgm: concat(pgm,.c) locallibs @@\
186 $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\
189 $(RM) pgm concat(pgm,.o) @@\
192 * Rule for compileing files with "et"
196 #define comp_et_prof(tbl) @@\
197 concat(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) @@\
203 $(RM) concat(src,.o) concat(src,.h) @@\
204 depend:: concat(src,.h)
205 #else /* !PROFILED_LIBS */
206 #define comp_et_prof(tbl) comp_et(tbl)
207 #endif /* PROFILED_LIBS */
209 #define comp_et(tbl) @@\
210 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
211 $(COMPILE_ET) concat(tbl,.et) @@\
213 $(RM) concat(src,.o) concat(src,.h)
215 #define comp_et_depend(src) @@\
218 depend:: concat(src,.h)
220 #define mk_cmds(tbl) @@\
221 concat(tbl,.o): concat(tbl,.ct) @@\
222 $(MAKE_COMMANDS) concat(tbl,.ct) @@\
227 * Rule for building some random object module
230 #define host_simple_object(obj,src) @@\
232 $(HCC) $(HCFLAGS) -c src @@\
237 #define ro_object(obj,src) @@\
239 $(CCRO) $(CFLAGS) -c src @@\
245 * Rule for building some random object module with compile flags and
246 * other dependendcies
249 #define host_flag_object(obj,src,flags,localdeps) @@\
250 obj: src localdeps @@\
251 $(HCC) $(HCFLAGS) flags -c src @@\
256 #define ro_flag_object(obj,src,flags,localdeps) @@\
257 obj: src localdeps @@\
258 $(CCRO) $(CFLAGS) flags -c src @@\
264 * Rule for building some random object module with compile flags, an
265 * intermediate output, and some other dependencies
268 #define host_cplx_object(obj,interim,src,flags,localdeps) @@\
269 obj: interim src localdeps @@\
270 $(HCC) $(HCFLAGS) flags -c src @@\
271 $(MV) interim obj @@\
276 #define ro_cplx_object(obj,interim,src,flags,localdeps) @@\
277 obj: src localdeps interim @@\
278 $(CCRO) $(CFLAGS) flags -c src @@\
279 $(MV) interim obj @@\
285 * Rule for building a program which is to be installed:
288 #define program(pgm,objs,localdeps,syslibs,installdir) @@\
291 pgm: localdeps objs @@\
292 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
295 $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\
301 * Rule for building a program which is to be installed setuid root:
304 #define suidprogram(pgm,objs,localdeps,syslibs,installdir) @@\
307 pgm: objs localdeps @@\
308 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
311 $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm @@\
317 * Rule for building a specially installed program
320 #define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\
323 pgm: objs localdeps @@\
324 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
327 $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\
333 * Special rule for building and installing a Berkeley r-command
334 * We need to preserve the original copies upon installation.
337 #define ucbprogram(pgm,objs,localdeps,syslibs,installdir) @@\
340 pgm: objs localdeps @@\
341 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
344 -if [ ! -f concat5(${DESTDIR},installdir,/,pgm,.ucb) -a -f concat4(${DESTDIR},installdir,/,pgm) ]; then \ @@\
345 mv concat4(${DESTDIR},installdir,/,pgm) concat5(${DESTDIR},installdir,/,pgm,.ucb); fi; exit 0 @@\
346 $(INSTALLSUID) pgm concat4(${DESTDIR},installdir,/,pgm) @@\
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).
357 #define manpage(section,page) @@\
360 $(INSTALLFILE) page concat4(${DESTDIR}${MANDIR}/man,section,/,`basename page`) @@\
363 * Rule for building makefile dependencies.
366 #define depend_target() @@\
368 @echo "### Now computing dependencies" @@\
369 @$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS) @@\
371 #define clean_target() @@\
373 $(RM) *~ \#* *.bak $(TAGSFILE)
375 #define tags_target() @@\
379 #define makefile_target() @@\
381 -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\
382 $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\
384 #define foreach_subdirs(name,subdirs) @@\
386 @for d in subdirs; \ @@\
388 (cd $$d; echo "### Making" name "in" `pwd`; \ @@\
389 $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \ @@\
390 echo "### Done with" `pwd`); \ @@\
393 #define print_target() @@\
397 #define src_target() @@\
402 -$(LN) ${SRCDIR}/$@ $@
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) @@\
413 #define do_subdirs(subdirs) @@\
414 do_subdirs_no_imakefile(subdirs) @@\
417 @echo "### Making Makefiles in" `pwd` @@\
418 @for d in subdirs; \ @@\
420 (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\
421 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
422 NEWTOP=../$(BUILDTOP) \ @@\
423 BUILDTOP=../$(BUILDTOP) \ @@\
426 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
427 NEWTOP=../$(BUILDTOP) \ @@\
429 echo "### Done with" `pwd`); \ @@\