Resolve many build warnings
[oweals/cde.git] / cde / config / cf / Imake.rules
1 XCOMM ---------------------------------------------------------------------
2 XCOMM Imake rules for building libraries, programs, scripts, and data files
3 XCOMM rules:  $TOG: Imake.rules /main/227 1998/02/02 12:07:57 kaleb $
4
5 /*
6  *                 MACHINE-INDEPENDENT RULES; DO NOT MODIFY
7  *
8  * Warning, when defining rules: make sure you do not include both a trailing
9  * backslash and double ampersand backslash or else you will get an extra
10  * backslash in the Makefile.
11  * 
12  * The following macros are defined for the various templates and Imakefiles
13  * (for a list of the applicable make variables, see the template files):
14  * 
15  * Concat                       (a,b)
16  * Concat3                      (a,b,c)
17  * Concat4                      (a,b,c,d)
18  * _Use                         (a,b)
19  * _UseCat                      (a,b,c)
20  * ProgramTargetName            (target)
21  * RunProgram                   (progvar,options)
22  * RunProgramWithSetup          (setup,progvar,options)
23  * RemoveFile                   (file)
24  * RemoveFiles                  (files)
25  * CenterLoadTarget             (target,srclist,libs,defines)
26  * CenterProgramTarget          (program,srclist,objlist,locallibs,syslibs)
27  * SentinelLinkTarget           (step,program,linklist)
28  * SentinelProgramTarget        (program,deplist,linklist)
29  * SentinelCplusplusProgramTarget       (program,deplist,linklist)
30  * PurifyLinkTarget             (step,program,linklist)
31  * PurifyProgramTarget          (program,deplist,linklist)
32  * PurifyCplusplusProgramTarget (program,deplist,linklist)
33  * ProofLinkTarget              (step,program,linklist)
34  * ProofProgramTarget           (program,deplist,linklist)
35  * ProofCplusplusProgramTarget  (program,deplist,linklist)
36  * ProofCleanTarget             ()
37  * RemoveTargetProgram          (program)
38  * MakeDir                      (dir)
39  * BuildIncludesTop             (srclist)
40  * BuildIncludes                (srclist,dstsubdir,dstupdir)
41  * LinkRule                     (program,options,objects,libraries)
42  * HostLinkRule                 (program,options,objects,libraries)
43  * NoCmpScript                  (target)
44  * NoConfigRec                  (target)
45  * NormalProgramTarget          (program,objects,deplibs,locallibs,syslibs)
46  * SetUIDProgramTarget          (program,objects,deplibs,locallibs,syslibs)
47  * SingleProgramTarget          (program,objects,locallibs,syslibs)
48  * SimpleProgramTarget          (program)
49  * ComplexProgramTarget         (program)
50  * ComplexProgramTarget_1       (program,locallib,syslib)
51  * ComplexProgramTarget_2       (program,locallib,syslib)
52  * ComplexProgramTarget_3       (program,locallib,syslib)
53  * ServerTargetWithFlags        (server,subdirs,objects,libs,syslibs,flags)
54  * ServerTarget                 (server,subdirs,objects,libs,syslibs)
55  * MoveToBakFile                (file)
56  * RMoveToBakFile               (file)
57  * RanLibrary                   (args)
58  * LibraryTargetName            (libname)
59  * LibraryTargetNameSuffix      (libname,suffix)
60  * InstallNamedTarget           (step,srcname,flags,dest,dstname)
61  * InstallTarget                (step,file,flags,dest)
62  * InstallLibrary               (libname,dest)
63  * MergeIntoInstalledLibrary    (tolib,fromlib)
64  * InstallLibraryAlias          (libname,alias,dest)
65  * InstallLintLibrary           (libname,dest)
66  * InstallManPageLong           (file,destdir,dest)
67  * InstallManPage               (file,destdir)
68  * InstallManPageAliases        (file,destdir,aliases)
69  * ManKeywordsTarget            (manpath)
70  * InstallNamedNonExec          (srcname,dstname,dest)
71  * InstallNonExecFile           (file,dest)
72  * InstallNonExecFileNoClobber  (file,dest)
73  * InstallNonExec               (file,dest)
74  * InstallProgramWithFlags      (program,dest,flags)
75  * InstallProgram               (program,dest)
76  * InstallScript                (program,dest)
77  * InstallNamedProg             (srcname,dstname,dest)
78  * InstallNamedProgNoClobber    (srcname,dstname,dest)
79  * MakeFlagsToShellFlags        (makeflags,shellcmd)
80  * LinkFileList                 (step,list,dir,sub)
81  * LinkVarDirectory             (mdir,cdir,rdir,ldir)
82  * InstallMultipleDestFlags     (step,list,dest,flags)
83  * InstallMultipleDest          (step,list,dest)
84  * InstallMultiple              (list,dest)
85  * InstallMultipleFlags         (list,dest,flags)
86  * InstallMultipleMan           (list,dest)
87  * DependDependency             ()
88  * DependTarget                 ()
89  * DependTarget3                (srcs1,srcs2,srcs3)
90  * CleanTarget                  ()
91  * TagsTarget                   ()
92  * ImakeDependency              (target)
93  * BuildMakefileTarget          (notused,imakeflags)
94  * MakefileTarget               ()
95  * LibMkdir                     (dir)
96  * LibCleanDir                  (dir)
97  * LintLibReferences            (varname,libname,libsource)
98  * UnsharedLibReferences        (varname,libname,libsource)
99  * ProjectUnsharedLibReferences (varname,libname,libsource,buildlibdir)
100  * SharedLibDependencies        (libname,libsource,revname)
101  * SharedDSLibDependencies      (libname,libsource,revname)
102  * SharedLibReferences          (varname,libname,libsource,revname,rev)
103  * SharedDSLibReferences        (varname,libname,libsource,revname,rev)
104  * ObjectCompile                (options)
105  * NormalLibObjCompile          (options)
106  * NormalSharedLibObjCompile    (options)
107  * LibObjCompile                (dir,options)
108  * DebuggedLibObjCompile        (options)
109  * ProfiledLibObjCompile        (options)
110  * SharedLibObjCompile          (options)
111  * NormalLibraryObjectRule      ()
112  * NormalFortranObjectRule      ()
113  * ObjectFromSpecialSource      (dst,src,flags)
114  * SpecialObjectRule            (objs,depends,options)
115  * SpecialCObjectRule           (basename,depends,options)
116  * LexFile                      (file)
117  * YaccFile                     (file,flags)
118  * YaccFileNoFlags              (file)
119  * MakeLibrary                  (libname,objlist)
120  * NormalLibraryTarget          (libname,objlist)
121  * NormalLibraryTarget2         (libname,objlist1,objlist2)
122  * NormalLibraryTarget3         (libname,objlist1,objlist2,objlist3)
123  * NormalDepLibraryTarget       (libname,deplist,objlist)
124  * UnsharedLibraryTarget        (libname,objlist,down,up)
125  * UnsharedLibraryTarget3       (libname,objlist1,objlist2,objlist3,down,up)
126  * SubdirLibraryRule            (objlist)
127  * ProfiledLibraryTarget        (libname,objlist)
128  * DebuggedLibraryTarget        (libname,objlist)
129  * AliasedLibraryTarget         (libname,alias)
130  * NormalRelocatableTarget      (objname,objlist)
131  * ProfiledRelocatableTarget    (objname,objlist)
132  * DebuggedRelocatableTarget    (objname,objlist)
133  * LintLibraryTarget            (libname,srclist)
134  * NormalLintTarget             (srclist)
135  * LintTarget                   ()
136  * LinkSourceFile               (src,dir)
137  * LinkFile                     (tofile,fromfile)
138  * MakeSubincludesForBuild      (step,dir,srclist)
139  * LangNamedTargetSubdirs       (lang,name,dirs,verb,flags,subname)
140  * LangNamedMakeSubdirs         (lang,name,dirs)
141  * LangMakeSubdirs              (lang,dirs)
142  * NamedTargetSubdirs           (name,dirs,verb,flags,subname)
143  * NamedMakeSubdirs             (name,dirs)
144  * MakeSubdirs                  (dirs)
145  * DependSubdirs                (dirs)
146  * ForceSubdirs                 (dirs)
147  * InstallSubdirs               (dirs)
148  * InstallManSubdirs            (dirs)
149  * IncludesSubdirs              (dirs)
150  * NamedCleanSubdirs            (name,dirs)
151  * CleanSubdirs                 (dirs)
152  * NamedTagSubdirs              (name,dirs)
153  * TagSubdirs                   (dirs)
154  * MakeLintSubdirs              (dirs,target,subtarget)
155  * LintSubdirs                  (dirs)
156  * MakeLintLibSubdirs           (dirs)
157  * MakeMakeOneSubdirs           ()
158  * MakeMakeSubdirs              (dirs,target)
159  * MakefileSubdirs              (dirs)
160  * CppScriptTarget              (dst,src,defs,deplist)
161  * MakeScriptFromCpp            (name,defs)
162  * CppFileTarget                (dst,src,defs,deplist)
163  * CppSourceFile                (dst,src,defs,deplist)
164  * MakeDirectories              (step,dirs)
165  * AllTarget                    (depends)
166  * MakeImakeDir                 ()
167  * DoUDB_SCRIPT3                (target, file, script, build)
168  * DoUDB_SCRIPT4                (target, file, script, build)
169  *
170  *
171  * The following are in specific <os>Lib.rules:
172  *
173  * SharedLibraryTarget          (libname,rev,solist,down,up)
174  * SharedLibraryDataTarget      (libname,rev,salist)
175  * InstallSharedLibrary         (libname,rev,dest)
176  * InstallSharedLibraryData     (libname,rev,dest)
177  * 
178  */
179
180 #define NullParameter
181
182 /* stringify macro */
183 #ifndef STR
184 # if defined(__llvm__)
185 # define STR2(x)        #x
186 # else
187 # define STR2(x)        "x"
188 # endif
189 #define STR(x)  STR2(x)
190 #endif
191
192 /* if [ -d ] or [ ! -d ] causes make to fail, define this as - */
193 #ifndef DirFailPrefix
194 #define DirFailPrefix
195 #endif
196
197 /*
198  * NoCmpScript - suppress clearmake build script comparison.
199  */
200 #ifndef NoCmpScript
201 #if HasClearmake
202 #define NoCmpScript(targ)                                               @@\
203 XCOMM special target for clearmake                                      @@\
204 .NO_CMP_SCRIPT: targ
205 #else
206 #define NoCmpScript(targ) /**/
207 #endif
208 #endif
209
210 /*
211  * NoConfigRec - suppress using clearmake configuration records.
212  */
213 #ifndef NoConfigRec
214 #if HasClearmake
215 #define NoConfigRec(targ)                                               @@\
216 XCOMM special target for clearmake                                      @@\
217 .NO_CONFIG_REC: targ
218 #else
219 #define NoConfigRec(targ) /**/
220 #endif
221 #endif
222
223 /*
224  * Concat - concatenates two strings.
225  */
226 #ifndef Concat
227 #if (__STDC__ && !defined(UnixCpp)) || defined(AnsiCpp) || defined(__llvm__)
228 #define Concat(a,b)a##b
229 #else
230 #define Concat(a,b)a/**/b
231 #endif
232 #endif
233
234 /*
235  * Concat3 - concatenates three strings.
236  */
237 #ifndef Concat3
238 #if (__STDC__ && !defined(UnixCpp)) || defined(AnsiCpp) || defined(__llvm__)
239 #define Concat3(a,b,c)a##b##c
240 #else
241 #define Concat3(a,b,c)a/**/b/**/c
242 #endif
243 #endif
244
245 /*
246  * Concat4 - concatenates four strings.
247  */
248 #ifndef Concat4
249 #if (__STDC__ && !defined(UnixCpp)) || defined(AnsiCpp) || defined(__llvm__)
250 #define Concat4(a,b,c,d)a##b##c##d
251 #else
252 #define Concat4(a,b,c,d)a/**/b/**/c/**/d
253 #endif
254 #endif
255
256 /*
257  * _XUse - makes a choice based on UseInstalledX11.
258  */
259 #ifndef _XUse
260 # if defined(UseInstalled) || UseInstalledX11
261 #  define _XUse(a,b) a
262 # else
263 #  define _XUse(a,b) b
264 # endif
265 #endif /* _XUse */
266
267 /*
268  * _Use - makes a choice based on UseInstalled.
269  */
270 #ifndef _Use
271 # define _Use   _XUse
272 #endif /* _Use */
273
274 /*
275  * _XUseCat - combination of _XUse and Concat.
276  *           exists to avoid problems with some preprocessors
277  */
278 #ifndef _XUseCat
279 # if (__STDC__ && !defined(UnixCpp)) || defined(AnsiCpp) || defined(__llvm__)
280 #  if defined(UseInstalled) || UseInstalledX11
281 #   define _XUseCat(a,b,c) a##c
282 #  else
283 #   define _XUseCat(a,b,c) b##c
284 #  endif
285 # else
286 #  if defined(UseInstalled) || UseInstalledX11
287 #   define _XUseCat(a,b,c) a/**/c
288 #  else
289 #   define _XUseCat(a,b,c) b/**/c
290 #  endif
291 # endif
292 #endif /* _XUseCat */
293
294 /*
295  * _UseCat - combination of _Use and Concat.
296  *           exists to avoid problems with some preprocessors
297  */
298 #ifndef _UseCat
299 # define _UseCat        _XUseCat
300 #endif /* _UseCat */
301
302 #ifndef ProgramTargetName
303 #define ProgramTargetName(target)target
304 #endif
305
306 #ifndef RunProgram
307 #define RunProgram(progvar,options) $(progvar) options
308 #endif
309
310 #ifndef RunProgramWithSetup
311 #define RunProgramWithSetup(setup,progvar,options) setup $(progvar) options
312 #endif
313
314 #ifndef RemoveFile
315 #define RemoveFile(file) $(RM) file
316 #endif /* RemoveFile */
317
318 #ifndef RemoveFiles
319 #define RemoveFiles(files) $(RM) files
320 #endif /* RemoveFiles */
321
322 /*
323  * CenterLoadTarget - generate rules to load files into CodeCenter
324  */
325 #ifndef CenterLoadTarget
326 #if HasCodeCenter
327 #define CenterLoadTarget(target,srclist,libs,defines)                   @@\
328 ProgramTargetName(target):: srclist                                     @@\
329         XCOMM load defines srclist libs
330 #else
331 #define CenterLoadTarget(target,srclist,libs,defines) /**/
332 #endif
333 #endif /* CenterLoadTarget */
334
335 /*
336  * CenterProgramTarget - generate rules to make CodeCenter read in sources
337  * and objects.
338  */
339 #ifndef CenterProgramTarget
340 #define CenterProgramTarget(program,srclist,objlist,locallibs,syslibs)  @@\
341 CenterLoadTarget(Concat(debug_,program),srclist,$(EXTRA_LDOPTIONS) $(LOCAL_LDFLAGS) $(LDPRELIBS) locallibs $(LDLIBS) syslibs,$(ALLDEFINES)) @@\
342                                                                         @@\
343 CenterLoadTarget(Concat(odebug_,program),objlist,$(EXTRA_LDOPTIONS) $(LOCAL_LDFLAGS) $(LDPRELIBS) locallibs $(LDLIBS) syslibs,$(ALLDEFINES))
344 #endif /* CenterProgramTarget */
345
346 #ifndef SentinelLinkTarget
347 #if HasSentinel
348 #define SentinelLinkTarget(step,program,linklist)                       @@\
349 ProgramTargetName(step.sentinel):                                       @@\
350         RemoveTargetProgram($@)                                         @@\
351         $(CCENVSETUP) $(SENTINEL) $(SENTINELOPTIONS) $(CC) -o program.sentinel $(LDOPTIONS) linklist $(EXTRA_LOAD_FLAGS)
352 #else
353 #define SentinelLinkTarget(step,program,linklist) /**/
354 #endif
355 #endif /* SentinelLinkTarget */
356
357 /*
358  * SentinelProgramTarget - generate rules to make Sentinel image
359  */
360 #ifndef SentinelProgramTarget
361 #if HasSentinel
362 #define SentinelProgramTarget(program,deplist,linklist)                 @@\
363 ProgramTargetName(program.sentinel): deplist                            @@\
364         RemoveTargetProgram($@)                                         @@\
365         $(CCENVSETUP) $(SENTINEL) $(SENTINELOPTIONS) $(CC) -o $@ $(LDOPTIONS) linklist $(EXTRA_LOAD_FLAGS) @@\
366                                                                         @@\
367 clean clean.sentinel::                                                  @@\
368         RemoveFile(program.sentinel)
369 #else
370 #define SentinelProgramTarget(program,deplist,linklist) /**/
371 #endif
372 #endif /* SentinelProgramTarget */
373
374 /*
375  * SentinelCplusplusProgramTarget - generate rules to make Sentinel image 
376  */
377 #ifndef SentinelCplusplusProgramTarget
378 #if HasSentinel
379 #define SentinelCplusplusProgramTarget(program,deplist,linklist)        @@\
380 ProgramTargetName(program.sentinel): deplist                            @@\
381         RemoveTargetProgram($@)                                         @@\
382         $(CXXENVSETUP) $(SENTINEL) $(SENTINELOPTIONS) $(CXX) -o $@ $(CXXLDOPTIONS) linklist $(EXTRA_LOAD_FLAGS) @@\
383                                                                         @@\
384 clean clean.sentinel::                                                  @@\
385         RemoveFile(program.sentinel)
386 #else
387 #define SentinelCplusplusProgramTarget(program,deplist,linklist) /**/
388 #endif
389 #endif /* SentinelCplusplusProgramTarget */
390
391 #ifndef PurifyLinkTarget
392 #if HasPurify
393 #define PurifyLinkTarget(step,program,linklist)                         @@\
394 ProgramTargetName(step.pure):                                           @@\
395         RemoveTargetProgram($@)                                         @@\
396         $(CCENVSETUP) $(PURIFY) $(PURIFYOPTIONS) $(CC) -o program.pure $(LDOPTIONS) linklist $(EXTRA_LOAD_FLAGS)
397 #else
398 #define PurifyLinkTarget(step,program,linklist) /**/
399 #endif
400 #endif /* PurifyLinkTarget */
401
402 /*
403  * PurifyProgramTarget - generate rules to make Purify'ed image
404  */
405 #ifndef PurifyProgramTarget
406 #if HasPurify
407 #define PurifyProgramTarget(program,deplist,linklist)                   @@\
408 ProgramTargetName(program.pure): deplist                                @@\
409         RemoveTargetProgram($@)                                         @@\
410         $(CCENVSETUP) $(PURIFY) $(PURIFYOPTIONS) $(CC) -o $@ $(LDOPTIONS) linklist $(EXTRA_LOAD_FLAGS) @@\
411                                                                         @@\
412 clean clean.pure::                                                      @@\
413         RemoveFile(program.pure)
414 #else
415 #define PurifyProgramTarget(program,deplist,linklist) /**/
416 #endif
417 #endif /* PurifyProgramTarget */
418
419 /*
420  * PurifyCplusplusProgramTarget - generate rules to make Purify'ed image
421  */
422 #ifndef PurifyCplusplusProgramTarget
423 #if HasPurify
424 #define PurifyCplusplusProgramTarget(program,deplist,linklist)          @@\
425 ProgramTargetName(program.pure): deplist                                @@\
426         RemoveTargetProgram($@)                                         @@\
427         $(CXXENVSETUP) $(PURIFY) $(PURIFYOPTIONS) $(CXX) -o $@ $(CXXLDOPTIONS) linklist $(EXTRA_LOAD_FLAGS) @@\
428                                                                         @@\
429 clean clean.pure::                                                      @@\
430         RemoveFile(program.pure)
431 #else
432 #define PurifyCplusplusProgramTarget(program,deplist,linklist) /**/
433 #endif
434 #endif /* PurifyCplusplusProgramTarget */
435
436 #ifndef ProofLinkTarget
437 #if HasTestCenter
438 #define ProofLinkTarget(step,program,linklist)                          @@\
439 ProgramTargetName(step.tc):                                             @@\
440         RemoveTargetProgram($@)                                         @@\
441         $(CCENVSETUP) $(PROOF) $(PROOFOPTIONS) $(CC) -o program.tc $(LDOPTIONS) linklist $(EXTRA_LOAD_FLAGS)
442 #else
443 #define ProofLinkTarget(step,program,linklist) /**/
444 #endif
445 #endif /* ProofLinkTarget */
446
447 /*
448  * ProofProgramTarget - generate rules to make Proof'ed image
449  */
450 #ifndef ProofProgramTarget
451 #if HasTestCenter
452 #define ProofProgramTarget(program,deplist,linklist)                    @@\
453 ProgramTargetName(program.tc): deplist                                  @@\
454         RemoveTargetProgram($@)                                         @@\
455         $(CCENVSETUP) $(PROOF) $(PROOFOPTIONS) $(CC) -o $@ $(LDOPTIONS) linklist $(EXTRA_LOAD_FLAGS) @@\
456                                                                         @@\
457 clean clean.tc::                                                        @@\
458         RemoveFiles(program.tc program.tc.*.*)
459 #else
460 #define ProofProgramTarget(program,deplist,linklist) /**/
461 #endif
462 #endif /* ProofProgramTarget */
463
464 /*
465  * ProofCplusplusProgramTarget - generate rules to make Proof'ed image
466  */
467 #ifndef ProofCplusplusProgramTarget
468 #if HasTestCenter
469 #define ProofCplusplusProgramTarget(program,deplist,linklist)           @@\
470 ProgramTargetName(program.tc): deplist                                  @@\
471         RemoveTargetProgram($@)                                         @@\
472         $(CXXENVSETUP) $(PROOF) $(PROOFOPTIONS) $(CXX) -o $@ $(CXXLDOPTIONS) linklist $(EXTRA_LOAD_FLAGS) @@\
473                                                                         @@\
474 clean clean.tc::                                                        @@\
475         RemoveFiles(program.tc program.tc.*.*)
476 #else
477 #define ProofCplusplusProgramTarget(program,deplist,linklist) /**/
478 #endif
479 #endif /* ProofCplusplusProgramTarget */
480
481 #ifndef ProofCleanTarget
482 #if HasTestCenter
483 #define ProofCleanTarget()                                              @@\
484 clean clean.tc::                                                        @@\
485         $(RM) -r TC.Cache
486 #else
487 #define ProofCleanTarget() /**/
488 #endif
489 #endif /* ProofCleanTarget */
490
491 #ifndef RemoveTargetProgram
492 #if RemoveTargetProgramByMoving
493 #define RemoveTargetProgram(program) \
494 -if [ -f program ]; then RemoveFile(Concat(program,~)); $(MV) program Concat(program,~); fi
495 #else
496 #define RemoveTargetProgram(program) RemoveFile(program)
497 #endif
498 #endif /* RemoveTargetProgram */
499
500 #ifndef MakeDir
501 #define MakeDir(dir) DirFailPrefix@if [ -d dir ]; then set +x; \        @@\
502                 else (set -x; $(MKDIRHIER) dir); fi
503 #endif /* MakeDir */
504
505 #ifndef BuildIncludesTop
506 #define BuildIncludesTop(srclist)                                       @@\
507 includes:: srclist                                                      @@\
508         MakeDir($(BUILDINCDIR))                                         @@\
509         @(set -x; cd $(BUILDINCDIR); for i in srclist; do \             @@\
510                 RemoveFile($$i); \                                      @@\
511                 $(LN) $(BUILDINCTOP)/$(CURRENT_DIR)/$$i .; \            @@\
512         done)
513 #endif /* BuildIncludesTop */
514
515 #ifndef BuildIncludes
516 #define BuildIncludes(srclist,dstsubdir,dstupdir)                       @@\
517 includes:: srclist                                                      @@\
518         MakeDir($(BUILDINCDIR)/dstsubdir)                               @@\
519         @(set -x; cd $(BUILDINCDIR)/dstsubdir; for i in srclist; do \   @@\
520                 RemoveFile($$i); \                                      @@\
521                 $(LN) $(BUILDINCTOP)/dstupdir/$(CURRENT_DIR)/$$i .; \   @@\
522         done)
523 #endif /* BuildIncludes */
524
525 /*
526  * LinkBuildBinary - export a binary from the build tree.
527  */
528 #ifndef LinkBuildBinary
529 #define LinkBuildBinary(binary)                                         @@\
530 all:: $(BUILDBINDIR)/binary binary                                      @@\
531                                                                         @@\
532 $(BUILDBINDIR)/binary: binary                                           @@\
533         RemoveFile($@)                                                  @@\
534         cd $(BUILDBINDIR) && $(LN) $(BUILDBINTOP)/$(CURRENT_DIR)/binary .
535 #endif /* LinkBuildBinary */
536
537 #ifndef BuildInterfaces
538 #define BuildInterfaces(srclist,dstsubdir,dstupdir)                     @@\
539 interfaces::                                                            @@\
540         MakeDir($(BUILDINCDIR)/dstsubdir)                               @@\
541         @(set -x; cd $(BUILDINCDIR)/dstsubdir; for i in srclist; do \   @@\
542                 RemoveFile($$i); \                                      @@\
543                 $(LN) $(BUILDINCTOP)/dstupdir/$(CURRENT_DIR)/$$i .; \   @@\
544         done)
545 #endif /* BuildInterfaces */
546
547 /*
548  * LinkRule - link a program
549  */
550 #ifndef LinkRule
551 #define LinkRule(program,options,objects,libraries) \
552 $(CCLINK) -o program options objects libraries $(EXTRA_LOAD_FLAGS)
553 #endif /* LinkRule */
554
555 /*
556  * HostLinkRule - link a utility to be used on the build host
557  * (differs from LinkRule if cross compiling)
558  */
559 #ifndef HostLinkRule
560 #define HostLinkRule LinkRule
561 #endif
562
563 #ifndef CplusplusLinkRule
564 #define CplusplusLinkRule(program,options,objects,libraries) \
565 $(CXXLINK) -o program options objects libraries $(EXTRA_LOAD_FLAGS)
566 #endif /* CplusplusLinkRule */
567
568 /*
569  * NormalProgramTarget - generate rules to compile and link the indicated 
570  * program; since it does not use any default object files, it may be used for
571  * multiple programs in the same Imakefile.
572  */
573 #ifndef NormalProgramTarget
574 #define NormalProgramTarget(program,objects,deplibs,locallibs,syslibs)  @@\
575 ProgramTargetName(program): objects deplibs                             @@\
576         RemoveTargetProgram($@)                                         @@\
577         LinkRule($@,$(LDOPTIONS),objects,locallibs $(LDLIBS) syslibs)   @@\
578                                                                         @@\
579 SentinelProgramTarget(program,objects deplibs,objects locallibs $(LDLIBS) syslibs) @@\
580 PurifyProgramTarget(program,objects deplibs,objects locallibs $(LDLIBS) syslibs) @@\
581 ProofProgramTarget(program,objects deplibs,objects locallibs $(LDLIBS) syslibs) @@\
582                                                                         @@\
583 clean::                                                                 @@\
584         RemoveFile(ProgramTargetName(program))
585 #endif /* NormalProgramTarget */
586
587
588 /*
589  * NormalCplusplusProgramTarget - Like NormalTargetProgram, but uses
590  * C++ linking rules.
591  */
592 #ifndef NormalCplusplusProgramTarget
593 #define NormalCplusplusProgramTarget(program,objects,deplibs,locallibs,syslibs) @@\
594 ProgramTargetName(program): objects deplibs                             @@\
595         RemoveTargetProgram($@)                                         @@\
596         CplusplusLinkRule($@,$(CXXLDOPTIONS),objects,locallibs $(LDLIBS) syslibs) @@\
597                                                                         @@\
598 SentinelCplusplusProgramTarget(program,objects deplibs,objects locallibs $(LDLIBS) syslibs) @@\
599 PurifyCplusplusProgramTarget(program,objects deplibs,objects locallibs $(LDLIBS) syslibs) @@\
600 ProofCplusplusProgramTarget(program,objects deplibs,objects locallibs $(LDLIBS) syslibs) @@\
601                                                                         @@\
602 clean::                                                                 @@\
603         RemoveFile(ProgramTargetName(program))
604 #endif /* NormalCplusplusProgramTarget */
605
606
607 #ifndef SetUIDProgramTarget
608 #define SetUIDProgramTarget NormalProgramTarget
609 #endif
610
611
612 /*
613  * SingleProgramTarget - obsolete version of NormalProgramTarget that does
614  * not have deplibs.
615  */
616 #ifndef SingleProgramTarget
617 #define SingleProgramTarget(program,objects,locallibs,syslibs)          @@\
618 NormalProgramTarget(program,objects,NullParameter,locallibs,syslibs)
619 #endif /* SingleProgramTarget */
620
621 /*
622  * SimpleProgramTarget - generate rules for compiling and linking programs
623  * that only have one C source file.  It should only be used in Imakefiles 
624  * that describe a single program.
625  */
626 #ifndef SimpleProgramTarget
627 #define SimpleProgramTarget(program)                                    @@\
628            OBJS = program.o                                             @@\
629            SRCS = program.c                                             @@\
630                                                                         @@\
631 ComplexProgramTarget(program)
632 #endif /* SimpleProgramTarget */
633
634 #ifndef SimpleCplusplusProgramTarget
635 #define SimpleCplusplusProgramTarget(program)                           @@\
636            OBJS = program.o                                             @@\
637            SRCS = program.CCsuf                                         @@\
638                                                                         @@\
639 ComplexCplusplusProgramTarget(program)
640 #endif /* SimpleCplusplusProgramTarget */
641
642 #ifndef ProgramTargetHelper
643 #define ProgramTargetHelper(program,srcs,objs,deplib,locallib,syslib)   @@\
644 ProgramTargetName(program): $(objs) $(deplib)                           @@\
645         RemoveTargetProgram($@)                                         @@\
646         LinkRule($@,$(LDOPTIONS),$(objs),locallib $(LDLIBS) syslib)     @@\
647                                                                         @@\
648 CenterProgramTarget(program,$(srcs),$(objs),locallib,syslib)            @@\
649 SentinelProgramTarget(program,$(objs) $(deplib),$(objs) locallib $(LDLIBS) syslib) @@\
650 PurifyProgramTarget(program,$(objs) $(deplib),$(objs) locallib $(LDLIBS) syslib) @@\
651 ProofProgramTarget(program,$(objs) $(deplib),$(objs) locallib $(LDLIBS) syslib) @@\
652                                                                         @@\
653 InstallProgram(program,$(BINDIR))                                       @@\
654 InstallManPage(program,$(MANDIR))
655 #endif /* ProgramTargetHelper */
656
657 #ifndef CplusplusProgramTargetHelper
658 #define CplusplusProgramTargetHelper(program,srcs,objs,deplib,locallib,syslib) @@\
659 ProgramTargetName(program): $(objs) $(deplib)                           @@\
660         RemoveTargetProgram($@)                                         @@\
661         CplusplusLinkRule($@,$(CXXLDOPTIONS),$(objs),locallib $(LDLIBS) syslib) @@\
662                                                                         @@\
663 CenterProgramTarget(program,$(srcs),$(objs),locallib,syslib)            @@\
664 SentinelCplusplusProgramTarget(program,$(objs) $(deplib),$(objs) locallib $(LDLIBS) syslib) @@\
665 PurifyCplusplusProgramTarget(program,$(objs) $(deplib),$(objs) locallib $(LDLIBS) syslib) @@\
666 ProofCplusplusProgramTarget(program,$(objs) $(deplib),$(objs) locallib $(LDLIBS) syslib) @@\
667                                                                         @@\
668 InstallProgram(program,$(BINDIR))                                       @@\
669 InstallManPage(program,$(MANDIR))
670 #endif /* CplusplusProgramTargetHelper */
671
672 /*
673  * ComplexProgramTarget - generate rules for compiling and linking the 
674  * program specified by $(OBJS) and $(SRCS), installing the program and its
675  * man page, and generating dependencies.  It should only be used in 
676  * Imakefiles that describe a single program.
677  */
678 #ifndef ComplexProgramTarget
679 #define ComplexProgramTarget(program)                                   @@\
680         PROGRAM = program                                               @@\
681                                                                         @@\
682 AllTarget(program)                                                      @@\
683                                                                         @@\
684 ProgramTargetHelper(program,SRCS,OBJS,DEPLIBS,$(LOCAL_LIBRARIES),NullParameter) @@\
685                                                                         @@\
686 DependTarget()                                                          @@\
687 LintTarget()                                                            @@\
688                                                                         @@\
689 clean::                                                                 @@\
690         RemoveFile(ProgramTargetName(program))
691 #endif /* ComplexProgramTarget */
692
693 #ifndef ComplexCplusplusProgramTarget
694 #define ComplexCplusplusProgramTarget(program)                          @@\
695         PROGRAM = program                                               @@\
696                                                                         @@\
697 AllTarget(program)                                                      @@\
698                                                                         @@\
699 CplusplusProgramTargetHelper(program,SRCS,OBJS,DEPLIBS,$(LOCAL_LIBRARIES),NullParameter) @@\
700                                                                         @@\
701 DependTarget()                                                          @@\
702 LintTarget()                                                            @@\
703                                                                         @@\
704 clean::                                                                 @@\
705         RemoveFile(ProgramTargetName(program))
706 #endif /* ComplexCplusplusProgramTarget */
707
708 /*
709  * ComplexProgramTarget_1 - generate rules for compiling and linking the
710  * program specified by $(OBJS1) and $(SRCS1), installing the program and its
711  * man page, and generating dependencies for it and any programs described
712  * by $(SRCS2) throgh $(SRCS10).  It should be used to build the primary 
713  * program in Imakefiles that describe multiple programs.
714  */
715 #ifndef ComplexProgramTarget_1
716 #define ComplexProgramTarget_1(program,locallib,syslib)                 @@\
717   OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) \                 @@\
718          $(OBJS6) $(OBJS7) $(OBJS8) $(OBJS9) $(OBJS10)                  @@\
719   SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4) $(SRCS5) \                 @@\
720          $(SRCS6) $(SRCS7) $(SRCS8) $(SRCS9) $(SRCS10)                  @@\
721                                                                         @@\
722 AllTarget($(PROGRAMS))                                                  @@\
723                                                                         @@\
724 ProgramTargetHelper(program,SRCS1,OBJS1,DEPLIBS1,locallib,syslib)       @@\
725                                                                         @@\
726 DependTarget()                                                          @@\
727 LintTarget()                                                            @@\
728                                                                         @@\
729 clean::                                                                 @@\
730         RemoveFiles($(PROGRAMS))
731 #endif /* ComplexProgramTarget_1 */
732
733 #ifndef ComplexCplusplusProgramTarget_1
734 #define ComplexCplusplusProgramTarget_1(program,locallib,syslib)        @@\
735   OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) \                 @@\
736          $(OBJS6) $(OBJS7) $(OBJS8) $(OBJS9) $(OBJS10)                  @@\
737   SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4) $(SRCS5) \                 @@\
738          $(SRCS6) $(SRCS7) $(SRCS8) $(SRCS9) $(SRCS10)                  @@\
739                                                                         @@\
740 AllTarget($(PROGRAMS))                                                  @@\
741                                                                         @@\
742 CplusplusProgramTargetHelper(program,SRCS1,OBJS1,DEPLIBS1,locallib,syslib)@@\
743                                                                         @@\
744 DependTarget()                                                          @@\
745 LintTarget()                                                            @@\
746                                                                         @@\
747 clean::                                                                 @@\
748         RemoveFiles($(PROGRAMS))
749 #endif /* ComplexCplusplusProgramTarget_1 */
750
751 /*
752  * ComplexProgramTarget_2 - generate rules for compiling and linking the
753  * program specified by $(OBJS2) and $(SRCS2) and installing the program and
754  * man page.  It should be used to build the second program in Imakefiles 
755  * describing more than one program.
756  */
757 #ifndef ComplexProgramTarget_2
758 #define ComplexProgramTarget_2(program,locallib,syslib)                 @@\
759 ProgramTargetHelper(program,SRCS2,OBJS2,DEPLIBS2,locallib,syslib)
760 #endif /* ComplexProgramTarget_2 */
761
762 #ifndef ComplexCplusplusProgramTarget_2
763 #define ComplexCplusplusProgramTarget_2(program,locallib,syslib)        @@\
764 CplusplusProgramTargetHelper(program,SRCS2,OBJS2,DEPLIBS2,locallib,syslib)
765 #endif /* ComplexCplusplusProgramTarget_2 */
766
767 /*
768  * ComplexProgramTarget_3 - generate rules for compiling and linking the
769  * program specified by $(OBJS3) and $(SRCS3) and installing the program and
770  * man page.  It should be used to build the third program in Imakefiles 
771  * describing more than one program.
772  */
773 #ifndef ComplexProgramTarget_3
774 #define ComplexProgramTarget_3(program,locallib,syslib)                 @@\
775 ProgramTargetHelper(program,SRCS3,OBJS3,DEPLIBS3,locallib,syslib)
776 #endif /* ComplexProgramTarget_3 */
777
778 #ifndef ComplexCplusplusProgramTarget_3
779 #define ComplexCplusplusProgramTarget_3(program,locallib,syslib)        @@\
780 CplusplusProgramTargetHelper(program,SRCS3,OBJS3,DEPLIBS3,locallib,syslib)
781 #endif /* ComplexCplusplusProgramTarget_3 */
782
783 /*
784  * ComplexProgramTarget_4 - generate rules for compiling and linking the
785  * program specified by $(OBJS4) and $(SRCS4) and installing the program and
786  * man page.  It should be used to build the third program in Imakefiles 
787  * describing more than one program.
788  */
789 #ifndef ComplexProgramTarget_4
790 #define ComplexProgramTarget_4(program,locallib,syslib)                 @@\
791 ProgramTargetHelper(program,SRCS4,OBJS4,DEPLIBS4,locallib,syslib)
792 #endif /* ComplexProgramTarget_4 */
793
794 #ifndef ComplexCplusplusProgramTarget_4
795 #define ComplexCplusplusProgramTarget_4(program,locallib,syslib)        @@\
796 CplusplusProgramTargetHelper(program,SRCS4,OBJS4,DEPLIBS4,locallib,syslib)
797 #endif /* ComplexCplusplusProgramTarget_4 */
798
799 /*
800  * ComplexProgramTarget_5 - generate rules for compiling and linking the
801  * program specified by $(OBJS5) and $(SRCS5) and installing the program and
802  * man page.  It should be used to build the third program in Imakefiles 
803  * describing more than one program.
804  */
805 #ifndef ComplexProgramTarget_5
806 #define ComplexProgramTarget_5(program,locallib,syslib)                 @@\
807 ProgramTargetHelper(program,SRCS5,OBJS5,DEPLIBS5,locallib,syslib)
808 #endif /* ComplexProgramTarget_5 */
809
810 #ifndef ComplexCplusplusProgramTarget_5
811 #define ComplexCplusplusProgramTarget_5(program,locallib,syslib)        @@\
812 CplusplusProgramTargetHelper(program,SRCS5,OBJS5,DEPLIBS5,locallib,syslib)
813 #endif /* ComplexCplusplusProgramTarget_5 */
814
815 /*
816  * ComplexProgramTarget_6 - generate rules for compiling and linking the
817  * program specified by $(OBJS6) and $(SRCS6) and installing the program and
818  * man page.  It should be used to build the third program in Imakefiles 
819  * describing more than one program.
820  */
821 #ifndef ComplexProgramTarget_6
822 #define ComplexProgramTarget_6(program,locallib,syslib)                 @@\
823 ProgramTargetHelper(program,SRCS6,OBJS6,DEPLIBS6,locallib,syslib)
824 #endif /* ComplexProgramTarget_6 */
825
826 #ifndef ComplexCplusplusProgramTarget_6
827 #define ComplexCplusplusProgramTarget_6(program,locallib,syslib)        @@\
828 CplusplusProgramTargetHelper(program,SRCS6,OBJS6,DEPLIBS6,locallib,syslib)
829 #endif /* ComplexCplusplusProgramTarget_6 */
830
831 /*
832  * ComplexProgramTarget_7 - generate rules for compiling and linking the
833  * program specified by $(OBJS7) and $(SRCS7) and installing the program and
834  * man page.  It should be used to build the third program in Imakefiles 
835  * describing more than one program.
836  */
837 #ifndef ComplexProgramTarget_7
838 #define ComplexProgramTarget_7(program,locallib,syslib)                 @@\
839 ProgramTargetHelper(program,SRCS7,OBJS7,DEPLIBS7,locallib,syslib)
840 #endif /* ComplexProgramTarget_7 */
841
842 #ifndef ComplexCplusplusProgramTarget_7
843 #define ComplexCplusplusProgramTarget_7(program,locallib,syslib)        @@\
844 CplusplusProgramTargetHelper(program,SRCS7,OBJS7,DEPLIBS7,locallib,syslib)
845 #endif /* ComplexCplusplusProgramTarget_7 */
846
847 /*
848  * ComplexProgramTarget_8 - generate rules for compiling and linking the
849  * program specified by $(OBJS8) and $(SRCS8) and installing the program and
850  * man page.  It should be used to build the third program in Imakefiles 
851  * describing more than one program.
852  */
853 #ifndef ComplexProgramTarget_8
854 #define ComplexProgramTarget_8(program,locallib,syslib)                 @@\
855 ProgramTargetHelper(program,SRCS8,OBJS8,DEPLIBS8,locallib,syslib)
856 #endif /* ComplexProgramTarget_8 */
857
858 #ifndef ComplexCplusplusProgramTarget_8
859 #define ComplexCplusplusProgramTarget_8(program,locallib,syslib)        @@\
860 CplusplusProgramTargetHelper(program,SRCS8,OBJS8,DEPLIBS8,locallib,syslib)
861 #endif /* ComplexCplusplusProgramTarget_8 */
862
863 /*
864  * ComplexProgramTarget_9 - generate rules for compiling and linking the
865  * program specified by $(OBJS9) and $(SRCS9) and installing the program and
866  * man page.  It should be used to build the third program in Imakefiles 
867  * describing more than one program.
868  */
869 #ifndef ComplexProgramTarget_9
870 #define ComplexProgramTarget_9(program,locallib,syslib)                 @@\
871 ProgramTargetHelper(program,SRCS9,OBJS9,DEPLIBS9,locallib,syslib)
872 #endif /* ComplexProgramTarget_9 */
873
874 #ifndef ComplexCplusplusProgramTarget_9
875 #define ComplexCplusplusProgramTarget_9(program,locallib,syslib)        @@\
876 CplusplusProgramTargetHelper(program,SRCS9,OBJS9,DEPLIBS9,locallib,syslib)
877 #endif /* ComplexCplusplusProgramTarget_9 */
878
879 /*
880  * ComplexProgramTarget_10 - generate rules for compiling and linking the
881  * program specified by $(OBJS10) and $(SRCS10) and installing the program and
882  * man page.  It should be used to build the third program in Imakefiles 
883  * describing more than one program.
884  */
885 #ifndef ComplexProgramTarget_10
886 #define ComplexProgramTarget_10(program,locallib,syslib)                @@\
887 ProgramTargetHelper(program,SRCS10,OBJS10,DEPLIBS10,locallib,syslib)
888 #endif /* ComplexProgramTarget_10 */
889
890 #ifndef ComplexCplusplusProgramTarget_10
891 #define ComplexCplusplusProgramTarget_10(program,locallib,syslib)       @@\
892 CplusplusProgramTargetHelper(program,SRCS10,OBJS10,DEPLIBS10,locallib,syslib)
893 #endif /* ComplexCplusplusProgramTarget_10 */
894
895 #ifndef MoveToBakFile
896 #define MoveToBakFile(file) -@if [ -f file ]; then set -x; \            @@\
897         $(MV) file file.bak; else exit 0; fi
898 #endif /* MoveToBakFile */
899
900 #ifndef RMoveToBakFile
901 #define RMoveToBakFile(file) -@if [ -f file ]; then set -x; \           @@\
902         RemoveFile(file.bak); $(MV) file file.bak; \                    @@\
903         else exit 0; fi
904 #endif /* RMoveToBakFile */
905
906 /*
907  * ServerTargetWithFlags - generate rules to compile, link, and relink a server
908  */
909 #ifndef ServerTargetWithFlags
910 #define ServerTargetWithFlags(server,subdirs,objects,libs,syslibs,flags) @@\
911 AllTarget(server)                                                       @@\
912 ProgramTargetName(server): subdirs objects libs                         @@\
913         MoveToBakFile($@)                                               @@\
914         LinkRule($@,$(LDOPTIONS),objects,libs $(LDLIBS) syslibs) @@\
915                                                                         @@\
916 Concat(load,server):                                                    @@\
917         MoveToBakFile(ProgramTargetName(server))                        @@\
918         LinkRule(ProgramTargetName(server),$(LDOPTIONS),objects,libs $(LDLIBS) syslibs) @@\
919                                                                         @@\
920 loadX:: Concat(load,server)                                             @@\
921                                                                         @@\
922 SentinelProgramTarget(server,subdirs objects libs,objects libs $(LDLIBS) syslibs) @@\
923 SentinelLinkTarget(Concat(load,server),server,objects libs $(LDLIBS) syslibs) @@\
924 PurifyProgramTarget(server,subdirs objects libs,objects libs $(LDLIBS) syslibs) @@\
925 PurifyLinkTarget(Concat(load,server),server,objects libs $(LDLIBS) syslibs) @@\
926 ProofProgramTarget(server,subdirs objects libs,objects libs $(LDLIBS) syslibs) @@\
927 ProofLinkTarget(Concat(load,server),server,objects libs $(LDLIBS) syslibs) @@\
928                                                                         @@\
929 InstallProgramWithFlags(server,$(BINDIR),flags)                         @@\
930                                                                         @@\
931 clean::                                                                 @@\
932         RemoveFile(ProgramTargetName(server))
933 #endif /* ServerTargetWithFlags */
934
935 /*
936  * ServerTarget - rules to compile, link, and relink a normal server
937  */
938 #ifndef ServerTarget
939 #define ServerTarget(server,subdirs,objects,libs,syslibs)               @@\
940 ServerTargetWithFlags(server,subdirs,objects,libs,syslibs,$(_NOOP_))
941 #endif /* ServerTarget */
942
943 #if DoRanlibCmd
944 #define RanLibrary(args) $(RANLIB) args
945 #else
946 #define RanLibrary(args) $(_NULLCMD_)
947 #endif
948
949 #ifndef LibraryTargetName
950 #define LibraryTargetName(libname)Concat(lib,libname.a)
951 #endif
952
953 #ifndef LibraryTargetNameSuffix
954 #define LibraryTargetNameSuffix(libname,suffix)Concat3(lib,libname,suffix.a)
955 #endif
956
957 #ifndef InstallNamedTarget
958 #define InstallNamedTarget(step,srcname,flags,dest,dstname)             @@\
959 step:: srcname                                                          @@\
960         MakeDir($(DESTDIR)dest)                                         @@\
961         $(INSTALL) $(INSTALLFLAGS) flags srcname $(DESTDIR)dest/dstname
962 #endif /* InstallNamedTarget */
963
964 /*
965  * InstallNamedTargetNoClobber - Like InstallNamedTarget, but doesn't
966  * do the install if an installed version already exists.  Useful
967  * for files that might have local customizations that you don't
968  * want to clobber.  Config files are good candidates for this.
969  */
970 #ifndef InstallNamedTargetNoClobber
971 #define InstallNamedTargetNoClobber(step,srcname,flags,dest,dstname)    @@\
972 step:: srcname                                                          @@\
973         MakeDir($(DESTDIR)dest)                                         @@\
974         @if [ -f $(DESTDIR)dest/dstname ]; then \                       @@\
975          echo "Not overwriting existing" $(DESTDIR)dest/dstname; \      @@\
976         else set -x; \                                                  @@\
977          $(INSTALL) $(INSTALLFLAGS) flags srcname $(DESTDIR)dest/dstname; fi
978 #endif /* InstallNamedTargetNoClobber */
979
980 #ifndef InstallTarget
981 #define InstallTarget(step,file,flags,dest)                             @@\
982 InstallNamedTarget(step,file,flags,dest,file)
983 #endif /* InstallTarget */
984
985 /*
986  * InstallLibrary - generate rules to install the indicated library.
987  */
988 #ifndef InstallLibrary
989 #define InstallLibrary(libname,dest)                                    @@\
990 install:: LibraryTargetName(libname)                                    @@\
991         MakeDir($(DESTDIR)dest)                                         @@\
992         $(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) LibraryTargetName(libname) $(DESTDIR)dest @@\
993         RanLibrary($(RANLIBINSTFLAGS) $(DESTDIR)dest/LibraryTargetName(libname))
994 #endif /* InstallLibrary */
995
996
997 /*
998  * InstallLinkKitLibrary - rule to install Link Kit library.
999  *                         (only used for XFree86). This is a no-op
1000  *                         rule so that Imakefiles on non-XFree86 systems
1001  *                         continue to build Makefiles correctly.
1002  */
1003 #ifndef InstallLinkKitLibrary
1004 #define InstallLinkKitLibrary(lib,dir)
1005 #endif
1006
1007
1008 /*
1009  * InstallLinkKitNamedLibrary - rule to install Link Kit library.
1010  *                         (only used for XFree86). This is a no-op
1011  *                         rule so that Imakefiles on non-XFree86 systems
1012  *                         continue to build Makefiles correctly.
1013  */
1014 #ifndef InstallLinkKitNamedLibrary
1015 #define InstallLinkKitNamedLibrary(lib,dlib,dir)
1016 #endif
1017
1018
1019 /*
1020  * MergeIntoInstalledLibrary - generate rules to merge one library into another
1021  */
1022 #ifndef MergeIntoInstalledLibrary
1023 #define MergeIntoInstalledLibrary(tolib,fromlib)                        @@\
1024 install::  fromlib                                                      @@\
1025         $(SCRIPTSRC)/mergelib $(DESTDIR)tolib fromlib
1026 #endif /* MergeIntoInstalledLibrary */
1027
1028 /*
1029  * InstallLibraryAlias - generate rules to create a link from one library name
1030  * to another for the purposes of aliasing.
1031  */
1032 #ifndef InstallLibraryAlias
1033 #define InstallLibraryAlias(libname,alias,dest)                         @@\
1034 install::                                                               @@\
1035         -(cd $(DESTDIR)dest; \                                          @@\
1036                 RemoveFile(LibraryTargetName(alias)); \                 @@\
1037                 $(LN) LibraryTargetName(libname) LibraryTargetName(alias))
1038 #endif /* InstallLibraryAlias */
1039
1040
1041 /*
1042  * InstallLintLibrary - generate rules to install the indicated lint library.
1043  */
1044 #ifndef InstallLintLibrary
1045 #define InstallLintLibrary(libname,dest)                                @@\
1046 InstallTarget(install.ln,Concat(llib-l,libname.ln),$(INSTLIBFLAGS),dest)
1047 #endif /* InstallLintLibrary */
1048
1049
1050 /*
1051  * InstallManPageLong - generate rules to install the indicated manual page,
1052  * giving it an alternate name.  This is used for installing man pages whose
1053  * base name without the .man suffix would normally be longer than 8 characters
1054  * (the limit for using source code control systems on files systems with 
1055  * short file names).
1056  */
1057 #ifndef InstallManPageLong
1058 #define InstallManPageLong(file,destdir,dest)                           @@\
1059 InstallNamedTarget(install.man,file.man,$(INSTMANFLAGS),destdir,dest.$(MANSUFFIX))
1060 #endif /* InstallManPageLong */
1061
1062
1063 /*
1064  * InstallManPage - generate rules to install the indicated manual page.
1065  */
1066 #ifndef InstallManPage
1067 #define InstallManPage(file,destdir)                                    @@\
1068 InstallManPageLong(file,destdir,file)
1069 #endif /* InstallManPage */
1070
1071
1072 /*
1073  * InstallManPageAliases - generate rules to install manual page aliases.
1074  */
1075 #ifndef InstallManPageAliases
1076 #define InstallManPageAliases(file,destdir,aliases)                     @@\
1077 install.man::                                                           @@\
1078         @(TMP=/tmp/tmp.$$$$; \                                          @@\
1079         RemoveFile($${TMP}); \                                          @@\
1080         echo .so `basename destdir`/file.$(MANSUFFIX) > $${TMP}; \      @@\
1081         for i in aliases; do (set -x; \                                 @@\
1082         $(INSTALL) $(INSTALLFLAGS) $(INSTMANFLAGS) $${TMP} $(DESTDIR)destdir/$$i.$(MANSUFFIX)); \ @@\
1083         done; \                                                         @@\
1084         RemoveFile($${TMP}))
1085 #endif /* InstallManPageAliases */
1086
1087 /*
1088  * ManKeywordsTarget - generate the database used by "man -k".
1089  * This rule updates the index in the directory "manpath", which
1090  * indexes all the manual pages in the section subdirectories under
1091  * it.  An update command is defined only on systems that have a
1092  * per MANPATH element index.  If the OS supports only one system-wide
1093  * database, we don't update it, because then we can't do cross
1094  * installations or use a non-empty DESTDIR for testing.
1095  */
1096 #ifndef ManKeywordsTarget
1097 #define ManKeywordsTarget(manpath) man_keywords::
1098 #endif
1099
1100 /*
1101  * InstallNamedNonExec - generate rules to install a data file
1102  */
1103 #ifndef InstallNamedNonExec
1104 #define InstallNamedNonExec(srcname,dstname,dest)                       @@\
1105 InstallNamedTarget(install,srcname,$(INSTDATFLAGS),dest,dstname)
1106 #endif /* InstallNamedNonExec */
1107
1108
1109 /*
1110  * InstallNonExecFile - generate rules to install a data file
1111  */
1112 #ifndef InstallNonExecFile
1113 #define InstallNonExecFile(file,dest)                                   @@\
1114 InstallTarget(install,file,$(INSTDATFLAGS),dest)
1115 #endif /* InstallNonExecFile */
1116
1117
1118 /*
1119  * InstallNonExecFileNoClobber - install a data file once
1120  */
1121 #ifndef InstallNonExecFileNoClobber
1122 #define InstallNonExecFileNoClobber(file,dest)                          @@\
1123 InstallNamedTargetNoClobber(install,file,$(INSTDATFLAGS),dest,file)
1124 #endif /* InstallNonExecFileNoClobber */
1125
1126
1127 /*
1128  * InstallLinkKitNonExecFile - rule for installing server Link Kit files.
1129  *                         (only used for XFree86). This is a no-op
1130  *                         rule so that Imakefiles on non-XFree86 systems
1131  *                         continue to build Makefiles correctly.
1132  */
1133 #ifndef InstallLinkKitNonExecFile
1134 #define InstallLinkKitNonExecFile(file,dir)
1135 #endif
1136
1137
1138 /*
1139  * InstallNonExec - generate rules to install a data file, but does not
1140  * try to create the destination directory (deprecated)
1141  */
1142 #ifndef InstallNonExec
1143 #define InstallNonExec(file,dest)                                       @@\
1144 install:: file                                                          @@\
1145         $(INSTALL) $(INSTALLFLAGS) $(INSTDATFLAGS) file $(DESTDIR)dest
1146 #endif /* InstallNonExec */
1147
1148
1149 /*
1150  * InstallProgramWithFlags - generate rules to install an executable program
1151  * using given install flags.
1152  */
1153 #ifndef InstallProgramWithFlags
1154 #define InstallProgramWithFlags(program,dest,flags)                     @@\
1155 InstallTarget(install,ProgramTargetName(program),$(INSTPGMFLAGS) flags,dest)
1156 #endif /* InstallProgramWithFlags */
1157
1158
1159 /*
1160  * InstallProgram - generate rules to install an executable program using any
1161  * special install flags set in $(INSTALLFLAGS).
1162  */
1163 #ifndef InstallProgram
1164 #define InstallProgram(program,dest)                                    @@\
1165 InstallProgramWithFlags(program,dest,NullParameter)
1166 #endif /* InstallProgram */
1167
1168
1169
1170 /*
1171  * InstallScript - install a shell script.
1172  */
1173 #ifndef InstallScript
1174 #define InstallScript(program,dest)                                     @@\
1175 InstallNamedTarget(install,program.script,$(INSTBINFLAGS),dest,program)
1176 #endif /* InstallScript */
1177
1178
1179 /*
1180  * InstallNamedProg - install a program with renaming and no stripping.
1181  */
1182 #ifndef InstallNamedProg
1183 #define InstallNamedProg(srcname,dstname,dest)                          @@\
1184 InstallNamedTarget(install,srcname,$(INSTBINFLAGS),dest,dstname)
1185 #endif /* InstallNamedProg */
1186
1187 /*
1188  * InstallNamedProgNoClobber - Like InstallNamedProg, but doesn't
1189  * do the install if an installed version already exists.
1190  */
1191 #ifndef InstallNamedProgNoClobber
1192 #define InstallNamedProgNoClobber(srcname,dstname,dest)                 @@\
1193 InstallNamedTargetNoClobber(install,srcname,$(INSTBINFLAGS),dest,dstname)
1194 #endif /* InstallNamedProgNoClobber */
1195
1196 /*
1197  * MakeFlagsToShellFlags - set variables before starting a loop.
1198  * makeflags is the set of "make" flags to check.
1199  * shellcmd is the shell command to execute if any of the flags are set.
1200  *
1201  * The usual use of this rule is to translate make's "don't quit on error"
1202  * flags into the equivalent for the shell.  To do this, "make -i" always
1203  * becomes "set +e".  "make -k" should also turn on "set +e" if the target
1204  * is building subdirectories.  That is, subdirectories are independent
1205  * and should appear to be multiple targets, even though they are
1206  * implemented in a loop in a single target.
1207  */
1208 #ifndef MakeFlagsToShellFlags
1209 #define MakeFlagsToShellFlags(makeflags,shellcmd)\
1210         for flag in ${MAKEFLAGS} ''; do \                               @@\
1211           case "$$flag" in *=*) ;; *[makeflags]*) shellcmd;; esac; done
1212 #endif
1213
1214 /*
1215  * LinkFileList - link a list of files from one place to another
1216  */
1217 #ifndef LinkFileList
1218 #define LinkFileList(step,list,dir,sub)                                 @@\
1219 step:: list                                                             @@\
1220         @MakeFlagsToShellFlags(i,set +e); \                             @@\
1221         echo "  cd" dir; cd dir && \                                    @@\
1222         for i in list; do (set -x; RemoveFile($$i); $(LN) sub/$$i .); done
1223 #endif
1224
1225 /*
1226  * LinkVarDirectory
1227  *
1228  * Make links from $LIBDIR (<ProjectRoot>/lib/X11) to /var/X11/
1229  * For example /usr/X11R6/lib/X11/xdm ==> /var/X11/xdm so that X 
1230  * binaries can be mounted from a read-only volume like a CD-ROM;
1231  * but files that may need to be edited can be stored locally on 
1232  * read-write media. If someone has an existing installation, be
1233  * careful and move existing files to the new location in /var.
1234  */
1235 #ifndef LinkVarDirectory
1236 #if HasVarDirectory
1237 #define LinkVarDirectory(mdir,cdir,rdir,ldir)                           @@\
1238 install::                                                               @@\
1239         MakeDir(Concat($(DESTDIR)$(LIBDIR)/,cdir))                      @@\
1240         MakeDir(Concat($(VARDIR)/,mdir))                                @@\
1241         @MakeFlagsToShellFlags(i,set +e); \                             @@\
1242         if [ -d Concat($(DESTDIR)$(LIBDIR)/,cdir) ]; then \             @@\
1243           cd Concat($(DESTDIR)$(LIBDIR)/,cdir); \                       @@\
1244           if [ -d rdir -a ! -h rdir ]; then \                           @@\
1245             (cd rdir; tar cf - . | (cd Concat($(VARDIR)/,mdir); tar xf -; exit 0); exit 0); \ @@\
1246           fi; \                                                         @@\
1247           $(RM) -r rdir; \                                              @@\
1248           $(LN) Concat($(VARDIR)/,mdir) ldir; \                         @@\
1249         fi
1250 #else
1251 #define LinkVarDirectory(mdir,cdir,rdir,ldir)
1252 #endif
1253 #endif
1254
1255
1256 /*
1257  * InstallMultipleDestFlags - generate rules to install multiple files at
1258  * once during a particular step in the build using a specific set of install 
1259  * flags.
1260  */
1261 #ifndef InstallMultipleDestFlags
1262 #define InstallMultipleDestFlags(step,list,dest,flags)                  @@\
1263 step:: list                                                             @@\
1264         MakeDir($(DESTDIR)dest)                                         @@\
1265         @MakeFlagsToShellFlags(i,set +e); \                             @@\
1266         for i in list; do \                                             @@\
1267                 (set -x; $(INSTALL) $(INSTALLFLAGS) flags $$i $(DESTDIR)dest); \        @@\
1268         done
1269 #endif /* InstallMultipleDestFlags */
1270
1271
1272 /*
1273  * InstallMultipleDest - generate rules to install multiple files at once
1274  * during a particular step in the build using any install flags set in 
1275  * $(INSTDATFLAGS).
1276  */
1277 #ifndef InstallMultipleDest
1278 #define InstallMultipleDest(step,list,dest)                             @@\
1279 InstallMultipleDestFlags(step,list,dest,$(INSTDATFLAGS))
1280 #endif /* InstallMultipleDest */
1281
1282 /*
1283  * InstallMultiple - generate rules to install multiple files at once 
1284  * during the install step of the build using any install flags set in 
1285  * $(INSTALLFLAGS).
1286  */
1287 #ifndef InstallMultiple
1288 #define InstallMultiple(list,dest)                                      @@\
1289 InstallMultipleDest(install,list,dest)
1290 #endif /* InstallMultiple */
1291
1292
1293 /*
1294  * InstallMultipleFlags - generate rules to install multiple files at once
1295  * during the install step of the build using the given install flags.
1296  */
1297 #ifndef InstallMultipleFlags
1298 #define InstallMultipleFlags(list,dest,flags)                           @@\
1299 InstallMultipleDestFlags(install,list,dest,flags)
1300 #endif /* InstallMultipleFlags */
1301
1302
1303 /*
1304  * InstallMultipleMan - generate rules to install a variety of manual pages
1305  * during the install.man step of the build.
1306  */
1307 #ifndef InstallMultipleMan
1308 #define InstallMultipleMan(list,dest)                                   @@\
1309 InstallMultipleDestFlags(install.man,list,dest,$(INSTMANFLAGS))
1310 #endif /* InstallMultipleMan */
1311
1312 /*
1313  * IncludeMakefile - rule to include another Makefile.
1314  * Must not generate an error or even a warning if the named file
1315  * is not present, since we use this to include Makefile.dep, which
1316  * may not be built yet.
1317  * This is defined non-null iff HasMakefileSafeInclude is YES.
1318  * The double-@ is to ensure no leading spaces on the line.
1319  */
1320 #ifndef IncludeMakefile
1321 #if HasClearmake
1322 #define IncludeMakefile(file) @@sinclude file
1323 #else
1324 #define IncludeMakefile(file) /**/
1325 #endif
1326 #endif
1327
1328 /*
1329  * DependDependencyStatement - Used by DependDependency to set up the
1330  * most specific dependency, which differs based on whether we support
1331  * a separate Makefile.dep on this platform.
1332  */
1333 #ifndef DependDependencyStatement
1334 #if HasMakefileSafeInclude
1335 #define DependDependencyStatement()                                     @@\
1336 DependFileName:: ProgramTargetName($(DEPEND))
1337 #else
1338 #define DependDependencyStatement()                                     @@\
1339 depend:: ProgramTargetName($(DEPEND))
1340 #endif
1341 #endif
1342
1343 /*
1344  * DependDependency - generate rules to build the makedepend program if 
1345  * this Imakefile is within the source tree.
1346  */
1347 #ifndef DependDependency
1348 #ifdef UseInstalled
1349 #define DependDependency() /**/
1350 #else
1351 #define DependDependency()                                              @@\
1352 DependDependencyStatement()                                             @@\
1353                                                                         @@\
1354 NoCmpScript(ProgramTargetName($(DEPEND)))                               @@\
1355                                                                         @@\
1356 ProgramTargetName($(DEPEND)):                                           @@\
1357         @echo "checking $@ over in $(DEPENDSRC) first..."; \            @@\
1358         cd $(DEPENDSRC) && $(MAKE); \                                   @@\
1359         echo "okay, continuing in $(CURRENT_DIR)"
1360
1361 #endif /* UseInstalled */
1362 #endif /* DependDependency */
1363
1364
1365 /*
1366  * DependTarget - generate rules to compute dependencies for all files listed
1367  * in $(SRCS).
1368  */
1369 #ifndef DependTarget
1370 #if HasMakefileSafeInclude
1371 #define DependTarget()                                                  @@\
1372 DependDependency()                                                      @@\
1373                                                                         @@\
1374 depend:: DependFileName                                                 @@\
1375                                                                         @@\
1376 DependFileName::                                                        @@\
1377         RunProgram(DEPEND,-f- $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- $(SRCS)) > $@
1378 #else /* HasMakefileSafeInclude */
1379 #define DependTarget()                                                  @@\
1380 DependDependency()                                                      @@\
1381                                                                         @@\
1382 depend::                                                                @@\
1383         RunProgram(DEPEND,$(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- $(SRCS))
1384 #endif /* HasMakefileSafeInclude else */
1385 #endif /* DependTarget */
1386
1387 /*
1388  * DependTarget3 - generate rules to compute dependencies for all files given.
1389  */
1390 #ifndef DependTarget3
1391 #if HasMakefileSafeInclude
1392 #define DependTarget3(srcs1,srcs2,srcs3)                                @@\
1393 DependDependency()                                                      @@\
1394                                                                         @@\
1395 depend:: DependFileName                                                 @@\
1396                                                                         @@\
1397 DependFileName::                                                        @@\
1398         RunProgram(DEPEND,-f- $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- srcs1) > $@  @@\
1399         RunProgram(DEPEND,-f- $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- srcs2) >> $@ @@\
1400         RunProgram(DEPEND,-f- $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- srcs3) >> $@
1401 #else /* HasMakefileSafeInclude */
1402 #define DependTarget3(srcs1,srcs2,srcs3)                                @@\
1403 DependDependency()                                                      @@\
1404                                                                         @@\
1405 depend::                                                                @@\
1406         RunProgram(DEPEND,$(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- srcs1)   @@\
1407         RunProgram(DEPEND,-a $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- srcs2)        @@\
1408         RunProgram(DEPEND,-a $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- srcs3)
1409 #endif /* HasMakefileSafeInclude else */
1410 #endif /* DependTarget3 */
1411
1412
1413 /*
1414  * CleanTarget - generate rules to remove any garbage files
1415  */
1416 #ifndef CleanTarget
1417 #define CleanTarget()                                                   @@\
1418 clean::                                                                 @@\
1419         $(RM) FilesToClean ExtraFilesToClean "#"*                       @@\
1420                                                                         @@\
1421 ProofCleanTarget()
1422 #endif /* CleanTarget */
1423
1424
1425 /*
1426  * TagsTarget - generate rules to compute tags files for C source code.
1427  */
1428 #ifndef TagsTarget
1429 #define TagsTarget()                                                    @@\
1430 tags::                                                                  @@\
1431         $(TAGS) -w *.[ch]                                               @@\
1432         $(TAGS) -xw *.[ch] > TAGS
1433 #endif /* TagsTarget */
1434
1435
1436 /*
1437  * ImakeDependency - generate rules to compile imake if this Imakefile is
1438  * within the source tree.
1439  */
1440 #ifndef ImakeDependency
1441 #ifdef UseInstalled
1442 #define ImakeDependency(target) /**/
1443 #else
1444 #define ImakeDependency(target)                                         @@\
1445 target:: ProgramTargetName($(IMAKE))                                    @@\
1446                                                                         @@\
1447 NoCmpScript(ProgramTargetName($(IMAKE)) $(IMAKE).Osuf)                  @@\
1448                                                                         @@\
1449 ProgramTargetName($(IMAKE)) $(IMAKE).Osuf:                              @@\
1450         -@(cd $(IMAKESRC); if [ -f Makefile ]; then \                   @@\
1451         echo "checking $@ in $(IMAKESRC) first..."; $(MAKE) all; else \ @@\
1452         echo "bootstrapping $@ from Makefile.ini in $(IMAKESRC) first..."; \    @@\
1453         $(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"; fi; \     @@\
1454         echo "okay, continuing in $(CURRENT_DIR)")
1455 #endif /* UseInstalled */
1456 #endif /* ImakeDependency */
1457
1458
1459 /*
1460  * BuildMakefileTarget - generate rules to build a Makefile from an Imakefile
1461  * and any special imake flags.  This is generally done automatically by the
1462  * template or by any special Imakefiles.  The first argument exists just
1463  * because imakeflags is usually empty and some preprocessors will complain
1464  * if an empty argument is passed as the sole argument to a macro.
1465  */
1466 #ifndef BuildMakefileTarget
1467 #define BuildMakefileTarget(notused,imakeflags)                         @@\
1468 ImakeDependency(Makefile)                                               @@\
1469                                                                         @@\
1470 Makefile::                                                              @@\
1471         RMoveToBakFile(Makefile)                                        @@\
1472         $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) imakeflags
1473
1474 #endif /* BuildMakefileTarget */
1475
1476
1477 /*
1478  * MakefileTarget - generate rules to build a normal Makefile.
1479  */
1480 #ifndef MakefileTarget
1481 #define MakefileTarget()                                                @@\
1482 BuildMakefileTarget(Imakefile,NullParameter)
1483 #endif /* MakefileTarget */
1484
1485
1486 /*
1487  * LibMkdir - helper for creating library object subdirectories
1488  */
1489 #ifndef LibMkdir
1490 #define LibMkdir(dir) DirFailPrefix@if [ -d dir ]; then exit 0; else set -x; mkdir dir; fi
1491 #endif
1492
1493 #ifndef LibMkdirLinkSubdirs
1494 #define LibMkdirLinkSubdirs(dir) DirFailPrefix@if [ -d dir ]; then \    @@\
1495             exit 0; \                                                   @@\
1496         else \                                                          @@\
1497             echo "mkdir dir"; mkdir dir; \                              @@\
1498             for i in $(SUBDIRS); do \                                   @@\
1499               j=`echo "$$i" | $(SED) -e 's;[^/]\{1,\};..;g'`; \         @@\
1500               $(MKDIRHIER) "dir/`dirname $$i`"; \                       @@\
1501               echo $(LN) "$$j/$$i/dir" "dir/$$i"; \                     @@\
1502               $(LN) "$$j/$$i/dir" "dir/$$i"; \                          @@\
1503             done; \                                                     @@\
1504         fi
1505 #endif
1506
1507 /*
1508  * LibCleanDir - helper for cleaning library object subdirectories
1509  */
1510 #ifndef LibCleanDir
1511 #define LibCleanDir(dir) -@if [ -d dir ]; then \                        @@\
1512                 set -x; $(RM) -r dir; else exit 0; fi
1513 #endif
1514
1515 /*
1516  * LintLibReferences - variables for lint libraries
1517  */
1518 #ifndef LintLibReferences
1519 #define LintLibReferences(varname,libname,libsource)                    @@\
1520 Concat(LINT,varname) = _UseCat($(LINTLIBDIR)/llib-l,libsource/llib-,libname.ln)
1521 #endif
1522
1523
1524 /*
1525  * UnsharedLibReferences - variables for unshared libraries
1526  */
1527 #ifndef UnsharedLibReferences
1528 #define UnsharedLibReferences(varname,libname,libsource)                @@\
1529 ProjectUnsharedLibReferences(varname,libname,libsource,$(BUILDLIBDIR))
1530 #endif
1531
1532 /*
1533  * ProjectUnsharedLibReferences - variables for unshared libraries
1534  */
1535 #ifndef ProjectUnsharedLibReferences
1536 #define ProjectUnsharedLibReferences(varname,libname,libsource,buildlibdir)     @@\
1537 Concat3(DEP,varname,LIB) = _UseCat($(USRLIBDIR)/lib,buildlibdir/lib,libname.a)  @@\
1538 Concat(varname,LIB) = LoaderLibPrefix Concat(-l,libname)                @@\
1539 LintLibReferences(varname,libname,libsource)
1540 #endif
1541
1542 /*
1543  * SharedLibDependencies - shared library dependencies
1544  */
1545 #ifndef SharedLibDependencies
1546 #define SharedLibDependencies(libname,libsource,revname) /**/
1547 #endif
1548
1549 /*
1550  * SharedDSLibDependencies - shared library dependencies with data separation
1551  */
1552 #ifndef SharedDSLibDependencies
1553 #define SharedDSLibDependencies(libname,libsource,revname) /**/
1554 #endif
1555
1556 /*
1557  * SharedLibReferences - variables for shared libraries
1558  */
1559 #ifndef SharedLibReferences
1560 #define SharedLibReferences(varname,libname,libsource,revname,rev)      @@\
1561 revname = rev                                                           @@\
1562 Concat3(DEP,varname,LIB) = SharedLibDependencies(libname,libsource,revname) @@\
1563 Concat(varname,LIB) = LoaderLibPrefix Concat(-l,libname)                @@\
1564 LintLibReferences(varname,libname,libsource)
1565 #endif
1566
1567 /*
1568  * SharedDSLibReferences - variables for shared libraries with data separation
1569  */
1570 #ifndef SharedDSLibReferences
1571 #define SharedDSLibReferences(varname,libname,libsource,revname,rev)    @@\
1572 revname = rev                                                           @@\
1573 Concat3(DEP,varname,LIB) = SharedDSLibDependencies(libname,libsource,revname) @@\
1574 Concat(varname,LIB) = LoaderLibPrefix Concat(-l,libname)                @@\
1575 LintLibReferences(varname,libname,libsource)
1576 #endif
1577
1578 /*
1579  * CPPOnlyCompile - run C compiler's preprocessor only
1580  */
1581 #ifndef CPPOnlyCompile
1582 #define CPPOnlyCompile(src,options) RemoveFile($@)                      @@\
1583         ClearmakeOSName \
1584         $(CC) -E $(CFLAGS) options src > $@
1585 #endif
1586
1587 /*
1588  * ObjectCompile - compile fragment for a normal object file
1589  */
1590 #ifndef ObjectCompile
1591 #define ObjectCompile(options) RemoveFile($@)                           @@\
1592         ClearmakeOSName \
1593         $(CC) -c $(CFLAGS) options $*.c
1594 #endif
1595
1596 #ifndef ObjectCplusplusCompile
1597 #define ObjectCplusplusCompile(options) RemoveFile($@)                  @@\
1598         ClearmakeOSName \
1599         $(CXX) -c $(CXXFLAGS) options $*.CCsuf
1600 #endif
1601
1602 /*
1603  * NormalLibObjCompile - compile fragment for a normal library object file
1604  */
1605 #ifndef NormalLibObjCompile
1606 #define NormalLibObjCompile(options) ObjectCompile(options)
1607 #endif
1608
1609 #ifndef NormalLibObjCplusplusCompile
1610 #define NormalLibObjCplusplusCompile(options) ObjectCplusplusCompile(options)
1611 #endif
1612
1613 /*
1614  * NormalSharedLibObjCompile - compile fragment for shared objects
1615  */
1616 #ifndef NormalSharedLibObjCompile
1617 #define NormalSharedLibObjCompile(options) NormalLibObjCompile(options $(SHLIBDEF) $(SHAREDCODEDEF) $(PICFLAGS))
1618 #endif
1619
1620 #ifndef NormalSharedLibObjCplusplusCompile
1621 #define NormalSharedLibObjCplusplusCompile(options) NormalLibObjCplusplusCompile(options $(SHLIBDEF) $(SHAREDCODEDEF) $(CXXPICFLAGS))
1622 #endif
1623
1624 /*
1625  * LibObjCompile - compile fragment for unshared/profiled/debugged objects
1626  */
1627 #ifndef LibObjCompile
1628 #define LibObjCompile(dir,options) RemoveFiles($@ dir/$@)               @@\
1629         ClearmakeOSName \
1630         $(CC) -c $(CCOPTIONS) $(ALLDEFINES) options $*.c                @@\
1631         $(MV) $@ dir/$@
1632 #endif
1633
1634 #ifndef LibObjCplusplusCompile
1635 #define LibObjCplusplusCompile(dir,options) RemoveFiles($@ dir/$@)      @@\
1636         ClearmakeOSName \
1637         $(CXX) -c $(CXXOPTIONS) $(CXXDEFINES) options $*.CCsuf          @@\
1638         $(MV) $@ dir/$@
1639 #endif
1640
1641 /*
1642  * DebuggedLibObjCompile - compile fragment for debugged objects
1643  */
1644 #ifndef DebuggedLibObjCompile
1645 #define DebuggedLibObjCompile(options) LibObjCompile(debugger,DebuggableCDebugFlags options)
1646 #endif
1647
1648 #ifndef DebuggedLibObjCplusplusCompile
1649 #define DebuggedLibObjCplusplusCompile(options) LibObjCplusplusCompile(debugger,DebuggableCplusplusDebugFlags options)
1650 #endif
1651
1652 /*
1653  * ProfiledLibObjCompile - compile fragment for profiled objects
1654  */
1655 #ifndef ProfiledLibObjCompile
1656 #define ProfiledLibObjCompile(options) LibObjCompile(profiled,ProfiledCDebugFlags options)
1657 #endif
1658
1659 #ifndef ProfiledLibObjCplusplusCompile
1660 #define ProfiledLibObjCplusplusCompile(options) LibObjCplusplusCompile(profiled,ProfiledCplusplusDebugFlags options)
1661 #endif
1662
1663 /*
1664  * UnsharedLibObjCompile - compile fragment for unshared objects
1665  */
1666 #ifndef UnsharedLibObjCompile
1667 #define UnsharedLibObjCompile(options) LibObjCompile(unshared,$(CDEBUGFLAGS) options)
1668 #endif
1669
1670 #ifndef UnsharedLibObjCplusplusCompile
1671 #define UnsharedLibObjCplusplusCompile(options) LibObjCplusplusCompile(unshared,$(CXXDEBUGFLAGS) options)
1672 #endif
1673
1674 /*
1675  * SharedLibObjCompile - compile fragment for shared objects
1676  */
1677 #ifndef SharedLibObjCompile
1678 #define SharedLibObjCompile(options) LibObjCompile(shared,options $(SHLIBDEF) $(SHAREDCODEDEF) $(PICFLAGS) $(CDEBUGFLAGS))
1679 #endif
1680
1681 /*
1682  * NormalLibraryObjectRule - for simple libraries
1683  */
1684 #ifndef NormalLibraryObjectRule
1685 #define NormalLibraryObjectRule()                                       @@\
1686 .c.Osuf:                                                                @@\
1687         NormalLibObjCompile($(_NOOP_))
1688 #endif /* NormalLibraryObjectRule */
1689
1690 #ifndef NormalCplusplusObjectRule
1691 #define NormalCplusplusObjectRule()                                     @@\
1692 .CCsuf.Osuf:                                                            @@\
1693         NormalLibObjCplusplusCompile($(_NOOP_))
1694 #endif
1695
1696 #ifndef NormalFortranObjectRule
1697 #define NormalFortranObjectRule()                                       @@\
1698 .f.Osuf:                                                                @@\
1699         RemoveFile($@)                                                  @@\
1700         ClearmakeOSName \
1701         $(FC) -c $(FCFLAGS) $*.f
1702 #endif
1703
1704 /*
1705  * SpecialObjectRule - generate rules to compile a file with special flags.
1706  */
1707 #ifndef SpecialObjectRule
1708 #define SpecialObjectRule(objs,depends,options)                         @@\
1709 objs:   depends                                                         @@\
1710         ObjectCompile(options)
1711 #endif /* SpecialObjectRule */
1712
1713 #ifndef SpecialCplusplusObjectRule
1714 #define SpecialCplusplusObjectRule(baseobj,basedep,options)             @@\
1715 baseobj.Osuf:   basedep.CCsuf                                           @@\
1716         ObjectCplusplusCompile(options)
1717 #endif /* SpecialCplusplusObjectRule */
1718
1719 /*
1720  * SpecialCObjectRule - generate rules to compile a C file with special flags.
1721  *                      also handles CodeCenter rules
1722  */
1723 #ifndef SpecialCObjectRule
1724 #define SpecialCObjectRule(basename,depends,options)                    @@\
1725 SpecialObjectRule(basename.Osuf,basename.c depends,options)             @@\
1726                                                                         @@\
1727 basename.i: basename.c depends                                          @@\
1728         CPPOnlyCompile(basename.c,options)                              @@\
1729                                                                         @@\
1730 CenterLoadTarget(debug_src,basename.c,NullParameter,$(ALLDEFINES) options)
1731 #endif /* SpecialCObjectRule */
1732
1733
1734 #ifndef ObjectFromSpecialSource
1735 #define ObjectFromSpecialSource(dst,src,flags)                          @@\
1736 NoConfigRec(dst.c)                                                      @@\
1737                                                                         @@\
1738 dst.c:  src.c                                                           @@\
1739         RemoveFile($@)                                                  @@\
1740         $(LN) $? $@                                                     @@\
1741                                                                         @@\
1742 SpecialCObjectRule(dst,NullParameter,flags)                             @@\
1743                                                                         @@\
1744 depend::  dst.c                                                         @@\
1745                                                                         @@\
1746 clean::                                                                 @@\
1747         RemoveFile(dst.c)
1748 #endif /* ObjectFromSpecialSource */
1749
1750 #ifndef LexFileExplicit
1751 #if HasClearmake                /* provide a place to hang ClearmakeOSName */
1752 #define LexFileExplicit(file)                                           @@\
1753 file.c: file.l                                                          @@\
1754         ClearmakeOSName \
1755         $(LEX) $(LFLAGS) file.l                                         @@\
1756         $(MV) lex.yy.c file.c
1757 #else
1758 #define LexFileExplicit(file) /* the default rule is fine */
1759 #endif
1760 #endif
1761
1762 #ifndef LexFile
1763 #define LexFile(file)                                                   @@\
1764 LexFileExplicit(file)                                                   @@\
1765                                                                         @@\
1766 depend:: file.c                                                         @@\
1767                                                                         @@\
1768 clean::                                                                 @@\
1769         RemoveFiles(lex.yy.c file.c)
1770 #endif /* LexFile */
1771
1772 #ifndef YaccFile
1773 #define YaccFile(file,flags)                                            @@\
1774 depend:: file.c                                                         @@\
1775                                                                         @@\
1776 file.h file.c: file.y                                                   @@\
1777         ClearmakeOSName \
1778         $(YACC) flags file.y                                            @@\
1779         $(MV) y.tab.c file.c                                            @@\
1780         @if [ -f y.tab.h ]; then set -x; $(MV) y.tab.h file.h; \        @@\
1781         else exit 0; fi                                                 @@\
1782                                                                         @@\
1783 clean::                                                                 @@\
1784         RemoveFiles(y.tab.c y.tab.h file.h file.c)
1785 #endif /* YaccFile */
1786
1787 #ifndef YaccFileNoFlags
1788 #define YaccFileNoFlags(file)                                           @@\
1789 depend:: file.c                                                         @@\
1790                                                                         @@\
1791 file.c: file.y                                                          @@\
1792         ClearmakeOSName \
1793         $(YACC) file.y                                                  @@\
1794         $(MV) y.tab.c file.c                                            @@\
1795                                                                         @@\
1796 clean::                                                                 @@\
1797         RemoveFiles(y.tab.c file.c)
1798 #endif /* YaccFileNoFlags */
1799
1800
1801 #ifndef MakeLibrary
1802 #define MakeLibrary(libname,objlist) $(AR) libname objlist
1803 #endif
1804
1805 #ifndef LinkBuildLibrary
1806 #ifdef UseInstalled
1807 #define LinkBuildLibrary(lib) $(_NULLCMD_)
1808 #else
1809 #define LinkBuildLibrary(lib) MakeDir($(BUILDLIBDIR))                   @@\
1810         RemoveFile($(BUILDLIBDIR)/lib)                                  @@\
1811         cd $(BUILDLIBDIR) && $(LN) $(BUILDLIBTOP)/$(CURRENT_DIR)/lib .
1812 #endif
1813 #endif /* LinkBuildLibrary */
1814
1815 #ifndef _LinkBuildLibrary /* will get redefined elsewhere */
1816 #define _LinkBuildLibrary(lib) $(_NULLCMD_)
1817 #endif /* _LinkBuildLibrary */
1818
1819 /*
1820  * NormalLibraryTarget - generate rules to create a library.
1821  */
1822 #ifndef NormalLibraryTarget
1823 #define NormalLibraryTarget(libname,objlist)                            @@\
1824 AllTarget(LibraryTargetName(libname))                                   @@\
1825                                                                         @@\
1826 LibraryTargetName(libname): objlist $(EXTRALIBRARYDEPS)                 @@\
1827         RemoveFile($@)                                                  @@\
1828         MakeLibrary($@,objlist)                                         @@\
1829         RanLibrary($@)                                                  @@\
1830         _LinkBuildLibrary($@)
1831 #endif /* NormalLibraryTarget */
1832
1833
1834 /*
1835  * NormalLibraryTarget2 - generate rules to create a library in two steps.
1836  * This is used to create libraries with large numbers of files.
1837  */
1838 #ifndef NormalLibraryTarget2
1839 #define NormalLibraryTarget2(libname,objlist1,objlist2)                 @@\
1840 AllTarget(LibraryTargetName(libname))                                   @@\
1841                                                                         @@\
1842 LibraryTargetName(libname): objlist1 objlist2 $(EXTRALIBRARYDEPS)       @@\
1843         RemoveFile($@)                                                  @@\
1844         MakeLibrary($@,objlist1)                                        @@\
1845         MakeLibrary($@,objlist2)                                        @@\
1846         RanLibrary($@)                                                  @@\
1847         _LinkBuildLibrary($@)
1848 #endif /* NormalLibraryTarget2 */
1849
1850
1851 /*
1852  * NormalLibraryTarget3 - generate rules to create a library in three steps.
1853  * This is used to create libraries with very large numbers of files.
1854  */
1855 #ifndef NormalLibraryTarget3
1856 #define NormalLibraryTarget3(libname,objlist1,objlist2,objlist3)        @@\
1857 AllTarget(LibraryTargetName(libname))                                   @@\
1858                                                                         @@\
1859 LibraryTargetName(libname): objlist1 objlist2 objlist3 $(EXTRALIBRARYDEPS)      @@\
1860         RemoveFile($@)                                                  @@\
1861         MakeLibrary($@,objlist1)                                        @@\
1862         MakeLibrary($@,objlist2)                                        @@\
1863         MakeLibrary($@,objlist3)                                        @@\
1864         RanLibrary($@)                                                  @@\
1865         _LinkBuildLibrary($@)
1866 #endif /* NormalLibraryTarget3 */
1867
1868
1869 /*
1870  * NormalDepLibraryTarget - generate rules to create a library.
1871  */
1872 #ifndef NormalDepLibraryTarget
1873 #define NormalDepLibraryTarget(libname,deplist,objlist)                 @@\
1874 AllTarget(LibraryTargetName(libname))                                   @@\
1875                                                                         @@\
1876 LibraryTargetName(libname): deplist $(EXTRALIBRARYDEPS)                 @@\
1877         RemoveFile($@)                                                  @@\
1878         MakeLibrary($@,objlist)                                         @@\
1879         RanLibrary($@)                                                  @@\
1880         _LinkBuildLibrary($@)
1881 #endif /* NormalDepLibraryTarget */
1882
1883
1884 /*
1885  * UnsharedLibraryTarget - generate rules to create a library.
1886  */
1887 #ifndef UnsharedLibraryTarget
1888 #define UnsharedLibraryTarget(libname,objlist,down,up)                  @@\
1889 AllTarget(LibraryTargetName(libname))                                   @@\
1890                                                                         @@\
1891 LibraryTargetName(libname): objlist $(EXTRALIBRARYDEPS)                 @@\
1892         RemoveFile($@)                                                  @@\
1893         (cd down && MakeLibrary(up/$@,objlist))                         @@\
1894         RanLibrary($@)                                                  @@\
1895         _LinkBuildLibrary($@)
1896 #endif /* UnsharedLibraryTarget */
1897
1898
1899 /*
1900  * UnsharedLibraryTarget3 - generate rules to create a library in three steps.
1901  * This is used to create libraries with very large numbers of files.
1902  */
1903 #ifndef UnsharedLibraryTarget3
1904 #define UnsharedLibraryTarget3(libname,objlist1,objlist2,objlist3,down,up) @@\
1905 AllTarget(LibraryTargetName(libname))                                   @@\
1906                                                                         @@\
1907 LibraryTargetName(libname): objlist1 objlist2 objlist3 $(EXTRALIBRARYDEPS)      @@\
1908         RemoveFile($@)                                                  @@\
1909         (cd down && MakeLibrary(up/$@,objlist1))                        @@\
1910         (cd down && MakeLibrary(up/$@,objlist2))                        @@\
1911         (cd down && MakeLibrary(up/$@,objlist3))                        @@\
1912         RanLibrary($@)                                                  @@\
1913         _LinkBuildLibrary($@)
1914 #endif /* UnsharedLibraryTarget3 */
1915
1916
1917 /*
1918  * SubdirLibraryRule -
1919  */
1920 #ifndef SubdirLibraryRule
1921 #define SubdirLibraryRule(objlist)                                      @@\
1922 all:: DONE                                                              @@\
1923                                                                         @@\
1924 DONE: objlist                                                           @@\
1925         RemoveFile($@)                                                  @@\
1926         touch $@                                                        @@\
1927                                                                         @@\
1928 clean::                                                                 @@\
1929         RemoveFile(DONE)
1930 #endif /* SubdirLibraryRule */
1931
1932
1933 /*
1934  * ProfiledLibraryTarget - generate rules to create a profiled library.
1935  */
1936 #ifndef ProfiledLibraryTarget
1937 #define ProfiledLibraryTarget(libname,objlist)                          @@\
1938 AllTarget(LibraryTargetNameSuffix(libname,_p))                          @@\
1939                                                                         @@\
1940 LibraryTargetNameSuffix(libname,_p): objlist $(EXTRALIBRARYDEPS)        @@\
1941         RemoveFile($@)                                                  @@\
1942         cd profiled && MakeLibrary(../$@,objlist)                       @@\
1943         RanLibrary($@)
1944
1945 #endif /* ProfiledLibraryTarget */
1946
1947
1948 /*
1949  * DebuggedLibraryTarget - generate rules to create a debuggable library.
1950  */
1951 #ifndef DebuggedLibraryTarget
1952 #define DebuggedLibraryTarget(libname,objlist)                          @@\
1953 AllTarget(LibraryTargetNameSuffix(libname,_d))                          @@\
1954                                                                         @@\
1955 LibraryTargetNameSuffix(libname,_d): objlist $(EXTRALIBRARYDEPS)        @@\
1956         RemoveFile($@)                                                  @@\
1957         cd debugger && MakeLibrary(../$@,objlist)                       @@\
1958         RanLibrary($@)
1959
1960 #endif /* DebuggedLibraryTarget */
1961
1962
1963 /*
1964  * AliasedLibraryTarget - generate rules to link one library to another.
1965  */
1966 #ifndef AliasedLibraryTarget
1967 #define AliasedLibraryTarget(libname,alias)                             @@\
1968 AllTarget(LibraryTargetName(alias))                                     @@\
1969                                                                         @@\
1970 LibraryTargetName(alias): LibraryTargetName(libname)                    @@\
1971         RemoveFile($@)                                                  @@\
1972         $(LN) LibraryTargetName(libname) $@                             @@\
1973                                                                         @@\
1974 clean::                                                                 @@\
1975         RemoveFile(LibraryTargetName(alias))
1976 #endif /* AliasedLibraryTarget */
1977
1978
1979 /*
1980  * NormalRelocatableTarget - generate rules to produce a relocatable object
1981  * file instead of a library.  
1982  */
1983 #ifndef NormalRelocatableTarget
1984 #define NormalRelocatableTarget(objname,objlist)                        @@\
1985 AllTarget(objname.Osuf)                                                 @@\
1986                                                                         @@\
1987 objname.Osuf: objlist $(EXTRALIBRARYDEPS)                               @@\
1988         RemoveFile($@)                                                  @@\
1989         $(LD) $(LDCOMBINEFLAGS) objlist -o $@
1990 #endif /* NormalRelocatableTarget */
1991
1992
1993 /*
1994  * ProfiledRelocatableTarget - generate rules to produce a profiled relocatable
1995  * object file instead of a library.
1996  */
1997 #ifndef ProfiledRelocatableTarget
1998 #define ProfiledRelocatableTarget(objname,objlist)                      @@\
1999 AllTarget(Concat(objname,_p.Osuf))                                      @@\
2000                                                                         @@\
2001 Concat(objname,_p.Osuf): objlist $(EXTRALIBRARYDEPS)                    @@\
2002         RemoveFile($@)                                                  @@\
2003         $(LD) -X -r objlist -o $@
2004
2005 #endif /* ProfiledRelocatableTarget */
2006
2007
2008 /*
2009  * DebuggedRelocatableTarget - generate rules to produce a debuggable 
2010  * relocatable object file instead of a library.
2011  */
2012 #ifndef DebuggedRelocatableTarget
2013 #define DebuggedRelocatableTarget(objname,objlist)                      @@\
2014 AllTarget(Concat(objname,_d.Osuf))                                      @@\
2015                                                                         @@\
2016 Concat(objname,_d.Osuf): objlist $(EXTRALIBRARYDEPS)                    @@\
2017         RemoveFile($@)                                                  @@\
2018         $(LD) -X -r objlist -o $@
2019
2020 #endif /* DebuggedRelocatableTarget */
2021
2022
2023 /*
2024  * LintLibraryTarget - generate rules to create a lint library.  Note that the
2025  * lint library is always forced to be newer than the library itself.
2026  */
2027 #ifndef LintLibraryTarget
2028 #define LintLibraryTarget(libname,srclist)                              @@\
2029 lintlib:: Concat(llib-l,libname.ln)                                     @@\
2030                                                                         @@\
2031 Concat(llib-l,libname.ln): srclist $(EXTRALIBRARYDEPS)                  @@\
2032         RemoveFile($@)                                                  @@\
2033         $(LINT) Concat($(LINTLIBFLAG),libname) $(LINTFLAGS) srclist
2034 #endif /* LintLibraryTarget */
2035
2036
2037 /*
2038  * NormalLintTarget - generate rules to lint a set of sources.
2039  */
2040 #ifndef NormalLintTarget
2041 #define NormalLintTarget(srclist)                                       @@\
2042 lint:                                                                   @@\
2043         $(LINT) $(LINTFLAGS) srclist $(LINTLIBS)                        @@\
2044 lint1:                                                                  @@\
2045         $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
2046 #endif /* NormalLintTarget */
2047
2048
2049 /*
2050  * LintTarget - generate rules to lint $(SRCS)
2051  */
2052 #ifndef LintTarget
2053 #define LintTarget()                                                    @@\
2054 NormalLintTarget($(SRCS))
2055 #endif
2056
2057
2058 /*
2059  * LinkSourceFile - snag source file from some other directory
2060  */
2061 #ifndef LinkSourceFile
2062 #define LinkSourceFile(src,dir)                                         @@\
2063 src:  dir/src                                                           @@\
2064         RemoveFile($@)                                                  @@\
2065         $(LN) $? $@                                                     @@\
2066                                                                         @@\
2067 NoConfigRec(src)                                                        @@\
2068                                                                         @@\
2069 includes:: src                                                          @@\
2070                                                                         @@\
2071 depend:: src                                                            @@\
2072                                                                         @@\
2073 clean::                                                                 @@\
2074         RemoveFile(src)
2075 #endif
2076
2077
2078 /*
2079  * LinkFile - link a file
2080  */
2081 #ifndef LinkFile
2082 #define LinkFile(tofile,fromfile)                                       @@\
2083 tofile:: fromfile                                                       @@\
2084         RemoveFile($@)                                                  @@\
2085         $(LN) $? $@                                                     @@\
2086                                                                         @@\
2087 NoConfigRec(tofile)                                                     @@\
2088                                                                         @@\
2089 includes:: tofile                                                       @@\
2090                                                                         @@\
2091 depend:: tofile                                                         @@\
2092                                                                         @@\
2093 clean::                                                                 @@\
2094         RemoveFile(tofile)
2095 #endif
2096
2097
2098 #ifndef MakeSubincludesForBuild
2099 #define MakeSubincludesForBuild(step,dir,srclist)                       @@\
2100 step::  dir srclist                                                     @@\
2101         @-(list=`echo srclist | $(SED) -e 's/[^ ]*\///g'`; \            @@\
2102                 set -x; cd dir; RemoveFiles($$list))                    @@\
2103         @for i in srclist; do \                                         @@\
2104                 (set -x; cd dir; $(LN) ../$$i .); \                     @@\
2105         done                                                            @@\
2106                                                                         @@\
2107 dir::                                                                   @@\
2108         $(MKDIRHIER) dir                                                @@\
2109                                                                         @@\
2110 clean::                                                                 @@\
2111         @-(if [ -d dir ]; then \                                        @@\
2112                 list=`echo srclist | $(SED) -e 's/[^ ]*\///g'`; \       @@\
2113                 set -x; cd dir; RemoveFile($$list); else exit 0; fi)
2114 #endif
2115
2116
2117 /*
2118  * LangNamedTargetSubdirs - recursively make a series of steps
2119  */
2120 #ifndef LangNamedTargetSubdirs
2121 #define LangNamedTargetSubdirs(lang,name,dirs,verb,flags,subname)       @@\
2122 name::                                                                  @@\
2123         @MakeFlagsToShellFlags(ik,set +e); \                            @@\
2124         for i in dirs ;\                                                @@\
2125         do \                                                            @@\
2126                 echo verb "in $(CURRENT_DIR)/$$i..."; \                 @@\
2127                 (cd $$i && LANG=lang $(MAKE) $(MFLAGS) flags subname);\ @@\
2128         done
2129 #endif
2130
2131
2132 /*
2133  * NamedMakeSubdirs - generate rules to do makes in the given subdirectories.
2134  * If you want CDEBUGFLAGS passed along to subdirectories, provide a line like
2135  * the following in the appropriate Imakefile
2136  * 
2137  *         #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
2138  */
2139 #ifndef LangNamedMakeSubdirs
2140 #define LangNamedMakeSubdirs(lang,name,dirs) \
2141 LangNamedTargetSubdirs(lang,name,dirs,"making" name,PassCDebugFlags,all)
2142 #endif /* LangNamedMakeSubdirs */
2143
2144 #ifndef LangMakeSubdirs
2145 #define LangMakeSubdirs(lang,dirs)                                      @@\
2146 LangNamedMakeSubdirs(lang,all,dirs)
2147 #endif /* LangMakeSubdirs */
2148
2149
2150
2151 /*
2152  * NamedTargetSubdirs - recursively make a series of steps
2153  */
2154 #ifndef NamedTargetSubdirs
2155 #define NamedTargetSubdirs(name,dirs,verb,flags,subname)                @@\
2156 name::                                                                  @@\
2157         @MakeFlagsToShellFlags(ik,set +e); \                            @@\
2158         for i in dirs ;\                                                @@\
2159         do \                                                            @@\
2160                 echo verb "in $(CURRENT_DIR)/$$i..."; \                 @@\
2161                 (cd $$i &&  $(MAKE) $(MFLAGS) flags subname); \         @@\
2162         done
2163 #endif
2164
2165
2166 /*
2167  * NamedMakeSubdirs - generate rules to do makes in the given subdirectories.
2168  * If you want CDEBUGFLAGS passed along to subdirectories, provide a line like
2169  * the following in the appropriate Imakefile
2170  * 
2171  *         #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
2172  */
2173 #ifndef NamedMakeSubdirs
2174 #define NamedMakeSubdirs(name,dirs) \
2175 NamedTargetSubdirs(name,dirs,"making" name,PassCDebugFlags,all)
2176 #endif /* NamedMakeSubdirs */
2177
2178 #ifndef MakeSubdirs
2179 #define MakeSubdirs(dirs)                                               @@\
2180 NamedMakeSubdirs(all,dirs)
2181 #endif /* MakeSubdirs */
2182
2183
2184 /*
2185  * DependSubdirs - generate rules to recursively compute dependencies as
2186  * part of the make depend step.
2187  */
2188 #ifndef DependSubdirs
2189 #define DependSubdirs(dirs) \
2190 NamedTargetSubdirs(depend,dirs,"depending",NullParameter,depend)
2191 #endif /* DependSubdirs */
2192
2193
2194 /*
2195  * ForceSubdirs - force make to build subdirectories
2196  */
2197 #ifndef ForceSubdirs
2198 #define ForceSubdirs(dirs)                                              @@\
2199 dirs: FRC                                                               @@\
2200         @cd $@ ; echo "making all in $(CURRENT_DIR)/$@..."; \           @@\
2201         $(MAKE) $(MFLAGS) PassCDebugFlags all                           @@\
2202                                                                         @@\
2203 FRC:
2204 #endif /* ForceSubdirs */
2205
2206 /*
2207  * InstallSubdirs - generate rules to recursively install programs and files.
2208  */
2209 #ifndef InstallSubdirs
2210 #define InstallSubdirs(dirs) \
2211 NamedTargetSubdirs(install,dirs,"installing",DESTDIR=$(DESTDIR),install)
2212 #endif /* InstallSubdirs */
2213
2214
2215 /*
2216  * InstallManSubdirs - generate rules to recursively install manual pages.
2217  */
2218 #ifndef InstallManSubdirs
2219 #define InstallManSubdirs(dirs) \
2220 NamedTargetSubdirs(install.man,dirs,"installing man pages",DESTDIR=$(DESTDIR),install.man)
2221 #endif /* InstallManSubdirs */
2222
2223
2224 /*
2225  * IncludesSubdirs - generate rules to recursively put include files in build
2226  */
2227 #ifndef IncludesSubdirs
2228 #define IncludesSubdirs(dirs) \
2229 NamedTargetSubdirs(includes,dirs,including,NullParameter,includes)
2230 #endif
2231
2232
2233 /*
2234  * InstallLinkKitSubdirs - generate rules to recursively install server Link
2235  *                         Kit (only used for XFree86). This is a no-op
2236  *                         rule so that Imakefiles on non-XFree86 systems
2237  *                         continue to build Makefiles correctly.
2238  */
2239 #ifndef InstallLinkKitSubdirs
2240 #define InstallLinkKitSubdirs(dirs)
2241 #endif
2242
2243
2244 /*
2245  * CleanSubdirs - generate rules to recursively clean out garbage files.
2246  */
2247 #define BootstrapCleanSubdirs /**/      /* used at top-level */
2248 #ifndef NamedCleanSubdirs
2249 #define NamedCleanSubdirs(name,dirs) \
2250 NamedTargetSubdirs(name,dirs,"cleaning",BootstrapCleanSubdirs,clean)
2251 #endif /* NamedCleanSubdirs */
2252
2253 #ifndef CleanSubdirs
2254 #define CleanSubdirs(dirs) \
2255 NamedCleanSubdirs(clean,dirs)
2256 #endif
2257
2258
2259 /*
2260  * TagSubdirs - generate rules to recursively create tags files.
2261  */
2262 #ifndef NamedTagSubdirs
2263 #define NamedTagSubdirs(name,dirs) \
2264 NamedTargetSubdirs(name,dirs,"tagging",TAGS='$(TAGS)',tags)
2265 #endif /* TagSubdirs */
2266
2267 #ifndef TagSubdirs
2268 #define TagSubdirs(dirs) \
2269 NamedTagSubdirs(tags,dirs)
2270 #endif
2271
2272 /*
2273  * MakeLintSubdirs - generate rules to recursively lint directories as part 
2274  * of the named step.
2275  */
2276 #ifndef MakeLintSubdirs
2277 #define MakeLintSubdirs(dirs,target,subtarget) \
2278 NamedTargetSubdirs(target,dirs,"linting" for target and subtarget,DESTDIR=$(DESTDIR) LINTOPTS='$(LINTOPTS)',subtarget)
2279 #endif /* MakeLintSubdirs */
2280
2281
2282 /*
2283  * LintSubdirs - generate rules to recursively lint directories as part of 
2284  * the make lint step.
2285  */
2286 #ifndef LintSubdirs
2287 #define LintSubdirs(dirs)                                               @@\
2288 MakeLintSubdirs(dirs,lint,lint)
2289 #endif /* LintSubdirs */
2290
2291
2292 /*
2293  * MakeLintLibSubdirs - generate rules to recursively create lint libraries.
2294  */
2295 #ifndef MakeLintLibSubdirs
2296 #define MakeLintLibSubdirs(dirs)                                        @@\
2297 MakeLintSubdirs(dirs,lintlib,lintlib)
2298 #endif /* MakeLintLibSubdirs */
2299
2300
2301 /*
2302  * MakeMakeOneSubdirs - generate rules to recreate $(ONESUBDIR)/Makefile
2303  * as part of the specified step in the build. This separate, explicit target
2304  * exists so that clearmake will know what its goal is and do wink-in.
2305  */
2306 #ifndef MakeMakeOneSubdirs
2307 #define MakeMakeOneSubdirs()                                            @@\
2308 $(ONESUBDIR)/Makefile:                                                  @@\
2309         @MakeFlagsToShellFlags(n,executeit="no"); \                     @@\
2310         cd $(ONESUBDIR); \                                              @@\
2311         if [ "$$executeit" != "no" ]; then \                            @@\
2312                 ImakeSubCmdHelper -DTOPDIR=$(IMAKETOP) -DCURDIR=$(ONECURDIR)$(ONESUBDIR); \ @@\
2313         fi;
2314 #endif /* MakeMakeOneSubdirs */
2315
2316
2317 /*
2318  * MakeMakeSubdirs - generate rules to recursively recreate Makefiles as part
2319  * of the specified step in the build.  If $(TOP) is set to an absolute path, 
2320  * do not prepend the ../ prefix.  This makes running things outside of the 
2321  * source tree much easier.
2322  */
2323 #ifndef MakeMakeSubdirs
2324 #define MakeMakeSubdirs(dirs,target)                                    @@\
2325 target::                                                                @@\
2326         -@MakeFlagsToShellFlags(ik,set +e); \                           @@\
2327         MakeFlagsToShellFlags(n,executeit="no"); \                      @@\
2328         for i in dirs ;\                                                @@\
2329         do \                                                            @@\
2330                 case "$(CURRENT_DIR)" in \                              @@\
2331                 .) curdir= ;; \                                         @@\
2332                 *) curdir=$(CURRENT_DIR)/ ;; \                          @@\
2333                 esac; \                                                 @@\
2334                 echo "making Makefiles in $$curdir$$i..."; \            @@\
2335                 itmp=`echo $$i | $(SED) -e 's;^\./;;g' -e 's;/\./;/;g'`; \      @@\
2336                 curtmp="$(CURRENT_DIR)" \                               @@\
2337                 toptmp=""; \                                            @@\
2338                 case "$$itmp" in \                                      @@\
2339                     ../?*) \                                            @@\
2340                         while echo "$$itmp" | grep '^\.\./' > /dev/null;\       @@\
2341                           do \                                          @@\
2342                              toptmp="/`basename $$curtmp`$$toptmp"; \   @@\
2343                              curtmp="`dirname $$curtmp`"; \             @@\
2344                              itmp="`echo $$itmp | $(SED) 's;\.\./;;'`"; \       @@\
2345                           done \                                        @@\
2346                     ;; \                                                @@\
2347                 esac; \                                                 @@\
2348                 case "$$itmp" in \                                      @@\
2349                 */?*/?*/?*/?*)  newtop=../../../../..;; \               @@\
2350                 */?*/?*/?*)     newtop=../../../..;; \                  @@\
2351                 */?*/?*)        newtop=../../..;; \                     @@\
2352                 */?*)           newtop=../..;; \                        @@\
2353                 *)              newtop=..;; \                           @@\
2354                 esac; \                                                 @@\
2355                 newtop="$$newtop$$toptmp"; \                            @@\
2356                 case "$(TOP)" in \                                      @@\
2357                 /?*) imaketop=$(TOP) \                                  @@\
2358                      imakeprefix= ;; \                                  @@\
2359                 .) imaketop=$$newtop \                                  @@\
2360                    imakeprefix=$$newtop/ ;; \                           @@\
2361                 *) imaketop=$$newtop/$(TOP) \                           @@\
2362                    imakeprefix=$$newtop/ ;; \                           @@\
2363                 esac; \                                                 @@\
2364                 RemoveFile($$i/Makefile.bak); \                         @@\
2365                 if [ -f $$i/Makefile ]; then \                          @@\
2366                         echo "  $(MV) Makefile Makefile.bak"; \         @@\
2367                         if [ "$$executeit" != "no" ]; then \            @@\
2368                                 $(MV) $$i/Makefile $$i/Makefile.bak; \  @@\
2369                         fi; \                                           @@\
2370                 fi; \                                                   @@\
2371                 $(MAKE) $(MFLAGS) $(MAKE_OPTS) ONESUBDIR=$$i ONECURDIR=$$curdir IMAKETOP=$$imaketop IMAKEPREFIX=$$imakeprefix $$i/Makefile; \   @@\
2372                 cd $$i; \                                               @@\
2373                 $(MAKE) $(MFLAGS) Makefiles; \                          @@\
2374                 cd $$newtop; \                                          @@\
2375         done
2376
2377 #ifdef UseInstalled
2378 #define ImakeSubCmdHelper $(IMAKE_CMD)
2379 #else
2380 #define ImakeSubCmdHelper $(IMAKEPREFIX)$(IMAKE) -I$(IMAKEPREFIX)$(IRULESRC) $(IMAKE_DEFINES) $(IMAKE_DEF_DTINFO)
2381 #endif
2382
2383 #endif /* MakeMakeSubdirs */
2384
2385
2386 /*
2387  * MakefileSubdirs - generate rules to create Makefiles.
2388  */
2389 #ifndef MakefileSubdirs
2390 #define MakefileSubdirs(dirs)                                           @@\
2391 MakeMakeOneSubdirs()                                                    @@\
2392 MakeMakeSubdirs(dirs,Makefiles)
2393 #endif /* MakefileSubdirs */
2394
2395 /*
2396  * Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM
2397  * to cpp, because that trick does not work on all ANSI C preprocessors.
2398  * Also delete line numbers from the cpp output (-P is not portable, I guess).
2399  */
2400 #ifndef CppSedMagic
2401 #define CppSedMagic $(SED) -e '/^#[line]* *[0-9][0-9]*  *.*$$/d' -e '/^XCOMM$$/s//#/' -e '/^XCOMM[^a-zA-Z0-9_]/s/^XCOMM/#/'
2402 #endif /* CppSedMagic */
2403
2404 #ifndef CppFileTarget
2405 #define CppFileTarget(dst,src,defs,deplist)                             @@\
2406 dst::  src deplist                                                      @@\
2407         RemoveFile($@)                                                  @@\
2408         ClearmakeOSName \
2409         $(CPP) CppNoLineInfoOption defs <src | CppSedMagic >$@          @@\
2410                                                                         @@\
2411 clean::                                                                 @@\
2412         RemoveFiles(dst)
2413 #endif /* CppFileTarget */
2414
2415 /*
2416  * CppScriptTarget - generate rules to create a shell script by running the
2417  * input through cpp.  If the ExecableScripts configuration parameter is not
2418  * set, then make sure that the first line begins with a colon.
2419  */
2420 #ifndef CppScriptTarget
2421 #if ExecableScripts             /* can use #! instead of colon */
2422 #define CppScriptTarget(dst,src,defs,deplist)                           @@\
2423 dst::   src deplist                                                     @@\
2424         RemoveFile($@)                                                  @@\
2425         ClearmakeOSName \
2426         $(CPP) CppNoLineInfoOption defs <src | CppSedMagic >$@          @@\
2427         chmod a+x $@                                                    @@\
2428                                                                         @@\
2429 clean::                                                                 @@\
2430         RemoveFiles(dst)
2431 #else
2432 #define CppScriptTarget(dst,src,defs,deplist)                           @@\
2433 dst::  src deplist                                                      @@\
2434         RemoveFile($@)                                                  @@\
2435         ClearmakeOSName \
2436         echo \: >$@                                                     @@\
2437         $(SED) '1d' src | $(CPP) CppNoLineInfoOption defs | CppSedMagic >>$@    @@\
2438         chmod a+x $@                                                    @@\
2439                                                                         @@\
2440 clean::                                                                 @@\
2441         RemoveFile(dst)
2442 #endif /* ExecableScripts */
2443 #endif /* CppScriptTarget */
2444
2445
2446 /*
2447  * MakeScriptFromCpp - generate rules to create a script from a file with a
2448  * .cpp suffix.
2449  */
2450 #ifndef MakeScriptFromCpp
2451 #define MakeScriptFromCpp(name,defs)                                    @@\
2452 CppScriptTarget(name,name.cpp,defs,NullParameter)
2453 #endif /* MakeScriptFromCpp */
2454
2455 #ifndef CppSourceFile
2456 #define CppSourceFile(dst,src,defs,deplist)                             @@\
2457 CppFileTarget(dst,src,defs,deplist)                                     @@\
2458                                                                         @@\
2459 includes:: dst                                                          @@\
2460                                                                         @@\
2461 depend:: dst
2462 #endif /* CppSourceFile */
2463
2464
2465 /*
2466  * SedFileTarget - generate rules to create a file by running the
2467  * input through sed.
2468  */
2469 #ifndef SedFileTarget
2470 #define SedFileTarget(dst,src,cmds)                                     @@\
2471 dst::  src                                                              @@\
2472         RemoveFile($@)                                                  @@\
2473         $(SED) cmds src >$@                                             @@\
2474         chmod a+x $@                                                    @@\
2475                                                                         @@\
2476 clean::                                                                 @@\
2477         RemoveFiles(dst)
2478 #endif /* SedFileTarget */
2479
2480 #ifndef SedSourceFile
2481 #define SedSourceFile(dst,src,cmds)                                     @@\
2482 SedFileTarget(dst,src,cmds)                                             @@\
2483                                                                         @@\
2484 includes:: dst                                                          @@\
2485                                                                         @@\
2486 depend:: dst
2487 #endif /* SedSourceFile */
2488
2489
2490 /*
2491  * MakeDirectories - generate rules to create a hierarchy of directories.
2492  */
2493 #ifndef MakeDirectories
2494 #define MakeDirectories(step,dirs)                                      @@\
2495 step::                                                                  @@\
2496         DirFailPrefix@MakeFlagsToShellFlags(i,set +e); \                @@\
2497         for i in dirs; do if [ -d $(DESTDIR)$$i ]; then \               @@\
2498                 set +x; else (set -x; $(MKDIRHIER) $(DESTDIR)$$i); fi \ @@\
2499         done
2500 #endif /* MakeDirectories */
2501
2502
2503 /*
2504  * AllTarget - generate rules to build necessary things during make all.
2505  */
2506 #ifndef AllTarget
2507 #define AllTarget(depends)                                              @@\
2508 all:: depends
2509 #endif /* AllTarget */
2510
2511
2512 /*
2513  * MakeImakeDir - call make in imake directory.
2514  */
2515 #ifndef MakeImakeDir
2516 #define MakeImakeDir() cd $(IMAKESRC) && \                              @@\
2517         if [ -f Makefile ]; then \                                      @@\
2518             $(MAKE) $(MFLAGS) BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"; \   @@\
2519         else \                                                          @@\
2520             $(MAKE) $(MFLAGS) -f Makefile.ini BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"; \                                                                   @@\
2521         fi
2522 #endif /* MakeImakeDir */
2523
2524
2525 /*
2526  * DoUDB_SCRIPT3 - macro for creation of udb scripts for installation
2527  */
2528 #ifndef DoUDB_SCRIPT3
2529 #define DoUDB_SCRIPT3(target, file, script, build)                      @@\
2530 target:: $(DATABASE_DIR)/file.udb                                       @@\
2531         script -toLst -ReleaseStream $(PLATFORM) \                      @@\
2532             $(DATABASE_DIR)/file.udb > file.lst                         @@\
2533         build file ../../..
2534 #endif
2535
2536
2537 /*
2538  * DoUDB_SCRIPT4 - macro for creation of udb scripts for installation
2539  */
2540 #ifndef DoUDB_SCRIPT4
2541 #define DoUDB_SCRIPT4(target, file, script, build)                      @@\
2542 target:: $(DATABASE_DIR)/file.udb                                       @@\
2543         script -toLst -ReleaseStream $(PLATFORM) \                      @@\
2544             $(DATABASE_DIR)/file.udb > file.lst                         @@\
2545         build file ../../../..
2546 #endif
2547
2548
2549 #ifdef DefineOldLibraryRules
2550 #include <oldlib.rules>
2551 #endif