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.
98 /* When debugging, leave symbols alone (don't do LD) */
99 #define library_obj_rule() @@\
101 $(CC) -c $(CFLAGS) $*.c
103 #define library_obj_rule() @@\
105 $(CC) -c $(CFLAGS) $*.c @@\
106 -$(LD) -x -r -o a.out $*.o @@\
110 #define library_ro_object(cfile) @@\
111 concat(cfile,.o): concat(cfile,.c) @@\
112 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
113 -$(LD) -x -r -o a.out $*.o @@\
116 #define library_asm_object(ofile,sfile) @@\
118 $(CPP) x.c | $(AS) - @@\
119 -$(LD) -x -r -o $*.o a.out @@\
122 #define install_library_target(libname,objs,srcs,lintlibs) @@\
124 all:: concat3(lib,libname,.a) @@\
125 all:: concat3(llib-l,libname,.ln) @@\
127 concat3(lib,libname,.a): objs @@\
130 $(ARCHIVE) $@ objs @@\
133 lint:: concat3(llib-l,libname,.ln) @@\
135 concat3(llib-l,libname,.ln): srcs @@\
136 $(LINT) concat($(LINTLIBFLAG),libname) $(LINTFLAGS) srcs lintlibs @@\
139 $(RM) concat3(lib,libname,.a) @@\
140 $(RM) concat3(llib-l,libname,.ln) @@\
144 $(INSTALLRAW) -c -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
145 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
146 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
147 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\
149 #endif /* PROFILED_LIBS */
152 * Rule for building utilities (binaries which don't get installed)
154 #define genutil(pgm,objs,localdeps,syslibs) @@\
157 pgm: objs localdeps @@\
158 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
164 * Rule for building "generator" programs.
167 #define generate(file,pgm,libs) @@\
169 pgm: concat(pgm,.c) libs @@\
170 $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\
176 $(RM) file pgm concat(pgm,.o)
178 #define generate_depend(file,pgm,libs) @@\
179 generate(file,pgm,libs) @@\
185 * Rule for building test programs (something which is not installed)
188 #define test(pgm,locallibs,syslibs) @@\
192 pgm: concat(pgm,.c) locallibs @@\
193 $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\
196 $(RM) pgm concat(pgm,.o) @@\
199 * Rule for compileing files with "et"
203 #define comp_et_prof(tbl) @@\
204 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
205 $(COMPILE_ET) concat(tbl,.et) -n @@\
206 $(CC) -c PROF_FLAG concat(tbl,.et.c) @@\
207 $(MV) concat(tbl,.et.o) concat3(profiled/,tbl,.o) @@\
208 $(COMPILE_ET) concat(tbl,.et) @@\
210 $(RM) concat(src,.o) concat(src,.h) @@\
211 depend:: concat(src,.h)
212 #else /* !PROFILED_LIBS */
213 #define comp_et_prof(tbl) comp_et(tbl)
214 #endif /* PROFILED_LIBS */
216 #define comp_et(tbl) @@\
217 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
218 $(COMPILE_ET) concat(tbl,.et) @@\
220 $(RM) concat(src,.o) concat(src,.h)
222 #define comp_et_depend(src) @@\
225 depend:: concat(src,.h)
227 #define mk_cmds(tbl) @@\
228 concat(tbl,.o): concat(tbl,.ct) @@\
229 $(MAKE_COMMANDS) concat(tbl,.ct) @@\
234 * Rule for building some random object module
237 #define host_simple_object(obj,src) @@\
239 $(HCC) $(HCFLAGS) -c src @@\
244 #define ro_object(obj,src) @@\
246 $(CCRO) $(CFLAGS) -c src @@\
252 * Rule for building some random object module with compile flags and
253 * other dependendcies
256 #define host_flag_object(obj,src,flags,localdeps) @@\
257 obj: src localdeps @@\
258 $(HCC) $(HCFLAGS) flags -c src @@\
263 #define ro_flag_object(obj,src,flags,localdeps) @@\
264 obj: src localdeps @@\
265 $(CCRO) $(CFLAGS) flags -c src @@\
271 * Rule for building some random object module with compile flags, an
272 * intermediate output, and some other dependencies
275 #define host_cplx_object(obj,interim,src,flags,localdeps) @@\
276 obj: interim src localdeps @@\
277 $(HCC) $(HCFLAGS) flags -c src @@\
278 $(MV) interim obj @@\
283 #define ro_cplx_object(obj,interim,src,flags,localdeps) @@\
284 obj: src localdeps interim @@\
285 $(CCRO) $(CFLAGS) flags -c src @@\
286 $(MV) interim obj @@\
292 * Rule for building a program which is to be installed:
295 #define program(pgm,objs,localdeps,syslibs,installdir) @@\
298 pgm: localdeps objs @@\
299 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
302 $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\
308 * Rule for building a program which is to be installed setuid root:
311 #define suidprogram(pgm,objs,localdeps,syslibs,installdir) @@\
314 pgm: objs localdeps @@\
315 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
318 $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm @@\
324 * Rule for building a specially installed program
327 #define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\
330 pgm: objs localdeps @@\
331 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
334 $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\
340 * Special rule for building and installing a Berkeley r-command
341 * We need to preserve the original copies upon installation.
344 #define ucbprogram(pgm,objs,localdeps,syslibs,installdir) @@\
347 pgm: objs localdeps @@\
348 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
351 -if [ ! -f concat5(${DESTDIR},installdir,/,pgm,.ucb) -a -f concat4(${DESTDIR},installdir,/,pgm) ]; then \ @@\
352 mv concat4(${DESTDIR},installdir,/,pgm) concat5(${DESTDIR},installdir,/,pgm,.ucb); fi; exit 0 @@\
353 $(INSTALLSUID) pgm concat4(${DESTDIR},installdir,/,pgm) @@\
360 * Rule for installing man pages. Section installing into should match
361 * suffix, or the man page won't show up when using man(1).
364 #define manpage(section,page) @@\
367 $(INSTALLFILE) page concat4(${DESTDIR}${MANDIR}/man,section,/,`basename page`) @@\
370 * Rule for building makefile dependencies.
373 #define depend_target() @@\
375 @echo "### Now computing dependencies" @@\
376 @$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS) @@\
378 #define clean_target() @@\
380 $(RM) *~ \#* *.bak $(TAGSFILE)
382 #define tags_target() @@\
386 #define makefile_target() @@\
388 -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\
389 $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\
391 #define foreach_subdirs(name,subdirs) @@\
393 @for d in subdirs; \ @@\
395 (cd $$d; echo "### Making" name "in" `pwd`; \ @@\
396 $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \ @@\
397 echo "### Done with" `pwd`); \ @@\
400 #define print_target() @@\
404 #define src_target() @@\
409 -$(LN) ${SRCDIR}/$@ $@
411 #define do_subdirs_no_imakefile(subdirs) @@\
412 foreach_subdirs(all, subdirs) @@\
413 foreach_subdirs(install, subdirs) @@\
414 foreach_subdirs(clean, subdirs) @@\
415 foreach_subdirs(depend, subdirs) @@\
416 foreach_subdirs(tags, subdirs) @@\
417 foreach_subdirs(print, subdirs) @@\
418 foreach_subdirs(src, subdirs) @@\
420 #define do_subdirs(subdirs) @@\
421 do_subdirs_no_imakefile(subdirs) @@\
424 @echo "### Making Makefiles in" `pwd` @@\
425 @for d in subdirs; \ @@\
427 (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\
428 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
429 NEWTOP=../$(BUILDTOP) \ @@\
430 BUILDTOP=../$(BUILDTOP) \ @@\
433 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
434 NEWTOP=../$(BUILDTOP) \ @@\
436 echo "### Done with" `pwd`); \ @@\