Annotation of src/share/mk/bsd.prog.mk, Revision 1.74
1.74 ! espie 1: # $OpenBSD: bsd.prog.mk,v 1.73 2017/07/04 00:59:11 espie Exp $
1.3 deraadt 2: # $NetBSD: bsd.prog.mk,v 1.55 1996/04/08 21:19:26 jtc Exp $
1.1 deraadt 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:
1.57 mpi 11: .SUFFIXES: .out .o .c .cc .cpp .C .cxx .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
1.54 pascal 12:
1.66 deraadt 13: .if (defined(LDSTATIC) && !defined(STATICPIE)) || defined(NOPIE)
1.54 pascal 14: CFLAGS+= ${NOPIE_FLAGS}
1.67 jsg 15: CXXFLAGS+= ${NOPIE_FLAGS}
1.54 pascal 16: AFLAGS+= ${NOPIE_FLAGS}
1.56 pascal 17: LDFLAGS+= ${NOPIE_LDFLAGS}
1.54 pascal 18: .endif
1.1 deraadt 19:
1.24 espie 20: .if ${WARNINGS:L} == "yes"
21: CFLAGS+= ${CDIAGFLAGS}
22: CXXFLAGS+= ${CXXDIAGFLAGS}
23: .endif
1.18 millert 24: CFLAGS+= ${COPTS}
1.24 espie 25: CXXFLAGS+= ${CXXOPTS}
1.1 deraadt 26:
1.8 niklas 27: CRTBEGIN?= ${DESTDIR}/usr/lib/crtbegin.o
28: CRTEND?= ${DESTDIR}/usr/lib/crtend.o
29:
1.1 deraadt 30: LIBCRT0?= ${DESTDIR}/usr/lib/crt0.o
31: LIBC?= ${DESTDIR}/usr/lib/libc.a
1.31 espie 32: LIBCRYPTO?= ${DESTDIR}/usr/lib/libcrypto.a
1.1 deraadt 33: LIBCURSES?= ${DESTDIR}/usr/lib/libcurses.a
34: LIBEDIT?= ${DESTDIR}/usr/lib/libedit.a
1.32 millert 35: LIBEVENT?= ${DESTDIR}/usr/lib/libevent.a
1.50 miod 36: LIBEXPAT?= ${DESTDIR}/usr/lib/libexpat.a
37: LIBFORM?= ${DESTDIR}/usr/lib/libform.a
38: LIBFORMW?= ${DESTDIR}/usr/lib/libformw.a
1.21 ho 39: LIBKEYNOTE?= ${DESTDIR}/usr/lib/libkeynote.a
1.1 deraadt 40: LIBKVM?= ${DESTDIR}/usr/lib/libkvm.a
1.3 deraadt 41: LIBL?= ${DESTDIR}/usr/lib/libl.a
1.1 deraadt 42: LIBM?= ${DESTDIR}/usr/lib/libm.a
1.50 miod 43: LIBMENU?= ${DESTDIR}/usr/lib/libmenu.a
44: LIBMENUW?= ${DESTDIR}/usr/lib/libmenuw.a
1.68 yasuoka 45: LIBRADIUS?= ${DESTDIR}/usr/lib/libradius.a
1.50 miod 46: LIBOSSAUDIO?= ${DESTDIR}/usr/lib/libossaudio.a
47: LIBPANEL?= ${DESTDIR}/usr/lib/libpanel.a
48: LIBPANELW?= ${DESTDIR}/usr/lib/libpanelw.a
1.31 espie 49: LIBPCAP?= ${DESTDIR}/usr/lib/libpcap.a
1.20 millert 50: LIBPERL?= ${DESTDIR}/usr/lib/libperl.a
1.50 miod 51: LIBPTHREAD?= ${DESTDIR}/usr/lib/libpthread.a
1.1 deraadt 52: LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a
53: LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a
1.50 miod 54: LIBSNDIO?= ${DESTDIR}/usr/lib/libsndio.a
1.19 beck 55: LIBSSL?= ${DESTDIR}/usr/lib/libssl.a
1.65 jsing 56: LIBTLS?= ${DESTDIR}/usr/lib/libtls.a
1.1 deraadt 57: LIBTERMCAP?= ${DESTDIR}/usr/lib/libtermcap.a
1.4 tholo 58: LIBTERMLIB?= ${DESTDIR}/usr/lib/libtermlib.a
1.31 espie 59: LIBUSB?= ${DESTDIR}/usr/lib/libusbhid.a
1.1 deraadt 60: LIBUTIL?= ${DESTDIR}/usr/lib/libutil.a
1.3 deraadt 61: LIBY?= ${DESTDIR}/usr/lib/liby.a
1.9 mickey 62: LIBZ?= ${DESTDIR}/usr/lib/libz.a
1.31 espie 63:
1.48 brad 64: .if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "amd64" || \
1.50 miod 65: ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "i386"
1.39 miod 66: LIBARCH?= ${DESTDIR}/usr/lib/lib${MACHINE_ARCH}.a
1.31 espie 67: .else
68: LIBARCH?=
69: .endif
1.1 deraadt 70:
71: .if defined(PROG)
1.74 ! espie 72: SRCS ?= ${PROG}.c
! 73: MAN ?= ${PROG}.1
! 74: .endif
! 75:
! 76: # if we have several progs, define appropriate vars instead
! 77: .if defined(PROGS)
! 78: . for p in ${PROGS}
! 79: SRCS_$p ?= $p.c
! 80: OBJS_$p = ${SRCS_$p:N*.h:N*.sh:R:S/$/.o/}
! 81: DPADD_$p ?= ${DPADD}
! 82: LDADD_$p ?= ${LDADD}
! 83:
! 84: # XXX still create SRCS, because it's what bsd.dep.mk understands
! 85: SRCS += ${SRCS_$p}
! 86:
! 87: # and we can write the actual target already
! 88: . if defined(OBJS_$p) && !empty(OBJS_$p)
! 89: . if !empty(SRCS_$p:M*.C) || !empty(SRCS_$p:M*.cc) || \
! 90: !empty(SRCS_$p:M*.cpp) || !empty(SRCS_$p:M*.cxx)
! 91: $p: ${LIBCRT0} ${OBJS_$p} ${LIBC} ${CRTBEGIN} ${CRTEND} ${DPADD_$p}
! 92: ${CXX} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS_$p} ${LDADD_$p}
! 93: . else
! 94: $p: ${LIBCRT0} ${OBJS_$p} ${LIBC} ${CRTBEGIN} ${CRTEND} ${DPADD_$p}
! 95: ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS_$p} ${LDADD_$p}
! 96: . endif
! 97: . endif
! 98: . endfor
! 99: MAN ?= ${PROGS:=.1}
! 100: .endif
! 101:
! 102: .if defined(PROG) || defined(PROGS)
! 103: # ... so we create appropriate full list of obj, dep, lex, yacc...
1.42 espie 104: . if !empty(SRCS:N*.h:N*.sh)
1.51 guenther 105: OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/}
1.74 ! espie 106: DEPS+= ${OBJS:.o=.d}
! 107: . endif
1.72 espie 108:
1.73 espie 109: _LEXINTM?=${SRCS:M*.l:.l=.c}
110: _YACCINTM?=${SRCS:M*.y:.y=.c}
1.74 ! espie 111: .endif
1.1 deraadt 112:
1.74 ! espie 113: .if defined(PROG)
1.42 espie 114: . if defined(OBJS) && !empty(OBJS)
1.74 ! espie 115: . if !empty(SRCS:M*.C) || !empty(SRCS:M*.cc) || \
! 116: !empty(SRCS:M*.cpp) || !empty(SRCS:M*.cxx)
1.8 niklas 117: ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${CRTBEGIN} ${CRTEND} ${DPADD}
1.42 espie 118: ${CXX} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
119: . else
1.8 niklas 120: ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${CRTBEGIN} ${CRTEND} ${DPADD}
1.41 espie 121: ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
1.42 espie 122: . endif
123: . endif # defined(OBJS) && !empty(OBJS)
1.74 ! espie 124: .endif
1.1 deraadt 125:
126: .MAIN: all
1.74 ! espie 127: all: ${PROG} ${PROGS} _SUBDIRUSE
1.71 espie 128:
1.74 ! espie 129: BUILDAFTER += ${PROG} ${PROGS} ${OBJS}
1.1 deraadt 130:
131: .if !target(clean)
132: clean: _SUBDIRUSE
1.61 deraadt 133: rm -f a.out [Ee]rrs mklog *.core y.tab.h \
1.74 ! espie 134: ${PROG} ${PROGS} ${OBJS} ${_LEXINTM} ${_YACCINTM} ${CLEANFILES}
1.1 deraadt 135: .endif
136:
137: cleandir: _SUBDIRUSE clean
138:
139: .if !target(install)
140: .if !target(beforeinstall)
141: beforeinstall:
142: .endif
143: .if !target(afterinstall)
144: afterinstall:
145: .endif
146:
147: .if !target(realinstall)
148: realinstall:
1.74 ! espie 149: . if defined(PROG)
1.52 guenther 150: ${INSTALL} ${INSTALL_COPY} -S ${INSTALL_STRIP} \
151: -o ${BINOWN} -g ${BINGRP} \
1.43 espie 152: -m ${BINMODE} ${PROG} ${DESTDIR}${BINDIR}/${PROG}
1.74 ! espie 153: . endif
! 154: . if defined(PROGS)
! 155: . for p in ${PROGS}
! 156: ${INSTALL} ${INSTALL_COPY} -S ${INSTALL_STRIP} \
! 157: -o ${BINOWN} -g ${BINGRP} \
! 158: -m ${BINMODE} $p ${DESTDIR}${BINDIR}/$p
! 159: . endfor
! 160: . endif
1.46 espie 161: .endif
162:
163: install: maninstall _SUBDIRUSE
1.1 deraadt 164: .if defined(LINKS) && !empty(LINKS)
1.28 espie 165: . for lnk file in ${LINKS}
166: @l=${DESTDIR}${lnk}; \
167: t=${DESTDIR}${file}; \
168: echo $$t -\> $$l; \
169: rm -f $$t; ln $$l $$t
170: . endfor
1.1 deraadt 171: .endif
172:
173: maninstall: afterinstall
174: afterinstall: realinstall
175: realinstall: beforeinstall
176: .endif
177:
178: .if !defined(NOMAN)
179: .include <bsd.man.mk>
1.72 espie 180: .endif
181:
182: # if we already got bsd.lib.mk we don't want to wreck that
183: .if !defined(_LIBS)
184: .s.o:
185: ${COMPILE.S} -MD -MF ${.TARGET:R}.d -o $@ ${.IMPSRC}
186:
187: .S.o:
188: ${COMPILE.S} -MD -MF ${.TARGET:R}.d -o $@ ${.IMPSRC}
1.1 deraadt 189: .endif
190:
191: .include <bsd.obj.mk>
192: .include <bsd.dep.mk>
193: .include <bsd.subdir.mk>
1.3 deraadt 194: .include <bsd.sys.mk>