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)
87 #define genutil(pgm,objs,localdeps,syslibs) @@\
90 pgm: objs localdeps @@\
91 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
97 * Rule for building "generator" programs.
100 #define generate(file,pgm,libs) @@\
102 pgm: concat(pgm,.c) libs @@\
103 $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\
109 $(RM) file pgm concat(pgm,.o)
111 #define generate_depend(file,pgm,libs) @@\
112 generate(file,pgm,libs) @@\
118 * Rule for building test programs (something which is not installed)
121 #define test(pgm,locallibs,syslibs) @@\
125 pgm: concat(pgm,.c) locallibs @@\
126 $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\
129 $(RM) pgm concat(pgm,.o) @@\
132 * Rule for building some random object module
135 #define host_simple_object(obj,src) @@\
137 $(HCC) $(HCFLAGS) -c src @@\
142 #define ro_object(obj,src) @@\
144 $(CCRO) $(CFLAGS) -c src @@\
150 * Rule for building some random object module with compile flags and
151 * other dependendcies
154 #define host_flag_object(obj,src,flags,localdeps) @@\
155 obj: src localdeps @@\
156 $(HCC) $(HCFLAGS) flags -c src @@\
161 #define ro_flag_object(obj,src,flags,localdeps) @@\
162 obj: src localdeps @@\
163 $(CCRO) $(CFLAGS) flags -c src @@\
169 * Rule for building some random object module with compile flags, an
170 * intermediate output, and some other dependencies
173 #define host_cplx_object(obj,interim,src,flags,localdeps) @@\
174 obj: src localdeps @@\
175 $(HCC) $(HCFLAGS) flags -c src @@\
176 $(MV) interim obj @@\
181 #define ro_cplx_object(obj,interim,src,flags,localdeps) @@\
182 obj: src localdeps @@\
183 $(CCRO) $(CFLAGS) flags -c src @@\
184 $(MV) interim obj @@\
190 * Rule for building a program which is to be installed:
193 #define program(pgm,objs,localdeps,syslibs,installdir) @@\
196 pgm: objs localdeps @@\
197 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
200 $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\
206 * Rule for building a program which is to be installed setuid root:
209 #define suidprogram(pgm,objs,localdeps,syslibs,installdir) @@\
212 pgm: objs localdeps @@\
213 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
216 $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm @@\
222 * Rule for building a specially installed program
225 #define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\
228 pgm: objs localdeps @@\
229 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
232 $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\
238 * Rule for installing man pages. Section installing into should match
239 * suffix, or the man page won't show up when using man(1).
242 #define manpage(section,page) @@\
245 $(INSTALLFILE) page concat3(${DESTDIR}${MANDIR}/man,section,/`basename page`) @@\
248 * Rule for building makefile dependencies.
251 #define depend_target() @@\
253 @echo "### Now computing dependencies" @@\
254 @$(DEPEND) -s "# DO NOT DELETE" $(CFLAGS) $(SRCS) @@\
256 #define clean_target() @@\
258 $(RM) *~ \#* *.bak $(TAGSFILE)
260 #define tags_target() @@\
264 #define makefile_target() @@\
266 -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\
267 $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\
269 #define foreach_subdirs(name,subdirs) @@\
271 @for d in subdirs; \ @@\
273 (cd $$d; echo "### Making" name "in" `pwd`; \ @@\
274 $(MAKE) $(MFLAGS) name ; \ @@\
275 echo "### Done with" `pwd`); \ @@\
278 #define print_target() @@\
282 #define src_target() @@\
286 -$(LN) ${SRCDIR}/$@ $@
288 #define do_subdirs_no_imakefile(subdirs) @@\
289 foreach_subdirs(all, subdirs) @@\
290 foreach_subdirs(install, subdirs) @@\
291 foreach_subdirs(clean, subdirs) @@\
292 foreach_subdirs(depend, subdirs) @@\
293 foreach_subdirs(tags, subdirs) @@\
294 foreach_subdirs(print, subdirs) @@\
295 foreach_subdirs(src, subdirs) @@\
297 #define do_subdirs(subdirs) @@\
298 do_subdirs_no_imakefile(subdirs) @@\
301 @echo "### Making Makefiles in" `pwd` @@\
302 @for d in subdirs; \ @@\
304 (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\
305 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
306 NEWTOP=../$(BUILDTOP) \ @@\
307 BUILDTOP=../$(BUILDTOP) \ @@\
310 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
311 NEWTOP=../$(BUILDTOP) \ @@\
313 echo "### Done with" `pwd`); \ @@\