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"
19 * Rule for building objects in libraries.
22 #define library_obj_rule() @@\
24 $(CC) -p -c $(CFLAGS) $*.c @@\
25 -$(LD) -X -r -o profiled/$*.o $*.o @@\
26 $(CC) -c $(CFLAGS) $*.c @@\
27 -$(LD) -x -r -o a.out $*.o @@\
31 * cc -R breaks profiling with -p on 4.3BSD on the VAX
32 * (and probably elsewhere), so we don't do it for the profiled version.
35 #define library_ro_object(cfile) @@\
36 concat(cfile,.o): concat(cfile,.c) @@\
37 $(CC) -p -c $(CFLAGS) concat(cfile,.c) @@\
38 -$(LD) -X -r -o profiled/$*.o $*.o @@\
39 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
40 -$(LD) -x -r -o a.out $*.o @@\
43 #define library_asm_object(ofile,sfile) @@\
46 $(CPP) -DPROF x.c | $(AS) - @@\
47 -$(LD) -X -r -o profiled/$*.o a.out @@\
48 $(CPP) x.c | $(AS) - @@\
49 -$(LD) -x -r -o $*.o a.out @@\
52 #define install_library_target(libname,objs,srcs,lintlibs) @@\
54 all:: concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
55 all:: concat3(llib-l,libname,.ln) @@\
57 concat3(lib,libname,.a): objs @@\
58 $(ARCHIVE) $@ objs @@\
61 concat3(lib,libname,_p.a): objs @@\
62 cd profiled; $(ARCHIVE) ../$@ objs @@\
65 lint:: concat3(llib-l,libname,.ln) @@\
67 concat3(llib-l,libname,.ln): srcs @@\
68 $(LINT) concat(-C,libname) $(CFLAGS) srcs lintlibs @@\
71 $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
72 $(RM) concat3(llib-l,libname,.ln) @@\
74 $(RM) profiled\/*.o @@\
77 $(INSTALLFILE) concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
78 $(RANLIB) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
79 $(INSTALLFILE) concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
80 $(RANLIB) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
81 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LIBDIR)/lint,llib-l,libname,.ln) @@\
84 * Rule for building utilities (binaries which don't get installed)
86 #define genutil(pgm,objs,localdeps,syslibs) @@\
89 pgm: objs localdeps @@\
90 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
96 * Rule for building "generator" programs.
99 #define generate(file,pgm,libs) @@\
101 pgm: concat(pgm,.c) libs @@\
102 $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\
108 $(RM) file pgm concat(pgm,.o)
110 #define generate_depend(file,pgm,libs) @@\
111 generate(file,pgm,libs) @@\
117 * Rule for building test programs (something which is not installed)
120 #define test(pgm,locallibs,syslibs) @@\
124 pgm: concat(pgm,.c) locallibs @@\
125 $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\
128 $(RM) pgm concat(pgm,.o) @@\
131 * Rule for compileing files with "et"
134 #define comp_et(src) @@\
135 concat(src,.h):: concat(src,.et) @@\
136 compile_et concat(src,.et) @@\
137 concat(src,.o):: concat(src,.et) @@\
138 compile_et concat(src,.et) @@\
140 $(RM) concat(src,.o) concat(src,.h) @@\
142 #define comp_et_depend(src) @@\
145 depend:: concat(src,.h) @@\
148 * Rule for building some random object module
151 #define host_simple_object(obj,src) @@\
153 $(HCC) $(HCFLAGS) -c src @@\
158 #define ro_object(obj,src) @@\
160 $(CCRO) $(CFLAGS) -c src @@\
166 * Rule for building some random object module with compile flags and
167 * other dependendcies
170 #define host_flag_object(obj,src,flags,localdeps) @@\
171 obj: src localdeps @@\
172 $(HCC) $(HCFLAGS) flags -c src @@\
177 #define ro_flag_object(obj,src,flags,localdeps) @@\
178 obj: src localdeps @@\
179 $(CCRO) $(CFLAGS) flags -c src @@\
185 * Rule for building some random object module with compile flags, an
186 * intermediate output, and some other dependencies
189 #define host_cplx_object(obj,interim,src,flags,localdeps) @@\
190 obj: interim src localdeps @@\
191 $(HCC) $(HCFLAGS) flags -c src @@\
192 $(MV) interim obj @@\
197 #define ro_cplx_object(obj,interim,src,flags,localdeps) @@\
198 obj: src localdeps interim @@\
199 $(CCRO) $(CFLAGS) flags -c src @@\
200 $(MV) interim obj @@\
206 * Rule for building a program which is to be installed:
209 #define program(pgm,objs,localdeps,syslibs,installdir) @@\
212 pgm: localdeps objs @@\
213 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
216 $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\
222 * Rule for building a program which is to be installed setuid root:
225 #define suidprogram(pgm,objs,localdeps,syslibs,installdir) @@\
228 pgm: objs localdeps @@\
229 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
232 $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm @@\
238 * Rule for building a specially installed program
241 #define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\
244 pgm: objs localdeps @@\
245 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
248 $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\
254 * Rule for installing man pages. Section installing into should match
255 * suffix, or the man page won't show up when using man(1).
258 #define manpage(section,page) @@\
261 $(INSTALLFILE) page concat3(${DESTDIR}${MANDIR}/man,section,/`basename page`) @@\
264 * Rule for building makefile dependencies.
267 #define depend_target() @@\
269 @echo "### Now computing dependencies" @@\
270 @$(DEPEND) -s "# DO NOT DELETE" $(CFLAGS) $(SRCS) @@\
272 #define clean_target() @@\
274 $(RM) *~ \#* *.bak $(TAGSFILE)
276 #define tags_target() @@\
280 #define makefile_target() @@\
282 -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\
283 $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\
285 #define foreach_subdirs(name,subdirs) @@\
287 @for d in subdirs; \ @@\
289 (cd $$d; echo "### Making" name "in" `pwd`; \ @@\
290 $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \ @@\
291 echo "### Done with" `pwd`); \ @@\
294 #define print_target() @@\
298 #define src_target() @@\
302 -$(LN) ${SRCDIR}/$@ $@
304 #define do_subdirs_no_imakefile(subdirs) @@\
305 foreach_subdirs(all, subdirs) @@\
306 foreach_subdirs(install, subdirs) @@\
307 foreach_subdirs(clean, subdirs) @@\
308 foreach_subdirs(depend, subdirs) @@\
309 foreach_subdirs(tags, subdirs) @@\
310 foreach_subdirs(print, subdirs) @@\
311 foreach_subdirs(src, subdirs) @@\
313 #define do_subdirs(subdirs) @@\
314 do_subdirs_no_imakefile(subdirs) @@\
317 @echo "### Making Makefiles in" `pwd` @@\
318 @for d in subdirs; \ @@\
320 (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\
321 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
322 NEWTOP=../$(BUILDTOP) \ @@\
323 BUILDTOP=../$(BUILDTOP) \ @@\
326 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
327 NEWTOP=../$(BUILDTOP) \ @@\
329 echo "### Done with" `pwd`); \ @@\