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.
27 * The MIPS loader doesn't have the -X flag or its functionality.
29 #define library_obj_rule() @@\
31 $(CC) PROF_FLAG -c $(CFLAGS) $*.c @@\
32 $(MV) $*.o profiled/$*.o @@\
33 $(CC) -c $(CFLAGS) $*.c @@\
34 -$(LD) -x -r -o a.out $*.o @@\
37 #define library_obj_rule() @@\
39 $(CC) PROF_FLAG -c $(CFLAGS) $*.c @@\
40 -$(LD) -X -r -o profiled/$*.o $*.o @@\
41 $(CC) -c $(CFLAGS) $*.c @@\
42 -$(LD) -x -r -o a.out $*.o @@\
46 * cc -R breaks profiling with -p on 4.3BSD on the VAX
47 * (and probably elsewhere), so we don't do it for the profiled version.
50 #define library_ro_object(cfile) @@\
51 concat(cfile,.o): concat(cfile,.c) @@\
52 $(CC) PROF_FLAG -c $(CFLAGS) concat(cfile,.c) @@\
53 -$(LD) -X -r -o profiled/$*.o $*.o @@\
54 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
55 -$(LD) -x -r -o a.out $*.o @@\
58 #define library_asm_object(ofile,sfile) @@\
61 $(CPP) -DPROF x.c | $(AS) - @@\
62 -$(LD) -X -r -o profiled/$*.o a.out @@\
63 $(CPP) x.c | $(AS) - @@\
64 -$(LD) -x -r -o $*.o a.out @@\
67 #define install_library_target(libname,objs,srcs,lintlibs) @@\
69 all:: concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
70 all:: concat3(llib-l,libname,.ln) @@\
72 concat3(lib,libname,.a): objs @@\
75 $(ARCHIVE) $@ objs @@\
78 concat3(lib,libname,_p.a): objs @@\
81 cd profiled; $(ARCHIVE) ../$@ objs @@\
84 lint:: concat3(llib-l,libname,.ln) @@\
86 concat3(llib-l,libname,.ln): srcs @@\
87 $(LINT) concat($(LINTLIBFLAG),libname) $(LINTFLAGS) srcs lintlibs @@\
90 $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
91 $(RM) concat3(llib-l,libname,.ln) @@\
93 $(RM) profiled/?*.o @@\
96 $(INSTALLRAW) -c -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
97 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
98 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
99 $(INSTALLRAW) -c -m 644 concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
100 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
101 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
102 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\
104 #else /* !PROFILED_LIBS */
106 * Rule for building objects in libraries.
110 /* When debugging, leave symbols alone (don't do LD) */
111 #define library_obj_rule() @@\
113 $(CC) -c $(CFLAGS) $*.c
115 #define library_obj_rule() @@\
117 $(CC) -c $(CFLAGS) $*.c @@\
118 -$(LD) -x -r -o a.out $*.o @@\
122 #define library_ro_object(cfile) @@\
123 concat(cfile,.o): concat(cfile,.c) @@\
124 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
125 -$(LD) -x -r -o a.out $*.o @@\
128 #define library_asm_object(ofile,sfile) @@\
130 $(CPP) x.c | $(AS) - @@\
131 -$(LD) -x -r -o $*.o a.out @@\
134 #define install_library_target(libname,objs,srcs,lintlibs) @@\
136 all:: concat3(lib,libname,.a) @@\
137 all:: concat3(llib-l,libname,.ln) @@\
139 concat3(lib,libname,.a): objs @@\
142 $(ARCHIVE) $@ objs @@\
145 lint:: concat3(llib-l,libname,.ln) @@\
147 concat3(llib-l,libname,.ln): srcs @@\
148 $(LINT) concat($(LINTLIBFLAG),libname) $(LINTFLAGS) srcs lintlibs @@\
151 $(RM) concat3(lib,libname,.a) @@\
152 $(RM) concat3(llib-l,libname,.ln) @@\
156 $(INSTALLRAW) -c -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
157 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
158 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
159 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\
161 #endif /* PROFILED_LIBS */
164 * Rule for building utilities (binaries which don't get installed)
166 #define genutil(pgm,objs,localdeps,syslibs) @@\
169 pgm: objs localdeps @@\
170 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
176 * Rule for building "generator" programs.
179 #define generate(file,pgm,libs) @@\
181 pgm: concat(pgm,.c) libs @@\
182 $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\
188 $(RM) file pgm concat(pgm,.o)
190 #define generate_depend(file,pgm,libs) @@\
191 generate(file,pgm,libs) @@\
197 * Rule for building test programs (something which is not installed)
200 #define test(pgm,locallibs,syslibs) @@\
204 pgm: concat(pgm,.c) locallibs @@\
205 $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\
208 $(RM) pgm concat(pgm,.o) @@\
211 * Rule for compileing files with "et"
215 #define comp_et_prof(tbl) @@\
216 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
217 $(COMPILE_ET) concat(tbl,.et) -n @@\
218 $(CC) -c PROF_FLAG concat(tbl,.et.c) @@\
219 $(MV) concat(tbl,.et.o) concat3(profiled/,tbl,.o) @@\
220 $(COMPILE_ET) concat(tbl,.et) @@\
222 $(RM) concat(tbl,.o) concat(tbl,.h) @@\
223 depend:: concat(tbl,.h)
224 #else /* !PROFILED_LIBS */
225 #define comp_et_prof(tbl) comp_et(tbl)
226 #endif /* PROFILED_LIBS */
228 #define comp_et(tbl) @@\
229 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
230 $(COMPILE_ET) concat(tbl,.et) @@\
232 $(RM) concat(tbl,.o) concat(tbl,.h)
234 #define comp_et_depend(src) @@\
235 comp_et_prof(src) @@\
237 depend:: concat(src,.h)
239 #define mk_cmds(tbl) @@\
240 concat(tbl,.o): concat(tbl,.ct) @@\
241 $(MAKE_COMMANDS) concat(tbl,.ct) @@\
246 * Rule for building some random object module
249 #define host_simple_object(obj,src) @@\
251 $(HCC) $(HCFLAGS) -c src @@\
256 #define ro_object(obj,src) @@\
258 $(CCRO) $(CFLAGS) -c src @@\
264 * Rule for building some random object module with compile flags and
265 * other dependendcies
268 #define host_flag_object(obj,src,flags,localdeps) @@\
269 obj: src localdeps @@\
270 $(HCC) $(HCFLAGS) flags -c src @@\
275 #define ro_flag_object(obj,src,flags,localdeps) @@\
276 obj: src localdeps @@\
277 $(CCRO) $(CFLAGS) flags -c src @@\
283 * Rule for building some random object module with compile flags, an
284 * intermediate output, and some other dependencies
287 #define host_cplx_object(obj,interim,src,flags,localdeps) @@\
288 obj: interim src localdeps @@\
289 $(HCC) $(HCFLAGS) flags -c src @@\
290 $(MV) interim obj @@\
295 #define ro_cplx_object(obj,interim,src,flags,localdeps) @@\
296 obj: src localdeps interim @@\
297 $(CCRO) $(CFLAGS) flags -c src @@\
298 $(MV) interim obj @@\
304 * Rule for building a program which is to be installed:
307 #define program(pgm,objs,localdeps,syslibs,installdir) @@\
310 pgm: localdeps objs @@\
311 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
314 $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\
320 * Rule for building a program which is to be installed setuid root:
323 #define suidprogram(pgm,objs,localdeps,syslibs,installdir) @@\
326 pgm: objs localdeps @@\
327 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
330 $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm @@\
336 * Rule for building a specially installed program
339 #define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\
342 pgm: objs localdeps @@\
343 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
346 $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\
352 * Special rule for building and installing a Berkeley r-command
353 * We need to preserve the original copies upon installation.
356 #define ucbprogram(pgm,objs,localdeps,syslibs,installdir) @@\
359 pgm: objs localdeps @@\
360 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
363 -if [ ! -f concat5(${DESTDIR},installdir,/,pgm,.ucb) -a -f concat4(${DESTDIR},installdir,/,pgm) ]; then \ @@\
364 mv concat4(${DESTDIR},installdir,/,pgm) concat5(${DESTDIR},installdir,/,pgm,.ucb); fi; exit 0 @@\
365 $(INSTALLSUID) pgm concat4(${DESTDIR},installdir,/,pgm) @@\
372 * Rule for installing man pages. Section installing into should match
373 * suffix, or the man page won't show up when using man(1).
376 #define manpage(section,page) @@\
379 $(INSTALLFILE) page concat4(${DESTDIR}${MANDIR}/man,section,/,`basename page`) @@\
382 * Rule for building makefile dependencies.
385 #define depend_target() @@\
387 @echo "### Now computing dependencies" @@\
388 @$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS) @@\
390 #define clean_target() @@\
392 $(RM) *~ \#* *.bak $(TAGSFILE)
394 #define tags_target() @@\
398 #define makefile_target() @@\
400 -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\
401 $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\
403 #define foreach_subdirs(name,subdirs) @@\
405 @for d in subdirs; \ @@\
407 (cd $$d; echo "### Making" name "in" `pwd`; \ @@\
408 $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \ @@\
409 echo "### Done with" `pwd`); \ @@\
412 #define print_target() @@\
416 #define src_target() @@\
421 -$(LN) ${SRCDIR}/$@ $@
423 #define do_subdirs_no_imakefile(subdirs) @@\
424 foreach_subdirs(all, subdirs) @@\
425 foreach_subdirs(install, subdirs) @@\
426 foreach_subdirs(clean, subdirs) @@\
427 foreach_subdirs(depend, subdirs) @@\
428 foreach_subdirs(tags, subdirs) @@\
429 foreach_subdirs(print, subdirs) @@\
430 foreach_subdirs(src, subdirs) @@\
432 #define do_subdirs(subdirs) @@\
433 do_subdirs_no_imakefile(subdirs) @@\
436 @echo "### Making Makefiles in" `pwd` @@\
437 @for d in subdirs; \ @@\
439 (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\
440 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
441 NEWTOP=../$(BUILDTOP) \ @@\
442 BUILDTOP=../$(BUILDTOP) \ @@\
445 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
446 NEWTOP=../$(BUILDTOP) \ @@\
448 echo "### Done with" `pwd`); \ @@\