home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-bin / x11r6.1 / lib / x11 / config / imake.rules < prev    next >
Encoding:
Text File  |  1996-10-17  |  67.1 KB  |  2,216 lines

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