xref: /freebsd/contrib/bmake/mk/sys/Generic.mk (revision 3c5ba95ad12285ad37c182a4bfc1b240ec6d18a7)
1#	$Id: Generic.mk,v 1.13 2017/05/05 18:02:16 sjg Exp $
2#
3
4# some reasonable defaults
5.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .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
83NM?=		nm
84
85PC?=		pc
86PFLAGS?=
87COMPILE.p?=	${PC} ${PFLAGS} ${CPPFLAGS} -c
88LINK.p?=	${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
89
90SHELL?=		sh
91
92SIZE?=		size
93
94YACC?=		yacc
95YFLAGS?=
96YACC.y?=	${YACC} ${YFLAGS}
97
98# C
99.c:
100	${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
101.c.o:
102	${COMPILE.c} ${.IMPSRC}
103.c.a:
104	${COMPILE.c} ${.IMPSRC}
105	${AR} ${ARFLAGS} $@ $*.o
106	rm -f $*.o
107.c.ln:
108	${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
109
110# C++
111${CXX_SUFFIXES}:
112	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
113${CXX_SUFFIXES:%=%.o}:
114	${COMPILE.cc} ${.IMPSRC}
115${CXX_SUFFIXES:%=%.a}:
116	${COMPILE.cc} ${.IMPSRC}
117	${AR} ${ARFLAGS} $@ $*.o
118	rm -f $*.o
119
120# Fortran/Ratfor
121.f:
122	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
123.f.o:
124	${COMPILE.f} ${.IMPSRC}
125.f.a:
126	${COMPILE.f} ${.IMPSRC}
127	${AR} ${ARFLAGS} $@ $*.o
128	rm -f $*.o
129
130.F:
131	${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
132.F.o:
133	${COMPILE.F} ${.IMPSRC}
134.F.a:
135	${COMPILE.F} ${.IMPSRC}
136	${AR} ${ARFLAGS} $@ $*.o
137	rm -f $*.o
138
139.r:
140	${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
141.r.o:
142	${COMPILE.r} ${.IMPSRC}
143.r.a:
144	${COMPILE.r} ${.IMPSRC}
145	${AR} ${ARFLAGS} $@ $*.o
146	rm -f $*.o
147
148# Pascal
149.p:
150	${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
151.p.o:
152	${COMPILE.p} ${.IMPSRC}
153.p.a:
154	${COMPILE.p} ${.IMPSRC}
155	${AR} ${ARFLAGS} $@ $*.o
156	rm -f $*.o
157
158# Assembly
159.s:
160	${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
161.s.o:
162	${COMPILE.s} ${.IMPSRC}
163.s.a:
164	${COMPILE.s} ${.IMPSRC}
165	${AR} ${ARFLAGS} $@ $*.o
166	rm -f $*.o
167.S:
168	${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
169.S.o:
170	${COMPILE.S} ${.IMPSRC}
171.S.a:
172	${COMPILE.S} ${.IMPSRC}
173	${AR} ${ARFLAGS} $@ $*.o
174	rm -f $*.o
175
176# Lex
177.l:
178	${LEX.l} ${.IMPSRC}
179	${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
180	rm -f lex.yy.c
181.l.c:
182	${LEX.l} ${.IMPSRC}
183	mv lex.yy.c ${.TARGET}
184.l.o:
185	${LEX.l} ${.IMPSRC}
186	${COMPILE.c} -o ${.TARGET} lex.yy.c
187	rm -f lex.yy.c
188
189# Yacc
190.y:
191	${YACC.y} ${.IMPSRC}
192	${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
193	rm -f y.tab.c
194.y.c:
195	${YACC.y} ${.IMPSRC}
196	mv y.tab.c ${.TARGET}
197.y.o:
198	${YACC.y} ${.IMPSRC}
199	${COMPILE.c} -o ${.TARGET} y.tab.c
200	rm -f y.tab.c
201
202# Shell
203.sh:
204	rm -f ${.TARGET}
205	cp ${.IMPSRC} ${.TARGET}
206
207