xref: /freebsd/contrib/bmake/mk/sys/Linux.mk (revision 389e4940069316fe667ffa263fa7d6390d0a960f)
1#	$Id: Linux.mk,v 1.9 2017/05/05 18:02:16 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=	rl
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
78SHELL=		sh
79
80YACC=		yacc
81YFLAGS=		-d
82YACC.y=		${YACC} ${YFLAGS}
83
84# C
85.c:
86	${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
87.c.o:
88	${COMPILE.c} ${.IMPSRC}
89.c.a:
90	${COMPILE.c} ${.IMPSRC}
91	${AR} ${ARFLAGS} $@ $*.o
92	rm -f $*.o
93
94# C++
95${CXX_SUFFIXES}:
96	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
97${CXX_SUFFIXES:%=%.o}:
98	${COMPILE.cc} ${.IMPSRC}
99${CXX_SUFFIXES:%=%.a}:
100	${COMPILE.cc} ${.IMPSRC}
101	${AR} ${ARFLAGS} $@ $*.o
102	rm -f $*.o
103
104# Fortran/Ratfor
105.f:
106	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
107.f.o:
108	${COMPILE.f} ${.IMPSRC}
109.f.a:
110	${COMPILE.f} ${.IMPSRC}
111	${AR} ${ARFLAGS} $@ $*.o
112	rm -f $*.o
113
114.F:
115	${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
116.F.o:
117	${COMPILE.F} ${.IMPSRC}
118.F.a:
119	${COMPILE.F} ${.IMPSRC}
120	${AR} ${ARFLAGS} $@ $*.o
121	rm -f $*.o
122
123.r:
124	${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
125.r.o:
126	${COMPILE.r} ${.IMPSRC}
127.r.a:
128	${COMPILE.r} ${.IMPSRC}
129	${AR} ${ARFLAGS} $@ $*.o
130	rm -f $*.o
131
132# Pascal
133.p:
134	${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
135.p.o:
136	${COMPILE.p} ${.IMPSRC}
137.p.a:
138	${COMPILE.p} ${.IMPSRC}
139	${AR} ${ARFLAGS} $@ $*.o
140	rm -f $*.o
141
142# Assembly
143.s:
144	${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
145.s.o:
146	${COMPILE.s} -o ${.TARGET} ${.IMPSRC}
147.s.a:
148	${COMPILE.s} ${.IMPSRC}
149	${AR} ${ARFLAGS} $@ $*.o
150	rm -f $*.o
151.S:
152	${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
153.S.o:
154	${COMPILE.S} ${.IMPSRC}
155.S.a:
156	${COMPILE.S} ${.IMPSRC}
157	${AR} ${ARFLAGS} $@ $*.o
158	rm -f $*.o
159
160# Lex
161.l:
162	${LEX.l} ${.IMPSRC}
163	${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
164	rm -f lex.yy.c
165.l.c:
166	${LEX.l} ${.IMPSRC}
167	mv lex.yy.c ${.TARGET}
168.l.o:
169	${LEX.l} ${.IMPSRC}
170	${COMPILE.c} -o ${.TARGET} lex.yy.c
171	rm -f lex.yy.c
172
173# Yacc
174.y:
175	${YACC.y} ${.IMPSRC}
176	${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
177	rm -f y.tab.c
178.y.c:
179	${YACC.y} ${.IMPSRC}
180	mv y.tab.c ${.TARGET}
181.y.o:
182	${YACC.y} ${.IMPSRC}
183	${COMPILE.c} -o ${.TARGET} y.tab.c
184	rm -f y.tab.c
185
186# Shell
187.sh:
188	rm -f ${.TARGET}
189	cp ${.IMPSRC} ${.TARGET}
190