home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / config / Imake.rules.orig < prev    next >
Encoding:
Text File  |  1991-08-22  |  43.4 KB  |  1,508 lines

  1. XCOMM -------------------------------------------------------------------------
  2. XCOMM Imake rules for building libraries, programs, scripts, and data files
  3. XCOMM rules:  $XConsortium: Imake.rules,v 1.121 91/08/22 16:32:50 rws Exp $
  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.  * SaberProgramTarget        (program,srclist,objlist,locallibs,syslibs)
  16.  * RemoveTargetProgram        (program)
  17.  * MakeDir            (dir)
  18.  * BuildIncludes        (srclist,dstsubdir,dstupdir)
  19.  * NormalProgramTarget        (program,objects,deplibs,locallibs,syslibs)
  20.  * SetUIDProgramTarget        (program,objects,deplibs,locallibs,syslibs)
  21.  * SingleProgramTarget        (program,objects,locallibs,syslibs)
  22.  * SimpleProgramTarget        (program)
  23.  * ComplexProgramTarget        (program)
  24.  * ComplexProgramTarget_1    (program,locallib,syslib)
  25.  * ComplexProgramTarget_2    (program,locallib,syslib)
  26.  * ComplexProgramTarget_3    (program,locallib,syslib)
  27.  * ServerTarget            (server,subdirs,objects,libs,syslibs)
  28.  * RanLibrary            (args)
  29.  * InstallLibrary        (libname,dest)
  30.  * MergeIntoInstalledLibrary    (tolib,fromlib)
  31.  * InstallLibraryAlias        (libname,alias,dest)
  32.  * InstallLintLibrary        (libname,dest)
  33.  * InstallManPageLong        (file,destdir,dest)
  34.  * InstallManPage        (file,destdir)
  35.  * InstallManPageAliases    (file,destdir,aliases)
  36.  * InstallNamedNonExec        (srcname,dstname,dest)
  37.  * InstallNonExecFile        (file,dest)
  38.  * InstallNonExec        (file,dest)
  39.  * InstallProgramWithFlags    (program,dest,flags)
  40.  * InstallProgram        (program,dest)
  41.  * InstallScript        (program,dest)
  42.  * InstallNamedProg        (srcname,dstname,dest)
  43.  * LinkFileList            (step,list,dir,sub)
  44.  * InstallMultipleDestFlags    (step,list,dest,flags)
  45.  * InstallMultipleDest        (step,list,dest)
  46.  * InstallMultiple        (list,dest)
  47.  * InstallMultipleFlags        (list,dest,flags)
  48.  * InstallMultipleMan        (list,dest)
  49.  * InstallAppDefaults        (class)
  50.  * InstallAppDefaultsLong    (file,class)
  51.  * DependDependency        ()
  52.  * DependTarget            ()
  53.  * DependTarget3        (srcs1,srcs2,srcs3)
  54.  * CleanTarget            ()
  55.  * TagsTarget            ()
  56.  * ImakeDependency        (target)
  57.  * BuildMakefileTarget        (notused,imakeflags)
  58.  * MakefileTarget        ()
  59.  * LibMkdir            (dir)
  60.  * LibCleanDir            (dir)
  61.  * ObjectCompile        (options)
  62.  * NormalLibObjCompile        (options)
  63.  * NormalSharedLibObjCompile    (options)
  64.  * LibObjCompile        (dir,options)
  65.  * DebuggedLibObjCompile    (options)
  66.  * ProfiledLibObjCompile    (options)
  67.  * SharedLibObjCompile        (options)
  68.  * NormalLibraryObjectRule    ()
  69.  * NormalFortranObjectRule    ()
  70.  * ObjectFromSpecialSource    (dst,src,flags)
  71.  * SpecialObjectRule        (objs,depends,options)
  72.  * NormalLibraryTarget        (libname,objlist)
  73.  * NormalLibraryTarget2        (libname,objlist1,objlist2)
  74.  * NormalLibraryTarget3        (libname,objlist1,objlist2,objlist3)
  75.  * NormalDepLibraryTarget    (libname,deplist,objlist)
  76.  * SubdirLibraryRule        (objlist)
  77.  * ProfiledLibraryTarget    (libname,objlist)
  78.  * DebuggedLibraryTarget    (libname,objlist)
  79.  * AliasedLibraryTarget        (libname,alias)
  80.  * NormalRelocatableTarget    (objname,objlist)
  81.  * ProfiledRelocatableTarget    (objname,objlist)
  82.  * DebuggedRelocatableTarget    (objname,objlist)
  83.  * LintLibraryTarget        (libname,srclist)
  84.  * NormalLintTarget        (srclist)
  85.  * LintTarget            ()
  86.  * LinkSourceFile        (src,dir)
  87.  * LinkFile            (tofile,fromfile)
  88.  * MakeSubincludesForBuild    (step,dir,srclist)
  89.  * NamedTargetSubdirs        (name,dirs,verb,flags,subname)
  90.  * NamedMakeSubdirs        (name,dirs)
  91.  * MakeSubdirs            (dirs)
  92.  * DependSubdirs        (dirs)
  93.  * ForceSubdirs            (dirs)
  94.  * InstallSubdirs        (dirs)
  95.  * InstallManSubdirs        (dirs)
  96.  * IncludesSubdirs        (dirs)
  97.  * NamedCleanSubdirs        (name,dirs)
  98.  * CleanSubdirs            (dirs)
  99.  * NamedTagSubdirs        (name,dirs)
  100.  * TagSubdirs            (dirs)
  101.  * MakeLintSubdirs        (dirs,target,subtarget)
  102.  * LintSubdirs            (dirs)
  103.  * MakeLintLibSubdirs        (dirs)
  104.  * MakeMakeSubdirs        (dirs,target)
  105.  * MakeNsubdirMakefiles        ()
  106.  * MakefileSubdirs        (dirs)
  107.  * CppScriptTarget        (dst,src,defs,deplist)
  108.  * MakeScriptFromCpp        (name,defs)
  109.  * CppFileTarget        (dst,src,defs,deplist)
  110.  * MakeDirectories        (step,dirs)
  111.  * MakeFontsDir            (deplist)
  112.  * MakeFonts            ()
  113.  * InstallFontObjs        (objs,dest)
  114.  * InstallFonts            (dest)
  115.  * InstallFontAliases        (dest)
  116.  * FontSrc            (basename)
  117.  * FontBaseObj            (basename)
  118.  * FontBaseObj            (basename)
  119.  * InstallFontScale        (dest)
  120.  * FontSrc            (basename)
  121.  * FontBaseObj            (basename)
  122.  * FontBaseObj            (basename)
  123.  * UncompressedFontTarget    (basename)
  124.  * UncompressedFontTarget    (basename)
  125.  * CompressedFontTarget        (basename)
  126.  * FontTarget            (basename)
  127.  * FontObj            (basename)
  128.  * FontTarget            (basename)
  129.  * FontObj            (basename)
  130.  * AllTarget            (depends)
  131.  *
  132.  *
  133.  * The following are in Imake.tmpl:
  134.  *
  135.  * Concat            (a,b)
  136.  * Concat3            (a,b,c)
  137.  * 
  138.  *
  139.  * The following are in specific <os>Lib.rules:
  140.  *
  141.  * SharedLibraryTarget        (libname,rev,solist,down,up)
  142.  * SharedLibraryDataTarget    (libname,rev,salist)
  143.  * InstallSharedLibrary        (libname,rev,dest)
  144.  * InstallSharedLibraryData    (libname,rev,dest)
  145.  * 
  146.  */
  147.  
  148. #define NullParameter
  149.  
  150. /* if [ -d ] or [ ! -d ] causes make to fail, define this as - */
  151. #ifndef DirFailPrefix
  152. #define DirFailPrefix
  153. #endif
  154.  
  155. /*
  156.  * SaberProgramTarget - generate rules to make Saber-C read in sources and
  157.  * objects.
  158.  */
  159. #ifndef SaberProgramTarget
  160. #if HasSaberC
  161. #define SaberProgramTarget(program,srclist,objlist,locallibs,syslibs)    @@\
  162. Concat(saber_,program):: srclist                    @@\
  163.     XCOMM load $(ALLDEFINES) srclist locallibs $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) syslibs @@\
  164.                                     @@\
  165. Concat(osaber_,program):: objlist                    @@\
  166.     XCOMM load $(ALLDEFINES) objlist locallibs $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) syslibs
  167.  
  168. #else
  169. #define SaberProgramTarget(program,srclist,objlist,locallibs,syslibs) /**/
  170. #endif
  171. #endif
  172.  
  173. #ifndef RemoveTargetProgram
  174. #if RemoveTargetProgramByMoving
  175. #define RemoveTargetProgram(program) \
  176. if [ -f program ]; then $(RM) Concat(program,~); $(MV) program Concat(program,~); fi
  177. #else
  178. #define RemoveTargetProgram(program) $(RM) program
  179. #endif
  180. #endif
  181.  
  182. #ifndef MakeDir
  183. #define MakeDir(dir) DirFailPrefix@if [ -d dir ]; then set +x; \    @@\
  184.         else (set -x; $(MKDIRHIER) dir); fi
  185. #endif
  186.  
  187. #ifndef BuildIncludes
  188. #define BuildIncludes(srclist,dstsubdir,dstupdir)            @@\
  189. includes::                                @@\
  190.     MakeDir($(BUILDINCDIR)/dstsubdir)                @@\
  191.     @(set -x; cd $(BUILDINCDIR)/dstsubdir; for i in srclist; do \    @@\
  192.         $(RM) $$i; \                        @@\
  193.         $(LN) $(BUILDINCTOP)/dstupdir/$(CURRENT_DIR)/$$i .; \    @@\
  194.     done)
  195. #endif /* BuildIncludes */
  196.  
  197. /*
  198.  * NormalProgramTarget - generate rules to compile and link the indicated 
  199.  * program; since it does not use any default object files, it may be used for
  200.  * multiple programs in the same Imakefile.
  201.  */
  202. #ifndef NormalProgramTarget
  203. #define    NormalProgramTarget(program,objects,deplibs,locallibs,syslibs)    @@\
  204. program: objects deplibs                        @@\
  205.     RemoveTargetProgram($@)                        @@\
  206.     $(CC) -o $@ objects $(LDOPTIONS) locallibs $(LDLIBS) syslibs $(EXTRA_LOAD_FLAGS) @@\
  207.                                     @@\
  208. clean::                                    @@\
  209.     $(RM) program
  210. #endif /* NormalProgramTarget */
  211.  
  212.  
  213. #ifndef SetUIDProgramTarget
  214. #define SetUIDProgramTarget NormalProgramTarget
  215. #endif
  216.  
  217.  
  218. /*
  219.  * SingleProgramTarget - obsolete version of NormalProgramTarget that does
  220.  * not have deplibs.
  221.  */
  222. #ifndef SingleProgramTarget
  223. #define    SingleProgramTarget(program,objects,locallibs,syslibs)        @@\
  224. NormalProgramTarget(program,objects,NullParameter,locallibs,syslibs)
  225. #endif /* SingleProgramTarget */
  226.  
  227. /*
  228.  * SimpleProgramTarget - generate rules for compiling and linking programs
  229.  * that only have one C source file.  It should only be used in Imakefiles 
  230.  * that describe a single program.
  231.  */
  232. #ifndef SimpleProgramTarget
  233. #define    SimpleProgramTarget(program)                    @@\
  234.            OBJS = program.o                        @@\
  235.            SRCS = program.c                        @@\
  236.                                     @@\
  237. ComplexProgramTarget(program)
  238. #endif /* SimpleProgramTarget */
  239.  
  240.  
  241.  
  242. /*
  243.  * ComplexProgramTarget - generate rules for compiling and linking the 
  244.  * program specified by $(OBJS) and $(SRCS), installing the program and its
  245.  * man page, and generating dependencies.  It should only be used in 
  246.  * Imakefiles that describe a single program.
  247.  */
  248. #ifndef ComplexProgramTarget
  249. #define    ComplexProgramTarget(program)                    @@\
  250.         PROGRAM = program                        @@\
  251.                                     @@\
  252. AllTarget(program)                            @@\
  253.                                     @@\
  254. program: $(OBJS) $(DEPLIBS)                        @@\
  255.     RemoveTargetProgram($@)                        @@\
  256.     $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) @@\
  257.                                     @@\
  258. SaberProgramTarget(program,$(SRCS),$(OBJS),$(LOCAL_LIBRARIES),NullParameter) @@\
  259.                                     @@\
  260. InstallProgram(program,$(BINDIR))                    @@\
  261. InstallManPage(program,$(MANDIR))                    @@\
  262. DependTarget()                                @@\
  263. LintTarget()                                @@\
  264.                                     @@\
  265. clean::                                    @@\
  266.     $(RM) $(PROGRAM)
  267. #endif /* ComplexProgramTarget */
  268.  
  269.  
  270. /*
  271.  * ComplexProgramTarget_1 - generate rules for compiling and linking the
  272.  * program specified by $(OBJS1) and $(SRCS1), installing the program and its
  273.  * man page, and generating dependencies for it and any programs described
  274.  * by $(SRCS2) and $(SRCS3).  It should be used to build the primary 
  275.  * program in Imakefiles that describe multiple programs.
  276.  */
  277. #ifndef ComplexProgramTarget_1
  278. #define    ComplexProgramTarget_1(program,locallib,syslib)            @@\
  279.             OBJS = $(OBJS1) $(OBJS2) $(OBJS3)                @@\
  280.             SRCS = $(SRCS1) $(SRCS2) $(SRCS3)                @@\
  281.                                     @@\
  282. AllTarget($(PROGRAMS))                            @@\
  283.                                     @@\
  284. program: $(OBJS1) $(DEPLIBS1)                        @@\
  285.     RemoveTargetProgram($@)                        @@\
  286.     $(CC) -o $@ $(LDOPTIONS) $(OBJS1) locallib $(LDLIBS) syslib $(EXTRA_LOAD_FLAGS) @@\
  287.                                     @@\
  288. InstallProgram(program,$(BINDIR))                    @@\
  289. InstallManPage(program,$(MANDIR))                    @@\
  290.                                     @@\
  291. SaberProgramTarget(program,$(SRCS1),$(OBJS1),locallib,syslib)        @@\
  292.                                     @@\
  293. DependTarget()                                @@\
  294. LintTarget()                                @@\
  295.                                     @@\
  296. clean::                                    @@\
  297.     $(RM) $(PROGRAMS)
  298. #endif /* ComplexProgramTarget_1 */
  299.  
  300.  
  301. /*
  302.  * ComplexProgramTarget_2 - generate rules for compiling and linking the
  303.  * program specified by $(OBJS2) and $(SRCS2) and installing the program and
  304.  * man page.  It should be used to build the second program in Imakefiles 
  305.  * describing more than one program.
  306.  */
  307. #ifndef ComplexProgramTarget_2
  308. #define    ComplexProgramTarget_2(program,locallib,syslib)            @@\
  309. program: $(OBJS2) $(DEPLIBS2)                        @@\
  310.     RemoveTargetProgram($@)                        @@\
  311.     $(CC) -o $@ $(LDOPTIONS) $(OBJS2) locallib $(LDLIBS) syslib $(EXTRA_LOAD_FLAGS) @@\
  312.                                     @@\
  313. SaberProgramTarget(program,$(SRCS2),$(OBJS2),locallib,syslib)        @@\
  314.                                     @@\
  315. InstallProgram(program,$(BINDIR))                    @@\
  316. InstallManPage(program,$(MANDIR))
  317. #endif /* ComplexProgramTarget_2 */
  318.  
  319.  
  320. /*
  321.  * ComplexProgramTarget_3 - generate rules for compiling and linking the
  322.  * program specified by $(OBJS3) and $(SRCS3) and installing the program and
  323.  * man page.  It should be used to build the third program in Imakefiles 
  324.  * describing more than one program.
  325.  */
  326. #ifndef ComplexProgramTarget_3
  327. #define    ComplexProgramTarget_3(program,locallib,syslib)            @@\
  328. program: $(OBJS3) $(DEPLIBS3)                        @@\
  329.     RemoveTargetProgram($@)                        @@\
  330.     $(CC) -o $@ $(LDOPTIONS) $(OBJS3) locallib $(LDLIBS) syslib $(EXTRA_LOAD_FLAGS) @@\
  331.                                     @@\
  332. SaberProgramTarget(program,$(SRCS3),$(OBJS3),locallib,syslib)        @@\
  333.                                     @@\
  334. InstallProgram(program,$(BINDIR))                    @@\
  335. InstallManPage(program,$(MANDIR))
  336. #endif /* ComplexProgramTarget_3 */
  337.  
  338.  
  339.  
  340. /*
  341.  * ServerTarget - generate rules to compile, link, and relink an X server.
  342.  */
  343. #ifndef ServerTarget
  344. #define    ServerTarget(server,subdirs,objects,libs,syslibs)        @@\
  345. server: subdirs objects libs                        @@\
  346.     -@if [ -f server ]; then set -x; \                @@\
  347.         $(MV) server server.bak; else exit 0; fi        @@\
  348.     $(CC) $(CDEBUGFLAGS) $(CCOPTIONS) -o server objects libs $(EXTRA_LIBRARIES) syslibs $(EXTRA_LOAD_FLAGS) @@\
  349.                                     @@\
  350. Concat(load,server):                            @@\
  351.     -@if [ -f server ]; then set -x; \                @@\
  352.         $(MV) server server.bak; else exit 0; fi        @@\
  353.     $(CC) $(CDEBUGFLAGS) $(CCOPTIONS) -o server objects libs $(EXTRA_LIBRARIES) syslibs $(EXTRA_LOAD_FLAGS)
  354. #endif /* ServerTarget */
  355.  
  356.  
  357. #if DoRanlibCmd
  358. #define RanLibrary(args) $(RANLIB) args
  359. #else
  360. #define RanLibrary(args) /**/
  361. #endif
  362.  
  363. /*
  364.  * InstallLibrary - generate rules to install the indicated library.
  365.  */
  366. #ifndef InstallLibrary
  367. #define    InstallLibrary(libname,dest)                    @@\
  368. install:: Concat(lib,libname.a)                        @@\
  369.     MakeDir($(DESTDIR)dest)                        @@\
  370.     $(INSTALL) -c $(INSTLIBFLAGS) Concat(lib,libname.a) $(DESTDIR)dest @@\
  371.     RanLibrary($(RANLIBINSTFLAGS) Concat($(DESTDIR)dest/lib,libname.a))
  372. #endif /* InstallLibrary */
  373.  
  374. /*
  375.  * MergeIntoInstalledLibrary - generate rules to merge one library into another
  376.  */
  377. #ifndef MergeIntoInstalledLibrary
  378. #define MergeIntoInstalledLibrary(tolib,fromlib)            @@\
  379. install::  fromlib                            @@\
  380.     $(SCRIPTSRC)/mergelib $(DESTDIR)tolib fromlib
  381. #endif /* MergeIntoInstalledLibrary */
  382.  
  383. /*
  384.  * InstallLibraryAlias - generate rules to create a link from one library name
  385.  * to another for the purposes of aliasing.
  386.  */
  387. #ifndef InstallLibraryAlias
  388. #define    InstallLibraryAlias(libname,alias,dest)                @@\
  389. install::                                @@\
  390.     -(cd $(DESTDIR)dest; \                        @@\
  391.         $(RM) Concat(lib,alias.a); \                @@\
  392.         $(LN) Concat(lib,libname.a) Concat(lib,alias.a))
  393. #endif /* InstallLibraryAlias */
  394.  
  395.  
  396. /*
  397.  * InstallLintLibrary - generate rules to install the indicated lint library.
  398.  */
  399. #ifndef InstallLintLibrary
  400. #define    InstallLintLibrary(libname,dest)                @@\
  401. install.ln:: Concat(llib-l,libname.ln)                    @@\
  402.     MakeDir($(DESTDIR)dest)                        @@\
  403.     $(INSTALL) -c $(INSTLIBFLAGS) Concat(llib-l,libname.ln) $(DESTDIR)dest
  404. #endif /* InstallLintLibrary */
  405.  
  406.  
  407. /*
  408.  * InstallManPageLong - generate rules to install the indicated manual page,
  409.  * giving it an alternate name.  This is used for installing man pages whose
  410.  * base name without the .man suffix would normally be longer than 8 characters
  411.  * (the limit for using source code control systems on files systems with 
  412.  * short file names).
  413.  */
  414. #ifndef InstallManPageLong
  415. #define    InstallManPageLong(file,destdir,dest)                @@\
  416. install.man:: file.man                            @@\
  417.     MakeDir($(DESTDIR)destdir)                    @@\
  418.     $(INSTALL) -c $(INSTMANFLAGS) file.man $(DESTDIR)destdir/dest.$(MANSUFFIX)
  419. #endif /* InstallManPageLong */
  420.  
  421.  
  422. /*
  423.  * InstallManPage - generate rules to install the indicated manual page.
  424.  */
  425. #ifndef InstallManPage
  426. #define    InstallManPage(file,destdir)                    @@\
  427. InstallManPageLong(file,destdir,file)
  428. #endif /* InstallManPage */
  429.  
  430.  
  431. /*
  432.  * InstallManPageAliases - generate rules to install manual page aliases.
  433.  */
  434. #ifndef InstallManPageAliases
  435. #define    InstallManPageAliases(file,destdir,aliases)            @@\
  436. install.man::                                @@\
  437.     @(TMP=/tmp/tmp.$$$$; \                        @@\
  438.     $(RM) $${TMP}; \                        @@\
  439.     echo .so `basename destdir`/file.$(MANSUFFIX) > $${TMP}; \    @@\
  440.     for i in aliases; do (set -x; \                    @@\
  441.     $(INSTALL) -c $(INSTMANFLAGS) $${TMP} $(DESTDIR)destdir/$$i.$(MANSUFFIX)); \ @@\
  442.     done; \                                @@\
  443.     $(RM) $${TMP})
  444. #endif /* InstallManPageAliases */
  445.  
  446.  
  447. /*
  448.  * InstallNamedNonExec - generate rules to install a data file
  449.  */
  450. #ifndef InstallNamedNonExec
  451. #define    InstallNamedNonExec(srcname,dstname,dest)            @@\
  452. install:: srcname                            @@\
  453.     MakeDir($(DESTDIR)dest)                        @@\
  454.     $(INSTALL) -c $(INSTDATFLAGS) srcname $(DESTDIR)dest/dstname
  455. #endif /* InstallNamedNonExec */
  456.  
  457.  
  458. /*
  459.  * InstallNonExecFile - generate rules to install a data file
  460.  */
  461. #ifndef InstallNonExecFile
  462. #define    InstallNonExecFile(file,dest)                    @@\
  463. install:: file                                @@\
  464.     MakeDir($(DESTDIR)dest)                        @@\
  465.     $(INSTALL) -c $(INSTDATFLAGS) file $(DESTDIR)dest
  466. #endif /* InstallNonExecFile */
  467.  
  468.  
  469. /*
  470.  * InstallNonExec - generate rules to install a data file, but does not
  471.  * try to create the destination directory (deprecated)
  472.  */
  473. #ifndef InstallNonExec
  474. #define    InstallNonExec(file,dest)                    @@\
  475. install:: file                                @@\
  476.     $(INSTALL) -c $(INSTDATFLAGS) file $(DESTDIR)dest
  477. #endif /* InstallNonExec */
  478.  
  479.  
  480. /*
  481.  * InstallProgramWithFlags - generate rules to install an executable program
  482.  * using given install flags.
  483.  */
  484. #ifndef InstallProgramWithFlags
  485. #define InstallProgramWithFlags(program,dest,flags)            @@\
  486. install:: program                            @@\
  487.     MakeDir($(DESTDIR)dest)                        @@\
  488.     $(INSTALL) -c $(INSTPGMFLAGS) flags program $(DESTDIR)dest
  489. #endif /* InstallProgramWithFlags */
  490.  
  491.  
  492. /*
  493.  * InstallProgram - generate rules to install an executable program using any
  494.  * special install flags set in $(INSTALLFLAGS).
  495.  */
  496. #ifndef InstallProgram
  497. #define    InstallProgram(program,dest)                    @@\
  498. InstallProgramWithFlags(program,dest,NullParameter)
  499. #endif /* InstallProgram */
  500.  
  501.  
  502.  
  503. /*
  504.  * InstallScript - install a shell script.
  505.  */
  506. #ifndef InstallScript
  507. #define    InstallScript(program,dest)                    @@\
  508. install:: program.script                        @@\
  509.     MakeDir($(DESTDIR)dest)                        @@\
  510.     $(INSTALL) -c $(INSTBINFLAGS) program.script $(DESTDIR)dest/program
  511. #endif /* InstallScript */
  512.  
  513.  
  514. /*
  515.  * InstallNamedProg - install a program with renaming and no stripping.
  516.  */
  517. #ifndef InstallNamedProg
  518. #define    InstallNamedProg(srcname,dstname,dest)                @@\
  519. install:: srcname                            @@\
  520.     MakeDir($(DESTDIR)dest)                        @@\
  521.     $(INSTALL) -c $(INSTBINFLAGS) srcname $(DESTDIR)dest/dstname
  522. #endif /* InstallNamedProg */
  523.  
  524.  
  525. /*
  526.  * LinkFileList - link a list of list of files from one place to another
  527.  */
  528. #ifndef LinkFileList
  529. #define LinkFileList(step,list,dir,sub)                    @@\
  530. step:: list                                @@\
  531.     @case '${MFLAGS}' in *[i]*) set +e;; esac; \            @@\
  532.     echo "    cd" dir; cd dir; \                    @@\
  533.     for i in list; do (set -x; $(RM) $$i; $(LN) sub/$$i .); done
  534. #endif
  535.  
  536.  
  537. /*
  538.  * InstallMultipleDestFlags - generate rules to install multiple files at
  539.  * once during a particular step in the build using a specific set of install 
  540.  * flags.
  541.  */
  542. #ifndef InstallMultipleDestFlags
  543. #define InstallMultipleDestFlags(step,list,dest,flags)            @@\
  544. step:: list                                @@\
  545.     MakeDir($(DESTDIR)dest)                        @@\
  546.     @case '${MFLAGS}' in *[i]*) set +e;; esac; \            @@\
  547.     for i in list; do \                        @@\
  548.         (set -x; $(INSTALL) -c flags $$i $(DESTDIR)dest); \    @@\
  549.     done
  550. #endif /* InstallMultipleDestFlags */
  551.  
  552.  
  553. /*
  554.  * InstallMultipleDest - generate rules to install multiple files at once
  555.  * during a particular step in the build using any install flags set in 
  556.  * $(INSTALLFLAGS).
  557.  */
  558. #ifndef InstallMultipleDest
  559. #define InstallMultipleDest(step,list,dest)                @@\
  560. InstallMultipleDestFlags(step,list,dest,$(INSTALLFLAGS))
  561. #endif /* InstallMultipleDest */
  562.  
  563. /*
  564.  * InstallMultiple - generate rules to install multiple files at once 
  565.  * during the install step of the build using any install flags set in 
  566.  * $(INSTALLFLAGS).
  567.  */
  568. #ifndef InstallMultiple
  569. #define    InstallMultiple(list,dest)                    @@\
  570. InstallMultipleDest(install,list,dest)
  571. #endif /* InstallMultiple */
  572.  
  573.  
  574. /*
  575.  * InstallMultipleFlags - generate rules to install multiple files at once
  576.  * during the install step of the build using the given install flags.
  577.  */
  578. #ifndef InstallMultipleFlags
  579. #define InstallMultipleFlags(list,dest,flags)                @@\
  580. InstallMultipleDestFlags(install,list,dest,flags)
  581. #endif /* InstallMultipleFlags */
  582.  
  583.  
  584. /*
  585.  * InstallMultipleMan - generate rules to install a variety of manual pages
  586.  * during the install.man step of the build.
  587.  */
  588. #ifndef InstallMultipleMan
  589. #define InstallMultipleMan(list,dest)                    @@\
  590. InstallMultipleDestFlags(install.man,list,dest,$(INSTMANFLAGS))
  591. #endif /* InstallMultipleMan */
  592.  
  593.  
  594. /*
  595.  * InstallAppDefaults - generate rules to install appliation default files 
  596.  * if the InstallAppDefFiles configuration parameter is set.
  597.  */
  598. #ifndef InstallAppDefaults
  599. #if InstallAppDefFiles
  600. #define    InstallAppDefaults(class)                    @@\
  601. install:: class.ad                            @@\
  602.     MakeDir($(DESTDIR)$(XAPPLOADDIR))                @@\
  603.     $(INSTALL) -c $(INSTAPPFLAGS) class.ad $(DESTDIR)$(XAPPLOADDIR)/class
  604. #else
  605. #define    InstallAppDefaults(class)
  606. #endif /* InstallAppDefFiles */
  607. #endif /* InstallAppDefaults */
  608.  
  609. /*
  610.  * InstallAppDefaultsLong - generate rules to install appliation default files 
  611.  * if the InstallAppDefFiles configuration parameter is set.
  612.  */
  613. #ifndef InstallAppDefaultsLong
  614. #if InstallAppDefFiles
  615. #define    InstallAppDefaultsLong(file,class)                @@\
  616. install:: file.ad                            @@\
  617.     MakeDir($(DESTDIR)$(XAPPLOADDIR))                @@\
  618.     $(INSTALL) -c $(INSTAPPFLAGS) file.ad $(DESTDIR)$(XAPPLOADDIR)/class
  619. #else
  620. #define    InstallAppDefaultsLong(file,class)
  621. #endif /* InstallAppDefFiles */
  622. #endif /* InstallAppDefaultsLong */
  623.  
  624.  
  625.  
  626.  
  627. /*
  628.  * DependDependency - generate rules to build the makedepend program if 
  629.  * this Imakefile is within the source tree.
  630.  */
  631. #ifndef DependDependency
  632. #ifdef UseInstalled
  633. #define DependDependency() /**/
  634. #else
  635. #define DependDependency()                         @@\
  636. depend:: $(DEPEND)                            @@\
  637.                                     @@\
  638. $(DEPEND):                                @@\
  639.     @echo "checking $@ over in $(DEPENDSRC) first..."; \        @@\
  640.     cd $(DEPENDSRC); $(MAKE); \                    @@\
  641.     echo "okay, continuing in $(CURRENT_DIR)"
  642.  
  643. #endif /* UseInstalled */
  644. #endif /* DependDependency */
  645.  
  646.  
  647. /*
  648.  * DependTarget - generate rules to compute dependencies for all files listed
  649.  * in $(SRCS).
  650.  */
  651. #ifndef DependTarget
  652. #define    DependTarget()                            @@\
  653. DependDependency()                            @@\
  654.                                     @@\
  655. depend::                                @@\
  656.     $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  657. #endif /* DependTarget */
  658.  
  659.  
  660. /*
  661.  * DependTarget3 - generate rules to compute dependencies for all files given.
  662.  */
  663. #ifndef DependTarget3
  664. #define    DependTarget3(srcs1,srcs2,srcs3)                @@\
  665. DependDependency()                            @@\
  666.                                     @@\
  667. depend::                                @@\
  668.     $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- srcs1    @@\
  669.     $(DEPEND) -a $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- srcs2    @@\
  670.     $(DEPEND) -a $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- srcs3
  671. #endif /* DependTarget3 */
  672.  
  673.  
  674. /*
  675.  * CleanTarget - generate rules to remove any garbage files; the #* is here
  676.  * instead of in the definition of RM_CMD because System V will treat the 
  677.  * pound sign in the RM_CMD variable as a comment.
  678.  */
  679. #ifndef CleanTarget
  680. #define    CleanTarget()                            @@\
  681. clean::                                    @@\
  682.     $(RM_CMD) "#"*
  683. #endif /* CleanTarget */
  684.  
  685.  
  686. /*
  687.  * TagsTarget - generate rules to compute tags files for C source code.
  688.  */
  689. #ifndef TagsTarget
  690. #define    TagsTarget()                            @@\
  691. tags::                                    @@\
  692.     $(TAGS) -w *.[ch]                        @@\
  693.     $(TAGS) -xw *.[ch] > TAGS
  694. #endif /* TagsTarget */
  695.  
  696.  
  697. /*
  698.  * ImakeDependency - generate rules to compile imake if this Imakefile is
  699.  * within the source tree.
  700.  */
  701. #ifndef ImakeDependency
  702. #ifdef UseInstalled
  703. #define ImakeDependency(target) /**/
  704. #else
  705. #define ImakeDependency(target)                        @@\
  706. target:: $(IMAKE)                            @@\
  707.                                     @@\
  708. $(IMAKE):                                @@\
  709.     @(cd $(IMAKESRC); if [ -f Makefile ]; then \            @@\
  710.     echo "checking $@ in $(IMAKESRC) first..."; $(MAKE) all; else \    @@\
  711.     echo "bootstrapping $@ from Makefile.ini in $(IMAKESRC) first..."; \    @@\
  712.     $(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"; fi; \    @@\
  713.     echo "okay, continuing in $(CURRENT_DIR)")
  714. #endif /* UseInstalled */
  715. #endif /* ImakeDependency */
  716.  
  717.  
  718. /*
  719.  * BuildMakefileTarget - generate rules to build a Makefile from an Imakefile
  720.  * and any special imake flags.  This is generally done automatically by the
  721.  * template or by any special Imakefiles.  The first argument exists just
  722.  * because imakeflags is usually empty and some preprocessors will complain
  723.  * if an empty argument is passed as the sole argument to a macro.
  724.  */
  725. #ifndef BuildMakefileTarget
  726. #define    BuildMakefileTarget(notused,imakeflags)                @@\
  727. ImakeDependency(Makefile)                        @@\
  728.                                     @@\
  729. Makefile::                                 @@\
  730.     -@if [ -f Makefile ]; then set -x; \                @@\
  731.         $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \    @@\
  732.     else exit 0; fi                            @@\
  733.     $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) imakeflags
  734.  
  735. #endif /* BuildMakefileTarget */
  736.  
  737.  
  738. /*
  739.  * MakefileTarget - generate rules to build a normal Makefile.
  740.  */
  741. #ifndef MakefileTarget
  742. #define MakefileTarget()                        @@\
  743. BuildMakefileTarget(Imakefile,NullParameter)
  744. #endif /* MakefileTarget */
  745.  
  746.  
  747. /*
  748.  * LibMkdir - helper for creating library object subdirectories
  749.  */
  750. #ifndef LibMkdir
  751. #define LibMkdir(dir) DirFailPrefix@if [ -d dir ]; then exit 0; else set -x; mkdir dir; fi
  752. #endif
  753.  
  754. /*
  755.  * LibCleanDir - helper for cleaning library object subdirectories
  756.  */
  757. #ifndef LibCleanDir
  758. #define LibCleanDir(dir) -@if [ -d dir ]; then \            @@\
  759.         (set -x; cd dir; $(RM) *.o); else exit 0; fi
  760. #endif
  761.  
  762. /*
  763.  * ObjectCompile - compile fragment for a normal object file
  764.  */
  765. #ifndef ObjectCompile
  766. #define ObjectCompile(options) $(RM) $@                    @@\
  767.     $(CC) -c $(CFLAGS) options $*.c
  768. #endif
  769.  
  770. /*
  771.  * NormalLibObjCompile - compile fragment for a normal library object file
  772.  */
  773. #ifndef NormalLibObjCompile
  774. #define NormalLibObjCompile(options) ObjectCompile(options)
  775. #endif
  776.  
  777. /*
  778.  * NormalSharedLibObjCompile - compile fragment for shared object when
  779.  * a normal library is not being built
  780.  */
  781. #ifndef NormalSharedLibObjCompile
  782. #define NormalSharedLibObjCompile(options) NormalLibObjCompile(options $(SHLIBDEF) $(SHAREDCODEDEF) $(PICFLAGS))
  783. #endif
  784.  
  785. /*
  786.  * LibObjCompile - compile fragment for shared/profiled/debugged objects
  787.  */
  788. #ifndef LibObjCompile
  789. #define LibObjCompile(dir,options) $(RM) $@ dir/$@            @@\
  790.     $(CC) -c $(CCOPTIONS) $(ALLDEFINES) options $*.c        @@\
  791.     $(MV) $@ dir/$@
  792. #endif
  793.  
  794. /*
  795.  * DebuggedLibObjCompile - compile fragment for debugged objects
  796.  */
  797. #ifndef DebuggedLibObjCompile
  798. #define DebuggedLibObjCompile(options) LibObjCompile(debugger,-g options)
  799. #endif
  800.  
  801. /*
  802.  * ProfiledLibObjCompile - compile fragment for profiled objects
  803.  */
  804. #ifndef ProfiledLibObjCompile
  805. #define ProfiledLibObjCompile(options) LibObjCompile(profiled,-pg options)
  806. #endif
  807.  
  808. /*
  809.  * SharedLibObjCompile - compile fragment for shared objects
  810.  */
  811. #ifndef SharedLibObjCompile
  812. #define SharedLibObjCompile(options) LibObjCompile(shared,options $(SHLIBDEF) $(SHAREDCODEDEF) $(PICFLAGS) $(CDEBUGFLAGS))
  813. #endif
  814.  
  815. /*
  816.  * NormalLibraryObjectRule - for simple libraries
  817.  */
  818. #ifndef NormalLibraryObjectRule
  819. #define    NormalLibraryObjectRule()                    @@\
  820. .c.o:                                    @@\
  821.     ObjectCompile($(_NOOP_))
  822. #endif /* NormalLibraryObjectRule */
  823.  
  824.  
  825. #ifndef NormalFortranObjectRule
  826. #define NormalFortranObjectRule()                    @@\
  827. .f.o:                                    @@\
  828.     $(RM) $@                            @@\
  829.     $(FC) -c $(FCFLAGS) $*.f
  830. #endif
  831.  
  832. #ifndef ObjectFromSpecialSource
  833. #define ObjectFromSpecialSource(dst,src,flags)                @@\
  834. dst.c:  src.c                                @@\
  835.     $(RM) $@                            @@\
  836.     $(LN) $? $@                            @@\
  837.                                     @@\
  838. dst.o:  dst.c                                @@\
  839.     ObjectCompile(flags)                        @@\
  840.                                     @@\
  841. depend::  dst.c                                @@\
  842.                                     @@\
  843. clean::                                    @@\
  844.     $(RM) dst.c
  845. #endif /* ObjectFromSpecialSource */
  846.  
  847. /*
  848.  * SpecialObjectRule - generate rules to compile a file with special flags.
  849.  */
  850. #ifndef SpecialObjectRule
  851. #define SpecialObjectRule(objs,depends,options)                @@\
  852. objs:    depends                                @@\
  853.     ObjectCompile(options)
  854. #endif /* SpecialObjectRule */
  855.  
  856.  
  857. /*
  858.  * NormalLibraryTarget - generate rules to create a library.
  859.  */
  860. #ifndef NormalLibraryTarget
  861. #define    NormalLibraryTarget(libname,objlist)                @@\
  862. AllTarget(Concat(lib,libname.a))                    @@\
  863.                                     @@\
  864. Concat(lib,libname.a): objlist                        @@\
  865.     $(RM) $@                            @@\
  866.     $(AR) $@ objlist                        @@\
  867.     RanLibrary($@)
  868. #endif /* NormalLibraryTarget */
  869.  
  870.  
  871. /*
  872.  * NormalLibraryTarget2 - generate rules to create a library in two steps.
  873.  * This is used to create libraries with large numbers of files.
  874.  */
  875. #ifndef NormalLibraryTarget2
  876. #define    NormalLibraryTarget2(libname,objlist1,objlist2)            @@\
  877. AllTarget(Concat(lib,libname.a))                    @@\
  878.                                     @@\
  879. Concat(lib,libname.a): objlist1 objlist2                @@\
  880.     $(RM) $@                            @@\
  881.     $(AR) $@ objlist1                        @@\
  882.     $(AR) $@ objlist2                        @@\
  883.     RanLibrary($@)
  884. #endif /* NormalLibraryTarget2 */
  885.  
  886.  
  887. /*
  888.  * NormalLibraryTarget3 - generate rules to create a library in three steps.
  889.  * This is used to create libraries with very large numbers of files.
  890.  */
  891. #ifndef NormalLibraryTarget3
  892. #define    NormalLibraryTarget3(libname,objlist1,objlist2,objlist3)    @@\
  893. AllTarget(Concat(lib,libname.a))                    @@\
  894.                                     @@\
  895. Concat(lib,libname.a): objlist1 objlist2 objlist3            @@\
  896.     $(RM) $@                            @@\
  897.     $(AR) $@ objlist1                        @@\
  898.     $(AR) $@ objlist2                        @@\
  899.     $(AR) $@ objlist3                        @@\
  900.     RanLibrary($@)
  901. #endif /* NormalLibraryTarget3 */
  902.  
  903.  
  904. /*
  905.  * NormalDepLibraryTarget - generate rules to create a library.
  906.  */
  907. #ifndef NormalDepLibraryTarget
  908. #define    NormalDepLibraryTarget(libname,deplist,objlist)            @@\
  909. AllTarget(Concat(lib,libname.a))                    @@\
  910.                                     @@\
  911. Concat(lib,libname.a): deplist                        @@\
  912.     $(RM) $@                            @@\
  913.     $(AR) $@ objlist                        @@\
  914.     RanLibrary($@)
  915. #endif /* NormalDepLibraryTarget */
  916.  
  917.  
  918. /*
  919.  * SubdirLibraryRule -
  920.  */
  921. #ifndef SubdirLibraryRule
  922. #define    SubdirLibraryRule(objlist)                    @@\
  923. all:: DONE                                @@\
  924.                                     @@\
  925. DONE: objlist                                @@\
  926.     touch $@                            @@\
  927.                                     @@\
  928. clean::                                    @@\
  929.     $(RM) DONE
  930. #endif /* SubdirLibraryRule */
  931.  
  932.  
  933. /*
  934.  * ProfiledLibraryTarget - generate rules to create a profiled library.
  935.  */
  936. #ifndef ProfiledLibraryTarget
  937. #define    ProfiledLibraryTarget(libname,objlist)                @@\
  938. AllTarget(Concat3(lib,libname,_p.a))                    @@\
  939.                                     @@\
  940. Concat3(lib,libname,_p.a): objlist                    @@\
  941.     $(RM) $@                            @@\
  942.     cd profiled; $(AR) ../$@ objlist                @@\
  943.     RanLibrary($@)
  944.  
  945. #endif /* ProfiledLibraryTarget */
  946.  
  947.  
  948. /*
  949.  * DebuggedLibraryTarget - generate rules to create a debuggable library.
  950.  */
  951. #ifndef DebuggedLibraryTarget
  952. #define    DebuggedLibraryTarget(libname,objlist)                @@\
  953. AllTarget(Concat3(lib,libname,_d.a))                    @@\
  954.                                     @@\
  955. Concat3(lib,libname,_d.a): objlist                    @@\
  956.     $(RM) $@                            @@\
  957.     cd debugger; $(AR) ../$@ objlist                @@\
  958.     RanLibrary($@)
  959.  
  960. #endif /* DebuggedLibraryTarget */
  961.  
  962.  
  963. /*
  964.  * AliasedLibraryTarget - generate rules to link one library to another.
  965.  */
  966. #ifndef AliasedLibraryTarget
  967. #define    AliasedLibraryTarget(libname,alias)                @@\
  968. AllTarget(Concat(lib,alias.a))                        @@\
  969.                                     @@\
  970. Concat(lib,alias.a): Concat(lib,libname.a)                @@\
  971.     $(RM) $@                            @@\
  972.     $(LN) Concat(lib,libname.a) $@
  973. #endif /* AliasedLibraryTarget */
  974.  
  975.  
  976. /*
  977.  * NormalRelocatableTarget - generate rules to produce a relocatable object
  978.  * file instead of a library.  
  979.  */
  980. #ifndef NormalRelocatableTarget
  981. #define    NormalRelocatableTarget(objname,objlist)            @@\
  982. AllTarget(objname.o)                            @@\
  983.                                     @@\
  984. objname.o: objlist                            @@\
  985.     $(RM) $@                            @@\
  986.     $(LD) $(LDCOMBINEFLAGS) objlist -o $@
  987. #endif /* NormalRelocatableTarget */
  988.  
  989.  
  990. /*
  991.  * ProfiledRelocatableTarget - generate rules to produce a profiled relocatable
  992.  * object file instead of a library.
  993.  */
  994. #ifndef ProfiledRelocatableTarget
  995. #define    ProfiledRelocatableTarget(objname,objlist)            @@\
  996. AllTarget(Concat(objname,_p.o))                        @@\
  997.                                     @@\
  998. Concat(objname,_p.o): objlist                        @@\
  999.     $(RM) $@                            @@\
  1000.     $(LD) -X -r objlist -o $@
  1001.  
  1002. #endif /* ProfiledRelocatableTarget */
  1003.  
  1004.  
  1005. /*
  1006.  * DebuggedRelocatableTarget - generate rules to produce a debuggable 
  1007.  * relocatable object file instead of a library.
  1008.  */
  1009. #ifndef DebuggedRelocatableTarget
  1010. #define    DebuggedRelocatableTarget(objname,objlist)            @@\
  1011. AllTarget(Concat(objname,_d.o))                        @@\
  1012.                                     @@\
  1013. Concat(objname,_d.o): objlist                        @@\
  1014.     $(RM) $@                            @@\
  1015.     $(LD) -X -r objlist -o $@
  1016.  
  1017. #endif /* DebuggedRelocatableTarget */
  1018.  
  1019.  
  1020. /*
  1021.  * LintLibraryTarget - generate rules to create a lint library.  Note that the
  1022.  * lint library is always forced to be newer than the library itself.
  1023.  */
  1024. #ifndef LintLibraryTarget
  1025. #define    LintLibraryTarget(libname,srclist)                @@\
  1026. lintlib:: Concat(llib-l,libname.ln)                    @@\
  1027.                                     @@\
  1028. Concat(llib-l,libname.ln): srclist                    @@\
  1029.     $(RM) $@                            @@\
  1030.     $(LINT) Concat($(LINTLIBFLAG),libname) $(LINTFLAGS) srclist
  1031. #endif /* LintLibraryTarget */
  1032.  
  1033.  
  1034. /*
  1035.  * NormalLintTarget - generate rules to lint a set of sources.
  1036.  */
  1037. #ifndef NormalLintTarget
  1038. #define NormalLintTarget(srclist)                    @@\
  1039. lint:                                    @@\
  1040.     $(LINT) $(LINTFLAGS) srclist $(LINTLIBS)            @@\
  1041. lint1:                                    @@\
  1042.     $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  1043. #endif /* NormalLintTarget */
  1044.  
  1045.  
  1046. /*
  1047.  * LintTarget - generate rules to lint $(SRCS)
  1048.  */
  1049. #ifndef LintTarget
  1050. #define LintTarget()                            @@\
  1051. NormalLintTarget($(SRCS))
  1052. #endif
  1053.  
  1054.  
  1055. /*
  1056.  * LinkSourceFile - snag source file from some other directory
  1057.  */
  1058. #ifndef LinkSourceFile
  1059. #define LinkSourceFile(src,dir)                        @@\
  1060. src:  dir/src                                @@\
  1061.     $(RM) $@                            @@\
  1062.     $(LN) $? $@                            @@\
  1063.  
  1064. #endif
  1065.  
  1066.  
  1067. /*
  1068.  * LinkFile - link a file
  1069.  */
  1070. #ifndef LinkFile
  1071. #define LinkFile(tofile,fromfile)                    @@\
  1072. tofile:: fromfile                            @@\
  1073.     $(RM) $@                            @@\
  1074.     $(LN) $? $@
  1075. #endif
  1076.  
  1077.  
  1078. #ifndef MakeSubincludesForBuild
  1079. #define MakeSubincludesForBuild(step,dir,srclist)            @@\
  1080. step::  dir srclist                            @@\
  1081.     @-(list=`echo srclist | sed -e 's/[^ ]*\///g'`; \        @@\
  1082.         set -x; cd dir; $(RM) $$list)                @@\
  1083.     @for i in srclist; do \                        @@\
  1084.         (set -x; cd dir; $(LN) ../$$i .); \            @@\
  1085.     done                                @@\
  1086.                                     @@\
  1087. dir::                                    @@\
  1088.     $(MKDIRHIER) dir                        @@\
  1089.                                     @@\
  1090. clean::                                    @@\
  1091.     @-(if [ -d dir ]; then \                    @@\
  1092.         list=`echo srclist | sed -e 's/[^ ]*\///g'`; \        @@\
  1093.         set -x; cd dir; $(RM) $$list; else exit 0; fi)
  1094. #endif
  1095.  
  1096.  
  1097. /*
  1098.  * NamedTargetSubdirs - recursively make a series of steps
  1099.  */
  1100. #ifndef NamedTargetSubdirs
  1101. #define NamedTargetSubdirs(name,dirs,verb,flags,subname)        @@\
  1102. name::                                    @@\
  1103.     @case '${MFLAGS}' in *[ik]*) set +e;; esac; \            @@\
  1104.     for i in dirs ;\                        @@\
  1105.     do \                                @@\
  1106.         (cd $$i ; echo verb "in $(CURRENT_DIR)/$$i..."; \    @@\
  1107.             $(MAKE) $(MFLAGS) flags subname); \        @@\
  1108.     done
  1109. #endif
  1110.  
  1111.  
  1112. /*
  1113.  * NamedMakeSubdirs - generate rules to do makes in the given subdirectories.
  1114.  * If you want CDEBUGFLAGS passed along to subdirectories, provide a line like
  1115.  * the following in the appropriate Imakefile
  1116.  * 
  1117.  *         #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
  1118.  */
  1119. #ifndef NamedMakeSubdirs
  1120. #define NamedMakeSubdirs(name,dirs) \
  1121. NamedTargetSubdirs(name,dirs,"making" name,PassCDebugFlags,all)
  1122. #endif /* NamedMakeSubdirs */
  1123.  
  1124. #ifndef MakeSubdirs
  1125. #define MakeSubdirs(dirs)                        @@\
  1126. NamedMakeSubdirs(all,dirs)
  1127. #endif /* MakeSubdirs */
  1128.  
  1129.  
  1130. /*
  1131.  * DependSubdirs - generate rules to recursively compute dependencies as
  1132.  * part of the make depend step.
  1133.  */
  1134. #ifndef DependSubdirs
  1135. #define DependSubdirs(dirs) \
  1136. NamedTargetSubdirs(depend,dirs,"depending",NullParameter,depend)
  1137. #endif /* DependSubdirs */
  1138.  
  1139.  
  1140. /*
  1141.  * ForceSubdirs - force make to build subdirectories
  1142.  */
  1143. #ifndef ForceSubdirs
  1144. #define ForceSubdirs(dirs)                        @@\
  1145. dirs: FRC                                @@\
  1146.     @cd $@ ; echo "making all in $(CURRENT_DIR)/$@..."; \        @@\
  1147.     $(MAKE) $(MFLAGS) PassCDebugFlags all                @@\
  1148.                                     @@\
  1149. FRC:
  1150. #endif /* ForceSubdirs */
  1151.  
  1152. /*
  1153.  * InstallSubdirs - generate rules to recursively install programs and files.
  1154.  */
  1155. #ifndef InstallSubdirs
  1156. #define InstallSubdirs(dirs) \
  1157. NamedTargetSubdirs(install,dirs,"installing",DESTDIR='$(DESTDIR)',install)
  1158. #endif /* InstallSubdirs */
  1159.  
  1160.  
  1161. /*
  1162.  * InstallManSubdirs - generate rules to recursively install manual pages.
  1163.  */
  1164. #ifndef InstallManSubdirs
  1165. #define InstallManSubdirs(dirs) \
  1166. NamedTargetSubdirs(install.man,dirs,"installing man pages",DESTDIR='$(DESTDIR)',install.man)
  1167. #endif /* InstallManSubdirs */
  1168.  
  1169.  
  1170. /*
  1171.  * IncludesSubdirs - generate rules to recursively put include files in build
  1172.  */
  1173. #ifndef IncludesSubdirs
  1174. #define IncludesSubdirs(dirs) \
  1175. NamedTargetSubdirs(includes,dirs,including,NullParameter,includes)
  1176. #endif
  1177.  
  1178.  
  1179. /*
  1180.  * CleanSubdirs - generate rules to recursively clean out garbage files.
  1181.  */
  1182. #ifndef NamedCleanSubdirs
  1183. #define NamedCleanSubdirs(name,dirs) \
  1184. NamedTargetSubdirs(name,dirs,"cleaning",RM_CMD='$(RM_CMD)',clean)
  1185. #endif /* NamedCleanSubdirs */
  1186.  
  1187. #ifndef CleanSubdirs
  1188. #define CleanSubdirs(dirs) \
  1189. NamedCleanSubdirs(clean,dirs)
  1190. #endif
  1191.  
  1192.  
  1193. /*
  1194.  * TagSubdirs - generate rules to recursively create tags files.
  1195.  */
  1196. #ifndef NamedTagSubdirs
  1197. #define NamedTagSubdirs(name,dirs) \
  1198. NamedTargetSubdirs(name,dirs,"tagging",TAGS='$(TAGS)',tags)
  1199. #endif /* TagSubdirs */
  1200.  
  1201. #ifndef TagSubdirs
  1202. #define TagSubdirs(dirs) \
  1203. NamedTagSubdirs(tags,dirs)
  1204. #endif
  1205.  
  1206. /*
  1207.  * MakeLintSubdirs - generate rules to recursively lint directories as part 
  1208.  * of the named step.
  1209.  */
  1210. #ifndef MakeLintSubdirs
  1211. #define MakeLintSubdirs(dirs,target,subtarget) \
  1212. NamedTargetSubdirs(target,dirs,"linting" for target and subtarget,DESTDIR='$(DESTDIR)' LINTOPTS='$(LINTOPTS)',subtarget)
  1213. #endif /* MakeLintSubdirs */
  1214.  
  1215.  
  1216. /*
  1217.  * LintSubdirs - generate rules to recursively lint directories as part of 
  1218.  * the make lint step.
  1219.  */
  1220. #ifndef LintSubdirs
  1221. #define LintSubdirs(dirs)                        @@\
  1222. MakeLintSubdirs(dirs,lint,lint)
  1223. #endif /* LintSubdirs */
  1224.  
  1225.  
  1226. /*
  1227.  * MakeLintLibSubdirs - generate rules to recursively create lint libraries.
  1228.  */
  1229. #ifndef MakeLintLibSubdirs
  1230. #define MakeLintLibSubdirs(dirs)                    @@\
  1231. MakeLintSubdirs(dirs,lintlib,lintlib)
  1232. #endif /* MakeLintLibSubdirs */
  1233.  
  1234.  
  1235. /*
  1236.  * MakeMakeSubdirs - generate rules to recursively recreate Makefiles as part
  1237.  * of the specified step in the build.  If $(TOP) is set to an absolute path, 
  1238.  * do not prepend the ../ prefix.  This makes running things outside of the 
  1239.  * source tree to be much easier.
  1240.  */
  1241. #ifndef MakeMakeSubdirs
  1242. #define MakeMakeSubdirs(dirs,target)                    @@\
  1243. target::                                @@\
  1244.     @case '${MFLAGS}' in *[ik]*) set +e;; esac; \            @@\
  1245.     for i in dirs ;\                        @@\
  1246.     do \                                @@\
  1247.         echo "making Makefiles in $(CURRENT_DIR)/$$i..."; \    @@\
  1248.         case "$$i" in \                        @@\
  1249.         ./?*/?*/?*/?*) newtop=../../../../ sub=subsubsubsub;; \    @@\
  1250.         ./?*/?*/?*) newtop=../../../ sub=subsubsub;; \        @@\
  1251.         ./?*/?*)    newtop=../../ sub=subsub;; \        @@\
  1252.         ./?*)       newtop=../ sub=sub;; \            @@\
  1253.         */?*/?*/?*)    newtop=../../../../ sub=subsubsubsub;; \    @@\
  1254.         */?*/?*)    newtop=../../../ sub=subsubsub;; \        @@\
  1255.         */?*)       newtop=../../ sub=subsub;; \        @@\
  1256.         *)        newtop=../ sub=sub;; \            @@\
  1257.         esac; \                            @@\
  1258.         case "$(TOP)" in \                    @@\
  1259.         /?*) newtop=  upprefix=  ;; \                @@\
  1260.         *) upprefix=../ ;; \                    @@\
  1261.         esac; \                            @@\
  1262.         $(MAKE) $${sub}dirMakefiles UPPREFIX=$$upprefix NEWTOP=$$newtop \        @@\
  1263.         MAKEFILE_SUBDIR=$$i NEW_CURRENT_DIR=$(CURRENT_DIR)/$$i;\ @@\
  1264.     done
  1265. #endif /* MakeMakeSubdirs */
  1266.  
  1267.  
  1268. /*
  1269.  * MakeNsubdirMakefiles - generate rules to create sub Makefiles.
  1270.  */
  1271. #ifndef MakeNsubdirMakefiles
  1272. #define MakeNsubdirMakefiles()                        @@\
  1273. subdirMakefiles:                            @@\
  1274.     $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                @@\
  1275.     -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \        @@\
  1276.     $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
  1277.     else exit 0; fi                            @@\
  1278.     cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \    @@\
  1279.     $(MAKE) $(MFLAGS) Makefiles                     @@\
  1280.                                     @@\
  1281. subsubdirMakefiles:                            @@\
  1282.     $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                @@\
  1283.     -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \        @@\
  1284.     $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
  1285.     else exit 0; fi                            @@\
  1286.     cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \    @@\
  1287.     $(MAKE) $(MFLAGS) Makefiles                     @@\
  1288.                                     @@\
  1289. subsubsubdirMakefiles:                            @@\
  1290.     $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                @@\
  1291.     -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \        @@\
  1292.     $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
  1293.     else exit 0; fi @@\
  1294.     cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \    @@\
  1295.     $(MAKE) $(MFLAGS) Makefiles                     @@\
  1296.                                     @@\
  1297. subsubsubsubdirMakefiles:                        @@\
  1298.     $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                @@\
  1299.     -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \        @@\
  1300.     $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
  1301.     else exit 0; fi                         @@\
  1302.     cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \    @@\
  1303.     $(MAKE) $(MFLAGS) Makefiles
  1304. #endif /* MakeNsubdirMakefiles */
  1305.  
  1306.  
  1307. /*
  1308.  * MakefileSubdirs - generate rules to create Makefiles.
  1309.  */
  1310. #ifndef MakefileSubdirs
  1311. #define MakefileSubdirs(dirs)                        @@\
  1312. MakeMakeSubdirs(dirs,Makefiles)                        @@\
  1313.                                     @@\
  1314. MakeNsubdirMakefiles()
  1315. #endif /* MakefileSubdirs */
  1316.  
  1317. /*
  1318.  * Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM
  1319.  * to cpp, because that trick does not work on all ANSI C preprocessors.
  1320.  * Also delete line numbers from the cpp output (-P is not portable, I guess).
  1321.  */
  1322. #ifndef CppSedMagic
  1323. #define CppSedMagic sed -e '/^#  *[0-9][0-9]*  *.*$$/d' \
  1324.             -e '/^XCOMM$$/s//#/' \
  1325.             -e '/^XCOMM[^a-zA-Z0-9_]/s/^XCOMM/#/'
  1326. #endif /* CppSedMagic */
  1327.  
  1328. /*
  1329.  * CppScriptTarget - generate rules to create a shell script by running the
  1330.  * input through cpp.  If the ExecableScripts configuration parameter is not
  1331.  * set, then make sure that the first line begins with a colon.
  1332.  */
  1333. #ifndef CppScriptTarget
  1334. #if ExecableScripts        /* can use #! instead of colon */
  1335. #define CppScriptTarget(dst,src,defs,deplist)                @@\
  1336. dst::  src deplist                            @@\
  1337.     $(RM) $@                            @@\
  1338.     $(CPP) defs <src | CppSedMagic >$@                @@\
  1339.     chmod a+x $@
  1340. #else
  1341. #define CppScriptTarget(dst,src,defs,deplist)                @@\
  1342. dst::  src deplist                            @@\
  1343.     $(RM) $@                            @@\
  1344.     echo \: >$@                            @@\
  1345.     sed '1d' src | $(CPP) defs | CppSedMagic >>$@            @@\
  1346.     chmod a+x $@
  1347. #endif /* ExecableScripts */
  1348. #endif /* CppScriptTarget */
  1349.  
  1350.  
  1351. /*
  1352.  * MakeScriptFromCpp - generate rules to create a script from a file with a
  1353.  * .cpp suffix.
  1354.  */
  1355. #ifndef MakeScriptFromCpp
  1356. #define MakeScriptFromCpp(name,defs)                    @@\
  1357. CppScriptTarget(name,name.cpp,defs,NullParameter)
  1358. #endif /* MakeScriptFromCpp */
  1359.  
  1360. #ifndef CppFileTarget
  1361. #define CppFileTarget(dst,src,defs,deplist)                @@\
  1362. dst::  src deplist                            @@\
  1363.     $(RM) $@                            @@\
  1364.     $(CPP) defs <src | CppSedMagic >$@
  1365. #endif /* CppFileTarget */
  1366.  
  1367. /*
  1368.  * MakeDirectories - generate rules to create a hierarchy of directories.
  1369.  */
  1370. #ifndef MakeDirectories
  1371. #define MakeDirectories(step,dirs)                    @@\
  1372. step::                                    @@\
  1373.     @case '${MFLAGS}' in *[i]*) set +e;; esac;            @@\
  1374.     DirFailPrefix@for i in dirs; do if [ -d $(DESTDIR)$$i ]; then \    @@\
  1375.         set +x; else (set -x; $(MKDIRHIER) $(DESTDIR)$$i); fi \    @@\
  1376.     done
  1377. #endif /* MakeDirectories */
  1378.  
  1379.  
  1380. /*
  1381.  * MakeFontsDir - generate rules to build fonts.dir database.
  1382.  */
  1383. #ifndef MakeFontsDir
  1384. #define MakeFontsDir(deplist)                        @@\
  1385. all:: fonts.dir                                @@\
  1386.                                     @@\
  1387. fonts.dir:  deplist                            @@\
  1388.     $(MKFONTDIR) .                            @@\
  1389.                                     @@\
  1390. clean::                                    @@\
  1391.     $(RM) fonts.dir
  1392. #endif /* MakeFontsDir */
  1393.  
  1394.  
  1395. /*
  1396.  * MakeFonts - generate rules to build font database.
  1397.  */
  1398. #ifndef MakeFonts
  1399. #define MakeFonts()                            @@\
  1400. all::  $(OBJS)                                @@\
  1401.                                     @@\
  1402. MakeFontsDir($(OBJS))                            @@\
  1403.                                     @@\
  1404. clean::                                    @@\
  1405.     $(RM) *.snf *.snf.Z *.pcf *.pcf.Z
  1406. #endif /* MakeFonts */
  1407.  
  1408.  
  1409. /*
  1410.  * InstallFontObjs - generate rules to install font files
  1411.  */
  1412. #ifndef InstallFontObjs
  1413. #define InstallFontObjs(objs,dest)                    @@\
  1414. InstallMultipleFlags(objs,dest,$(INSTDATFLAGS))                @@\
  1415.                                     @@\
  1416. install::  fonts.dir                            @@\
  1417.     MakeDir($(DESTDIR)dest)                        @@\
  1418.     $(INSTALL) -c $(INSTDATFLAGS) fonts.dir $(DESTDIR)dest
  1419. #endif /* InstallFontObjs */
  1420.  
  1421.  
  1422. /*
  1423.  * InstallFonts - generate rules to install font files
  1424.  */
  1425. #ifndef InstallFonts
  1426. #define InstallFonts(dest)                        @@\
  1427. InstallFontObjs($(OBJS),dest)
  1428. #endif /* InstallFonts */
  1429.  
  1430.  
  1431. /*
  1432.  * InstallFontAliases - generate rules to install font aliases databases. 
  1433.  */
  1434. #ifndef InstallFontAliases
  1435. #define InstallFontAliases(dest)                    @@\
  1436. install::  fonts.alias                            @@\
  1437.     MakeDir($(DESTDIR)dest)                        @@\
  1438.     $(INSTALL) -c $(INSTDATFLAGS) fonts.alias $(DESTDIR)dest
  1439. #endif /* InstallFontAliases */
  1440.  
  1441. #define FontSrc(basename) basename.bdf
  1442. #ifdef SnfFonts
  1443. #define FontBaseObj(basename) basename.snf
  1444. #else
  1445. #define FontBaseObj(basename) basename.pcf
  1446. #endif
  1447.  
  1448. /*
  1449.  * InstallFontScale - generate rules to install font scale database.
  1450.  */
  1451. #ifndef InstallFontScale
  1452. #define InstallFontScale(dest)                        @@\
  1453. install::  fonts.scale                            @@\
  1454.     MakeDir($(DESTDIR)dest)                        @@\
  1455.     $(INSTALL) -c $(INSTDATFLAGS) fonts.scale $(DESTDIR)dest
  1456. #endif /* InstallFontScale */
  1457.  
  1458. #define FontSrc(basename) basename.bdf
  1459. #ifdef SnfFonts
  1460. #define FontBaseObj(basename) basename.snf
  1461. #else
  1462. #define FontBaseObj(basename) basename.pcf
  1463. #endif
  1464.  
  1465. /*
  1466.  * UncompressedFontTarget
  1467.  */
  1468. #ifndef UncompressedFontTarget
  1469. #ifdef SnfFonts
  1470. #define UncompressedFontTarget(basename)                @@\
  1471. FontBaseObj(basename):  FontSrc(basename)                @@\
  1472.     $(FONTC) $(FONTCFLAGS) $? >$@
  1473. #else
  1474. #define UncompressedFontTarget(basename)                @@\
  1475. FontBaseObj(basename):  FontSrc(basename)                @@\
  1476.     $(FONTC) $(FONTCFLAGS) $? -o $@
  1477. #endif
  1478. #endif /* CompressedFontTarget */
  1479.  
  1480. /*
  1481.  * CompressedFontTarget
  1482.  */
  1483. #ifndef CompressedFontTarget
  1484. #define CompressedFontTarget(basename)                    @@\
  1485. FontBaseObj(basename).Z:  FontSrc(basename)                @@\
  1486.     $(FONTC) $(FONTCFLAGS) $? | $(COMPRESS) > $@
  1487. #endif /* CompressedFontTarget */
  1488.  
  1489. #ifdef CompressAllFonts
  1490. #define FontTarget(basename) CompressedFontTarget(basename)
  1491. #define FontObj(basename) FontBaseObj(basename).Z
  1492. #else
  1493. #define FontTarget(basename) UncompressedFontTarget(basename)
  1494. #define FontObj(basename) FontBaseObj(basename)
  1495. #endif /* CompressAllFonts */
  1496.  
  1497. /*
  1498.  * AllTarget - generate rules to build necessary things during make all.
  1499.  */
  1500. #ifndef AllTarget
  1501. #define AllTarget(depends)                        @@\
  1502. all:: depends
  1503. #endif /* AllTarget */
  1504.  
  1505. #ifdef DefineOldLibraryRules
  1506. #include <oldlib.rules>
  1507. #endif
  1508.