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