Annotation of src/share/mk/bsd.prog.mk, Revision 1.12
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}
68: ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
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:
139: realinstall: _PROGSUBDIR
140: .if defined(PROG)
1.9 cgd 141: install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.1 cgd 142: ${PROG} ${DESTDIR}${BINDIR}
143: .endif
144: .if defined(HIDEGAME)
145: (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
146: chown games.bin ${PROG})
147: .endif
148: .if defined(LINKS) && !empty(LINKS)
149: @set ${LINKS}; \
150: while test $$# -ge 2; do \
151: l=${DESTDIR}$$1; \
152: shift; \
153: t=${DESTDIR}$$1; \
154: shift; \
155: echo $$t -\> $$l; \
156: rm -f $$t; \
157: ln $$l $$t; \
158: done; true
159: .endif
160:
161: install: maninstall
162: maninstall: afterinstall
163: afterinstall: realinstall
164: realinstall: beforeinstall
165: .endif
166:
167: .if !target(lint)
168: lint: ${SRCS} _PROGSUBDIR
169: .if defined(PROG)
170: @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
171: .endif
172: .endif
173:
174: .if !target(obj)
175: .if defined(NOOBJ)
176: obj: _PROGSUBDIR
177: .else
178: obj: _PROGSUBDIR
1.3 cgd 179: @cd ${.CURDIR}; rm -f obj > /dev/null 2>&1 || true; \
1.2 cgd 180: here=`pwd`; subdir=`echo $$here | sed 's,^/usr/src/,,'`; \
181: if test $$here != $$subdir ; then \
182: dest=/usr/obj/$$subdir ; \
183: echo "$$here -> $$dest"; ln -s $$dest obj; \
184: if test -d /usr/obj -a ! -d $$dest; then \
185: mkdir -p $$dest; \
186: else \
187: true; \
188: fi; \
1.1 cgd 189: else \
1.2 cgd 190: true ; \
191: dest=$$here/obj ; \
192: echo "making $$here/obj" ; \
193: if test ! -d obj ; then \
194: mkdir $$here/obj; \
195: fi ; \
1.1 cgd 196: fi;
197: .endif
198: .endif
199:
200: .if !target(tags)
201: tags: ${SRCS} _PROGSUBDIR
202: .if defined(PROG)
203: -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
204: sed "s;\${.CURDIR}/;;" > tags
205: .endif
206: .endif
207:
208: .if !defined(NOMAN)
209: .include <bsd.man.mk>
210: .endif
CVSweb <webmaster@jp.NetBSD.org>