]>
Commit | Line | Data |
---|---|---|
2e387221 | 1 | /**/# $Source$ |
2e387221 | 2 | /**/# |
3 | ||
b9be51ef | 4 | #ifdef __STDC__ |
5 | #define concat(x,y) x##y | |
6 | #define concat3(x,y,z) x##y##z | |
7 | #define concat4(w,x,y,z) w##x##y##z | |
83791534 | 8 | #define concat5(v,w,x,y,z) v##w##x##y##z |
b9be51ef | 9 | #define requote(x) #x |
10 | #else | |
df897414 | 11 | #define concat(x,y)x/**/y |
12 | #define concat3(x,y,z)x/**/y/**/z | |
13 | #define concat4(w,x,y,z)w/**/x/**/y/**/z | |
83791534 | 14 | #define concat5(v,w,x,y,z)v/**/w/**/x/**/y/**/z |
b9be51ef | 15 | #define requote(x) "x" |
16 | #endif | |
17 | ||
df897414 | 18 | #ifdef PROFILED_LIBS |
b9be51ef | 19 | /* |
20 | * Rule for building objects in libraries. | |
21 | */ | |
22 | ||
bdcaf132 | 23 | #if defined(mips) || defined(_AIX) |
bb64d499 | 24 | /* |
bdcaf132 | 25 | * The MIPS & AIX loaders don't have the -X flag or its functionality. |
bb64d499 | 26 | */ |
27 | #define library_obj_rule() @@\ | |
28 | .c.o: @@\ | |
29 | $(CC) PROF_FLAG -c $(CFLAGS) $*.c @@\ | |
30 | $(MV) $*.o profiled/$*.o @@\ | |
31 | $(CC) -c $(CFLAGS) $*.c @@\ | |
32 | -$(LD) -x -r -o a.out $*.o @@\ | |
33 | $(MV) a.out $*.o | |
bdcaf132 | 34 | #else /* ! mips && ! _AIX */ |
b9be51ef | 35 | #define library_obj_rule() @@\ |
36 | .c.o: @@\ | |
df897414 | 37 | $(CC) PROF_FLAG -c $(CFLAGS) $*.c @@\ |
b9be51ef | 38 | -$(LD) -X -r -o profiled/$*.o $*.o @@\ |
39 | $(CC) -c $(CFLAGS) $*.c @@\ | |
40 | -$(LD) -x -r -o a.out $*.o @@\ | |
41 | $(MV) a.out $*.o | |
bb64d499 | 42 | #endif /* mips */ |
b9be51ef | 43 | /* |
44 | * cc -R breaks profiling with -p on 4.3BSD on the VAX | |
45 | * (and probably elsewhere), so we don't do it for the profiled version. | |
46 | */ | |
47 | ||
48 | #define library_ro_object(cfile) @@\ | |
49 | concat(cfile,.o): concat(cfile,.c) @@\ | |
df897414 | 50 | $(CC) PROF_FLAG -c $(CFLAGS) concat(cfile,.c) @@\ |
b9be51ef | 51 | -$(LD) -X -r -o profiled/$*.o $*.o @@\ |
52 | $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\ | |
53 | -$(LD) -x -r -o a.out $*.o @@\ | |
54 | $(MV) a.out $*.o | |
55 | ||
56 | #define library_asm_object(ofile,sfile) @@\ | |
57 | ofile: sfile @@\ | |
58 | $(CP) sfile x.c @@\ | |
59 | $(CPP) -DPROF x.c | $(AS) - @@\ | |
60 | -$(LD) -X -r -o profiled/$*.o a.out @@\ | |
61 | $(CPP) x.c | $(AS) - @@\ | |
62 | -$(LD) -x -r -o $*.o a.out @@\ | |
63 | $(RM) a.out x.c | |
64 | ||
65 | #define install_library_target(libname,objs,srcs,lintlibs) @@\ | |
66 | @@\ | |
67 | all:: concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\ | |
68 | all:: concat3(llib-l,libname,.ln) @@\ | |
69 | @@\ | |
70 | concat3(lib,libname,.a): objs @@\ | |
d1e9e56b | 71 | $(RM) $@.bak @@\ |
72 | -$(MV) $@ $@.bak @@\ | |
b9be51ef | 73 | $(ARCHIVE) $@ objs @@\ |
74 | $(RANLIB) $@ @@\ | |
75 | @@\ | |
76 | concat3(lib,libname,_p.a): objs @@\ | |
d1e9e56b | 77 | $(RM) $@.bak @@\ |
78 | -$(MV) $@ $@.bak @@\ | |
b9be51ef | 79 | cd profiled; $(ARCHIVE) ../$@ objs @@\ |
80 | $(RANLIB) $@ @@\ | |
81 | @@\ | |
2e387221 | 82 | lint:: concat3(llib-l,libname,.ln) @@\ |
b9be51ef | 83 | @@\ |
84 | concat3(llib-l,libname,.ln): srcs @@\ | |
322efbe6 | 85 | $(LINT) concat($(LINTLIBFLAG),libname) $(LINTFLAGS) srcs lintlibs @@\ |
b9be51ef | 86 | @@\ |
87 | clean:: @@\ | |
88 | $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\ | |
89 | $(RM) concat3(llib-l,libname,.ln) @@\ | |
90 | $(RM) objs @@\ | |
df897414 | 91 | $(RM) profiled/?*.o @@\ |
b9be51ef | 92 | @@\ |
93 | install:: @@\ | |
f111b4b2 | 94 | $(INSTALLRAW) -c -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\ |
f9d599c8 | 95 | $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\ |
93fe6c95 | 96 | $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\ |
f111b4b2 | 97 | $(INSTALLRAW) -c -m 644 concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\ |
f9d599c8 | 98 | $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\ |
93fe6c95 | 99 | $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\ |
f9d599c8 | 100 | $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\ |
b9be51ef | 101 | |
df897414 | 102 | #else /* !PROFILED_LIBS */ |
103 | /* | |
104 | * Rule for building objects in libraries. | |
105 | */ | |
106 | ||
d56d6311 | 107 | #ifdef DEBUG_LIBS |
108 | /* When debugging, leave symbols alone (don't do LD) */ | |
109 | #define library_obj_rule() @@\ | |
110 | .c.o: @@\ | |
111 | $(CC) -c $(CFLAGS) $*.c | |
112 | #else | |
df897414 | 113 | #define library_obj_rule() @@\ |
114 | .c.o: @@\ | |
115 | $(CC) -c $(CFLAGS) $*.c @@\ | |
116 | -$(LD) -x -r -o a.out $*.o @@\ | |
117 | $(MV) a.out $*.o | |
d56d6311 | 118 | #endif |
df897414 | 119 | |
120 | #define library_ro_object(cfile) @@\ | |
121 | concat(cfile,.o): concat(cfile,.c) @@\ | |
122 | $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\ | |
123 | -$(LD) -x -r -o a.out $*.o @@\ | |
124 | $(MV) a.out $*.o | |
125 | ||
126 | #define library_asm_object(ofile,sfile) @@\ | |
127 | ofile: sfile @@\ | |
128 | $(CPP) x.c | $(AS) - @@\ | |
129 | -$(LD) -x -r -o $*.o a.out @@\ | |
130 | $(RM) a.out x.c | |
131 | ||
132 | #define install_library_target(libname,objs,srcs,lintlibs) @@\ | |
133 | @@\ | |
134 | all:: concat3(lib,libname,.a) @@\ | |
135 | all:: concat3(llib-l,libname,.ln) @@\ | |
136 | @@\ | |
137 | concat3(lib,libname,.a): objs @@\ | |
d1e9e56b | 138 | $(RM) $@.bak @@\ |
139 | -$(MV) $@ $@.bak @@\ | |
df897414 | 140 | $(ARCHIVE) $@ objs @@\ |
141 | $(RANLIB) $@ @@\ | |
142 | @@\ | |
143 | lint:: concat3(llib-l,libname,.ln) @@\ | |
144 | @@\ | |
145 | concat3(llib-l,libname,.ln): srcs @@\ | |
322efbe6 | 146 | $(LINT) concat($(LINTLIBFLAG),libname) $(LINTFLAGS) srcs lintlibs @@\ |
df897414 | 147 | @@\ |
148 | clean:: @@\ | |
149 | $(RM) concat3(lib,libname,.a) @@\ | |
150 | $(RM) concat3(llib-l,libname,.ln) @@\ | |
151 | $(RM) objs @@\ | |
152 | @@\ | |
153 | install:: @@\ | |
f111b4b2 | 154 | $(INSTALLRAW) -c -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\ |
df897414 | 155 | $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\ |
93fe6c95 | 156 | $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\ |
c87509c1 | 157 | $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\ |
df897414 | 158 | |
159 | #endif /* PROFILED_LIBS */ | |
160 | ||
b9be51ef | 161 | /* |
162 | * Rule for building utilities (binaries which don't get installed) | |
163 | */ | |
b9be51ef | 164 | #define genutil(pgm,objs,localdeps,syslibs) @@\ |
165 | all:: pgm @@\ | |
166 | @@\ | |
167 | pgm: objs localdeps @@\ | |
83791534 | 168 | $(CC) $(CFLAGS) -o $@ objs syslibs @@\ |
b9be51ef | 169 | @@\ |
170 | clean:: @@\ | |
171 | $(RM) pgm objs @@\ | |
172 | ||
173 | /* | |
174 | * Rule for building "generator" programs. | |
175 | */ | |
176 | ||
177 | #define generate(file,pgm,libs) @@\ | |
178 | @@\ | |
179 | pgm: concat(pgm,.c) libs @@\ | |
180 | $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\ | |
181 | @@\ | |
182 | file: pgm @@\ | |
7caabe5f | 183 | ./pgm file @@\ |
b9be51ef | 184 | @@\ |
185 | clean:: @@\ | |
186 | $(RM) file pgm concat(pgm,.o) | |
187 | ||
188 | #define generate_depend(file,pgm,libs) @@\ | |
189 | generate(file,pgm,libs) @@\ | |
190 | @@\ | |
191 | depend:: file | |
192 | ||
193 | ||
194 | /* | |
195 | * Rule for building test programs (something which is not installed) | |
196 | */ | |
197 | ||
198 | #define test(pgm,locallibs,syslibs) @@\ | |
199 | @@\ | |
200 | all:: pgm @@\ | |
201 | @@\ | |
202 | pgm: concat(pgm,.c) locallibs @@\ | |
203 | $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\ | |
204 | @@\ | |
205 | clean:: @@\ | |
206 | $(RM) pgm concat(pgm,.o) @@\ | |
207 | ||
7caabe5f | 208 | /* |
209 | * Rule for compileing files with "et" | |
210 | */ | |
211 | ||
df897414 | 212 | #define comp_et(tbl) @@\ |
bdcaf132 | 213 | concat(tbl,.h) concat(tbl,.c): concat(tbl,.et) @@\ |
df897414 | 214 | $(COMPILE_ET) concat(tbl,.et) @@\ |
215 | clean:: @@\ | |
bdcaf132 | 216 | $(RM) concat(tbl,.c) concat(tbl,.h) |
7caabe5f | 217 | |
218 | #define comp_et_depend(src) @@\ | |
bdcaf132 | 219 | comp_et(src) @@\ |
7caabe5f | 220 | @@\ |
df897414 | 221 | depend:: concat(src,.h) |
7caabe5f | 222 | |
7b74aba1 | 223 | #define mk_cmds(tbl) @@\ |
224 | concat(tbl,.o): concat(tbl,.ct) @@\ | |
225 | $(MAKE_COMMANDS) concat(tbl,.ct) @@\ | |
226 | clean:: @@\ | |
bb64d499 | 227 | $(RM) concat(tbl,.o) |
7b74aba1 | 228 | |
b9be51ef | 229 | /* |
230 | * Rule for building some random object module | |
231 | */ | |
232 | ||
233 | #define host_simple_object(obj,src) @@\ | |
234 | obj: src @@\ | |
235 | $(HCC) $(HCFLAGS) -c src @@\ | |
236 | @@\ | |
237 | clean:: @@\ | |
238 | $(RM) obj @@\ | |
239 | ||
240 | #define ro_object(obj,src) @@\ | |
241 | obj: src @@\ | |
242 | $(CCRO) $(CFLAGS) -c src @@\ | |
243 | @@\ | |
244 | clean:: @@\ | |
245 | $(RM) obj @@\ | |
246 | ||
2e387221 | 247 | /* |
248 | * Rule for building some random object module with compile flags and | |
249 | * other dependendcies | |
250 | */ | |
251 | ||
252 | #define host_flag_object(obj,src,flags,localdeps) @@\ | |
253 | obj: src localdeps @@\ | |
254 | $(HCC) $(HCFLAGS) flags -c src @@\ | |
255 | @@\ | |
256 | clean:: @@\ | |
257 | $(RM) obj @@\ | |
258 | ||
259 | #define ro_flag_object(obj,src,flags,localdeps) @@\ | |
260 | obj: src localdeps @@\ | |
261 | $(CCRO) $(CFLAGS) flags -c src @@\ | |
262 | @@\ | |
263 | clean:: @@\ | |
264 | $(RM) obj @@\ | |
265 | ||
266 | /* | |
267 | * Rule for building some random object module with compile flags, an | |
268 | * intermediate output, and some other dependencies | |
269 | */ | |
270 | ||
271 | #define host_cplx_object(obj,interim,src,flags,localdeps) @@\ | |
7caabe5f | 272 | obj: interim src localdeps @@\ |
2e387221 | 273 | $(HCC) $(HCFLAGS) flags -c src @@\ |
274 | $(MV) interim obj @@\ | |
275 | @@\ | |
276 | clean:: @@\ | |
277 | $(RM) obj @@\ | |
278 | ||
279 | #define ro_cplx_object(obj,interim,src,flags,localdeps) @@\ | |
7caabe5f | 280 | obj: src localdeps interim @@\ |
2e387221 | 281 | $(CCRO) $(CFLAGS) flags -c src @@\ |
282 | $(MV) interim obj @@\ | |
283 | @@\ | |
284 | clean:: @@\ | |
285 | $(RM) obj @@\ | |
286 | ||
b9be51ef | 287 | /* |
288 | * Rule for building a program which is to be installed: | |
289 | */ | |
290 | ||
291 | #define program(pgm,objs,localdeps,syslibs,installdir) @@\ | |
292 | all:: pgm @@\ | |
293 | @@\ | |
7caabe5f | 294 | pgm: localdeps objs @@\ |
295 | $(CC) $(CFLAGS) -o $@ objs syslibs @@\ | |
b9be51ef | 296 | @@\ |
297 | install:: @@\ | |
2e387221 | 298 | $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\ |
299 | @@\ | |
300 | clean:: @@\ | |
301 | $(RM) pgm objs @@\ | |
302 | ||
b9be51ef | 303 | /* |
304 | * Rule for building a specially installed program | |
305 | */ | |
306 | ||
307 | #define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\ | |
308 | all:: pgm @@\ | |
309 | @@\ | |
310 | pgm: objs localdeps @@\ | |
f9d599c8 | 311 | $(CC) $(CFLAGS) -o $@ objs syslibs @@\ |
b9be51ef | 312 | @@\ |
313 | install:: @@\ | |
2e387221 | 314 | $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\ |
b9be51ef | 315 | @@\ |
316 | clean:: @@\ | |
317 | $(RM) pgm objs @@\ | |
318 | ||
319 | /* | |
2e387221 | 320 | * Rule for installing man pages. Section installing into should match |
321 | * suffix, or the man page won't show up when using man(1). | |
b9be51ef | 322 | */ |
323 | ||
324 | #define manpage(section,page) @@\ | |
325 | all:: @@\ | |
326 | install:: page @@\ | |
28580807 | 327 | $(INSTALLFILE) page concat4(${DESTDIR}${MANDIR}/man,section,/,`basename page`) @@\ |
b9be51ef | 328 | |
329 | /* | |
2e387221 | 330 | * Rule for building makefile dependencies. |
b9be51ef | 331 | */ |
332 | ||
333 | #define depend_target() @@\ | |
334 | depend:: $(SRCS) @@\ | |
2e387221 | 335 | @echo "### Now computing dependencies" @@\ |
322efbe6 | 336 | @$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS) @@\ |
b9be51ef | 337 | |
338 | #define clean_target() @@\ | |
339 | clean:: @@\ | |
340 | $(RM) *~ \#* *.bak $(TAGSFILE) | |
341 | ||
342 | #define tags_target() @@\ | |
343 | tags:: @@\ | |
344 | $(TAGGER) *.c *.h | |
345 | ||
346 | #define makefile_target() @@\ | |
347 | Makefile:: @@\ | |
348 | -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\ | |
349 | $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\ | |
350 | ||
351 | #define foreach_subdirs(name,subdirs) @@\ | |
352 | name:: @@\ | |
353 | @for d in subdirs; \ @@\ | |
354 | do \ @@\ | |
355 | (cd $$d; echo "### Making" name "in" `pwd`; \ @@\ | |
7caabe5f | 356 | $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \ @@\ |
b9be51ef | 357 | echo "### Done with" `pwd`); \ @@\ |
358 | done | |
359 | ||
360 | #define print_target() @@\ | |
361 | print:: ${CODE} @@\ | |
362 | ${LPR} ${CODE} | |
363 | ||
364 | #define src_target() @@\ | |
365 | src:: ${CODE} @@\ | |
366 | @@\ | |
367 | ${CODE}: @@\ | |
719b9402 | 368 | $(RM) $@ @@\ |
b9be51ef | 369 | -$(LN) ${SRCDIR}/$@ $@ |
370 | ||
371 | #define do_subdirs_no_imakefile(subdirs) @@\ | |
372 | foreach_subdirs(all, subdirs) @@\ | |
373 | foreach_subdirs(install, subdirs) @@\ | |
374 | foreach_subdirs(clean, subdirs) @@\ | |
375 | foreach_subdirs(depend, subdirs) @@\ | |
376 | foreach_subdirs(tags, subdirs) @@\ | |
377 | foreach_subdirs(print, subdirs) @@\ | |
378 | foreach_subdirs(src, subdirs) @@\ | |
379 | ||
380 | #define do_subdirs(subdirs) @@\ | |
381 | do_subdirs_no_imakefile(subdirs) @@\ | |
382 | @@\ | |
383 | Makefiles:: @@\ | |
384 | @echo "### Making Makefiles in" `pwd` @@\ | |
385 | @for d in subdirs; \ @@\ | |
386 | do \ @@\ | |
387 | (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\ | |
388 | $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\ | |
389 | NEWTOP=../$(BUILDTOP) \ @@\ | |
390 | BUILDTOP=../$(BUILDTOP) \ @@\ | |
391 | -f ../Makefile \ @@\ | |
392 | Makefile; \ @@\ | |
393 | $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\ | |
394 | NEWTOP=../$(BUILDTOP) \ @@\ | |
395 | Makefiles; \ @@\ | |
396 | echo "### Done with" `pwd`); \ @@\ | |
397 | done | |
398 | ||
399 | ||
bdcaf132 | 400 | /* Compile Embeded SQL source */ |
b9be51ef | 401 | |
bdcaf132 | 402 | #ifdef INGRES |
403 | #define sqlrule() @@\ | |
404 | .SUFFIXES: .sc .dc @@\ | |
405 | .dc.sc: @@\ | |
406 | $(AWK) -f $(SRCTOP)/util/imake.includes/ingres.awk < $< > $*.sc @@\ | |
407 | @@\ | |
408 | .sc.c: @@\ | |
409 | /usr/rtingres/bin/esqlc -p $* | |
410 | #define sqlfile(file) @@\ | |
411 | concat(file,.sc): concat(file,.dc) @@\ | |
412 | concat(file,.c): concat(file,.sc) @@\ | |
413 | clean:: @@\ | |
414 | $(RM) concat(file,.sc) concat(file,.c) | |
415 | #endif | |
416 | #ifdef INFORMIX | |
417 | #define sqlrule() @@\ | |
418 | .SUFFIXES: .ec .dc @@\ | |
419 | .dc.ec: @@\ | |
420 | $(AWK) -f $(SRCTOP)/util/imake.includes/informix.awk < $< > $*.ec @@\ | |
421 | @@\ | |
422 | .ec.c: @@\ | |
423 | /usr/informix/bin/esql -e $*.ec | |
424 | #define sqlfile(file) @@\ | |
425 | concat(file,.ec): concat(file,.dc) @@\ | |
426 | concat(file,.c): concat(file,.ec) @@\ | |
427 | clean:: @@\ | |
428 | $(RM) concat(file,.ec) concat(file,.c) | |
429 | #endif | |
430 | #ifdef ORACLE | |
431 | #define sqlrule() @@\ | |
432 | .SUFFIXES: .pc .dc @@\ | |
433 | .dc.pc: @@\ | |
434 | $(AWK) -f $(SRCTOP)/util/imake.includes/oracle.awk < $< > $*.pc @@\ | |
435 | @@\ | |
436 | .pc.c: @@\ | |
437 | /usr/oracle/bin/pcc INAME=$*.pc | |
438 | #define sqlfile(file) @@\ | |
439 | concat(file,.pc): concat(file,.dc) @@\ | |
440 | concat(file,.c): concat(file,.pc) @@\ | |
441 | clean:: @@\ | |
442 | $(RM) concat(file,.pc) concat(file,.c) | |
443 | #endif |