Annotation of src/share/mk/bsd.prog.mk, Revision 1.19
1.1 cgd 1: # @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
2:
3: .if exists(${.CURDIR}/../Makefile.inc)
4: .include "${.CURDIR}/../Makefile.inc"
5: .endif
6:
1.18 mycroft 7: .SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
1.1 cgd 8:
9: .8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
10: nroff -mandoc ${.IMPSRC} > ${.TARGET}
11:
12: CFLAGS+=${COPTS}
13:
14: STRIP?= -s
15:
16: BINGRP?= bin
17: BINOWN?= bin
18: BINMODE?= 555
19:
1.4 nate 20: LIBCRT0?= /usr/lib/crt0.o
1.1 cgd 21: LIBC?= /usr/lib/libc.a
22: LIBCOMPAT?= /usr/lib/libcompat.a
1.15 cgd 23: .ifndef EXPORTABLE_SYSTEM
24: LIBCRYPT?= /usr/lib/libcrypt.a
25: .endif
1.1 cgd 26: LIBCURSES?= /usr/lib/libcurses.a
27: LIBDBM?= /usr/lib/libdbm.a
28: LIBDES?= /usr/lib/libdes.a
29: LIBL?= /usr/lib/libl.a
30: LIBKDB?= /usr/lib/libkdb.a
31: LIBKRB?= /usr/lib/libkrb.a
32: LIBM?= /usr/lib/libm.a
33: LIBMP?= /usr/lib/libmp.a
34: LIBPC?= /usr/lib/libpc.a
35: LIBPLOT?= /usr/lib/libplot.a
36: LIBRESOLV?= /usr/lib/libresolv.a
1.5 cgd 37: LIBRPC?= /usr/lib/librpc.a
1.17 brezak 38: LIBRPCSVC?= /usr/lib/librpcsvc.a
1.1 cgd 39: LIBTERM?= /usr/lib/libterm.a
40: LIBUTIL?= /usr/lib/libutil.a
41:
42: .if defined(SHAREDSTRINGS)
43: CLEANFILES+=strings
44: .c.o:
45: ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
46: @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
47: @rm -f x.c
1.18 mycroft 48:
49: .cc.o:
50: ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
51: @mv -f x.c x.cc
52: @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
53:
54: .C.o:
55: ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
56: @mv -f x.c x.C
57: @${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
1.1 cgd 58: .endif
59:
60: .if defined(PROG)
61: .if defined(SRCS)
62:
63: OBJS+= ${SRCS:R:S/$/.o/g}
64:
1.4 nate 65: .if defined(LDONLY)
66:
67: ${PROG}: ${LIBCRT0} ${LIBC} ${OBJS} ${DPADD}
68: ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDADD}
69:
70: .else defined(LDONLY)
71:
1.1 cgd 72: ${PROG}: ${OBJS} ${LIBC} ${DPADD}
73: ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
74:
1.4 nate 75: .endif
76:
1.1 cgd 77: .else defined(PROG)
78:
79: SRCS= ${PROG}.c
80:
81: ${PROG}: ${SRCS} ${LIBC} ${DPADD}
1.13 mycroft 82: ${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
1.1 cgd 83:
84: MKDEP= -p
85:
86: .endif
87:
88: .if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
89: !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
1.10 mycroft 90: !defined(MAN7) && !defined(MAN8)
1.1 cgd 91: MAN1= ${PROG}.0
92: .endif
93: .endif
1.11 mycroft 94:
95: .if !defined(NOMAN)
1.1 cgd 96: MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
1.10 mycroft 97: .endif
1.1 cgd 98:
99: _PROGSUBDIR: .USE
100: .if defined(SUBDIR) && !empty(SUBDIR)
101: @for entry in ${SUBDIR}; do \
102: (echo "===> $$entry"; \
103: if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
104: cd ${.CURDIR}/$${entry}.${MACHINE}; \
105: else \
106: cd ${.CURDIR}/$${entry}; \
107: fi; \
108: ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
109: done
110: .endif
111:
112: .MAIN: all
113: all: ${PROG} ${MANALL} _PROGSUBDIR
114:
115: .if !target(clean)
116: clean: _PROGSUBDIR
117: rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
118: .endif
119:
120: .if !target(cleandir)
121: cleandir: _PROGSUBDIR
1.8 cgd 122: rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
1.1 cgd 123: rm -f .depend ${MANALL}
124: .endif
125:
126: # some of the rules involve .h sources, so remove them from mkdep line
127: .if !target(depend)
128: depend: .depend _PROGSUBDIR
129: .depend: ${SRCS}
130: .if defined(PROG)
1.19 ! cgd 131: mkdep ${MKDEP} ${CFLAGS:M-[ID+]*} ${.ALLSRC:M*.c} ${.ALLSRC:M*.cc} \
! 132: ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}
1.1 cgd 133: .endif
134: .endif
135:
136: .if !target(install)
137: .if !target(beforeinstall)
138: beforeinstall:
1.12 mycroft 139: .if defined(DESTDIR) || defined(BINDIR)
1.8 cgd 140: @if [ ! -d "${DESTDIR}${BINDIR}" ]; then \
1.7 cgd 141: /bin/rm -f ${DESTDIR}${BINDIR} ; \
1.6 cgd 142: mkdir -p ${DESTDIR}${BINDIR} ; \
143: chown root.wheel ${DESTDIR}${BINDIR} ; \
144: chmod 755 ${DESTDIR}${BINDIR} ; \
145: else \
146: true ; \
147: fi
1.12 mycroft 148: .endif
1.1 cgd 149: .endif
150: .if !target(afterinstall)
151: afterinstall:
152: .endif
153:
1.14 mycroft 154: .if !target(realinstall)
1.1 cgd 155: realinstall: _PROGSUBDIR
156: .if defined(PROG)
1.9 cgd 157: install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.1 cgd 158: ${PROG} ${DESTDIR}${BINDIR}
159: .endif
160: .if defined(HIDEGAME)
161: (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
162: chown games.bin ${PROG})
163: .endif
164: .if defined(LINKS) && !empty(LINKS)
165: @set ${LINKS}; \
166: while test $$# -ge 2; do \
167: l=${DESTDIR}$$1; \
168: shift; \
169: t=${DESTDIR}$$1; \
170: shift; \
171: echo $$t -\> $$l; \
172: rm -f $$t; \
173: ln $$l $$t; \
174: done; true
1.14 mycroft 175: .endif
1.1 cgd 176: .endif
177:
178: install: maninstall
179: maninstall: afterinstall
180: afterinstall: realinstall
181: realinstall: beforeinstall
182: .endif
183:
184: .if !target(lint)
185: lint: ${SRCS} _PROGSUBDIR
186: .if defined(PROG)
187: @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
188: .endif
189: .endif
190:
191: .if !target(obj)
192: .if defined(NOOBJ)
193: obj: _PROGSUBDIR
194: .else
195: obj: _PROGSUBDIR
1.3 cgd 196: @cd ${.CURDIR}; rm -f obj > /dev/null 2>&1 || true; \
1.2 cgd 197: here=`pwd`; subdir=`echo $$here | sed 's,^/usr/src/,,'`; \
198: if test $$here != $$subdir ; then \
199: dest=/usr/obj/$$subdir ; \
200: echo "$$here -> $$dest"; ln -s $$dest obj; \
201: if test -d /usr/obj -a ! -d $$dest; then \
202: mkdir -p $$dest; \
203: else \
204: true; \
205: fi; \
1.1 cgd 206: else \
1.2 cgd 207: true ; \
208: dest=$$here/obj ; \
209: echo "making $$here/obj" ; \
210: if test ! -d obj ; then \
211: mkdir $$here/obj; \
212: fi ; \
1.1 cgd 213: fi;
214: .endif
215: .endif
216:
217: .if !target(tags)
218: tags: ${SRCS} _PROGSUBDIR
219: .if defined(PROG)
220: -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
221: sed "s;\${.CURDIR}/;;" > tags
222: .endif
223: .endif
224:
225: .if !defined(NOMAN)
226: .include <bsd.man.mk>
227: .endif
CVSweb <webmaster@jp.NetBSD.org>