]> andersk Git - moira.git/blob - util/imake.includes/Imake.rules
add new funky rules; clean up install steps and fix spelling
[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
87 #define genutil(pgm,objs,localdeps,syslibs)                             @@\
88 all:: pgm                                                               @@\
89                                                                         @@\
90 pgm: objs localdeps                                                     @@\
91         $(CC) $(CFLAGS) -o $@ objs localdeps syslibs                    @@\
92                                                                         @@\
93 clean::                                                                 @@\
94         $(RM) pgm objs                                                  @@\
95
96 /*
97  * Rule for building "generator" programs.
98  */
99
100 #define generate(file,pgm,libs)                                         @@\
101                                                                         @@\
102 pgm: concat(pgm,.c) libs                                                @@\
103         $(HCC) $(HCFLAGS) -o $@ $@.c libs                               @@\
104                                                                         @@\
105 file: pgm                                                               @@\
106         ./pgm > file                                                    @@\
107                                                                         @@\
108 clean::                                                                 @@\
109         $(RM) file pgm concat(pgm,.o)                                   
110
111 #define generate_depend(file,pgm,libs)                                  @@\
112         generate(file,pgm,libs)                                         @@\
113                                                                         @@\
114 depend:: file
115
116
117 /*
118  * Rule for building test programs (something which is not installed)
119  */
120
121 #define test(pgm,locallibs,syslibs)                                     @@\
122                                                                         @@\
123 all:: pgm                                                               @@\
124                                                                         @@\
125 pgm: concat(pgm,.c) locallibs                                           @@\
126         $(CC) $(CFLAGS) -o $@ $@.c locallibs syslibs                    @@\
127                                                                         @@\
128 clean::                                                                 @@\
129         $(RM) pgm concat(pgm,.o)                                        @@\
130
131 /*
132  * Rule for building some random object module
133  */
134
135 #define host_simple_object(obj,src)                                     @@\
136 obj:    src                                                             @@\
137         $(HCC) $(HCFLAGS) -c src                                        @@\
138                                                                         @@\
139 clean::                                                                 @@\
140         $(RM) obj                                                       @@\
141
142 #define ro_object(obj,src)                                              @@\
143 obj:    src                                                             @@\
144         $(CCRO) $(CFLAGS) -c src                                        @@\
145                                                                         @@\
146 clean::                                                                 @@\
147         $(RM) obj                                                       @@\
148         
149 /*
150  * Rule for building some random object module with compile flags and
151  * other dependendcies
152  */
153
154 #define host_flag_object(obj,src,flags,localdeps)                       @@\
155 obj:    src localdeps                                                   @@\
156         $(HCC) $(HCFLAGS) flags -c src                                  @@\
157                                                                         @@\
158 clean::                                                                 @@\
159         $(RM) obj                                                       @@\
160
161 #define ro_flag_object(obj,src,flags,localdeps)                         @@\
162 obj:    src localdeps                                                   @@\
163         $(CCRO) $(CFLAGS) flags -c src                                  @@\
164                                                                         @@\
165 clean::                                                                 @@\
166         $(RM) obj                                                       @@\
167         
168 /*
169  * Rule for building some random object module with compile flags, an
170  * intermediate output, and some other dependencies
171  */
172
173 #define host_cplx_object(obj,interim,src,flags,localdeps)               @@\
174 obj:    src localdeps                                                   @@\
175         $(HCC) $(HCFLAGS) flags -c src                                  @@\
176         $(MV) interim obj                                               @@\
177                                                                         @@\
178 clean::                                                                 @@\
179         $(RM) obj                                                       @@\
180
181 #define ro_cplx_object(obj,interim,src,flags,localdeps)                 @@\
182 obj:    src localdeps                                                   @@\
183         $(CCRO) $(CFLAGS) flags -c src                                  @@\
184         $(MV) interim obj                                               @@\
185                                                                         @@\
186 clean::                                                                 @@\
187         $(RM) obj                                                       @@\
188         
189 /*
190  * Rule for building a program which is to be installed:
191  */
192
193 #define program(pgm,objs,localdeps,syslibs,installdir)                  @@\
194 all:: pgm                                                               @@\
195                                                                         @@\
196 pgm: objs localdeps                                                     @@\
197         $(CC) $(CFLAGS) -o $@ objs localdeps syslibs                    @@\
198                                                                         @@\
199 install::                                                               @@\
200         $(INSTALLPROG) pgm ${DESTDIR}installdir/pgm                     @@\
201                                                                         @@\
202 clean::                                                                 @@\
203         $(RM) pgm objs                                                  @@\
204
205 /*
206  * Rule for building a program which is to be installed setuid root:
207  */
208
209 #define suidprogram(pgm,objs,localdeps,syslibs,installdir)              @@\
210 all:: pgm                                                               @@\
211                                                                         @@\
212 pgm: objs localdeps                                                     @@\
213         $(CC) $(CFLAGS) -o $@ objs localdeps syslibs                    @@\
214                                                                         @@\
215 install::                                                               @@\
216         $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm                     @@\
217                                                                         @@\
218 clean::                                                                 @@\
219         $(RM) pgm objs                                                  @@\
220
221 /*
222  * Rule for building a specially installed program
223  */
224
225 #define program_spinst(pgm,objs,localdeps,syslibs,installdir,instopts)  @@\
226 all:: pgm                                                               @@\
227                                                                         @@\
228 pgm: objs localdeps                                                     @@\
229         $(CC) $(CFLAGS) -o $@ objs localdeps syslibs                    @@\
230                                                                         @@\
231 install::                                                               @@\
232         $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm             @@\
233                                                                         @@\
234 clean::                                                                 @@\
235         $(RM) pgm objs                                                  @@\
236
237 /*
238  * Rule for installing man pages.  Section installing into should match
239  * suffix, or the man page won't show up when using man(1).
240  */
241
242 #define manpage(section,page)                                           @@\
243 all::                                                                   @@\
244 install:: page                                                          @@\
245         $(INSTALLFILE) page concat3(${DESTDIR}${MANDIR}/man,section,/`basename page`) @@\
246
247 /*
248  * Rule for building makefile dependencies.
249  */
250
251 #define depend_target()                                                 @@\
252 depend:: $(SRCS)                                                        @@\
253         @echo "### Now computing dependencies"                          @@\
254         @$(DEPEND) -s "# DO NOT DELETE" $(CFLAGS) $(SRCS)               @@\
255
256 #define clean_target()                                                  @@\
257 clean::                                                                 @@\
258         $(RM) *~ \#* *.bak $(TAGSFILE)                          
259
260 #define tags_target()                                                   @@\
261 tags::                                                                  @@\
262         $(TAGGER) *.c *.h
263
264 #define makefile_target()                                               @@\
265 Makefile::                                                              @@\
266         -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak                @@\
267         $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile                        @@\
268
269 #define foreach_subdirs(name,subdirs)                                   @@\
270 name::                                                                  @@\
271         @for d in subdirs; \                                            @@\
272         do \                                                            @@\
273                 (cd $$d; echo "### Making" name "in" `pwd`;     \       @@\
274                         $(MAKE) $(MFLAGS) name ;        \               @@\
275                         echo "### Done with" `pwd`);            \       @@\
276         done
277
278 #define print_target()                                                  @@\
279 print:: ${CODE}                                                         @@\
280         ${LPR} ${CODE}
281         
282 #define src_target()                                                    @@\
283 src:: ${CODE}                                                           @@\
284                                                                         @@\
285 ${CODE}:                                                                @@\
286         -$(LN) ${SRCDIR}/$@ $@
287
288 #define do_subdirs_no_imakefile(subdirs)                                @@\
289         foreach_subdirs(all, subdirs)                                   @@\
290         foreach_subdirs(install, subdirs)                               @@\
291         foreach_subdirs(clean, subdirs)                                 @@\
292         foreach_subdirs(depend, subdirs)                                @@\
293         foreach_subdirs(tags, subdirs)                                  @@\
294         foreach_subdirs(print, subdirs)                                 @@\
295         foreach_subdirs(src, subdirs)                                   @@\
296
297 #define do_subdirs(subdirs)                                             @@\
298         do_subdirs_no_imakefile(subdirs)                                @@\
299                                                                         @@\
300 Makefiles::                                                             @@\
301         @echo "### Making Makefiles in" `pwd`                           @@\
302         @for d in subdirs; \                                            @@\
303         do \                                                            @@\
304                 (cd $$d; echo "### Making Makefile in" `pwd`; \         @@\
305                         $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \            @@\
306                         NEWTOP=../$(BUILDTOP)           \               @@\
307                         BUILDTOP=../$(BUILDTOP)         \               @@\
308                         -f ../Makefile                  \               @@\
309                         Makefile; \                                     @@\
310                         $(MAKE) $(MFLAGS) SRCTOP=$(SRCTOP) \            @@\
311                         NEWTOP=../$(BUILDTOP)           \               @@\
312                         Makefiles; \                                    @@\
313                         echo "### Done with" `pwd`); \                  @@\
314         done
315
316
317
This page took 0.066538 seconds and 5 git commands to generate.