1#	$NetBSD: OpenBSD.sys.mk,v 1.1 2002/11/17 09:18:00 cjep Exp $
2#	@(#)sys.mk	8.2 (Berkeley) 3/21/94
3
4OS ?=		OpenBSD
5unix ?=		We run ${OS}.
6
7.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h
8.SUFFIXES: .sh .m4
9
10.LIBS:		.a
11
12# need to make sure this is set
13MACHINE_ARCH.${MACHINE} ?= ${MACHINE}
14.if empty(MACHINE_ARCH)
15MACHINE_ARCH  ?= ${MACHINE_ARCH.${MACHINE}}
16.endif
17
18AR ?=		ar
19ARFLAGS ?=	rl
20RANLIB ?=	ranlib
21
22AS ?=		as
23AFLAGS ?=
24.if ${MACHINE_ARCH} == "sparc64"
25AFLAGS+= -Wa,-Av9a
26.endif
27COMPILE.s ?=	${CC} ${AFLAGS} -c
28LINK.s ?=	${CC} ${AFLAGS} ${LDFLAGS}
29COMPILE.S ?=	${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
30LINK.S ?=	${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
31
32CC ?=		cc
33.if ${MACHINE_ARCH} == "alpha" || \
34    ${MACHINE_ARCH} == "i386" || \
35    ${MACHINE_ARCH} == "m68k" || \
36    ${MACHINE_ARCH} == "sparc" || \
37    ${MACHINE_ARCH} == "vax"
38DBG ?=	-O2
39.else
40DBG ?=	-O
41.endif
42CFLAGS ?=	${DBG}
43COMPILE.c ?=	${CC} ${CFLAGS} ${CPPFLAGS} -c
44LINK.c ?=	${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
45
46CXX ?=		c++
47CXXFLAGS ?=	${CFLAGS}
48COMPILE.cc ?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
49LINK.cc ?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
50
51OBJC ?=		${CC}
52OBJCFLAGS ?=	${CFLAGS}
53COMPILE.m ?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
54LINK.m ?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
55
56CPP ?=		cpp
57CPPFLAGS ?=
58
59FC ?=		f77
60FFLAGS ?=	-O
61RFLAGS ?=
62COMPILE.f ?=	${FC} ${FFLAGS} -c
63LINK.f ?=	${FC} ${FFLAGS} ${LDFLAGS}
64COMPILE.F ?=	${FC} ${FFLAGS} ${CPPFLAGS} -c
65LINK.F ?=	${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
66COMPILE.r ?=	${FC} ${FFLAGS} ${RFLAGS} -c
67LINK.r ?=	${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
68
69INSTALL ?=	install
70
71LEX ?=		lex
72LFLAGS ?=
73LEX.l ?=		${LEX} ${LFLAGS}
74
75LD ?=		ld
76LDFLAGS ?=
77
78LINT ?=		lint
79LINTFLAGS ?=	-chapbxzF
80
81LORDER ?=	lorder
82
83NM ?=		nm
84
85PC ?=		pc
86PFLAGS ?=
87COMPILE.p ?=	${PC} ${PFLAGS} ${CPPFLAGS} -c
88LINK.p ?=	${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
89
90SIZE ?=		size
91
92TSORT ?= 	tsort -q
93
94YACC ?=		yacc
95YFLAGS ?=
96YACC.y ?=	${YACC} ${YFLAGS}
97
98# C
99.c:
100	${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
101.c.o:
102	${COMPILE.c} ${.IMPSRC}
103.c.a:
104	${COMPILE.c} ${.IMPSRC}
105	${AR} ${ARFLAGS} $@ $*.o
106	rm -f $*.o
107.c.ln:
108	${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
109
110# C++
111${CXX_SUFFIXES}:
112	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
113${CXX_SUFFIXES:%=%.o}:
114	${COMPILE.cc} ${.IMPSRC}
115${CXX_SUFFIXES:%=%.a}:
116	${COMPILE.cc} ${.IMPSRC}
117	${AR} ${ARFLAGS} $@ $*.o
118	rm -f $*.o
119
120# Fortran/Ratfor
121.f:
122	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
123.f.o:
124	${COMPILE.f} ${.IMPSRC}
125.f.a:
126	${COMPILE.f} ${.IMPSRC}
127	${AR} ${ARFLAGS} $@ $*.o
128	rm -f $*.o
129
130.F:
131	${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
132.F.o:
133	${COMPILE.F} ${.IMPSRC}
134.F.a:
135	${COMPILE.F} ${.IMPSRC}
136	${AR} ${ARFLAGS} $@ $*.o
137	rm -f $*.o
138
139.r:
140	${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
141.r.o:
142	${COMPILE.r} ${.IMPSRC}
143.r.a:
144	${COMPILE.r} ${.IMPSRC}
145	${AR} ${ARFLAGS} $@ $*.o
146	rm -f $*.o
147
148# Pascal
149.p:
150	${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
151.p.o:
152	${COMPILE.p} ${.IMPSRC}
153.p.a:
154	${COMPILE.p} ${.IMPSRC}
155	${AR} ${ARFLAGS} $@ $*.o
156	rm -f $*.o
157
158# Assembly
159.s:
160	${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
161.s.o:
162	${COMPILE.s} ${.IMPSRC}
163.s.a:
164	${COMPILE.s} ${.IMPSRC}
165	${AR} ${ARFLAGS} $@ $*.o
166	rm -f $*.o
167.S:
168	${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
169.S.o:
170	${COMPILE.S} ${.IMPSRC}
171.S.a:
172	${COMPILE.S} ${.IMPSRC}
173	${AR} ${ARFLAGS} $@ $*.o
174	rm -f $*.o
175
176# Lex
177.l:
178	${LEX.l} ${.IMPSRC}
179	${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
180	rm -f lex.yy.c
181.l.c:
182	${LEX.l} ${.IMPSRC}
183	mv lex.yy.c ${.TARGET}
184.l.o:
185	${LEX.l} ${.IMPSRC}
186	${COMPILE.c} -o ${.TARGET} lex.yy.c
187	rm -f lex.yy.c
188
189# Yacc
190.y:
191	${YACC.y} ${.IMPSRC}
192	${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
193	rm -f y.tab.c
194.y.c:
195	${YACC.y} ${.IMPSRC}
196	mv y.tab.c ${.TARGET}
197.y.o:
198	${YACC.y} ${.IMPSRC}
199	${COMPILE.c} -o ${.TARGET} y.tab.c
200	rm -f y.tab.c
201
202# Shell
203.sh:
204	rm -f ${.TARGET}
205	cp ${.IMPSRC} ${.TARGET}
206