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"
20 * Rule for building objects in libraries.
23 #define library_obj_rule() @@\
25 $(CC) PROF_FLAG -c $(CFLAGS) $*.c @@\
26 -$(LD) -X -r -o profiled/$*.o $*.o @@\
27 $(CC) -c $(CFLAGS) $*.c @@\
28 -$(LD) -x -r -o a.out $*.o @@\
32 * cc -R breaks profiling with -p on 4.3BSD on the VAX
33 * (and probably elsewhere), so we don't do it for the profiled version.
36 #define library_ro_object(cfile) @@\
37 concat(cfile,.o): concat(cfile,.c) @@\
38 $(CC) PROF_FLAG -c $(CFLAGS) concat(cfile,.c) @@\
39 -$(LD) -X -r -o profiled/$*.o $*.o @@\
40 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
41 -$(LD) -x -r -o a.out $*.o @@\
44 #define library_asm_object(ofile,sfile) @@\
47 $(CPP) -DPROF x.c | $(AS) - @@\
48 -$(LD) -X -r -o profiled/$*.o a.out @@\
49 $(CPP) x.c | $(AS) - @@\
50 -$(LD) -x -r -o $*.o a.out @@\
53 #define install_library_target(libname,objs,srcs,lintlibs) @@\
55 all:: concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
56 all:: concat3(llib-l,libname,.ln) @@\
58 concat3(lib,libname,.a): objs @@\
59 $(ARCHIVE) $@ objs @@\
62 concat3(lib,libname,_p.a): objs @@\
63 cd profiled; $(ARCHIVE) ../$@ objs @@\
66 lint:: concat3(llib-l,libname,.ln) @@\
68 concat3(llib-l,libname,.ln): srcs @@\
69 $(LINT) concat(-C,libname) $(LINTFLAGS) srcs lintlibs @@\
72 $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
73 $(RM) concat3(llib-l,libname,.ln) @@\
75 $(RM) profiled/?*.o @@\
78 $(INSTALLRAW) -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
79 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
80 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
81 $(INSTALLRAW) -m 644 concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
82 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
83 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
84 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\
86 #else /* !PROFILED_LIBS */
88 * Rule for building objects in libraries.
91 #define library_obj_rule() @@\
93 $(CC) -c $(CFLAGS) $*.c @@\
94 -$(LD) -x -r -o a.out $*.o @@\
97 #define library_ro_object(cfile) @@\
98 concat(cfile,.o): concat(cfile,.c) @@\
99 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
100 -$(LD) -x -r -o a.out $*.o @@\
103 #define library_asm_object(ofile,sfile) @@\
105 $(CPP) x.c | $(AS) - @@\
106 -$(LD) -x -r -o $*.o a.out @@\
109 #define install_library_target(libname,objs,srcs,lintlibs) @@\
111 all:: concat3(lib,libname,.a) @@\
112 all:: concat3(llib-l,libname,.ln) @@\
114 concat3(lib,libname,.a): objs @@\
115 $(ARCHIVE) $@ objs @@\
118 lint:: concat3(llib-l,libname,.ln) @@\
120 concat3(llib-l,libname,.ln): srcs @@\
121 $(LINT) concat(-C,libname) $(LINTFLAGS) srcs lintlibs @@\
124 $(RM) concat3(lib,libname,.a) @@\
125 $(RM) concat3(llib-l,libname,.ln) @@\
129 $(INSTALLRAW) -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
130 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
131 $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
132 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBBDIR)/,llib-l,libname,.ln) @@\
134 #endif /* PROFILED_LIBS */
137 * Rule for building utilities (binaries which don't get installed)
139 #define genutil(pgm,objs,localdeps,syslibs) @@\
142 pgm: objs localdeps @@\
143 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
149 * Rule for building "generator" programs.
152 #define generate(file,pgm,libs) @@\
154 pgm: concat(pgm,.c) libs @@\
155 $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\
161 $(RM) file pgm concat(pgm,.o)
163 #define generate_depend(file,pgm,libs) @@\
164 generate(file,pgm,libs) @@\
170 * Rule for building test programs (something which is not installed)
173 #define test(pgm,locallibs,syslibs) @@\
177 pgm: concat(pgm,.c) locallibs @@\
178 $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\
181 $(RM) pgm concat(pgm,.o) @@\
184 * Rule for compileing files with "et"
188 #define comp_et_prof(tbl) @@\
189 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
190 $(COMPILE_ET) concat(tbl,.et) -n @@\
191 $(CC) -c PROF_FLAG concat(tbl,.et.c) @@\
192 $(MV) concat(tbl,.et.o) concat3(profiled/,tbl,.o) @@\
193 $(COMPILE_ET) concat(tbl,.et) @@\
195 $(RM) concat(src,.o) concat(src,.h) @@\
196 depend:: concat(src,.h)
197 #else /* !PROFILED_LIBS */
198 #define comp_et_prof(tbl) comp_et(tbl)
199 #endif /* PROFILED_LIBS */
201 #define comp_et(tbl) @@\
202 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
203 $(COMPILE_ET) concat(tbl,.et) @@\
205 $(RM) concat(src,.o) concat(src,.h)
207 #define comp_et_depend(src) @@\
210 depend:: concat(src,.h)
213 * Rule for building some random object module
216 #define host_simple_object(obj,src) @@\
218 $(HCC) $(HCFLAGS) -c src @@\
223 #define ro_object(obj,src) @@\
225 $(CCRO) $(CFLAGS) -c src @@\
231 * Rule for building some random object module with compile flags and
232 * other dependendcies
235 #define host_flag_object(obj,src,flags,localdeps) @@\
236 obj: src localdeps @@\
237 $(HCC) $(HCFLAGS) flags -c src @@\
242 #define ro_flag_object(obj,src,flags,localdeps) @@\
243 obj: src localdeps @@\
244 $(CCRO) $(CFLAGS) flags -c src @@\
250 * Rule for building some random object module with compile flags, an
251 * intermediate output, and some other dependencies
254 #define host_cplx_object(obj,interim,src,flags,localdeps) @@\
255 obj: interim src localdeps @@\
256 $(HCC) $(HCFLAGS) flags -c src @@\
257 $(MV) interim obj @@\
262 #define ro_cplx_object(obj,interim,src,flags,localdeps) @@\
263 obj: src localdeps interim @@\
264 $(CCRO) $(CFLAGS) flags -c src @@\
265 $(MV) interim obj @@\
271 * Rule for building a program which is to be installed:
274 #define program(pgm,objs,localdeps,syslibs,installdir) @@\
277 pgm: localdeps objs @@\
278 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
281 $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\
287 * Rule for building a program which is to be installed setuid root:
290 #define suidprogram(pgm,objs,localdeps,syslibs,installdir) @@\
293 pgm: objs localdeps @@\
294 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
297 $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm @@\
303 * Rule for building a specially installed program
306 #define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\
309 pgm: objs localdeps @@\
310 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
313 $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\
319 * Rule for installing man pages. Section installing into should match
320 * suffix, or the man page won't show up when using man(1).
323 #define manpage(section,page) @@\
326 $(INSTALLFILE) page concat4(${DESTDIR}${MANDIR}/man,section,/,`basename page`) @@\
329 * Rule for building makefile dependencies.
332 #define depend_target() @@\
334 @echo "### Now computing dependencies" @@\
335 @$(DEPEND) -s "# DO NOT DELETE" $(CFLAGS) $(SRCS) @@\
337 #define clean_target() @@\
339 $(RM) *~ \#* *.bak $(TAGSFILE)
341 #define tags_target() @@\
345 #define makefile_target() @@\
347 -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\
348 $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\
350 #define foreach_subdirs(name,subdirs) @@\
352 @for d in subdirs; \ @@\
354 (cd $$d; echo "### Making" name "in" `pwd`; \ @@\
355 $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \ @@\
356 echo "### Done with" `pwd`); \ @@\
359 #define print_target() @@\
363 #define src_target() @@\
367 -$(LN) ${SRCDIR}/$@ $@
369 #define do_subdirs_no_imakefile(subdirs) @@\
370 foreach_subdirs(all, subdirs) @@\
371 foreach_subdirs(install, subdirs) @@\
372 foreach_subdirs(clean, subdirs) @@\
373 foreach_subdirs(depend, subdirs) @@\
374 foreach_subdirs(tags, subdirs) @@\
375 foreach_subdirs(print, subdirs) @@\
376 foreach_subdirs(src, subdirs) @@\
378 #define do_subdirs(subdirs) @@\
379 do_subdirs_no_imakefile(subdirs) @@\
382 @echo "### Making Makefiles in" `pwd` @@\
383 @for d in subdirs; \ @@\
385 (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\
386 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
387 NEWTOP=../$(BUILDTOP) \ @@\
388 BUILDTOP=../$(BUILDTOP) \ @@\
391 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
392 NEWTOP=../$(BUILDTOP) \ @@\
394 echo "### Done with" `pwd`); \ @@\