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