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