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