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