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