xref: /openbsd/share/mk/bsd.prog.mk (revision 7b36286a)
1#	$OpenBSD: bsd.prog.mk,v 1.49 2006/06/30 19:00:29 otto Exp $
2#	$NetBSD: bsd.prog.mk,v 1.55 1996/04/08 21:19:26 jtc Exp $
3#	@(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
4
5.if exists(${.CURDIR}/../Makefile.inc)
6.include "${.CURDIR}/../Makefile.inc"
7.endif
8
9.include <bsd.own.mk>
10
11.SUFFIXES: .out .ln .o .c .cc .C .cxx .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
12
13.if ${WARNINGS:L} == "yes"
14CFLAGS+=       ${CDIAGFLAGS}
15CXXFLAGS+=     ${CXXDIAGFLAGS}
16.endif
17CFLAGS+=	${COPTS}
18CXXFLAGS+=     ${CXXOPTS}
19
20.if ${ELF_TOOLCHAIN:L} == "yes"
21CRTBEGIN?=       ${DESTDIR}/usr/lib/crtbegin.o
22CRTEND?=         ${DESTDIR}/usr/lib/crtend.o
23.endif
24
25LIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
26LIB45?=		${DESTDIR}/usr/lib/lib45.a
27LIBACL?=	${DESTDIR}/usr/lib/libacl.a
28LIBASN1?=	${DESTDIR}/usr/lib/libasn1.a
29LIBC?=		${DESTDIR}/usr/lib/libc.a
30LIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
31LIBCRYPTO?=	${DESTDIR}/usr/lib/libcrypto.a
32LIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
33LIBDES?=	${DESTDIR}/usr/lib/libdes.a
34LIBEDIT?=	${DESTDIR}/usr/lib/libedit.a
35LIBEVENT?=	${DESTDIR}/usr/lib/libevent.a
36LIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
37LIBGSSAPI?=	${DESTDIR}/usr/lib/libgssapi.a
38LIBHDB?=	${DESTDIR}/usr/lib/libhdb.a
39LIBKADM?=	${DESTDIR}/usr/lib/libkadm.a
40LIBKADM5CLNT?=	${DESTDIR}/usr/lib/libkadm5clnt.a
41LIBKADM5SRV?=	${DESTDIR}/usr/lib/libkadm5srv.a
42LIBKAFS?=	${DESTDIR}/usr/lib/libkafs.a
43LIBKDB?=	${DESTDIR}/usr/lib/libkdb.a
44LIBKEYNOTE?=	${DESTDIR}/usr/lib/libkeynote.a
45LIBKRB?=	${DESTDIR}/usr/lib/libkrb.a
46LIBKRB5?=	${DESTDIR}/usr/lib/libkrb5.a
47LIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
48LIBL?=		${DESTDIR}/usr/lib/libl.a
49LIBM?=		${DESTDIR}/usr/lib/libm.a
50LIBOLDCURSES?=	${DESTDIR}/usr/lib/libocurses.a
51LIBPCAP?=	${DESTDIR}/usr/lib/libpcap.a
52LIBPERL?=	${DESTDIR}/usr/lib/libperl.a
53LIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
54LIBSECTOK?=	${DESTDIR}/usr/lib/libsectok.a
55LIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
56LIBSSL?=	${DESTDIR}/usr/lib/libssl.a
57LIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
58LIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
59LIBTERMLIB?=	${DESTDIR}/usr/lib/libtermlib.a
60LIBUSB?=	${DESTDIR}/usr/lib/libusbhid.a
61LIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
62LIBWRAP?=	${DESTDIR}/usr/lib/libwrap.a
63LIBY?=		${DESTDIR}/usr/lib/liby.a
64LIBZ?=		${DESTDIR}/usr/lib/libz.a
65
66.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "amd64" || \
67    ${MACHINE_ARCH} == "i386"
68LIBARCH?=	${DESTDIR}/usr/lib/lib${MACHINE_ARCH}.a
69.else
70LIBARCH?=
71.endif
72
73# old stuff
74LIBDBM?=	${DESTDIR}/usr/lib/libdbm.a
75LIBMP?=		${DESTDIR}/usr/lib/libmp.a
76LIBPC?=		${DESTDIR}/usr/lib/libpc.a
77LIBPLOT?=	${DESTDIR}/usr/lib/libplot.a
78LIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
79
80.if defined(PROG)
81SRCS?=	${PROG}.c
82.  if !empty(SRCS:N*.h:N*.sh)
83OBJS+=	${SRCS:N*.h:N*.sh:R:S/$/.o/g}
84_LEXINTM+=${SRCS:M*.l:.l=.c}
85_YACCINTM+=${SRCS:M*.y:.y=.c}
86LOBJS+=	${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} ${SRCS:M*.y:.y=.ln} ${SRCS:M*.l:.l=.ln}
87.  endif
88
89.  if defined(OBJS) && !empty(OBJS)
90.    if !empty(SRCS:M*.C) || !empty(SRCS:M*.cc) || !empty(SRCS:M*.cxx)
91${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${CRTBEGIN} ${CRTEND} ${DPADD}
92	${CXX} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
93.    else
94${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${CRTBEGIN} ${CRTEND} ${DPADD}
95	${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
96.    endif
97.  endif	# defined(OBJS) && !empty(OBJS)
98
99.  if	!defined(MAN)
100MAN=	${PROG}.1
101.  endif	# !defined(MAN)
102.endif	# defined(PROG)
103
104.MAIN: all
105all: ${PROG} _SUBDIRUSE
106
107.if !target(clean)
108clean: _SUBDIRUSE
109	rm -f a.out [Ee]rrs mklog core *.core y.tab.h \
110	    ${PROG} ${OBJS} ${LOBJS} ${_LEXINTM} ${_YACCINTM} ${CLEANFILES}
111.endif
112
113cleandir: _SUBDIRUSE clean
114
115.if !target(install)
116.if !target(beforeinstall)
117beforeinstall:
118.endif
119.if !target(afterinstall)
120afterinstall:
121.endif
122
123.if !target(realinstall)
124realinstall:
125.if defined(PROG)
126	${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP} -o ${BINOWN} -g ${BINGRP} \
127	    -m ${BINMODE} ${PROG} ${DESTDIR}${BINDIR}/${PROG}
128.endif
129.endif
130
131install: maninstall _SUBDIRUSE
132.if defined(LINKS) && !empty(LINKS)
133.  for lnk file in ${LINKS}
134	@l=${DESTDIR}${lnk}; \
135	 t=${DESTDIR}${file}; \
136	 echo $$t -\> $$l; \
137	 rm -f $$t; ln $$l $$t
138.  endfor
139.endif
140
141maninstall: afterinstall
142afterinstall: realinstall
143realinstall: beforeinstall
144.endif
145
146.if !target(lint)
147lint: ${LOBJS}
148.if defined(LOBJS) && !empty(LOBJS)
149	@${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
150.endif
151.endif
152
153.if !defined(NOMAN)
154.include <bsd.man.mk>
155.endif
156
157.if !defined(NONLS)
158.include <bsd.nls.mk>
159.endif
160
161.include <bsd.obj.mk>
162.include <bsd.dep.mk>
163.include <bsd.subdir.mk>
164.include <bsd.sys.mk>
165