1/* $Id: Local.rules,v 5.1 2003/12/13 21:22:36 bertg Exp $
2 *
3 * NO NEED TO EDIT THIS FILE; ONLY EDIT Local.config.
4 */
5
6/* Some Imake configurations still don't have XCOMM defined, shame on them */
7#ifndef XCOMM
8#define XCOMM #
9#endif
10/* And some don't have NullParameter either, double shame */
11#ifndef NullParameter
12#define NullParameter
13#endif
14
15/* The deprecated InstallNonExec must be used on systems that don't
16 * have the newer InstallNonExecFile. */
17#ifndef InstallNonExecFile
18#define InstallNonExecFile	InstallNonExec
19#endif
20
21/*
22 * The following rules are similar to to the ComplexProgramTarget_n family
23 * except they install the binaries in $(INSTBINDIR) instead of $(BINDIR),
24 * thereby circumventing the problem that auxilary programs X's Imake.rules
25 * uses have to be situated in the same directory as you want your binary
26 * installed in.  (Such dependencies are errors of the Imake files for X IMO.)
27 *
28 * Another difference is that these macros doesn't install the manual
29 * automatically -- you have to invoke the install.man target manually
30 * so it's not so counter-intuitive to invoke the install.man rule
31 * explicitly too, besides, you might not have a manual page in this
32 * directory, or at all.
33 */
34#ifndef ProgramTarget
35#define	ProgramTarget(program,locallib,syslib)				@@\
36                                                                        @@\
37AllTarget($(PROGRAMS))							@@\
38                                                                        @@\
39program: $(OBJS) $(DEPLIBS)						@@\
40	RemoveTargetProgram($@)						@@\
41	$(CC) -o $@ $(LDOPTIONS) $(OBJS) locallib $(LDLIBS) syslib $(EXTRA_LOAD_FLAGS) @@\
42									@@\
43InstallProgram(program,$(INSTBINDIR))					@@\
44                                                                        @@\
45DependTarget()								@@\
46LintTarget()								@@\
47                                                                        @@\
48clean::									@@\
49	$(RM) $(PROGRAMS)
50#endif /* ProgramTarget */
51
52
53#ifndef ProgramTarget_1
54#define	ProgramTarget_1(program,locallib,syslib)			@@\
55            OBJS = $(OBJS1) $(OBJS2) $(OBJS3)				@@\
56            SRCS = $(SRCS1) $(SRCS2) $(SRCS3)				@@\
57                                                                        @@\
58AllTarget($(PROGRAMS))							@@\
59                                                                        @@\
60program: $(OBJS1) $(DEPLIBS1)						@@\
61	RemoveTargetProgram($@)						@@\
62	$(CC) -o $@ $(LDOPTIONS) $(OBJS1) locallib $(LDLIBS) syslib $(EXTRA_LOAD_FLAGS) @@\
63									@@\
64InstallProgram(program,$(INSTBINDIR))					@@\
65                                                                        @@\
66DependTarget()								@@\
67LintTarget()								@@\
68                                                                        @@\
69clean::									@@\
70	$(RM) $(PROGRAMS)
71#endif /* ProgramTarget_1 */
72
73
74#ifndef ProgramTarget_2
75#define	ProgramTarget_2(program,locallib,syslib)			@@\
76program: $(OBJS2) $(DEPLIBS2)						@@\
77	RemoveTargetProgram($@)						@@\
78	$(CC) -o $@ $(LDOPTIONS) $(OBJS2) locallib $(LDLIBS) syslib $(EXTRA_LOAD_FLAGS) @@\
79                                                                        @@\
80InstallProgram(program,$(INSTBINDIR))
81#endif /* ProgramTarget_2 */
82
83
84#ifndef ProgramTarget_3
85#define	ProgramTarget_3(program,locallib,syslib)			@@\
86program: $(OBJS3) $(DEPLIBS3)						@@\
87	RemoveTargetProgram($@)						@@\
88	$(CC) -o $@ $(LDOPTIONS) $(OBJS3) locallib $(LDLIBS) syslib $(EXTRA_LOAD_FLAGS) @@\
89                                                                        @@\
90InstallProgram(program,$(INSTBINDIR))
91#endif /* ProgramTarget_3 */
92
93
94
95/*
96	Create target by running through msub.
97*/
98#define MsubTarget(dest,src)						@@\
99AllTarget(dest)								@@\
100dest: $(MSUB) src							@@\
101	$(MSUB) $(MSUBFLAGS) src >dest					@@\
102StuffToClean(dest)
103
104#define MsubTargetPersistent(dest,src)					@@\
105AllTarget(dest)								@@\
106dest: $(MSUB) src							@@\
107	$(RM) dest							@@\
108	$(MSUB) $(MSUBFLAGS) src >dest
109
110/* Add MsubDepend once to each Imakefile which uses Msub Targets. */
111#define MsubDepend							@@\
112$(MSUB): $(MSUB).o $(MSUB).c						@@\
113	@echo "Checking $@ over in $(MSUBSRC) first.."; \		@@\
114	cd $(MSUBSRC) || exit 1; $(MAKE) || exit 1; \			@@\
115	echo "Okay, continuing in $(CURRENT_DIR)"
116
117
118/*
119 * These rules are from the imake.support file of the msub package.
120 */
121/*
122	Create a target by running a template through some filter.
123*/
124
125#ifndef	ScriptFromTemplateTarget
126#define	ScriptFromTemplateTarget(dst,src,command,deps)			@@\
127AllTarget(dst)								@@\
128StuffToClean(dst)							@@\
129dst:: src deps								@@\
130	command src > $@
131#endif
132
133
134/*
135	Create an executable target for some arbitrary program by running a
136	template through some filter.  prog must be a full pathname.
137
138	If the ExecableScripts configuration parameter is not YES, make sure
139	the first line begins with a colon and write the script into a temp
140	file, have the program execute that, and remove the temp file when
141	done.  Ugly ugly ugly.
142*/
143
144#ifndef	ExecScriptFromTemplateTarget
145#if ExecableScripts		/* can use #! */
146#define	ExecScriptFromTemplateTarget(prog,dst,src,command,deps)		@@\
147AllTarget(dst)								@@\
148StuffToClean(dst)							@@\
149dst::  src deps								@@\
150	$(RM) $@							@@\
151	echo "#!"prog > $@						@@\
152	command src >> $@						@@\
153	chmod a+x $@
154#else
155#define	ExecScriptFromTemplateTarget(prog,dst,src,command,deps)		@@\
156AllTarget(dst)								@@\
157StuffToClean(dst)							@@\
158dst::  src deps								@@\
159	$(RM) $@							@@\
160	echo \: > $@							@@\
161	echo 'x=/tmp/xx$$$$' >> $@					@@\
162	echo "cat > "'$$x'" << 'EOF'" >> $@				@@\
163	command src >> $@						@@\
164	echo EOF >> $@							@@\
165	echo prog '$$x' '$$@' >> $@					@@\
166	echo $(RM) '$$x' >> $@						@@\
167	chmod a+x $@
168#endif /* ExecableScripts */
169#endif /* ExecScriptFromTemplateTarget */
170
171
172/* From X11R6 Imake.rules file:
173 * MakeMakeSubdirs - generate rules to recursively recreate Makefiles as part
174 * of the specified step in the build.  If $(TOP) is set to an absolute path,
175 * do not prepend the ../ prefix.  This makes running things outside of the
176 * source tree to be much easier.
177 */
178#ifdef MakeMakeSubdirs
179#undef MakeMakeSubdirs
180#endif
181#define MakeMakeSubdirs(dirs,target)					@@\
182target::								@@\
183	-@case '${MFLAGS}' in *[ik]*) set +e;; esac; \			@@\
184	case '${MFLAGS}' in *n*) executeit="no";; esac; \		@@\
185	for i in dirs ;\						@@\
186	do \								@@\
187		case "$(CURRENT_DIR)" in \				@@\
188		.) curdir= ;; \						@@\
189		*) curdir=$(CURRENT_DIR)/ ;; \				@@\
190		esac; \							@@\
191		echo "making Makefiles in $$curdir$$i..."; \		@@\
192		case "$$i" in \						@@\
193		*/?*/?*/?*)	newtop=../../../..;; \			@@\
194		*/?*/?*)	newtop=../../..;; \			@@\
195		*/?*)		newtop=../..;; \			@@\
196		*)		newtop=..;; \				@@\
197		esac; \							@@\
198		case "$(TOP)" in \					@@\
199		/?*) imaketop=$(TOP) \					@@\
200		     imakeprefix= ;; \					@@\
201		.) imaketop=$$newtop \					@@\
202		   imakeprefix=$$newtop/ ;; \				@@\
203		*) imaketop=$$newtop/$(TOP) \				@@\
204		   imakeprefix=$$newtop/ ;; \				@@\
205		esac; \							@@\
206		cd $$i || exit 1; \					@@\
207		$(RM) Makefile.bak;	 \				@@\
208		if [ -f Makefile ]; then \				@@\
209			echo "	$(MV) Makefile Makefile.bak"; \		@@\
210			if [ "$$executeit" != "no" ]; then \		@@\
211				$(MV) Makefile Makefile.bak; \		@@\
212			fi; \						@@\
213		fi; \							@@\
214		if [ "$$executeit" != "no" ]; then \			@@\
215			ImakeSubCmdHelper -DTOPDIR=$$imaketop -DCURDIR=$$curdir$$i; \ @@\
216		fi; \							@@\
217		$(MAKE) $(MFLAGS) Makefiles; \				@@\
218		cd $$newtop || exit 1; \				@@\
219	done
220
221#ifdef ImakeSubCmdHelper
222#undef ImakeSubCmdHelper
223#endif
224#ifdef UseInstalled
225#define ImakeSubCmdHelper $(IMAKE_CMD)
226#else
227#define ImakeSubCmdHelper $$imakeprefix$(IMAKE) -I$$imakeprefix$(IRULESRC) $(IMAKE_DEFINES)
228#endif
229
230
231
232#ifndef CtagFiles
233#define CtagFiles(extra)						@@\
234ctags::									@@\
235	$(CTAGS) $(CTAGOPTIONS) extra
236#endif /* CtagFiles */
237
238
239#ifndef CtagSubdirs
240#define CtagSubdirs(extra)						@@\
241ctags::									@@\
242	@for flag in ${MAKEFLAGS} ''; do \				@@\
243	case "$$flag" in *=*) ;; *[ik]*) set +e;; esac; done; \		@@\
244	for i in extra ;\						@@\
245	do \								@@\
246	echo "tagging" "in $(CURRENT_DIR)/$$i..."; \			@@\
247	$(MAKE) -C $$i CTAGS='$(CTAGS)' CTAGOPTIONS='$(CTAGOPTIONS)' ctags; \	@@\
248	done
249#endif /* CtagSubdirs */
250
251
252#ifndef StuffToClean
253#define StuffToClean(extra)						@@\
254clean::									@@\
255	$(RM) extra
256#endif /* StuffToClean */
257
258
259#ifndef AllTarget
260#define AllTarget(depends)						@@\
261all:: depends
262#endif /* AllTarget */
263