xref: /freebsd/contrib/bmake/mk/sys/NetBSD.mk (revision 640235e2c2ba32947f7c59d168437ffa1280f1e6)
1#	$NetBSD: sys.mk,v 1.66.2.1 2002/06/05 03:31:01 lukem Exp $
2#	@(#)sys.mk	8.2 (Berkeley) 3/21/94
3
4OS=		NetBSD
5unix?=		We run ${OS}.
6
7.if !defined(MAKE_VERSION)
8# we are running native make
9# which defined MAKE_VERSION between 20010609 and 20090324
10# so we can make a rough guess
11.if defined(.MAKE.LEVEL)
12MAKE_VERSION = 20090908
13.elif defined(.MAKE.MAKEFILES)
14# introduced 20071008
15MAKE_VERSION = 20090324
16.else
17# this just before when MAKE_VERSION was introduced
18MAKE_VERSION = 20010606
19.endif
20.endif
21
22.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h
23.SUFFIXES: .sh .m4
24
25.LIBS:		.a
26
27AR?=		ar
28ARFLAGS?=	rl
29RANLIB?=	ranlib
30
31AS?=		as
32AFLAGS?=
33COMPILE.s?=	${CC} ${AFLAGS} -c
34LINK.s?=	${CC} ${AFLAGS} ${LDFLAGS}
35COMPILE.S?=	${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
36LINK.S?=	${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
37
38CC?=		cc
39
40# need to make sure this is set
41MACHINE_ARCH.${MACHINE} ?= ${MACHINE}
42.if empty(MACHINE_ARCH)
43MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}}
44.endif
45
46#
47# CPU model, derived from MACHINE_ARCH
48#
49MACHINE_CPU=	${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips/:C/sh3e[bl]/sh3/:S/m68000/m68k/:S/armeb/arm/}
50
51.if ${MACHINE_CPU} == "alpha" || \
52    ${MACHINE_CPU} == "arm" || \
53    ${MACHINE_CPU} == "i386" || \
54    ${MACHINE_CPU} == "m68k" || \
55    ${MACHINE_CPU} == "mips" || \
56    ${MACHINE_CPU} == "powerpc" || \
57    ${MACHINE_CPU} == "sparc" || \
58    ${MACHINE_CPU} == "vax"
59DBG?=	-O2
60.elif ${MACHINE_ARCH} == "x86_64"
61DBG?=
62.elif ${MACHINE_ARCH} == "sparc64"
63DBG?=	-O -ffixed-g4	#Hack for embedany memory model compatibility
64.else
65DBG?=	-O
66.endif
67CFLAGS?=	${DBG}
68COMPILE.c?=	${CC} ${CFLAGS} ${CPPFLAGS} -c
69LINK.c?=	${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
70
71CXX?=		c++
72CXXFLAGS?=	${CFLAGS}
73COMPILE.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
74LINK.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
75
76OBJC?=		${CC}
77OBJCFLAGS?=	${CFLAGS}
78COMPILE.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
79LINK.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
80
81CPP?=		cpp
82CPPFLAGS?=
83
84FC?=		f77
85FFLAGS?=	-O
86RFLAGS?=
87COMPILE.f?=	${FC} ${FFLAGS} -c
88LINK.f?=	${FC} ${FFLAGS} ${LDFLAGS}
89COMPILE.F?=	${FC} ${FFLAGS} ${CPPFLAGS} -c
90LINK.F?=	${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
91COMPILE.r?=	${FC} ${FFLAGS} ${RFLAGS} -c
92LINK.r?=	${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
93
94INSTALL?=	install
95
96LEX?=		lex
97LFLAGS?=
98LEX.l?=		${LEX} ${LFLAGS}
99
100LD?=		ld
101LDFLAGS?=
102
103LINT?=		lint
104LINTFLAGS?=	-chapbxzF
105
106LORDER?=	lorder
107
108MAKE?=		make
109
110NM?=		nm
111
112PC?=		pc
113PFLAGS?=
114COMPILE.p?=	${PC} ${PFLAGS} ${CPPFLAGS} -c
115LINK.p?=	${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
116
117SHELL?=		sh
118
119SIZE?=		size
120
121TSORT?= 	tsort -q
122
123YACC?=		yacc
124YFLAGS?=
125YACC.y?=	${YACC} ${YFLAGS}
126
127# C
128.c:
129	${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
130.c.o:
131	${COMPILE.c} ${.IMPSRC}
132.c.a:
133	${COMPILE.c} ${.IMPSRC}
134	${AR} ${ARFLAGS} $@ $*.o
135	rm -f $*.o
136.c.ln:
137	${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
138
139# C++
140${CXX_SUFFIXES}:
141	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
142${CXX_SUFFIXES:%=%.o}:
143	${COMPILE.cc} ${.IMPSRC}
144${CXX_SUFFIXES:%=%.a}:
145	${COMPILE.cc} ${.IMPSRC}
146	${AR} ${ARFLAGS} $@ $*.o
147	rm -f $*.o
148
149# Fortran/Ratfor
150.f:
151	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
152.f.o:
153	${COMPILE.f} ${.IMPSRC}
154.f.a:
155	${COMPILE.f} ${.IMPSRC}
156	${AR} ${ARFLAGS} $@ $*.o
157	rm -f $*.o
158
159.F:
160	${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
161.F.o:
162	${COMPILE.F} ${.IMPSRC}
163.F.a:
164	${COMPILE.F} ${.IMPSRC}
165	${AR} ${ARFLAGS} $@ $*.o
166	rm -f $*.o
167
168.r:
169	${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
170.r.o:
171	${COMPILE.r} ${.IMPSRC}
172.r.a:
173	${COMPILE.r} ${.IMPSRC}
174	${AR} ${ARFLAGS} $@ $*.o
175	rm -f $*.o
176
177# Pascal
178.p:
179	${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
180.p.o:
181	${COMPILE.p} ${.IMPSRC}
182.p.a:
183	${COMPILE.p} ${.IMPSRC}
184	${AR} ${ARFLAGS} $@ $*.o
185	rm -f $*.o
186
187# Assembly
188.s:
189	${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
190.s.o:
191	${COMPILE.s} ${.IMPSRC}
192.s.a:
193	${COMPILE.s} ${.IMPSRC}
194	${AR} ${ARFLAGS} $@ $*.o
195	rm -f $*.o
196.S:
197	${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
198.S.o:
199	${COMPILE.S} ${.IMPSRC}
200.S.a:
201	${COMPILE.S} ${.IMPSRC}
202	${AR} ${ARFLAGS} $@ $*.o
203	rm -f $*.o
204
205# Lex
206.l:
207	${LEX.l} ${.IMPSRC}
208	${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
209	rm -f lex.yy.c
210.l.c:
211	${LEX.l} ${.IMPSRC}
212	mv lex.yy.c ${.TARGET}
213.l.o:
214	${LEX.l} ${.IMPSRC}
215	${COMPILE.c} -o ${.TARGET} lex.yy.c
216	rm -f lex.yy.c
217
218# Yacc
219.y:
220	${YACC.y} ${.IMPSRC}
221	${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
222	rm -f y.tab.c
223.y.c:
224	${YACC.y} ${.IMPSRC}
225	mv y.tab.c ${.TARGET}
226.y.o:
227	${YACC.y} ${.IMPSRC}
228	${COMPILE.c} -o ${.TARGET} y.tab.c
229	rm -f y.tab.c
230
231# Shell
232.sh:
233	rm -f ${.TARGET}
234	cp ${.IMPSRC} ${.TARGET}
235