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