move a variable declaration
[unix-history] / usr / src / share / mk / bsd.prog.mk
CommitLineData
7aa8e083 1# @(#)bsd.prog.mk 5.19 (Berkeley) %G%
4536b9e5 2
3d68901b
KB
3.if exists(${.CURDIR}/../Makefile.inc)
4.include "${.CURDIR}/../Makefile.inc"
2cf63a09 5.endif
68cbfc75 6
8ae45ce0
KB
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:
1a57a1db 10 nroff -mandoc -h ${.IMPSRC} > ${.TARGET}
8ae45ce0
KB
11
12CFLAGS+=${COPTS}
13
ddcabc30
KB
14STRIP?= -s
15
16BINGRP?= bin
17BINOWN?= bin
18BINMODE?= 555
19
3d68901b
KB
20LIBC?= /lib/libc.a
21LIBCOMPAT?= /usr/lib/libcompat.a
22LIBCURSES?= /usr/lib/libcurses.a
23LIBDBM?= /usr/lib/libdbm.a
24LIBDES?= /usr/lib/libdes.a
25LIBL?= /usr/lib/libl.a
26LIBKDB?= /usr/lib/libkdb.a
27LIBKRB?= /usr/lib/libkrb.a
28LIBM?= /usr/lib/libm.a
29LIBMP?= /usr/lib/libmp.a
30LIBPC?= /usr/lib/libpc.a
31LIBPLOT?= /usr/lib/libplot.a
1a57a1db 32LIBRESOLV?= /usr/lib/libresolv.a
3d68901b
KB
33LIBRPC?= /usr/lib/sunrpc.a
34LIBTERM?= /usr/lib/libterm.a
35LIBUTIL?= /usr/lib/libutil.a
68cbfc75 36
8ae45ce0 37.if defined(SHAREDSTRINGS)
7aa8e083 38CLEANFILES+=strings
8ae45ce0 39.c.o:
78768172 40 ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
8ae45ce0
KB
41 @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
42 @rm -f x.c
43.endif
44
3a5e4842 45.if defined(PROG)
9e327654 46.if defined(SRCS)
272f5bac 47
3d68901b 48OBJS+= ${SRCS:.c=.o}
2cf63a09 49
3d68901b
KB
50${PROG}: ${OBJS} ${LIBC} ${DPADD}
51 ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
68cbfc75 52
3a5e4842 53.else defined(PROG)
9e327654
KB
54
55SRCS= ${PROG}.c
56
3d68901b
KB
57${PROG}: ${SRCS} ${LIBC} ${DPADD}
58 ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
9e327654 59
d89c9bc1
KB
60MKDEP= -p
61
3d68901b 62.endif
272f5bac 63
3d68901b
KB
64.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
65 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
66 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
67MAN1= ${PROG}.0
68.endif
3a5e4842 69.endif
3d68901b 70MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
9e327654 71
ddcabc30 72_PROGSUBDIR: .USE
3d68901b
KB
73.if defined(SUBDIR) && !empty(SUBDIR)
74 @for entry in ${SUBDIR}; do \
ddcabc30 75 (echo "===> $$entry"; \
3d68901b
KB
76 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
77 cd ${.CURDIR}/$${entry}.${MACHINE}; \
78 else \
79 cd ${.CURDIR}/$${entry}; \
80 fi; \
4a3b34cb 81 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}) \
3d68901b
KB
82 done
83.endif
68cbfc75 84
3d68901b 85.MAIN: all
ddcabc30 86all: ${PROG} ${MANALL} _PROGSUBDIR
9e327654 87
3d68901b 88.if !target(clean)
ddcabc30 89clean: _PROGSUBDIR
3d68901b
KB
90 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
91.endif
68cbfc75 92
8d3c2d2e 93.if !target(cleandir)
ddcabc30 94cleandir: _PROGSUBDIR
3d68901b
KB
95 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
96 rm -f .depend ${.CURDIR}/tags ${MANALL}
8d3c2d2e 97.endif
9e327654 98
3d68901b 99# some of the rules involve .h sources, so remove them from mkdep line
8d3c2d2e 100.if !target(depend)
55633bd7
KB
101depend: .depend _PROGSUBDIR
102.depend: ${SRCS}
4a3b34cb 103.if defined(PROG)
d89c9bc1 104 mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
8d3c2d2e 105.endif
4a3b34cb 106.endif
8d3c2d2e
KB
107
108.if !target(install)
109.if !target(beforeinstall)
110beforeinstall:
111.endif
ddcabc30
KB
112.if !target(afterinstall)
113afterinstall:
114.endif
2cf63a09 115
ddcabc30
KB
116realinstall: _PROGSUBDIR
117.if defined(PROG)
2cf63a09 118 install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
9e327654 119 ${PROG} ${DESTDIR}${BINDIR}
ddcabc30 120.endif
3d68901b
KB
121.if defined(HIDEGAME)
122 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
123 chown games.bin ${PROG})
2cf63a09 124.endif
ddcabc30
KB
125.if defined(LINKS) && !empty(LINKS)
126 @set ${LINKS}; \
127 while test $$# -ge 2; do \
128 l=${DESTDIR}$$1; \
129 shift; \
130 t=${DESTDIR}$$1; \
131 shift; \
132 echo $$t -\> $$l; \
133 rm -f $$t; \
134 ln $$l $$t; \
135 done; true
136.endif
3d68901b 137
ddcabc30
KB
138install: maninstall
139maninstall: afterinstall
140afterinstall: realinstall
141realinstall: beforeinstall
8d3c2d2e
KB
142.endif
143
144.if !target(lint)
ddcabc30 145lint: ${SRCS} _PROGSUBDIR
4a3b34cb 146.if defined(PROG)
3d68901b 147 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
8d3c2d2e 148.endif
4a3b34cb 149.endif
3d68901b 150
1a57a1db
KB
151.if !target(obj)
152.if defined(NOOBJ)
153obj: _PROGSUBDIR
154.else
155obj: _PROGSUBDIR
156 @cd ${.CURDIR}; rm -rf obj; \
157 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
158 echo "$$here -> $$dest"; ln -s $$dest obj
159.endif
160.endif
161
8d3c2d2e 162.if !target(tags)
ddcabc30 163tags: ${SRCS} _PROGSUBDIR
4a3b34cb 164.if defined(PROG)
1a57a1db 165 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
fd716964 166 sed "s;\${.CURDIR}/;;" > tags
8d3c2d2e 167.endif
4a3b34cb 168.endif
3d68901b 169
ddcabc30
KB
170.if !defined(NOMAN)
171.include <bsd.man.mk>
172.endif