xref: /minix3/share/mk/sys.mk (revision 72965c888556d9fcaba2bb0392bec8cae8bf4b98)
10a6a1f1dSLionel Sambuc#	$NetBSD: sys.mk,v 1.128 2015/07/06 00:21:51 chs Exp $
2e1091647SArun Thomas#	@(#)sys.mk	8.2 (Berkeley) 3/21/94
384d9c625SLionel Sambuc#
484d9c625SLionel Sambuc# This file contains the basic rules for make(1) and is read first
584d9c625SLionel Sambuc# Do not put conditionals that are set on different files here and
684d9c625SLionel Sambuc# expect them to work.
7e1091647SArun Thomas
86567e50aSGianluca Guida# This variable should be used to differentiate Minix builds in Makefiles.
96567e50aSGianluca Guida__MINIX=	yes
106567e50aSGianluca Guida
1184d9c625SLionel Sambuc.if !defined(__MINIX)
1284d9c625SLionel Sambucunix?=		We run NetBSD.
1384d9c625SLionel Sambuc
1484d9c625SLionel Sambuc.SUFFIXES: .a .o .ln .s .S .c .cc .cpp .cxx .C .f .F .r .p .l .y .sh
1584d9c625SLionel Sambuc.else
1684d9c625SLionel Sambucunix?=		We run MINIX.
1784d9c625SLionel Sambuc
1884d9c625SLionel Sambuc.SUFFIXES: .a .o .bc .ln .s .S .c .cc .cpp .cxx .C .f .F .r .p .l .y .sh
1984d9c625SLionel Sambuc
20b8a678efSLionel Sambuc.if ${MKSMALL:U} == "yes"
21fbd82e76SLionel SambucCPPFLAGS+= -DNDEBUG
22b8a678efSLionel SambucDBG=	-Os
23b8a678efSLionel Sambuc.endif
24f1deff71SLionel Sambuc
25*72965c88SDavid van Moolenbroek.if ${MKMAGIC:Uno} == "yes" || ${MKASR:Uno} == "yes"
26bcc17a81SDavid van MoolenbroekCPPFLAGS+= -D_MINIX_MAGIC=1
27bcc17a81SDavid van MoolenbroekSTRIPFLAG= -s
28bcc17a81SDavid van MoolenbroekDBG=-g
29bcc17a81SDavid van Moolenbroek.endif
30bcc17a81SDavid van Moolenbroek
31f1deff71SLionel Sambuc#LSC: Be a bit smarter about the default compiler
32f1deff71SLionel Sambuc.if exists(/usr/pkg/bin/clang) || exists(/usr/bin/clang)
33f1deff71SLionel SambucCC?=	clang
34f1deff71SLionel Sambuc.endif
35f1deff71SLionel Sambuc
36f1deff71SLionel Sambuc.if exists(/usr/pkg/bin/gcc) || exists(/usr/bin/gcc)
37f1deff71SLionel SambucCC?=	gcc
38f1deff71SLionel Sambuc.endif
39b8a678efSLionel Sambuc.endif # defined(__MINIX)
40e1091647SArun Thomas
41e1091647SArun Thomas.LIBS:		.a
42e1091647SArun Thomas
439152e1c5SLionel SambucAR?=		ar
44e1091647SArun ThomasARFLAGS?=	rl
45e1091647SArun ThomasRANLIB?=	ranlib
46e1091647SArun Thomas
47e1091647SArun ThomasAS?=		as
48e1091647SArun ThomasAFLAGS?=
499152e1c5SLionel SambucCOMPILE.s?=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} -c
509152e1c5SLionel SambucLINK.s?=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${LDFLAGS}
510a6a1f1dSLionel Sambuc_ASM_TRADITIONAL_CPP=	-x assembler-with-cpp
529152e1c5SLionel SambucCOMPILE.S?=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} ${_ASM_TRADITIONAL_CPP} -c
539152e1c5SLionel SambucLINK.S?=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} ${LDFLAGS}
54e1091647SArun Thomas
55b8a678efSLionel SambucCC?=		cc
569152e1c5SLionel Sambuc.if ${MACHINE_ARCH} == "sh3el" || ${MACHINE_ARCH} == "sh3eb"
57e1091647SArun Thomas# -O2 is too -falign-* zealous for low-memory sh3 machines
58e1091647SArun ThomasDBG?=	-Os -freorder-blocks
599152e1c5SLionel Sambuc.elif ${MACHINE_ARCH} == "m68k" || ${MACHINE_ARCH} == "m68000"
600a6a1f1dSLionel Sambuc# -freorder-blocks (enabled by -O2) produces much bigger code
610a6a1f1dSLionel SambucDBG?=	-O2 -fno-reorder-blocks
6284d9c625SLionel Sambuc.elif ${MACHINE_ARCH} == "coldfire"
6384d9c625SLionel SambucDBG?=	-O1
640a6a1f1dSLionel Sambuc.elif !empty(MACHINE_ARCH:Maarch64*)
650a6a1f1dSLionel SambucDBG?=	-O2 ${"${.TARGET:M*.po}" == "":? -fomit-frame-pointer:}
66e1091647SArun Thomas.elif ${MACHINE_ARCH} == "vax"
67e1091647SArun ThomasDBG?=	-O1 -fgcse -fstrength-reduce -fgcse-after-reload
68e1091647SArun Thomas.else
69b8a678efSLionel SambucDBG?=	-O2
70e1091647SArun Thomas.endif
713ceafe99SLionel Sambuc.if !defined(__MINIX)
72e1091647SArun ThomasCFLAGS?=	${DBG}
733ceafe99SLionel Sambuc.else
743ceafe99SLionel SambucCFLAGS+=	${DBG}
753ceafe99SLionel Sambuc.endif # !defined(__MINIX)
76e1091647SArun ThomasLDFLAGS?=
77e1091647SArun ThomasCOMPILE.c?=	${CC} ${CFLAGS} ${CPPFLAGS} -c
78e1091647SArun ThomasLINK.c?=	${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
79e1091647SArun Thomas
809152e1c5SLionel Sambuc# C Type Format data is required for DTrace
8184d9c625SLionel SambucCTFFLAGS	?=	-g -L VERSION
820a6a1f1dSLionel SambucCTFMFLAGS	?=	-t -g -L VERSION
839152e1c5SLionel Sambuc
84e1091647SArun ThomasCXX?=		c++
8584d9c625SLionel SambucCXXFLAGS?=	${CFLAGS:N-Wno-traditional:N-Wstrict-prototypes:N-Wmissing-prototypes:N-Wno-pointer-sign:N-ffreestanding:N-std=gnu[0-9][0-9]:N-Wold-style-definition:N-Wno-format-zero-length}
86e1091647SArun Thomas
87e1091647SArun Thomas__ALLSRC1=	${empty(DESTDIR):?${.ALLSRC}:${.ALLSRC:S|^${DESTDIR}|^destdir|}}
88e1091647SArun Thomas__ALLSRC2=	${empty(MAKEOBJDIR):?${__ALLSRC1}:${__ALLSRC1:S|^${MAKEOBJDIR}|^obj|}}
89e1091647SArun Thomas__ALLSRC3=	${empty(NETBSDSRCDIR):?${__ALLSRC2}:${__ALLSRC2:S|^${NETBSDSRCDIR}|^src|}}
909152e1c5SLionel Sambuc__BUILDSEED=	${BUILDSEED}/${__ALLSRC3:O}/${.TARGET}
919152e1c5SLionel Sambuc_CXXSEED?=	${BUILDSEED:D-frandom-seed=${__BUILDSEED:hash}}
92e1091647SArun Thomas
93e1091647SArun ThomasCOMPILE.cc?=	${CXX} ${_CXXSEED} ${CXXFLAGS} ${CPPFLAGS} -c
94e1091647SArun ThomasLINK.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
95e1091647SArun Thomas
96e1091647SArun ThomasOBJC?=		${CC}
97e1091647SArun ThomasOBJCFLAGS?=	${CFLAGS}
98e1091647SArun ThomasCOMPILE.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
99e1091647SArun ThomasLINK.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
100e1091647SArun Thomas
101e1091647SArun ThomasCPP?=		cpp
102e1091647SArun ThomasCPPFLAGS?=
103e1091647SArun Thomas
104e1091647SArun ThomasFC?=		f77
105e1091647SArun ThomasFFLAGS?=	-O
106e1091647SArun ThomasRFLAGS?=
107e1091647SArun ThomasCOMPILE.f?=	${FC} ${FFLAGS} -c
108e1091647SArun ThomasLINK.f?=	${FC} ${FFLAGS} ${LDFLAGS}
109e1091647SArun ThomasCOMPILE.F?=	${FC} ${FFLAGS} ${CPPFLAGS} -c
110e1091647SArun ThomasLINK.F?=	${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
111e1091647SArun ThomasCOMPILE.r?=	${FC} ${FFLAGS} ${RFLAGS} -c
112e1091647SArun ThomasLINK.r?=	${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
113e1091647SArun Thomas
114e1091647SArun ThomasINSTALL?=	install
115e1091647SArun Thomas
116e1091647SArun ThomasLD?=		ld
117e1091647SArun Thomas
118e1091647SArun ThomasLEX?=		lex
119e1091647SArun ThomasLFLAGS?=
120e1091647SArun ThomasLEX.l?=		${LEX} ${LFLAGS}
121e1091647SArun Thomas
122e1091647SArun ThomasLINT?=		lint
1230a6a1f1dSLionel SambucLINTFLAGS?=	-chapbxzgFS
124e1091647SArun Thomas
125e1091647SArun ThomasLORDER?=	lorder
126e1091647SArun Thomas
127e1091647SArun ThomasMAKE?=		make
128e1091647SArun Thomas
129e1091647SArun ThomasNM?=		nm
130e1091647SArun Thomas
131e1091647SArun ThomasPC?=		pc
132e1091647SArun ThomasPFLAGS?=
133e1091647SArun ThomasCOMPILE.p?=	${PC} ${PFLAGS} ${CPPFLAGS} -c
134e1091647SArun ThomasLINK.p?=	${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
135e1091647SArun Thomas
136e1091647SArun ThomasSHELL?=		sh
137e1091647SArun Thomas
138e1091647SArun ThomasSIZE?=		size
139e1091647SArun Thomas
140e1091647SArun ThomasTSORT?= 	tsort -q
141e1091647SArun Thomas
142e1091647SArun ThomasYACC?=		yacc
143e1091647SArun ThomasYFLAGS?=
144e1091647SArun ThomasYACC.y?=	${YACC} ${YFLAGS}
145e1091647SArun Thomas
146e1091647SArun Thomas# C
147e1091647SArun Thomas.c:
148e1091647SArun Thomas	${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
1490a6a1f1dSLionel Sambuc# XXX: disable for now
1500a6a1f1dSLionel Sambuc#	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
151e1091647SArun Thomas.c.o:
152e1091647SArun Thomas	${COMPILE.c} ${.IMPSRC}
1530a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
154e1091647SArun Thomas.c.a:
155e1091647SArun Thomas	${COMPILE.c} ${.IMPSRC}
156e1091647SArun Thomas	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
157e1091647SArun Thomas	rm -f ${.PREFIX}.o
158e1091647SArun Thomas.c.ln:
159e1091647SArun Thomas	${LINT} ${LINTFLAGS} \
160e1091647SArun Thomas	    ${CPPFLAGS:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
161e1091647SArun Thomas	    -i ${.IMPSRC}
162e1091647SArun Thomas
163e1091647SArun Thomas# C++
164e1091647SArun Thomas.cc .cpp .cxx .C:
165e1091647SArun Thomas	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
166e1091647SArun Thomas.cc.o .cpp.o .cxx.o .C.o:
167e1091647SArun Thomas	${COMPILE.cc} ${.IMPSRC}
168e1091647SArun Thomas.cc.a .cpp.a .cxx.a .C.a:
169e1091647SArun Thomas	${COMPILE.cc} ${.IMPSRC}
170e1091647SArun Thomas	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
171e1091647SArun Thomas	rm -f ${.PREFIX}.o
172e1091647SArun Thomas
173e1091647SArun Thomas# Fortran/Ratfor
174e1091647SArun Thomas.f:
175e1091647SArun Thomas	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
176e1091647SArun Thomas.f.o:
177e1091647SArun Thomas	${COMPILE.f} ${.IMPSRC}
1780a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
179e1091647SArun Thomas.f.a:
180e1091647SArun Thomas	${COMPILE.f} ${.IMPSRC}
181e1091647SArun Thomas	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
182e1091647SArun Thomas	rm -f ${.PREFIX}.o
183e1091647SArun Thomas
184e1091647SArun Thomas.F:
185e1091647SArun Thomas	${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
1860a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
187e1091647SArun Thomas.F.o:
188e1091647SArun Thomas	${COMPILE.F} ${.IMPSRC}
1890a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
190e1091647SArun Thomas.F.a:
191e1091647SArun Thomas	${COMPILE.F} ${.IMPSRC}
192e1091647SArun Thomas	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
193e1091647SArun Thomas	rm -f ${.PREFIX}.o
194e1091647SArun Thomas
195e1091647SArun Thomas.r:
196e1091647SArun Thomas	${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
197e1091647SArun Thomas.r.o:
198e1091647SArun Thomas	${COMPILE.r} ${.IMPSRC}
1990a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
200e1091647SArun Thomas.r.a:
201e1091647SArun Thomas	${COMPILE.r} ${.IMPSRC}
202e1091647SArun Thomas	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
203e1091647SArun Thomas	rm -f ${.PREFIX}.o
204e1091647SArun Thomas
205e1091647SArun Thomas# Pascal
206e1091647SArun Thomas.p:
207e1091647SArun Thomas	${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
2080a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
209e1091647SArun Thomas.p.o:
210e1091647SArun Thomas	${COMPILE.p} ${.IMPSRC}
2110a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
212e1091647SArun Thomas.p.a:
213e1091647SArun Thomas	${COMPILE.p} ${.IMPSRC}
214e1091647SArun Thomas	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
215e1091647SArun Thomas	rm -f ${.PREFIX}.o
216e1091647SArun Thomas
217e1091647SArun Thomas# Assembly
218e1091647SArun Thomas.s:
219e1091647SArun Thomas	${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
2200a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
221e1091647SArun Thomas.s.o:
222e1091647SArun Thomas	${COMPILE.s} ${.IMPSRC}
2230a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
224e1091647SArun Thomas.s.a:
225e1091647SArun Thomas	${COMPILE.s} ${.IMPSRC}
226e1091647SArun Thomas	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
227e1091647SArun Thomas	rm -f ${.PREFIX}.o
228e1091647SArun Thomas.S:
229e1091647SArun Thomas	${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
2300a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
231e1091647SArun Thomas.S.o:
232e1091647SArun Thomas	${COMPILE.S} ${.IMPSRC}
2330a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
234e1091647SArun Thomas.S.a:
235e1091647SArun Thomas	${COMPILE.S} ${.IMPSRC}
236e1091647SArun Thomas	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
237e1091647SArun Thomas	rm -f ${.PREFIX}.o
238e1091647SArun Thomas
239e1091647SArun Thomas# Lex
240e1091647SArun Thomas.l:
241e1091647SArun Thomas	${LEX.l} ${.IMPSRC}
242e1091647SArun Thomas	${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
243e1091647SArun Thomas	rm -f lex.yy.c
244e1091647SArun Thomas.l.c:
245e1091647SArun Thomas	${LEX.l} ${.IMPSRC}
246e1091647SArun Thomas	mv lex.yy.c ${.TARGET}
247e1091647SArun Thomas.l.o:
248e1091647SArun Thomas	${LEX.l} ${.IMPSRC}
249e1091647SArun Thomas	${COMPILE.c} -o ${.TARGET} lex.yy.c
2500a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
251e1091647SArun Thomas	rm -f lex.yy.c
252e1091647SArun Thomas
253e1091647SArun Thomas# Yacc
254e1091647SArun Thomas.y:
255e1091647SArun Thomas	${YACC.y} ${.IMPSRC}
256e1091647SArun Thomas	${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
257e1091647SArun Thomas	rm -f y.tab.c
258e1091647SArun Thomas.y.c:
259e1091647SArun Thomas	${YACC.y} ${.IMPSRC}
260e1091647SArun Thomas	mv y.tab.c ${.TARGET}
261e1091647SArun Thomas.y.o:
262e1091647SArun Thomas	${YACC.y} ${.IMPSRC}
263e1091647SArun Thomas	${COMPILE.c} -o ${.TARGET} y.tab.c
2640a6a1f1dSLionel Sambuc	${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
265e1091647SArun Thomas	rm -f y.tab.c
266e1091647SArun Thomas
267e1091647SArun Thomas# Shell
2689152e1c5SLionel Sambuc.sh:
2699152e1c5SLionel Sambuc	rm -f ${.TARGET}
2709152e1c5SLionel Sambuc	cp ${.IMPSRC} ${.TARGET}
2719152e1c5SLionel Sambuc	chmod a+x ${.TARGET}
272