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