1/****************************************************************************
2
3	FWF.rules
4
5	This file contains additional rules used by the Free Widget
6	Foundation imake build system.
7
8 ****************************************************************************/
9
10#ifndef NullParameter
11#define NullParameter
12#endif
13
14/*
15 * AddToLibraryTarget(libdir,libname,objlist)
16 *
17 */
18
19#ifndef AddToLibraryTarget
20#define	AddToLibraryTarget(target,libdir,libname,objlist)		@@\
21target:: libdir/libname							@@\
22									@@\
23libdir/libname:: objlist						@@\
24	-@(if [ ! -f libdir/libname ]; then \				@@\
25		$(MKDIRHIER) libdir ; \					@@\
26		echo Creating Library libdir/libname ; \		@@\
27		$(AR) libdir/libname ; \				@@\
28		RanLibrary(libdir/libname) ; \				@@\
29	fi; exit 0)							@@\
30	@echo Adding objlist To Library libdir/libname			@@\
31	$(ARMERGE) libdir/libname objlist				@@\
32	RanLibrary(libdir/libname)
33#endif /* AddToLibraryTarget */
34
35/*
36 * FileCopyWhenNeeded(fromdir,fromname,todir,toname)
37 *
38 */
39#ifndef FileCopyWhenNeeded
40#define FileCopyWhenNeeded(fromdir,fromname,todir,toname)		@@\
41todir/toname: fromdir/fromname						@@\
42	@$(MKDIRHIER) todir						@@\
43	$(CP) fromdir/fromname todir/toname
44#endif /* FileCopyWhenNeeded */
45
46/*
47 * RequireThisFileForDepend(file)
48 *
49 */
50#ifndef RequireThisFileForDepend
51#define RequireThisFileForDepend(file)					@@\
52depend:: file								@@\
53
54#endif /* RequireThisFileForDepend */
55
56/*
57 * RequireThisFileForInit(file)
58 *
59 */
60#ifndef RequireThisFileForInit
61#define RequireThisFileForInit(file)					@@\
62init:: file								@@\
63
64#endif /* RequireThisFileForInit */
65
66/*
67 * InitSubdirs(dirs)
68 *
69 */
70#ifndef InitSubdirs
71#define InitSubdirs(dirs)						@@\
72NamedTargetSubdirs(init,dirs,"initializing build tree",NullParameter,init)
73#endif /* InitSubdirs */
74
75/*
76 * MakeObjectsSubdirs(dirs)
77 *
78 */
79#ifndef MakeObjectsSubdirs
80#define MakeObjectsSubdirs(dirs)					@@\
81NamedTargetSubdirs(objects,dirs,"building objects",NullParameter,objects)
82#endif /* MakeObjectsSubdirs */
83
84/*
85 * MakeExecsSubdirs(dirs)
86 *
87 */
88#ifndef MakeExecsSubdirs
89#define MakeExecsSubdirs(dirs)						@@\
90NamedTargetSubdirs(execs,dirs,"building executables",NullParameter,execs)
91#endif /* MakeExecsSubdirs */
92
93/*
94 * GatherDescriptionSubdirs(dirs)
95 *
96 */
97#ifndef GatherDescriptionSubdirs
98#define GatherDescriptionSubdirs(dirs)					@@\
99NamedTargetSubdirs(gather,dirs,"gathering index entries",NullParameter,gather)
100#endif /* GatherDescriptionSubdirs */
101
102/*
103 * GatherDescription(from,to)
104 *
105 */
106#ifndef GatherDescription
107#define GatherDescription(from,to)					@@\
108gather::								@@\
109	-@(if [ -f from ]; then \					@@\
110		cat from >> to ; \					@@\
111		echo accumulated index entry from ; \			@@\
112	fi; exit 0)
113#endif /* GatherDescription */
114
115/*
116 * ConstructIndex(target)
117 *
118 */
119#ifndef ConstructIndex
120#define ConstructIndex(target)						@@\
121target:: initindex gather						@@\
122									@@\
123initindex:								@@\
124	-@rm -f README.INDEX						@@\
125	@cat .README.INDEX.HEADER > README.INDEX
126#endif /* ConstructIndex */
127
128/*
129 * DeleteWhenCleaning(names)
130 *
131 */
132#ifndef DeleteWhenCleaning
133#define DeleteWhenCleaning(names)					@@\
134clean::									@@\
135	$(RM) -rf names							@@\
136									@@\
137squeakyclean::								@@\
138	$(RM) -rf names
139#endif /* DeleteWhenCleaning */
140
141/*
142 * InstallLibraryFile(srcdir,lib,destdir)
143 *
144 */
145#ifndef InstallLibraryFile
146#define InstallLibraryFile(srcdir,lib,destdir)				@@\
147install:: srcdir/lib							@@\
148	$(INSTALL) -c $(INSTLIBFLAGS) srcdir/lib destdir		@@\
149	RanLibrary($(RANLIBINSTFLAGS) destdir/lib)
150#endif /* InstallLibraryFile */
151
152/*
153 * CreateExportStructure(exportdir,root)
154 *
155 */
156#ifndef CreateExportStructure
157#define CreateExportStructure(exporttop,root)				@@\
158exporttop/root::							@@\
159	$(MKDIRHIER) exporttop/root
160#endif /* CreateExportStructure */
161
162/*
163 * ExportFile(exportdir,relolddir,filename)
164 *
165 */
166#ifndef ExportFile
167#define ExportFile(exportdir,relolddir,filename)			@@\
168exportsetup: exportdir/filename						@@\
169exportdir/filename: exportdir						@@\
170	( cd exportdir; $(RM) filename; $(LN) relolddir/filename filename )
171#endif /* ExportFile */
172
173/*
174 * ExportDirectory(exportdir,relolddir,dirname)
175 *
176 */
177#ifndef ExportDir
178#define ExportDir(exportdir,relolddir,dirname)				@@\
179subdirclean:: exportdir/dirname						@@\
180	@echo "Squeaky cleaning (you can re-make Makefiles later)"	@@\
181NamedSqueakyCleanSubdirs(subdirclean,exportdir/dirname)		@@\
182									@@\
183exportsetup: exportdir/dirname						@@\
184exportdir/dirname: exportdir						@@\
185	( cd exportdir; $(RM) dirname; $(LN) relolddir/dirname dirname )
186#endif /* ExportDir */
187
188/*
189 * BuildSharForExport(exportdir,root,sharfile)
190 *
191 */
192#ifndef BuildSharForExport
193#define BuildSharForExport(exportdir,root,basename)			@@\
194shar: subdirclean exportsetup						@@\
195	@echo "Building shar file.  Do 'make Makefiles' first if fails"	@@\
196	@( cd exportdir; shar -a root > basename-`sed -e "s/.*Version \([^,]*\),.*/\1/" < FWF/VERSION`.shar ) @@\
197	@echo "Placed shar file in export"
198#endif /* BuildSharForExport */
199
200/*
201 * BuildQuickSharForExport(exportdir,root,sharfile)
202 *
203 */
204#ifndef BuildQuickSharForExport
205#define BuildQuickSharForExport(exportdir,root,basename)         @@\
206quickshar: exportsetup                       @@\
207	@( cd exportdir; shar -h -a root > basename-`sed -e "s/.*Version \([^,]*\),.*/\1/" < FWF/VERSION`.shar ) @@\
208	@echo "Placed shar file in export"
209#endif /* BuildQuickSharForExport */
210
211
212/*
213 * BuildTarForExport(exportdir,root,tarfile)
214 *
215 */
216#ifndef BuildTarForExport
217#define BuildTarForExport(exportdir,root,basename)			@@\
218tar: subdirclean exportsetup 						@@\
219	@echo "Building tar file.  Do 'make Makefiles' first if fails"	@@\
220	@( cd exportdir; find . -name '*.[ch]' -exec touch {} \;; tar chvf basename-`sed -e "s/.*Version \([^,]*\),.*/\1/" < FWF/VERSION`.tar root ) @@\
221	@echo "Placed tar file in export"
222#endif /* BuildTarForExport */
223
224/*
225 * BuildQuickTarForExport(exportdir,root,tarfile)
226 *
227 */
228#ifndef BuildQuickTarForExport
229#define BuildQuickTarForExport(exportdir,root,basename)          @@\
230quicktar: exportsetup                        @@\
231	@( cd exportdir; tar chvf basename-`sed -e "s/.*Version \([^,]*\),.*/\1/" < FWF/VERSION`.tar root ) @@\
232	@echo "Placed tar file in export"
233#endif /* BuildQuickTarForExport */
234
235
236/*
237 * ObjectRuleWithFlags
238 */
239#ifndef ObjectRuleWithFlags
240#define	ObjectRuleWithFlags(flags)					@@\
241.c.o:									@@\
242	$(RM) $@							@@\
243	$(CC) -c flags $*.c
244#endif /* ObjectRuleWithFlags */
245
246/*
247 * DependTargetWithFlags(flags,sources)
248 *
249 */
250#ifndef DependTargetWithFlags
251#define	DependTargetWithFlags(flags,sources)				@@\
252DependDependency()							@@\
253									@@\
254depend::								@@\
255	$(DEPEND) -s "# DO NOT DELETE" -- flags -- sources
256#endif /* DependTargetWithFlags */
257
258/*
259 * SqueakyCleanTarget()
260 *
261 */
262#ifndef SqueakyCleanTarget
263#define	SqueakyCleanTarget()						@@\
264squeakyclean::								@@\
265	$(SQUEAKY_RM_CMD) "#"*
266#endif /* SqueakyCleanTarget */
267
268/*
269 * NamedSqueakyCleanSubdirs(name,dirs)
270 *
271 */
272#ifndef NamedSqueakyCleanSubdirs
273#define NamedSqueakyCleanSubdirs(name,dirs)				@@\
274NamedTargetSubdirs(name,dirs,"squeaky cleaning",SQUEAKY_RM_CMD='$(SQUEAKY_RM_CMD)',squeakyclean)
275#endif /* NamedSqueakyCleanSubdirs */
276
277/*
278 * SqueakyCleanSubdirs(dirs)
279 *
280 */
281#ifndef SqueakyCleanSubdirs
282#define SqueakyCleanSubdirs(dirs)					@@\
283NamedSqueakyCleanSubdirs(squeakyclean,dirs)
284#endif
285