]> andersk Git - moira.git/blame - util/imake.includes/Imake.rules
Programmer: John Kohl
[moira.git] / util / imake.includes / Imake.rules
CommitLineData
2e387221 1/**/# $Source$
2/**/# $Author$
3/**/# $Header$
4/**/#
5
b9be51ef 6#ifdef __STDC__
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 requote(x) #x
11#else
df897414 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
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
23#define library_obj_rule() @@\
24.c.o: @@\
df897414 25 $(CC) PROF_FLAG -c $(CFLAGS) $*.c @@\
b9be51ef 26 -$(LD) -X -r -o profiled/$*.o $*.o @@\
27 $(CC) -c $(CFLAGS) $*.c @@\
28 -$(LD) -x -r -o a.out $*.o @@\
29 $(MV) a.out $*.o
30
31/*
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.
34 */
35
36#define library_ro_object(cfile) @@\
37concat(cfile,.o): concat(cfile,.c) @@\
df897414 38 $(CC) PROF_FLAG -c $(CFLAGS) concat(cfile,.c) @@\
b9be51ef 39 -$(LD) -X -r -o profiled/$*.o $*.o @@\
40 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
41 -$(LD) -x -r -o a.out $*.o @@\
42 $(MV) a.out $*.o
43
44#define library_asm_object(ofile,sfile) @@\
45ofile: sfile @@\
46 $(CP) sfile x.c @@\
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 @@\
51 $(RM) a.out x.c
52
53#define install_library_target(libname,objs,srcs,lintlibs) @@\
54 @@\
55all:: concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
56all:: concat3(llib-l,libname,.ln) @@\
57 @@\
58concat3(lib,libname,.a): objs @@\
59 $(ARCHIVE) $@ objs @@\
60 $(RANLIB) $@ @@\
61 @@\
62concat3(lib,libname,_p.a): objs @@\
63 cd profiled; $(ARCHIVE) ../$@ objs @@\
64 $(RANLIB) $@ @@\
65 @@\
2e387221 66lint:: concat3(llib-l,libname,.ln) @@\
b9be51ef 67 @@\
68concat3(llib-l,libname,.ln): srcs @@\
69 $(LINT) concat(-C,libname) $(CFLAGS) srcs lintlibs @@\
70 @@\
71clean:: @@\
72 $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a) @@\
73 $(RM) concat3(llib-l,libname,.ln) @@\
74 $(RM) objs @@\
df897414 75 $(RM) profiled/?*.o @@\
b9be51ef 76 @@\
77install:: @@\
2e387221 78 $(INSTALLFILE) concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
7caabe5f 79 $(RANLIB) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
2e387221 80 $(INSTALLFILE) concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
7caabe5f 81 $(RANLIB) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
82 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LIBDIR)/lint,llib-l,libname,.ln) @@\
b9be51ef 83
df897414 84#else /* !PROFILED_LIBS */
85/*
86 * Rule for building objects in libraries.
87 */
88
89#define library_obj_rule() @@\
90.c.o: @@\
91 $(CC) -c $(CFLAGS) $*.c @@\
92 -$(LD) -x -r -o a.out $*.o @@\
93 $(MV) a.out $*.o
94
95#define library_ro_object(cfile) @@\
96concat(cfile,.o): concat(cfile,.c) @@\
97 $(CCRO) -c $(CFLAGS) concat(cfile,.c) @@\
98 -$(LD) -x -r -o a.out $*.o @@\
99 $(MV) a.out $*.o
100
101#define library_asm_object(ofile,sfile) @@\
102ofile: sfile @@\
103 $(CPP) x.c | $(AS) - @@\
104 -$(LD) -x -r -o $*.o a.out @@\
105 $(RM) a.out x.c
106
107#define install_library_target(libname,objs,srcs,lintlibs) @@\
108 @@\
109all:: concat3(lib,libname,.a) @@\
110all:: concat3(llib-l,libname,.ln) @@\
111 @@\
112concat3(lib,libname,.a): objs @@\
113 $(ARCHIVE) $@ objs @@\
114 $(RANLIB) $@ @@\
115 @@\
116lint:: concat3(llib-l,libname,.ln) @@\
117 @@\
118concat3(llib-l,libname,.ln): srcs @@\
119 $(LINT) concat(-C,libname) $(CFLAGS) srcs lintlibs @@\
120 @@\
121clean:: @@\
122 $(RM) concat3(lib,libname,.a) @@\
123 $(RM) concat3(llib-l,libname,.ln) @@\
124 $(RM) objs @@\
125 @@\
126install:: @@\
127 $(INSTALLFILE) concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
128 $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a) @@\
129 $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LIBDIR)/lint,llib-l,libname,.ln) @@\
130
131#endif /* PROFILED_LIBS */
132
b9be51ef 133/*
134 * Rule for building utilities (binaries which don't get installed)
135 */
b9be51ef 136#define genutil(pgm,objs,localdeps,syslibs) @@\
137all:: pgm @@\
138 @@\
139pgm: objs localdeps @@\
140 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
141 @@\
142clean:: @@\
143 $(RM) pgm objs @@\
144
145/*
146 * Rule for building "generator" programs.
147 */
148
149#define generate(file,pgm,libs) @@\
150 @@\
151pgm: concat(pgm,.c) libs @@\
152 $(HCC) $(HCFLAGS) -o $@ $@.c libs @@\
153 @@\
154file: pgm @@\
7caabe5f 155 ./pgm file @@\
b9be51ef 156 @@\
157clean:: @@\
158 $(RM) file pgm concat(pgm,.o)
159
160#define generate_depend(file,pgm,libs) @@\
161 generate(file,pgm,libs) @@\
162 @@\
163depend:: file
164
165
166/*
167 * Rule for building test programs (something which is not installed)
168 */
169
170#define test(pgm,locallibs,syslibs) @@\
171 @@\
172all:: pgm @@\
173 @@\
174pgm: concat(pgm,.c) locallibs @@\
175 $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs @@\
176 @@\
177clean:: @@\
178 $(RM) pgm concat(pgm,.o) @@\
179
7caabe5f 180/*
181 * Rule for compileing files with "et"
182 */
183
df897414 184#ifdef PROFILED_LIBS
185#define comp_et_prof(tbl) @@\
186concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
187 $(COMPILE_ET) concat(tbl,.et) -n @@\
188 $(CC) -c PROF_FLAG concat(tbl,.et.c) @@\
189 $(MV) concat(tbl,.et.o) concat3(profiled/,tbl,.o) @@\
190 $(COMPILE_ET) concat(tbl,.et) @@\
7caabe5f 191clean:: @@\
192 $(RM) concat(src,.o) concat(src,.h) @@\
df897414 193depend:: concat(src,.h)
194#else /* !PROFILED_LIBS */
195#define comp_et_prof(tbl) comp_et(tbl)
196#endif /* PROFILED_LIBS */
197
198#define comp_et(tbl) @@\
199concat(tbl,.h) concat(tbl,.o): concat(tbl,.et) @@\
200 $(COMPILE_ET) concat(tbl,.et) @@\
201clean:: @@\
202 $(RM) concat(src,.o) concat(src,.h)
7caabe5f 203
204#define comp_et_depend(src) @@\
205 comp_et(src) @@\
206 @@\
df897414 207depend:: concat(src,.h)
7caabe5f 208
b9be51ef 209/*
210 * Rule for building some random object module
211 */
212
213#define host_simple_object(obj,src) @@\
214obj: src @@\
215 $(HCC) $(HCFLAGS) -c src @@\
216 @@\
217clean:: @@\
218 $(RM) obj @@\
219
220#define ro_object(obj,src) @@\
221obj: src @@\
222 $(CCRO) $(CFLAGS) -c src @@\
223 @@\
224clean:: @@\
225 $(RM) obj @@\
226
2e387221 227/*
228 * Rule for building some random object module with compile flags and
229 * other dependendcies
230 */
231
232#define host_flag_object(obj,src,flags,localdeps) @@\
233obj: src localdeps @@\
234 $(HCC) $(HCFLAGS) flags -c src @@\
235 @@\
236clean:: @@\
237 $(RM) obj @@\
238
239#define ro_flag_object(obj,src,flags,localdeps) @@\
240obj: src localdeps @@\
241 $(CCRO) $(CFLAGS) flags -c src @@\
242 @@\
243clean:: @@\
244 $(RM) obj @@\
245
246/*
247 * Rule for building some random object module with compile flags, an
248 * intermediate output, and some other dependencies
249 */
250
251#define host_cplx_object(obj,interim,src,flags,localdeps) @@\
7caabe5f 252obj: interim src localdeps @@\
2e387221 253 $(HCC) $(HCFLAGS) flags -c src @@\
254 $(MV) interim obj @@\
255 @@\
256clean:: @@\
257 $(RM) obj @@\
258
259#define ro_cplx_object(obj,interim,src,flags,localdeps) @@\
7caabe5f 260obj: src localdeps interim @@\
2e387221 261 $(CCRO) $(CFLAGS) flags -c src @@\
262 $(MV) interim obj @@\
263 @@\
264clean:: @@\
265 $(RM) obj @@\
266
b9be51ef 267/*
268 * Rule for building a program which is to be installed:
269 */
270
271#define program(pgm,objs,localdeps,syslibs,installdir) @@\
272all:: pgm @@\
273 @@\
7caabe5f 274pgm: localdeps objs @@\
275 $(CC) $(CFLAGS) -o $@ objs syslibs @@\
b9be51ef 276 @@\
277install:: @@\
2e387221 278 $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm @@\
279 @@\
280clean:: @@\
281 $(RM) pgm objs @@\
282
283/*
284 * Rule for building a program which is to be installed setuid root:
285 */
286
287#define suidprogram(pgm,objs,localdeps,syslibs,installdir) @@\
288all:: pgm @@\
289 @@\
290pgm: objs localdeps @@\
291 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
292 @@\
293install:: @@\
294 $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm @@\
b9be51ef 295 @@\
296clean:: @@\
297 $(RM) pgm objs @@\
298
299/*
300 * Rule for building a specially installed program
301 */
302
303#define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts) @@\
304all:: pgm @@\
305 @@\
306pgm: objs localdeps @@\
307 $(CC) $(CFLAGS) -o $@ objs localdeps syslibs @@\
308 @@\
309install:: @@\
2e387221 310 $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm @@\
b9be51ef 311 @@\
312clean:: @@\
313 $(RM) pgm objs @@\
314
315/*
2e387221 316 * Rule for installing man pages. Section installing into should match
317 * suffix, or the man page won't show up when using man(1).
b9be51ef 318 */
319
320#define manpage(section,page) @@\
321all:: @@\
322install:: page @@\
323 $(INSTALLFILE) page concat3(${DESTDIR}${MANDIR}/man,section,/`basename page`) @@\
324
325/*
2e387221 326 * Rule for building makefile dependencies.
b9be51ef 327 */
328
329#define depend_target() @@\
330depend:: $(SRCS) @@\
2e387221 331 @echo "### Now computing dependencies" @@\
b9be51ef 332 @$(DEPEND) -s "# DO NOT DELETE" $(CFLAGS) $(SRCS) @@\
333
334#define clean_target() @@\
335clean:: @@\
336 $(RM) *~ \#* *.bak $(TAGSFILE)
337
338#define tags_target() @@\
339tags:: @@\
340 $(TAGGER) *.c *.h
341
342#define makefile_target() @@\
343Makefile:: @@\
344 -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak @@\
345 $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile @@\
346
347#define foreach_subdirs(name,subdirs) @@\
348name:: @@\
349 @for d in subdirs; \ @@\
350 do \ @@\
351 (cd $$d; echo "### Making" name "in" `pwd`; \ @@\
7caabe5f 352 $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \ @@\
b9be51ef 353 echo "### Done with" `pwd`); \ @@\
354 done
355
356#define print_target() @@\
357print:: ${CODE} @@\
358 ${LPR} ${CODE}
359
360#define src_target() @@\
361src:: ${CODE} @@\
362 @@\
363${CODE}: @@\
364 -$(LN) ${SRCDIR}/$@ $@
365
366#define do_subdirs_no_imakefile(subdirs) @@\
367 foreach_subdirs(all, subdirs) @@\
368 foreach_subdirs(install, subdirs) @@\
369 foreach_subdirs(clean, subdirs) @@\
370 foreach_subdirs(depend, subdirs) @@\
371 foreach_subdirs(tags, subdirs) @@\
372 foreach_subdirs(print, subdirs) @@\
373 foreach_subdirs(src, subdirs) @@\
374
375#define do_subdirs(subdirs) @@\
376 do_subdirs_no_imakefile(subdirs) @@\
377 @@\
378Makefiles:: @@\
379 @echo "### Making Makefiles in" `pwd` @@\
380 @for d in subdirs; \ @@\
381 do \ @@\
382 (cd $$d; echo "### Making Makefile in" `pwd`; \ @@\
383 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
384 NEWTOP=../$(BUILDTOP) \ @@\
385 BUILDTOP=../$(BUILDTOP) \ @@\
386 -f ../Makefile \ @@\
387 Makefile; \ @@\
388 $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \ @@\
389 NEWTOP=../$(BUILDTOP) \ @@\
390 Makefiles; \ @@\
391 echo "### Done with" `pwd`); \ @@\
392 done
393
394
395
This page took 0.107856 seconds and 5 git commands to generate.