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