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