xref: /freebsd/contrib/bmake/mk/sys/SunOS.mk (revision 25f3fb54b6bdf5c3112535832462dc130e315dee)
1#	$Id: SunOS.mk,v 1.6 2014/04/05 22:56:54 sjg Exp $
2
3.if ${.PARSEFILE} == "sys.mk"
4.include <host-target.mk>
5
6OS?=		SunOS.${HOST_OSMAJOR}
7unix?=		We run ${OS}.
8.endif
9
10.if ${HOST_OSMAJOR} > 4
11ROOT_GROUP=	root
12
13SHLIB_FULLVERSION = ${SHLIB_MAJOR}
14
15# suppress the dependency
16LIBCRT0= /dev/null
17
18.ifndef CC
19# the PATH below may find an ancient gcc
20CC := ${gcc:L:${M_whence}}
21.export CC
22.endif
23
24# the stuff in /usr/xpg4/bin is usually more sane.
25PATH=/usr/xpg4/bin:/usr/sbin:/usr/bin:/usr/ucb:/usr/sfw/bin:/opt/gnu/bin:/usr/ccs/bin:/usr/local/bin
26.export PATH
27
28DSHLIBEXT = .so
29HOST_LIBDIRS = /usr/lib /lib /usr/sfw/lib
30
31# no -X
32LD_X=
33LD_x=
34RANLIB=		:
35CPP=		/usr/ccs/lib/cpp
36.else
37ROOT_GROUP=	wheel
38RANLIB=		ranlib
39CPP=		cpp
40.endif
41
42# the rest is common
43
44.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
45
46.LIBS:		.a
47
48AR=		ar
49ARFLAGS=	rl
50
51AS=		as
52AS_STDIN=	-
53AFLAGS=
54COMPILE.s=	${AS} ${AFLAGS}
55LINK.s=		${CC} ${AFLAGS} ${LDFLAGS}
56COMPILE.S=	${CC} ${AFLAGS} ${CPPFLAGS} -c
57LINK.S=		${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
58.if exists(/opt/gnu/bin/gcc) || exists(/usr/local/bin/gcc)
59CC ?=		gcc -pipe
60DBG=		-O -g
61STATIC=		-static
62.else
63CC ?=             cc
64DBG=         -g
65STATIC=         -Bstatic
66.endif
67CFLAGS=		${DBG}
68COMPILE.c=	${CC} ${CFLAGS} ${CPPFLAGS} -c
69LINK.c=		${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
70
71CXX=		g++
72CXXFLAGS=	${CFLAGS}
73COMPILE.cc=	${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
74LINK.cc=	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
75
76.if defined(DESTDIR)
77CPPFLAGS+=	-nostdinc -idirafter ${DESTDIR}/usr/include
78.endif
79
80MK_DEP=	mkdeps.sh -N
81FC=		f77
82FFLAGS=		-O
83RFLAGS=
84COMPILE.f=	${FC} ${FFLAGS} -c
85LINK.f=		${FC} ${FFLAGS} ${LDFLAGS}
86COMPILE.F=	${FC} ${FFLAGS} ${CPPFLAGS} -c
87LINK.F=		${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
88COMPILE.r=	${FC} ${FFLAGS} ${RFLAGS} -c
89LINK.r=		${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
90
91LEX=		lex
92LFLAGS=
93LEX.l=		${LEX} ${LFLAGS}
94
95LD=		ld
96LDFLAGS=
97
98LINT=		lint
99LINTFLAGS=	-chapbx
100
101MAKE=		bmake
102
103PC=		pc
104PFLAGS=
105COMPILE.p=	${PC} ${PFLAGS} ${CPPFLAGS} -c
106LINK.p=		${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
107
108SHELL=		sh
109
110.if exists(/usr/local/bin/bison) || exists(/opt/gnu/bin/bison)
111YACC=		bison -y
112.else
113YACC=		yacc
114.endif
115YFLAGS=		-d
116YACC.y=		${YACC} ${YFLAGS}
117
118# C
119.c:
120	${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
121.c.o:
122	${COMPILE.c} ${.IMPSRC}
123.c.a:
124	${COMPILE.c} ${.IMPSRC}
125	${AR} ${ARFLAGS} $@ $*.o
126	rm -f $*.o
127
128# C++
129.cc:
130	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
131.cc.o:
132	${COMPILE.cc} ${.IMPSRC}
133.cc.a:
134	${COMPILE.cc} ${.IMPSRC}
135	${AR} ${ARFLAGS} $@ $*.o
136	rm -f $*.o
137
138.C:
139	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
140.C.o:
141	${COMPILE.cc} ${.IMPSRC}
142.C.a:
143	${COMPILE.cc} ${.IMPSRC}
144	${AR} ${ARFLAGS} $@ $*.o
145	rm -f $*.o
146
147# Fortran/Ratfor
148.f:
149	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
150.f.o:
151	${COMPILE.f} ${.IMPSRC}
152.f.a:
153	${COMPILE.f} ${.IMPSRC}
154	${AR} ${ARFLAGS} $@ $*.o
155	rm -f $*.o
156
157.F:
158	${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
159.F.o:
160	${COMPILE.F} ${.IMPSRC}
161.F.a:
162	${COMPILE.F} ${.IMPSRC}
163	${AR} ${ARFLAGS} $@ $*.o
164	rm -f $*.o
165
166.r:
167	${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
168.r.o:
169	${COMPILE.r} ${.IMPSRC}
170.r.a:
171	${COMPILE.r} ${.IMPSRC}
172	${AR} ${ARFLAGS} $@ $*.o
173	rm -f $*.o
174
175# Pascal
176.p:
177	${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
178.p.o:
179	${COMPILE.p} ${.IMPSRC}
180.p.a:
181	${COMPILE.p} ${.IMPSRC}
182	${AR} ${ARFLAGS} $@ $*.o
183	rm -f $*.o
184
185# Assembly
186.s:
187	${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
188.s.o:
189	${COMPILE.s} ${.IMPSRC}
190.s.a:
191	${COMPILE.s} ${.IMPSRC}
192	${AR} ${ARFLAGS} $@ $*.o
193	rm -f $*.o
194.S:
195	${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
196.S.o:
197	${COMPILE.S} ${.IMPSRC}
198.S.a:
199	${COMPILE.S} ${.IMPSRC}
200	${AR} ${ARFLAGS} $@ $*.o
201	rm -f $*.o
202
203# Lex
204.l:
205	${LEX.l} ${.IMPSRC}
206	${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
207	rm -f lex.yy.c
208.l.c:
209	${LEX.l} ${.IMPSRC}
210	mv lex.yy.c ${.TARGET}
211.l.o:
212	${LEX.l} ${.IMPSRC}
213	${COMPILE.c} -o ${.TARGET} lex.yy.c
214	rm -f lex.yy.c
215
216# Yacc
217.y:
218	${YACC.y} ${.IMPSRC}
219	${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
220	rm -f y.tab.c
221.y.c:
222	${YACC.y} ${.IMPSRC}
223	mv y.tab.c ${.TARGET}
224.y.o:
225	${YACC.y} ${.IMPSRC}
226	${COMPILE.c} -o ${.TARGET} y.tab.c
227	rm -f y.tab.c
228
229# Shell
230.sh:
231	rm -f ${.TARGET}
232	cp ${.IMPSRC} ${.TARGET}
233