]> andersk Git - moira.git/blob - util/imake.includes/Imake.rules
Programmer: John Kohl
[moira.git] / util / imake.includes / Imake.rules
1 /**/#   $Source$
2 /**/#   $Author$
3 /**/#   $Header$
4 /**/#
5
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
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"
16 #endif
17
18 #ifdef PROFILED_LIBS
19 /*
20  * Rule for building objects in libraries.
21  */
22
23 #define library_obj_rule()                                              @@\
24 .c.o:                                                                   @@\
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                                      @@\
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)                                        @@\
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                                      @@\
42         $(MV) a.out $*.o
43
44 #define library_asm_object(ofile,sfile)                                 @@\
45 ofile: 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                                                                         @@\
55 all:: concat3(lib,libname,.a) concat3(lib,libname,_p.a)                 @@\
56 all:: concat3(llib-l,libname,.ln)                                       @@\
57                                                                         @@\
58 concat3(lib,libname,.a): objs                                           @@\
59         $(ARCHIVE) $@ objs                                              @@\
60         $(RANLIB) $@                                                    @@\
61                                                                         @@\
62 concat3(lib,libname,_p.a): objs                                         @@\
63         cd profiled; $(ARCHIVE) ../$@ objs                              @@\
64         $(RANLIB) $@                                                    @@\
65                                                                         @@\
66 lint:: concat3(llib-l,libname,.ln)                                      @@\
67                                                                         @@\
68 concat3(llib-l,libname,.ln): srcs                                       @@\
69         $(LINT) concat(-C,libname) $(CFLAGS) srcs lintlibs              @@\
70                                                                         @@\
71 clean::                                                                 @@\
72         $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a)         @@\
73         $(RM) concat3(llib-l,libname,.ln)                               @@\
74         $(RM) objs                                                      @@\
75         $(RM) profiled/?*.o                                             @@\
76                                                                         @@\
77 install::                                                               @@\
78         $(INSTALLFILE) concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a)     @@\
79         $(RANLIB) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a)          @@\
80         $(INSTALLFILE) concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
81         $(RANLIB) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a)                @@\
82         $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LIBDIR)/lint,llib-l,libname,.ln) @@\
83
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)                                        @@\
96 concat(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)                                 @@\
102 ofile: 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                                                                         @@\
109 all:: concat3(lib,libname,.a)                                           @@\
110 all:: concat3(llib-l,libname,.ln)                                       @@\
111                                                                         @@\
112 concat3(lib,libname,.a): objs                                           @@\
113         $(ARCHIVE) $@ objs                                              @@\
114         $(RANLIB) $@                                                    @@\
115                                                                         @@\
116 lint:: concat3(llib-l,libname,.ln)                                      @@\
117                                                                         @@\
118 concat3(llib-l,libname,.ln): srcs                                       @@\
119         $(LINT) concat(-C,libname) $(CFLAGS) srcs lintlibs              @@\
120                                                                         @@\
121 clean::                                                                 @@\
122         $(RM) concat3(lib,libname,.a)                                   @@\
123         $(RM) concat3(llib-l,libname,.ln)                               @@\
124         $(RM) objs                                                      @@\
125                                                                         @@\
126 install::                                                               @@\
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
133 /*
134  * Rule for building utilities (binaries which don't get installed)
135  */
136 #define genutil(pgm,objs,localdeps,syslibs)                             @@\
137 all:: pgm                                                               @@\
138                                                                         @@\
139 pgm: objs localdeps                                                     @@\
140         $(CC) $(CFLAGS) -o $@ objs localdeps syslibs                    @@\
141                                                                         @@\
142 clean::                                                                 @@\
143         $(RM) pgm objs                                                  @@\
144
145 /*
146  * Rule for building "generator" programs.
147  */
148
149 #define generate(file,pgm,libs)                                         @@\
150                                                                         @@\
151 pgm: concat(pgm,.c) libs                                                @@\
152         $(HCC) $(HCFLAGS) -o $@ $@.c libs                               @@\
153                                                                         @@\
154 file: pgm                                                               @@\
155         ./pgm file                                                      @@\
156                                                                         @@\
157 clean::                                                                 @@\
158         $(RM) file pgm concat(pgm,.o)                                   
159
160 #define generate_depend(file,pgm,libs)                                  @@\
161         generate(file,pgm,libs)                                         @@\
162                                                                         @@\
163 depend:: file
164
165
166 /*
167  * Rule for building test programs (something which is not installed)
168  */
169
170 #define test(pgm,locallibs,syslibs)                                     @@\
171                                                                         @@\
172 all:: pgm                                                               @@\
173                                                                         @@\
174 pgm: concat(pgm,.c) locallibs                                           @@\
175         $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs                    @@\
176                                                                         @@\
177 clean::                                                                 @@\
178         $(RM) pgm concat(pgm,.o)                                        @@\
179
180 /* 
181  * Rule for compileing files with "et"
182  */
183
184 #ifdef PROFILED_LIBS
185 #define comp_et_prof(tbl)                                               @@\
186 concat(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)                                   @@\
191 clean::                                                                 @@\
192         $(RM) concat(src,.o) concat(src,.h)                             @@\
193 depend:: 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)                                                    @@\
199 concat(tbl,.h) concat(tbl,.o): concat(tbl,.et)                          @@\
200         $(COMPILE_ET) concat(tbl,.et)                                   @@\
201 clean::                                                                 @@\
202         $(RM) concat(src,.o) concat(src,.h)
203
204 #define comp_et_depend(src)                                             @@\
205         comp_et(src)                                                    @@\
206                                                                         @@\
207 depend:: concat(src,.h)
208
209 /*
210  * Rule for building some random object module
211  */
212
213 #define host_simple_object(obj,src)                                     @@\
214 obj:    src                                                             @@\
215         $(HCC) $(HCFLAGS) -c src                                        @@\
216                                                                         @@\
217 clean::                                                                 @@\
218         $(RM) obj                                                       @@\
219
220 #define ro_object(obj,src)                                              @@\
221 obj:    src                                                             @@\
222         $(CCRO) $(CFLAGS) -c src                                        @@\
223                                                                         @@\
224 clean::                                                                 @@\
225         $(RM) obj                                                       @@\
226         
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)                       @@\
233 obj:    src localdeps                                                   @@\
234         $(HCC) $(HCFLAGS) flags -c src                                  @@\
235                                                                         @@\
236 clean::                                                                 @@\
237         $(RM) obj                                                       @@\
238
239 #define ro_flag_object(obj,src,flags,localdeps)                         @@\
240 obj:    src localdeps                                                   @@\
241         $(CCRO) $(CFLAGS) flags -c src                                  @@\
242                                                                         @@\
243 clean::                                                                 @@\
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)               @@\
252 obj:    interim src localdeps                                           @@\
253         $(HCC) $(HCFLAGS) flags -c src                                  @@\
254         $(MV) interim obj                                               @@\
255                                                                         @@\
256 clean::                                                                 @@\
257         $(RM) obj                                                       @@\
258
259 #define ro_cplx_object(obj,interim,src,flags,localdeps)                 @@\
260 obj:    src localdeps interim                                           @@\
261         $(CCRO) $(CFLAGS) flags -c src                                  @@\
262         $(MV) interim obj                                               @@\
263                                                                         @@\
264 clean::                                                                 @@\
265         $(RM) obj                                                       @@\
266         
267 /*
268  * Rule for building a program which is to be installed:
269  */
270
271 #define program(pgm,objs,localdeps,syslibs,installdir)                  @@\
272 all:: pgm                                                               @@\
273                                                                         @@\
274 pgm: localdeps objs                                                     @@\
275         $(CC) $(CFLAGS) -o $@ objs syslibs                              @@\
276                                                                         @@\
277 install::                                                               @@\
278         $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm                     @@\
279                                                                         @@\
280 clean::                                                                 @@\
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)              @@\
288 all:: pgm                                                               @@\
289                                                                         @@\
290 pgm: objs localdeps                                                     @@\
291         $(CC) $(CFLAGS) -o $@ objs localdeps syslibs                    @@\
292                                                                         @@\
293 install::                                                               @@\
294         $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm                     @@\
295                                                                         @@\
296 clean::                                                                 @@\
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)  @@\
304 all:: pgm                                                               @@\
305                                                                         @@\
306 pgm: objs localdeps                                                     @@\
307         $(CC) $(CFLAGS) -o $@ objs localdeps syslibs                    @@\
308                                                                         @@\
309 install::                                                               @@\
310         $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm             @@\
311                                                                         @@\
312 clean::                                                                 @@\
313         $(RM) pgm objs                                                  @@\
314
315 /*
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).
318  */
319
320 #define manpage(section,page)                                           @@\
321 all::                                                                   @@\
322 install:: page                                                          @@\
323         $(INSTALLFILE) page concat3(${DESTDIR}${MANDIR}/man,section,/`basename page`) @@\
324
325 /*
326  * Rule for building makefile dependencies.
327  */
328
329 #define depend_target()                                                 @@\
330 depend:: $(SRCS)                                                        @@\
331         @echo "### Now computing dependencies"                          @@\
332         @$(DEPEND) -s "# DO NOT DELETE" $(CFLAGS) $(SRCS)               @@\
333
334 #define clean_target()                                                  @@\
335 clean::                                                                 @@\
336         $(RM) *~ \#* *.bak $(TAGSFILE)                          
337
338 #define tags_target()                                                   @@\
339 tags::                                                                  @@\
340         $(TAGGER) *.c *.h
341
342 #define makefile_target()                                               @@\
343 Makefile::                                                              @@\
344         -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak                @@\
345         $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile                        @@\
346
347 #define foreach_subdirs(name,subdirs)                                   @@\
348 name::                                                                  @@\
349         @for d in subdirs; \                                            @@\
350         do \                                                            @@\
351                 (cd $$d; echo "### Making" name "in" `pwd`;     \       @@\
352                         $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) name ; \   @@\
353                         echo "### Done with" `pwd`);            \       @@\
354         done
355
356 #define print_target()                                                  @@\
357 print:: ${CODE}                                                         @@\
358         ${LPR} ${CODE}
359         
360 #define src_target()                                                    @@\
361 src:: ${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                                                                         @@\
378 Makefiles::                                                             @@\
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.113408 seconds and 5 git commands to generate.