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