xref: /freebsd/contrib/bmake/mk/sys/Generic.mk (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
1#	$Id: Generic.mk,v 1.11 2010/09/24 05:59:53 sjg Exp $
2#
3
4# some reasonable defaults
5.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
6.SUFFIXES: .sh .m4
7
8.LIBS:		.a
9
10tools = \
11	ar \
12	lorder \
13	ranlib \
14	tsort
15
16.for t in ${tools}
17${t:tu} := ${t:${M_whence}}
18.endfor
19
20# need to make sure this is set
21MACHINE_ARCH.${MACHINE} ?= ${MACHINE}
22.if empty(MACHINE_ARCH)
23MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}}
24.endif
25
26.if !empty(TSORT)
27TSORT += -q
28.endif
29
30ARFLAGS?=	rl
31
32AS?=		as
33AFLAGS?=
34.if ${MACHINE_ARCH} == "sparc64"
35AFLAGS+= -Wa,-Av9a
36.endif
37COMPILE.s?=	${CC} ${AFLAGS} -c
38LINK.s?=	${CC} ${AFLAGS} ${LDFLAGS}
39COMPILE.S?=	${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
40LINK.S?=	${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
41
42CC?=		cc
43DBG?=		-O2
44CFLAGS?=	${DBG}
45COMPILE.c?=	${CC} ${CFLAGS} ${CPPFLAGS} -c
46LINK.c?=	${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
47
48CXX?=		c++
49CXXFLAGS?=	${CFLAGS}
50COMPILE.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
51LINK.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
52
53OBJC?=		${CC}
54OBJCFLAGS?=	${CFLAGS}
55COMPILE.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
56LINK.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
57
58CPP?=		cpp
59CPPFLAGS?=
60
61FC?=		f77
62FFLAGS?=	-O
63RFLAGS?=
64COMPILE.f?=	${FC} ${FFLAGS} -c
65LINK.f?=	${FC} ${FFLAGS} ${LDFLAGS}
66COMPILE.F?=	${FC} ${FFLAGS} ${CPPFLAGS} -c
67LINK.F?=	${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
68COMPILE.r?=	${FC} ${FFLAGS} ${RFLAGS} -c
69LINK.r?=	${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
70
71INSTALL?=	install
72
73LEX?=		lex
74LFLAGS?=
75LEX.l?=		${LEX} ${LFLAGS}
76
77LD?=		ld
78LDFLAGS?=
79
80LINT?=		lint
81LINTFLAGS?=	-chapbxzF
82
83MAKE?=		${.MAKE}
84
85NM?=		nm
86
87PC?=		pc
88PFLAGS?=
89COMPILE.p?=	${PC} ${PFLAGS} ${CPPFLAGS} -c
90LINK.p?=	${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
91
92SHELL?=		sh
93
94SIZE?=		size
95
96YACC?=		yacc
97YFLAGS?=
98YACC.y?=	${YACC} ${YFLAGS}
99
100# C
101.c:
102	${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
103.c.o:
104	${COMPILE.c} ${.IMPSRC}
105.c.a:
106	${COMPILE.c} ${.IMPSRC}
107	${AR} ${ARFLAGS} $@ $*.o
108	rm -f $*.o
109.c.ln:
110	${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
111
112# C++
113.cc .cpp .cxx .C:
114	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
115.cc.o .cpp.o .cxx.o .C.o:
116	${COMPILE.cc} ${.IMPSRC}
117.cc.a .cpp.a .cxx.a .C.a:
118	${COMPILE.cc} ${.IMPSRC}
119	${AR} ${ARFLAGS} $@ $*.o
120	rm -f $*.o
121
122# Fortran/Ratfor
123.f:
124	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
125.f.o:
126	${COMPILE.f} ${.IMPSRC}
127.f.a:
128	${COMPILE.f} ${.IMPSRC}
129	${AR} ${ARFLAGS} $@ $*.o
130	rm -f $*.o
131
132.F:
133	${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
134.F.o:
135	${COMPILE.F} ${.IMPSRC}
136.F.a:
137	${COMPILE.F} ${.IMPSRC}
138	${AR} ${ARFLAGS} $@ $*.o
139	rm -f $*.o
140
141.r:
142	${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
143.r.o:
144	${COMPILE.r} ${.IMPSRC}
145.r.a:
146	${COMPILE.r} ${.IMPSRC}
147	${AR} ${ARFLAGS} $@ $*.o
148	rm -f $*.o
149
150# Pascal
151.p:
152	${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
153.p.o:
154	${COMPILE.p} ${.IMPSRC}
155.p.a:
156	${COMPILE.p} ${.IMPSRC}
157	${AR} ${ARFLAGS} $@ $*.o
158	rm -f $*.o
159
160# Assembly
161.s:
162	${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
163.s.o:
164	${COMPILE.s} ${.IMPSRC}
165.s.a:
166	${COMPILE.s} ${.IMPSRC}
167	${AR} ${ARFLAGS} $@ $*.o
168	rm -f $*.o
169.S:
170	${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
171.S.o:
172	${COMPILE.S} ${.IMPSRC}
173.S.a:
174	${COMPILE.S} ${.IMPSRC}
175	${AR} ${ARFLAGS} $@ $*.o
176	rm -f $*.o
177
178# Lex
179.l:
180	${LEX.l} ${.IMPSRC}
181	${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
182	rm -f lex.yy.c
183.l.c:
184	${LEX.l} ${.IMPSRC}
185	mv lex.yy.c ${.TARGET}
186.l.o:
187	${LEX.l} ${.IMPSRC}
188	${COMPILE.c} -o ${.TARGET} lex.yy.c
189	rm -f lex.yy.c
190
191# Yacc
192.y:
193	${YACC.y} ${.IMPSRC}
194	${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
195	rm -f y.tab.c
196.y.c:
197	${YACC.y} ${.IMPSRC}
198	mv y.tab.c ${.TARGET}
199.y.o:
200	${YACC.y} ${.IMPSRC}
201	${COMPILE.c} -o ${.TARGET} y.tab.c
202	rm -f y.tab.c
203
204# Shell
205.sh:
206	rm -f ${.TARGET}
207	cp ${.IMPSRC} ${.TARGET}
208
209