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