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