xref: /freebsd/contrib/bmake/mk/sys/Linux.mk (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
1#	$Id: Linux.mk,v 1.16 2022/09/09 17:44:29 sjg Exp $
2#	$NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
3#	@(#)sys.mk	5.11 (Berkeley) 3/13/91
4
5OS ?=		Linux
6unix ?=		We run ${OS}.
7
8ROOT_GROUP ?=	root
9
10# would be better to work out where it is...
11LIBCRT0 ?= /dev/null
12
13NEED_SOLINKS ?=yes
14
15.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4
16
17.LIBS:		.a
18
19AR ?=		ar
20ARFLAGS ?=	r
21RANLIB ?=		ranlib
22
23AS ?=		as
24AFLAGS=
25COMPILE.s ?=	${AS} ${AFLAGS}
26LINK.s ?=		${CC} ${AFLAGS} ${LDFLAGS}
27COMPILE.S ?=	${CC} ${AFLAGS} ${CPPFLAGS} -c
28LINK.S ?=		${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
29.if exists(/usr/local/bin/gcc)
30CC ?=		gcc -pipe
31DBG ?=		-O -g
32STATIC ?=		-static
33.else
34CC ?=             cc -pipe
35DBG ?=         -g
36STATIC ?=         -Bstatic
37.endif
38CFLAGS ?=		${DBG}
39COMPILE.c ?=	${CC} ${CFLAGS} ${CPPFLAGS} -c
40LINK.c ?=		${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
41
42CXX ?=		g++
43CXXFLAGS ?=	${CFLAGS}
44COMPILE.cc ?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
45LINK.cc ?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
46
47CPP ?=		cpp
48.if defined(DESTDIR)
49CPPFLAGS+=	-nostdinc -idirafter ${DESTDIR}/usr/include
50.endif
51
52MK_DEP ?=	mkdeps.sh -N
53FC ?=		f77
54FFLAGS ?=		-O
55RFLAGS=
56COMPILE.f ?=	${FC} ${FFLAGS} -c
57LINK.f ?=		${FC} ${FFLAGS} ${LDFLAGS}
58COMPILE.F ?=	${FC} ${FFLAGS} ${CPPFLAGS} -c
59LINK.F ?=		${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
60COMPILE.r ?=	${FC} ${FFLAGS} ${RFLAGS} -c
61LINK.r ?=		${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
62
63LEX ?=		lex
64LFLAGS=
65LEX.l ?=		${LEX} ${LFLAGS}
66
67LD ?=		ld
68LDFLAGS=
69
70LINT ?=		lint
71LINTFLAGS ?=	-chapbx
72
73PC ?=		pc
74PFLAGS=
75COMPILE.p ?=	${PC} ${PFLAGS} ${CPPFLAGS} -c
76LINK.p ?=		${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
77
78YACC ?=		yacc
79YFLAGS ?=		-d
80YACC.y ?=		${YACC} ${YFLAGS}
81
82# C
83.c:
84	${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
85.c.o:
86	${COMPILE.c} ${.IMPSRC}
87.c.a:
88	${COMPILE.c} ${.IMPSRC}
89	${AR} ${ARFLAGS} $@ $*.o
90	rm -f $*.o
91
92# C++
93${CXX_SUFFIXES}:
94	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
95${CXX_SUFFIXES:%=%.o}:
96	${COMPILE.cc} ${.IMPSRC}
97${CXX_SUFFIXES:%=%.a}:
98	${COMPILE.cc} ${.IMPSRC}
99	${AR} ${ARFLAGS} $@ $*.o
100	rm -f $*.o
101
102# Fortran/Ratfor
103.f:
104	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
105.f.o:
106	${COMPILE.f} ${.IMPSRC}
107.f.a:
108	${COMPILE.f} ${.IMPSRC}
109	${AR} ${ARFLAGS} $@ $*.o
110	rm -f $*.o
111
112.F:
113	${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
114.F.o:
115	${COMPILE.F} ${.IMPSRC}
116.F.a:
117	${COMPILE.F} ${.IMPSRC}
118	${AR} ${ARFLAGS} $@ $*.o
119	rm -f $*.o
120
121.r:
122	${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
123.r.o:
124	${COMPILE.r} ${.IMPSRC}
125.r.a:
126	${COMPILE.r} ${.IMPSRC}
127	${AR} ${ARFLAGS} $@ $*.o
128	rm -f $*.o
129
130# Pascal
131.p:
132	${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
133.p.o:
134	${COMPILE.p} ${.IMPSRC}
135.p.a:
136	${COMPILE.p} ${.IMPSRC}
137	${AR} ${ARFLAGS} $@ $*.o
138	rm -f $*.o
139
140# Assembly
141.s:
142	${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
143.s.o:
144	${COMPILE.s} -o ${.TARGET} ${.IMPSRC}
145.s.a:
146	${COMPILE.s} ${.IMPSRC}
147	${AR} ${ARFLAGS} $@ $*.o
148	rm -f $*.o
149.S:
150	${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
151.S.o:
152	${COMPILE.S} ${.IMPSRC}
153.S.a:
154	${COMPILE.S} ${.IMPSRC}
155	${AR} ${ARFLAGS} $@ $*.o
156	rm -f $*.o
157
158# Lex
159.l:
160	${LEX.l} ${.IMPSRC}
161	${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
162	rm -f lex.yy.c
163.l.c:
164	${LEX.l} ${.IMPSRC}
165	mv lex.yy.c ${.TARGET}
166.l.o:
167	${LEX.l} ${.IMPSRC}
168	${COMPILE.c} -o ${.TARGET} lex.yy.c
169	rm -f lex.yy.c
170
171# Yacc
172.y:
173	${YACC.y} ${.IMPSRC}
174	${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
175	rm -f y.tab.c
176.y.c:
177	${YACC.y} ${.IMPSRC}
178	mv y.tab.c ${.TARGET}
179.y.o:
180	${YACC.y} ${.IMPSRC}
181	${COMPILE.c} -o ${.TARGET} y.tab.c
182	rm -f y.tab.c
183
184# Shell
185.sh:
186	rm -f ${.TARGET}
187	cp ${.IMPSRC} ${.TARGET}
188	chmod a+x ${.TARGET}
189
190
191# egrep is deprecated
192EGREP = grep -E
193