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