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