xref: /freebsd/contrib/bmake/mk/sys/SunOS.mk (revision 77a1348b3c1cfe8547be49a121b56299a1e18b69)
1#	$Id: SunOS.mk,v 1.8 2017/05/05 18:02:17 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 ${CXX_SUFFIXES} .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
101PC=		pc
102PFLAGS=
103COMPILE.p=	${PC} ${PFLAGS} ${CPPFLAGS} -c
104LINK.p=		${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
105
106SHELL=		sh
107
108.if exists(/usr/local/bin/bison) || exists(/opt/gnu/bin/bison)
109YACC=		bison -y
110.else
111YACC=		yacc
112.endif
113YFLAGS=		-d
114YACC.y=		${YACC} ${YFLAGS}
115
116# C
117.c:
118	${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
119.c.o:
120	${COMPILE.c} ${.IMPSRC}
121.c.a:
122	${COMPILE.c} ${.IMPSRC}
123	${AR} ${ARFLAGS} $@ $*.o
124	rm -f $*.o
125
126# C++
127${CXX_SUFFIXES}:
128	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
129${CXX_SUFFIXES:%=%.o}:
130	${COMPILE.cc} ${.IMPSRC}
131${CXX_SUFFIXES:%=%.a}:
132	${COMPILE.cc} ${.IMPSRC}
133	${AR} ${ARFLAGS} $@ $*.o
134	rm -f $*.o
135
136# Fortran/Ratfor
137.f:
138	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
139.f.o:
140	${COMPILE.f} ${.IMPSRC}
141.f.a:
142	${COMPILE.f} ${.IMPSRC}
143	${AR} ${ARFLAGS} $@ $*.o
144	rm -f $*.o
145
146.F:
147	${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
148.F.o:
149	${COMPILE.F} ${.IMPSRC}
150.F.a:
151	${COMPILE.F} ${.IMPSRC}
152	${AR} ${ARFLAGS} $@ $*.o
153	rm -f $*.o
154
155.r:
156	${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
157.r.o:
158	${COMPILE.r} ${.IMPSRC}
159.r.a:
160	${COMPILE.r} ${.IMPSRC}
161	${AR} ${ARFLAGS} $@ $*.o
162	rm -f $*.o
163
164# Pascal
165.p:
166	${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
167.p.o:
168	${COMPILE.p} ${.IMPSRC}
169.p.a:
170	${COMPILE.p} ${.IMPSRC}
171	${AR} ${ARFLAGS} $@ $*.o
172	rm -f $*.o
173
174# Assembly
175.s:
176	${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
177.s.o:
178	${COMPILE.s} ${.IMPSRC}
179.s.a:
180	${COMPILE.s} ${.IMPSRC}
181	${AR} ${ARFLAGS} $@ $*.o
182	rm -f $*.o
183.S:
184	${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
185.S.o:
186	${COMPILE.S} ${.IMPSRC}
187.S.a:
188	${COMPILE.S} ${.IMPSRC}
189	${AR} ${ARFLAGS} $@ $*.o
190	rm -f $*.o
191
192# Lex
193.l:
194	${LEX.l} ${.IMPSRC}
195	${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
196	rm -f lex.yy.c
197.l.c:
198	${LEX.l} ${.IMPSRC}
199	mv lex.yy.c ${.TARGET}
200.l.o:
201	${LEX.l} ${.IMPSRC}
202	${COMPILE.c} -o ${.TARGET} lex.yy.c
203	rm -f lex.yy.c
204
205# Yacc
206.y:
207	${YACC.y} ${.IMPSRC}
208	${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
209	rm -f y.tab.c
210.y.c:
211	${YACC.y} ${.IMPSRC}
212	mv y.tab.c ${.TARGET}
213.y.o:
214	${YACC.y} ${.IMPSRC}
215	${COMPILE.c} -o ${.TARGET} y.tab.c
216	rm -f y.tab.c
217
218# Shell
219.sh:
220	rm -f ${.TARGET}
221	cp ${.IMPSRC} ${.TARGET}
222