xref: /illumos-gate/usr/src/cmd/make/bin/make.rules.file (revision 5db531e3faa94427746eae754b11770fd8416b6d)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21# Copyright 2003 Sun Microsystems, Inc. All rights reserved.
22# Use is subject to license terms.
23#
24
25SUFFIXES = .o .c .c~ .cc .cc~ .y .y~ .l .l~ .s .s~ .sh .sh~ .S .S~ .i .ln \
26	.h .h~ .f .f~ .for .for~ .F .F~ .f90 .f90~ .ftn .ftn~ .mod .mod~ \
27	.sym .def .def~ .p .p~ .r .r~ .cps .cps~ .C .C~ .Y .Y~ .L .L~ \
28	.java .java~ .class
29
30.SUFFIXES: $(SUFFIXES)
31
32# OUTPUT_OPTION should be defined to "-o $@" when
33# the default rules are used for non-local files.
34OUTPUT_OPTION=
35
36#	C language section.
37CC=cc
38CFLAGS=
39CPPFLAGS=
40LINT=lint
41LINTFLAGS=
42COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c
43LINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
44LINT.c=$(LINT) $(LINTFLAGS) $(CPPFLAGS)
45.c:
46	$(LINK.c) -o $@ $< $(LDLIBS)
47.c~:
48	$(GET) $(GFLAGS) -p $< > $*.c
49	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $*.c
50.c.o:
51	$(COMPILE.c) $(OUTPUT_OPTION) $<
52.c~.o:
53	$(GET) $(GFLAGS) -p $< > $*.c
54	$(CC) $(CFLAGS) -c  $*.c
55.c.i:
56	$(CC) $(CFLAGS) $(CPPFLAGS) -P $<
57.c~.i:
58	$(GET) $(GFLAGS) -p $< > $*.c
59	$(CC) $(CFLAGS) $(CPPFLAGS) -P $*.c
60.c.ln:
61	$(LINT.c) $(OUTPUT_OPTION) -c $<
62.c~.ln:
63	$(GET) $(GFLAGS) -p $< > $*.c
64	$(LINT.c) $(OUTPUT_OPTION) -c $*.c
65.c.a:
66	$(COMPILE.c) -o $% $<
67	$(AR) $(ARFLAGS) $@ $%
68	$(RM) $%
69.c~.a:
70	$(GET) $(GFLAGS) -p $< > $*.c
71	$(COMPILE.c) -o $% $*.c
72	$(AR) $(ARFLAGS) $@ $%
73	$(RM) $%
74
75#	C language section. yacc.
76YACC=yacc
77YFLAGS=
78YACC.y=$(YACC) $(YFLAGS)
79.y:
80	$(YACC.y) $<
81	$(LINK.c) -o $@ y.tab.c $(LDLIBS)
82	$(RM) y.tab.c
83.y~:
84	$(GET) $(GFLAGS) -p $< > $*.y
85	$(YACC) $(YFLAGS) $*.y
86	$(COMPILE.c) -o $@ y.tab.c
87	$(RM) y.tab.c
88
89.y.c:
90	$(YACC.y) $<
91	mv y.tab.c $@
92.y~.c:
93	$(GET) $(GFLAGS) -p $< > $*.y
94	$(YACC) $(YFLAGS) $*.y
95	mv y.tab.c $@
96.y.ln:
97	$(YACC.y) $<
98	$(LINT.c) -o $@ -i y.tab.c
99	$(RM) y.tab.c
100.y~.ln:
101	$(GET) $(GFLAGS) -p $< > $*.y
102	$(YACC.y) $*.y
103	$(LINT.c) -o $@ -i y.tab.c
104	$(RM) y.tab.c
105.y.o:
106	$(YACC.y) $<
107	$(COMPILE.c) -o $@ y.tab.c
108	$(RM) y.tab.c
109.y~.o:
110	$(GET) $(GFLAGS) -p $< > $*.y
111	$(YACC) $(YFLAGS) $*.y
112	$(CC) $(CFLAGS) -c y.tab.c
113	rm -f y.tab.c
114	mv y.tab.o $@
115
116#	C language section. lex.
117LEX=lex
118LFLAGS=
119LEX.l=$(LEX) $(LFLAGS) -t
120.l:
121	$(RM) $*.c
122	$(LEX.l) $< > $*.c
123	$(LINK.c) -o $@ $*.c -ll $(LDLIBS)
124	$(RM) $*.c
125.l~:
126	$(GET) $(GFLAGS) -p $< > $*.l
127	$(LEX) $(LFLAGS) $*.l
128	$(CC) $(CFLAGS) -c lex.yy.c
129	rm -f lex.yy.c
130	mv lex.yy.c $@
131
132.l.c :
133	$(RM) $@
134	$(LEX.l) $< > $@
135.l~.c:
136	$(GET) $(GFLAGS) -p $< > $*.l
137	$(LEX) $(LFLAGS) $*.l
138	mv lex.yy.c $@
139.l.ln:
140	$(RM) $*.c
141	$(LEX.l) $< > $*.c
142	$(LINT.c) -o $@ -i $*.c
143	$(RM) $*.c
144.l~.ln:
145	$(GET) $(GFLAGS) -p $< > $*.l
146	$(RM) $*.c
147	$(LEX.l) $*.l > $*.c
148	$(LINT.c) -o $@ -i $*.c
149	$(RM) $*.c
150.l.o:
151	$(RM) $*.c
152	$(LEX.l) $< > $*.c
153	$(COMPILE.c) -o $@ $*.c
154	$(RM) $*.c
155.l~.o:
156	$(GET) $(GFLAGS) -p $< > $*.l
157	$(LEX) $(LFLAGS) $*.l
158	$(CC) $(CFLAGS) -c lex.yy.c
159	rm -f lex.yy.c
160	mv lex.yy.c $@
161
162#       C++ language section.
163CCC=CC
164CCFLAGS=
165COMPILE.cc=$(CCC) $(CCFLAGS) $(CPPFLAGS)  -c
166LINK.cc=$(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS)
167COMPILE.C=$(CCC) $(CCFLAGS) $(CPPFLAGS)  -c
168LINK.C=$(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS)
169.cc:
170	$(LINK.cc) -o $@ $< $(LDLIBS)
171.cc~:
172	$(GET) $(GFLAGS) -p $< > $*.cc
173	$(LINK.cc) -o $@ $*.cc $(LDLIBS)
174.cc.o:
175	$(COMPILE.cc) $(OUTPUT_OPTION) $<
176.cc~.o:
177	$(GET) $(GFLAGS) -p $< > $*.cc
178	$(COMPILE.cc) $(OUTPUT_OPTION) $*.cc
179.cc.i:
180	$(CCC) $(CCFLAGS) $(CPPFLAGS) -P $<
181.cc~.i:
182	$(GET) $(GFLAGS) -p $< > $*.cc
183	$(CCC) $(CCFLAGS) $(CPPFLAGS) -P $*.cc
184.cc.a:
185	$(COMPILE.cc) -o $% $<
186	$(AR) $(ARFLAGS) $@ $%
187	$(RM) $%
188.cc~.a:
189	$(GET) $(GFLAGS) -p $< > $*.cc
190	$(COMPILE.cc) -o $% $*.cc
191	$(AR) $(ARFLAGS) $@ $%
192	$(RM) $%
193
194.C:
195	$(LINK.C) -o $@ $< $(LDLIBS)
196.C~:
197	$(GET) $(GFLAGS) -p $< > $*.C
198	$(LINK.C) -o $@ $*.C $(LDLIBS)
199.C.o:
200	$(COMPILE.C) $(OUTPUT_OPTION) $<
201.C~.o:
202	$(GET) $(GFLAGS) -p $< > $*.C
203	$(COMPILE.C) $(OUTPUT_OPTION) $*.C
204.C.i:
205	$(CCC) $(CCFLAGS) $(CPPFLAGS) -P $<
206.C~.i:
207	$(GET) $(GFLAGS) -p $< > $*.C
208	$(CCC) $(CCFLAGS) $(CPPFLAGS) -P  $*.C
209.C.a:
210	$(COMPILE.C) -o $% $<
211	$(AR) $(ARFLAGS) $@ $%
212	$(RM) $%
213.C~.a:
214	$(GET) $(GFLAGS) -p $< > $*.C
215	$(COMPILE.C) -o $% $*.C
216	$(AR) $(ARFLAGS) $@ $%
217	$(RM) $%
218
219#	FORTRAN section.
220FC=f77
221FFLAGS=
222COMPILE.f=$(FC) $(FFLAGS)  -c
223LINK.f=$(FC) $(FFLAGS) $(LDFLAGS)
224COMPILE.F=$(FC) $(FFLAGS) $(CPPFLAGS)  -c
225LINK.F=$(FC) $(FFLAGS) $(CPPFLAGS) $(LDFLAGS)
226.f:
227	$(LINK.f) -o $@ $< $(LDLIBS)
228.f~:
229	$(GET) $(GFLAGS) -p $< > $*.f
230	$(FC) $(FFLAGS) $(LDFLAGS) -o $@ $*.f
231.f.o:
232	$(COMPILE.f) $(OUTPUT_OPTION) $<
233.f~.o:
234	$(GET) $(GFLAGS) -p $< > $*.f
235	$(FC) $(FFLAGS) -c  $*.f
236.f.a:
237	$(COMPILE.f) -o $% $<
238	$(AR) $(ARFLAGS) $@ $%
239	$(RM) $%
240.f~.a:
241	$(GET) $(GFLAGS) -p $< > $*.f
242	$(COMPILE.f) -o $% $*.f
243	$(AR) $(ARFLAGS) $@ $%
244	$(RM) $%
245.for:
246	$(LINK.f) -o $@ $< $(LDLIBS)
247.for~:
248	$(GET) $(GFLAGS) -p $< > $*.for
249	$(FC) $(FFLAGS) $(LDFLAGS) -o $@ $*.for
250.for.o:
251	$(COMPILE.f) $(OUTPUT_OPTION) $<
252.for~.o:
253	$(GET) $(GFLAGS) -p $< > $*.for
254	$(FC) $(FFLAGS) -c  $*.for
255.for.a:
256	$(COMPILE.f) -o $% $<
257	$(AR) $(ARFLAGS) $@ $%
258	$(RM) $%
259.for~.a:
260	$(GET) $(GFLAGS) -p $< > $*.for
261	$(COMPILE.f) -o $% $*.for
262	$(AR) $(ARFLAGS) $@ $%
263	$(RM) $%
264.F:
265	$(LINK.F) -o $@ $< $(LDLIBS)
266.F~:
267	$(GET) $(GFLAGS) -p $< > $*.F
268	$(FC) $(FFLAGS) $(LDFLAGS) -o $@ $*.F
269.F.o:
270	$(COMPILE.F) $(OUTPUT_OPTION) $<
271.F~.o:
272	$(GET) $(GFLAGS) -p $< > $*.F
273	$(FC) $(FFLAGS) -c  $*.F
274.F.a:
275	$(COMPILE.F) -o $% $<
276	$(AR) $(ARFLAGS) $@ $%
277	$(RM) $%
278.F~.a:
279	$(GET) $(GFLAGS) -p $< > $*.F
280	$(COMPILE.F) -o $% $*.F
281	$(AR) $(ARFLAGS) $@ $%
282	$(RM) $%
283
284#	FORTRAN section. ratfor.
285RFLAGS=
286COMPILE.r=$(FC) $(FFLAGS) $(RFLAGS)  -c
287LINK.r=$(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS)
288.r:
289	$(LINK.r) -o $@ $< $(LDLIBS)
290.r~:
291	$(GET) $(GFLAGS) -p $< > $*.r
292	$(LINK.r) -o $@ $*.r $(LDLIBS)
293.r.o:
294	$(COMPILE.r) $(OUTPUT_OPTION) $<
295.r~.o:
296	$(GET) $(GFLAGS) -p $< > $*.r
297	$(COMPILE.r) $(OUTPUT_OPTION) $*.r
298.r.a:
299	$(COMPILE.r) -o $% $<
300	$(AR) $(ARFLAGS) $@ $%
301	$(RM) $%
302.r~.a:
303	$(GET) $(GFLAGS) -p $< > $*.r
304	$(COMPILE.r) -o $% $*.r
305	$(AR) $(ARFLAGS) $@ $%
306	$(RM) $%
307
308#	FORTRAN 90 section.
309F90C=f90
310F90FLAGS=
311COMPILE.f90=$(F90C) $(F90FLAGS) -c
312LINK.f90=$(F90C) $(F90FLAGS) $(LDFLAGS)
313COMPILE.ftn=$(F90C) $(F90FLAGS) -c
314LINK.ftn=$(F90C) $(F90FLAGS) $(LDFLAGS)
315.f90:
316	$(LINK.f90) -o $@ $< $(LDLIBS)
317.f90~:
318	$(GET) $(GFLAGS) -p $< > $*.f90
319	$(LINK.f90) -o $@ $*.f90 $(LDLIBS)
320.f90.o:
321	$(COMPILE.f90) $(OUTPUT_OPTION) $<
322.f90~.o:
323	$(GET) $(GFLAGS) -p $< > $*.f90
324	$(COMPILE.f90) $(OUTPUT_OPTION) $*.f90
325.f90.a:
326	$(COMPILE.f90) -o $% $<
327	$(AR) $(ARFLAGS) $@ $%
328	$(RM) $%
329.f90~.a:
330	$(GET) $(GFLAGS) -p $< > $*.f90
331	$(COMPILE.f90) -o $% $*.f90
332	$(AR) $(ARFLAGS) $@ $%
333	$(RM) $%
334.ftn:
335	$(LINK.ftn) -o $@ $< $(LDLIBS)
336.ftn~:
337	$(GET) $(GFLAGS) -p $< > $*.ftn
338	$(LINK.ftn) -o $@ $*.ftn $(LDLIBS)
339.ftn.o:
340	$(COMPILE.ftn) $(OUTPUT_OPTION) $<
341.ftn~.o:
342	$(GET) $(GFLAGS) -p $< > $*.ftn
343	$(COMPILE.ftn) $(OUTPUT_OPTION) $*.ftn
344.ftn.a:
345	$(COMPILE.ftn) -o $% $<
346	$(AR) $(ARFLAGS) $@ $%
347	$(RM) $%
348.ftn~.a:
349	$(GET) $(GFLAGS) -p $< > $*.ftn
350	$(COMPILE.ftn) -o $% $*.ftn
351	$(AR) $(ARFLAGS) $@ $%
352	$(RM) $%
353
354#	Modula-2 section.
355M2C=m2c
356M2FLAGS=
357MODFLAGS=
358DEFFLAGS=
359COMPILE.def=$(M2C) $(M2FLAGS) $(DEFFLAGS)
360COMPILE.mod=$(M2C) $(M2FLAGS) $(MODFLAGS)
361.def.sym:
362	$(COMPILE.def) -o $@ $<
363.def~.sym:
364	$(GET) $(GFLAGS) -p $< > $*.def
365	$(COMPILE.def) -o $@ $*.def
366.mod:
367	$(COMPILE.mod) -o $@ -e $@ $<
368.mod~:
369	$(GET) $(GFLAGS) -p $< > $*.mod
370	$(COMPILE.mod) -o $@ -e $@ $*.mod
371.mod.o:
372	$(COMPILE.mod) -o $@ $<
373.mod~.o:
374	$(GET) $(GFLAGS) -p $< > $*.mod
375	$(COMPILE.mod) -o $@ $*.mod
376.mod.a:
377	$(COMPILE.mod) -o $% $<
378	$(AR) $(ARFLAGS) $@ $%
379	$(RM) $%
380.mod~.a:
381	$(GET) $(GFLAGS) -p $< > $*.mod
382	$(COMPILE.mod) -o $% $*.mod
383	$(AR) $(ARFLAGS) $@ $%
384	$(RM) $%
385
386#	Pascal section.
387PC=pc
388PFLAGS=
389COMPILE.p=$(PC) $(PFLAGS) $(CPPFLAGS)  -c
390LINK.p=$(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS)
391.p:
392	$(LINK.p) -o $@ $< $(LDLIBS)
393.p~:
394	$(GET) $(GFLAGS) -p $< > $*.p
395	$(LINK.p) -o $@ $*.p $(LDLIBS)
396.p.o:
397	$(COMPILE.p) $(OUTPUT_OPTION) $<
398.p~.o:
399	$(GET) $(GFLAGS) -p $< > $*.p
400	$(COMPILE.p) $(OUTPUT_OPTION) $*.p
401.p.a:
402	$(COMPILE.p) -o $% $<
403	$(AR) $(ARFLAGS) $@ $%
404	$(RM) $%
405.p~.a:
406	$(GET) $(GFLAGS) -p $< > $*.p
407	$(COMPILE.p) -o $% $*.p
408	$(AR) $(ARFLAGS) $@ $%
409	$(RM) $%
410
411#	Assembly section.
412AS=as
413ASFLAGS=
414COMPILE.s=$(AS) $(ASFLAGS)
415COMPILE.S=$(CC) $(ASFLAGS) $(CPPFLAGS)  -c
416.s.o:
417	$(COMPILE.s) -o $@ $<
418.s~.o:
419	$(GET) $(GFLAGS) -p $< > $*.s
420	$(COMPILE.s) -o $@ $*.s
421.s.a:
422	$(COMPILE.s) -o $% $<
423	$(AR) $(ARFLAGS) $@ $%
424	$(RM) $%
425.s~.a:
426	$(GET) $(GFLAGS) -p $< > $*.s
427	$(COMPILE.s) -o $% $*.s
428	$(AR) $(ARFLAGS) $@ $%
429	$(RM) $%
430.S.o:
431	$(COMPILE.S) -o $@ $<
432.S~.o:
433	$(GET) $(GFLAGS) -p $< > $*.S
434	$(COMPILE.S) -o $@ $*.S
435.S.a:
436	$(COMPILE.S) -o $% $<
437	$(AR) $(ARFLAGS) $@ $%
438	$(RM) $%
439.S~.a:
440	$(GET) $(GFLAGS) -p $< > $*.S
441	$(COMPILE.S) -o $% $*.S
442	$(AR) $(ARFLAGS) $@ $%
443	$(RM) $%
444
445#	Shell section.
446.sh:
447	$(RM) $@
448	cat $< > $@
449	chmod +x $@
450.sh~:
451	$(GET) $(GFLAGS) -p $< > $*.sh
452	cp $*.sh $@
453	chmod a+x $@
454
455#	NeWS section
456CPS=cps
457CPSFLAGS=
458.cps.h:
459	$(CPS) $(CPSFLAGS) $*.cps
460.cps~.h:
461	$(GET) $(GFLAGS) -p $< > $*.cps
462	$(CPS) $(CPSFLAGS) $*.cps
463
464#	JAVA section
465JAVAC=javac
466JAVACFLAGS=
467.java.class:
468	$(JAVAC) $(JAVACFLAGS) $<
469.java~.class:
470	$(GET) $(GFLAGS) -p $< > $*.java
471	$(JAVAC) $(JAVACFLAGS) $<
472
473#	Miscellaneous section.
474LD=ld
475LDFLAGS=
476LDLIBS=
477MAKE=make
478RM=rm -f
479AR=ar
480ARFLAGS=rv
481GET=get
482GFLAGS=
483
484markfile.o:	markfile
485	echo "static char _sccsid[] = \"`grep @'(#)' markfile`\";" > markfile.c
486	cc -c markfile.c
487	$(RM) markfile.c
488
489SCCSFLAGS=
490SCCSGETFLAGS=-s
491.SCCS_GET:
492	sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@ -G$@
493
494.SCCS_GET_POSIX:
495	sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@
496
497.GET_POSIX:
498	$(GET) $(GFLAGS) s.$@
499