This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / share / mk / bsd.prog.mk
CommitLineData
15637ed4
RG
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
12CFLAGS+=${COPTS}
13
14STRIP?= -s
15
16BINGRP?= bin
17BINOWN?= bin
18BINMODE?= 555
19
20LIBCRT0?= /usr/lib/crt0.o
21LIBC?= /usr/lib/libc.a
22LIBCOMPAT?= /usr/lib/libcompat.a
23LIBCURSES?= /usr/lib/libcurses.a
24LIBDBM?= /usr/lib/libdbm.a
25LIBDES?= /usr/lib/libdes.a
26LIBL?= /usr/lib/libl.a
27LIBKDB?= /usr/lib/libkdb.a
28LIBKRB?= /usr/lib/libkrb.a
29LIBM?= /usr/lib/libm.a
30LIBMP?= /usr/lib/libmp.a
31LIBPC?= /usr/lib/libpc.a
32LIBPLOT?= /usr/lib/libplot.a
33LIBRESOLV?= /usr/lib/libresolv.a
34LIBRPC?= /usr/lib/sunrpc.a
35LIBTERM?= /usr/lib/libterm.a
36LIBUTIL?= /usr/lib/libutil.a
37
38.if defined(SHAREDSTRINGS)
39CLEANFILES+=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
49OBJS+= ${SRCS:R:S/$/.o/g}
50
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
58${PROG}: ${OBJS} ${LIBC} ${DPADD}
59 ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
60
61.endif
62
63.else defined(PROG)
64
65SRCS= ${PROG}.c
66
67${PROG}: ${SRCS} ${LIBC} ${DPADD}
68 ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
69
70MKDEP= -p
71
72.endif
73
74.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
75 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
76 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
77MAN1= ${PROG}.0
78.endif
79.endif
80MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
81
82_PROGSUBDIR: .USE
83.if defined(SUBDIR) && !empty(SUBDIR)
84 @for entry in ${SUBDIR}; do \
85 (echo "===> $$entry"; \
86 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
87 cd ${.CURDIR}/$${entry}.${MACHINE}; \
88 else \
89 cd ${.CURDIR}/$${entry}; \
90 fi; \
91 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
92 done
93.endif
94
95.MAIN: all
96all: ${PROG} ${MANALL} _PROGSUBDIR
97
98.if !target(clean)
99clean: _PROGSUBDIR
100 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES} ${MANALL}
101.endif
102
103.if !target(cleandir)
104cleandir: _PROGSUBDIR
105 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES} \
106 ${MANALL} ${.CURDIR}/tags .depend
107 cd ${.CURDIR}; rm -rf obj;
108.endif
109
110# some of the rules involve .h sources, so remove them from mkdep line
111.if !target(depend)
112depend: .depend _PROGSUBDIR
113.depend: ${SRCS}
114.if defined(PROG)
115 mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
116.endif
117.endif
118
119.if !target(install)
120.if !target(beforeinstall)
121beforeinstall:
122.endif
123.if !target(afterinstall)
124afterinstall:
125.endif
126
127realinstall: _PROGSUBDIR
128.if defined(PROG)
129 install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
130 ${PROG} ${DESTDIR}${BINDIR}
131.endif
132.if defined(HIDEGAME)
133 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
134 chown games.bin ${PROG})
135.endif
136.if defined(LINKS) && !empty(LINKS)
137 @set ${LINKS}; \
138 while test $$# -ge 2; do \
139 l=${DESTDIR}$$1; \
140 shift; \
141 t=${DESTDIR}$$1; \
142 shift; \
143 echo $$t -\> $$l; \
144 rm -f $$t; \
145 ln $$l $$t; \
146 done; true
147.endif
148
149install: maninstall
150maninstall: afterinstall
151afterinstall: realinstall
152realinstall: beforeinstall
153.endif
154
155.if !target(lint)
156lint: ${SRCS} _PROGSUBDIR
157.if defined(PROG)
158 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
159.endif
160.endif
161
162.if !target(obj)
163.if defined(NOOBJ)
164obj: _PROGSUBDIR
165.else
166obj: _PROGSUBDIR
167 @cd ${.CURDIR}; rm -rf obj; \
168 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
169 echo "$$here -> $$dest"; ln -s $$dest obj; \
170 if test -d /usr/obj -a ! -d $$dest; then \
171 mkdir -p $$dest; \
172 else \
173 true; \
174 fi;
175.endif
176.endif
177
178.if !target(tags)
179tags: ${SRCS} _PROGSUBDIR
180.if defined(PROG)
181 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
182 sed "s;\${.CURDIR}/;;" > tags
183.endif
184.endif
185
186.if !defined(NOMAN)
187.include <bsd.man.mk>
188.endif