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