]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.prog.mk
This commit was generated by cvs2svn to compensate for changes in r91041,
[FreeBSD/FreeBSD.git] / share / mk / bsd.prog.mk
1 #       from: @(#)bsd.prog.mk   5.26 (Berkeley) 6/25/91
2 # $FreeBSD$
3
4 .if !target(__initialized__)
5 __initialized__:
6 .if exists(${.CURDIR}/../Makefile.inc)
7 .include "${.CURDIR}/../Makefile.inc"
8 .endif
9 .endif
10
11 .SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S
12
13 CFLAGS+=${COPTS} ${DEBUG_FLAGS}
14
15 .if !defined(DEBUG_FLAGS)
16 STRIP?= -s
17 .endif
18
19 .if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" )
20 LDFLAGS+= -static
21 .endif
22
23 .if defined(PROG)
24 .if defined(SRCS)
25
26 # If there are Objective C sources, link with Objective C libraries.
27 .if ${SRCS:M*.m} != ""
28 OBJCLIBS?= -lobjc
29 LDADD+= ${OBJCLIBS}
30 .endif
31
32 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
33
34 ${PROG}: ${OBJS}
35         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
36
37 .else !defined(SRCS)
38
39 .if !target(${PROG})
40 SRCS=   ${PROG}.c
41
42 # Always make an intermediate object file because:
43 # - it saves time rebuilding when only the library has changed
44 # - the name of the object gets put into the executable symbol table instead of
45 #   the name of a variable temporary object.
46 # - it's useful to keep objects around for crunching.
47 OBJS=   ${PROG}.o
48
49 ${PROG}: ${OBJS}
50         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
51 .endif
52
53 .endif
54
55 .if     !defined(NOMAN) && !defined(MAN) && \
56         !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
57         !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
58         !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \
59         !defined(MAN1aout)
60 MAN=    ${PROG}.1
61 MAN1=   ${MAN}
62 .endif
63 .endif
64
65 .MAIN: all
66 all: objwarn ${PROG} ${SCRIPTS} ${FILES}
67 .if !defined(NOMAN)
68 all: all-man 
69 .endif
70 all: _SUBDIR
71
72 CLEANFILES+= ${PROG} ${OBJS}
73
74 .if defined(PROG)
75 _EXTRADEPEND:
76 .if ${OBJFORMAT} == aout
77         echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \
78             ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
79 .else
80         echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
81 .endif
82 .endif
83
84 .if !target(install)
85 .if !target(beforeinstall)
86 beforeinstall:
87 .endif
88
89 _INSTALLFLAGS:= ${INSTALLFLAGS}
90 .for ie in ${INSTALLFLAGS_EDIT}
91 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
92 .endfor
93
94 realinstall: beforeinstall
95 .if defined(PROG)
96 .if defined(PROGNAME)
97         ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
98             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
99 .else
100         ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
101             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
102 .endif
103 .endif
104 .if defined(HIDEGAME)
105         (cd ${DESTDIR}${ORIGBINDIR}; ln -fs dm ${PROG}; \
106             chown -h ${BINOWN}:${ORIGBINGRP} ${PROG})
107 .endif
108 .if defined(LINKS) && !empty(LINKS)
109         @set ${LINKS}; \
110         while test $$# -ge 2; do \
111                 l=${DESTDIR}$$1; \
112                 shift; \
113                 t=${DESTDIR}$$1; \
114                 shift; \
115                 ${ECHO} $$t -\> $$l; \
116                 ln -f $$l $$t; \
117         done; true
118 .endif
119 .if defined(SYMLINKS) && !empty(SYMLINKS)
120         @set ${SYMLINKS}; \
121         while test $$# -ge 2; do \
122                 l=$$1; \
123                 shift; \
124                 t=${DESTDIR}$$1; \
125                 shift; \
126                 ${ECHO} $$t -\> $$l; \
127                 ln -fs $$l $$t; \
128         done; true
129 .endif
130
131 .if defined(SCRIPTS) && !empty(SCRIPTS)
132 realinstall: _scriptsinstall
133
134 SCRIPTSDIR?=    ${BINDIR}
135 SCRIPTSOWN?=    ${BINOWN}
136 SCRIPTSGRP?=    ${BINGRP}
137 SCRIPTSMODE?=   ${BINMODE}
138
139 .for script in ${SCRIPTS}
140 .if defined(SCRIPTSNAME)
141 SCRIPTSNAME_${script:T}?=       ${SCRIPTSNAME}
142 .else
143 SCRIPTSNAME_${script:T}?=       ${script:T:R}
144 .endif
145 SCRIPTSDIR_${script:T}?=        ${SCRIPTSDIR}
146 SCRIPTSOWN_${script:T}?=        ${SCRIPTSOWN}
147 SCRIPTSGRP_${script:T}?=        ${SCRIPTSGRP}
148 SCRIPTSMODE_${script:T}?=       ${SCRIPTSMODE}
149 _scriptsinstall: _SCRIPTSINS_${script:T}
150 _SCRIPTSINS_${script:T}: ${script}
151         ${INSTALL} ${COPY} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
152             -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
153             ${_INSTALLFLAGS} ${.ALLSRC} \
154             ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
155 .endfor
156 .endif
157
158 .if defined(FILES) && !empty(FILES)
159 realinstall: _filesinstall
160
161 FILESDIR?=      ${BINDIR}
162 FILESOWN?=      ${SHAREOWN}
163 FILESGRP?=      ${SHAREGRP}
164 FILESMODE?=     ${SHAREMODE}
165
166 .for file in ${FILES}
167 .if defined(FILESNAME)
168 FILESNAME_${file:T}?=   ${FILESNAME}
169 .else
170 FILESNAME_${file:T}?=   ${file:T}
171 .endif
172 FILESDIR_${file:T}?=    ${FILESDIR}
173 FILESOWN_${file:T}?=    ${FILESOWN}
174 FILESGRP_${file:T}?=    ${FILESGRP}
175 FILESMODE_${file:T}?=   ${FILESMODE}
176 _filesinstall: _FILESINS_${file:T}
177 _FILESINS_${file:T}: ${file}
178         ${INSTALL} ${COPY} -o ${FILESOWN_${.ALLSRC:T}} \
179             -g ${FILESGRP_${.ALLSRC:T}} -m ${FILESMODE_${.ALLSRC:T}} \
180             ${_INSTALLFLAGS} ${.ALLSRC} \
181             ${DESTDIR}${FILESDIR_${.ALLSRC:T}}/${FILESNAME_${.ALLSRC:T}}
182 .endfor
183 .endif
184
185 install: afterinstall _SUBDIR
186 .if !defined(NOMAN)
187 afterinstall: realinstall maninstall
188 .else
189 afterinstall: realinstall
190 .endif
191 .endif
192
193 DISTRIBUTION?=  bin
194 .if !target(distribute)
195 distribute: _SUBDIR
196 .for dist in ${DISTRIBUTION}
197         cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
198 .endfor
199 .endif
200
201 .if !target(lint)
202 lint: ${SRCS} _SUBDIR
203 .if defined(PROG)
204         ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} | more 2>&1
205 .endif
206 .endif
207
208 .if defined(NOTAGS)
209 tags:
210 .endif
211
212 .if !target(tags)
213 tags: ${SRCS} _SUBDIR
214 .if defined(PROG)
215         @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
216 .if defined(HTML)
217         @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
218 .endif
219 .endif
220 .endif
221
222 .if !defined(NOMAN)
223 .include <bsd.man.mk>
224 .else
225 .if !target(all-man)
226 all-man:
227 .endif
228 .if !target(maninstall)
229 maninstall:
230 .endif
231 .endif
232
233 .if !target(regress)
234 regress:
235 .endif
236
237 .if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES)
238 .include <bsd.libnames.mk>
239 .endif
240
241 .include <bsd.dep.mk>
242
243 .if defined(PROG) && !exists(${DEPENDFILE})
244 ${OBJS}: ${SRCS:M*.h}
245 .endif
246
247 .include <bsd.obj.mk>
248
249 .include <bsd.sys.mk>