]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.prog.mk
This commit was generated by cvs2svn to compensate for changes in r162852,
[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 .ln .s .S .asm
7
8 # XXX The use of COPTS in modern makefiles is discouraged.
9 .if defined(COPTS)
10 CFLAGS+=${COPTS}
11 .endif
12
13 .if ${MK_ASSERT_DEBUG} == "no"
14 CFLAGS+= -DNDEBUG
15 NO_WERROR=
16 .endif
17
18 .if defined(DEBUG_FLAGS)
19 CFLAGS+=${DEBUG_FLAGS}
20 .endif
21
22 .if defined(CRUNCH_CFLAGS)
23 CFLAGS+=${CRUNCH_CFLAGS}
24 .endif
25
26 .if !defined(DEBUG_FLAGS)
27 STRIP?= -s
28 .endif
29
30 .if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
31 LDFLAGS+= -static
32 .endif
33
34 .if defined(PROG_CXX)
35 PROG=   ${PROG_CXX}
36 .endif
37
38 .if defined(PROG)
39 .if defined(SRCS)
40
41 # If there are Objective C sources, link with Objective C libraries.
42 .if !empty(SRCS:M*.m)
43 OBJCLIBS?= -lobjc -lpthread
44 LDADD+= ${OBJCLIBS}
45 .endif
46
47 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
48
49 ${PROG}: ${OBJS}
50 .if defined(PROG_CXX)
51         ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
52 .else
53         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
54 .endif
55
56 .else   # !defined(SRCS)
57
58 .if !target(${PROG})
59 .if defined(PROG_CXX)
60 SRCS=   ${PROG}.cc
61 .else
62 SRCS=   ${PROG}.c
63 .endif
64
65 # Always make an intermediate object file because:
66 # - it saves time rebuilding when only the library has changed
67 # - the name of the object gets put into the executable symbol table instead of
68 #   the name of a variable temporary object.
69 # - it's useful to keep objects around for crunching.
70 OBJS=   ${PROG}.o
71
72 ${PROG}: ${OBJS}
73 .if defined(PROG_CXX)
74         ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
75 .else
76         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
77 .endif
78 .endif
79
80 .endif
81
82 .if     ${MK_MAN} != "no" && !defined(MAN) && \
83         !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
84         !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
85         !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \
86         !defined(MAN1aout)
87 MAN=    ${PROG}.1
88 MAN1=   ${MAN}
89 .endif
90 .endif
91
92 all: objwarn ${PROG} ${SCRIPTS}
93 .if ${MK_MAN} != "no"
94 all: _manpages
95 .endif
96
97 .if defined(PROG)
98 CLEANFILES+= ${PROG}
99 .endif
100
101 .if defined(OBJS)
102 CLEANFILES+= ${OBJS}
103 .endif
104
105 .include <bsd.libnames.mk>
106
107 .if defined(PROG)
108 _EXTRADEPEND:
109 .if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib)
110 .if defined(DPADD) && !empty(DPADD)
111         echo ${PROG}: ${DPADD} >> ${DEPENDFILE}
112 .endif
113 .else
114         echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
115 .if defined(PROG_CXX)
116         echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
117 .endif
118 .endif
119 .endif
120
121 .if !target(install)
122
123 .if defined(PRECIOUSPROG)
124 .if !defined(NO_FSCHG)
125 INSTALLFLAGS+= -fschg
126 .endif
127 INSTALLFLAGS+= -S
128 .endif
129
130 _INSTALLFLAGS:= ${INSTALLFLAGS}
131 .for ie in ${INSTALLFLAGS_EDIT}
132 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
133 .endfor
134
135 .if !target(realinstall) && !defined(INTERNALPROG)
136 realinstall: _proginstall
137 .ORDER: beforeinstall _proginstall
138 _proginstall:
139 .if defined(PROG)
140 .if defined(PROGNAME)
141         ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
142             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
143 .else
144         ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
145             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
146 .endif
147 .endif
148 .endif  # !target(realinstall)
149
150 .if defined(SCRIPTS) && !empty(SCRIPTS)
151 realinstall: _scriptsinstall
152 .ORDER: beforeinstall _scriptsinstall
153
154 SCRIPTSDIR?=    ${BINDIR}
155 SCRIPTSOWN?=    ${BINOWN}
156 SCRIPTSGRP?=    ${BINGRP}
157 SCRIPTSMODE?=   ${BINMODE}
158
159 .for script in ${SCRIPTS}
160 .if defined(SCRIPTSNAME)
161 SCRIPTSNAME_${script:T}?=       ${SCRIPTSNAME}
162 .else
163 SCRIPTSNAME_${script:T}?=       ${script:T:R}
164 .endif
165 SCRIPTSDIR_${script:T}?=        ${SCRIPTSDIR}
166 SCRIPTSOWN_${script:T}?=        ${SCRIPTSOWN}
167 SCRIPTSGRP_${script:T}?=        ${SCRIPTSGRP}
168 SCRIPTSMODE_${script:T}?=       ${SCRIPTSMODE}
169 _scriptsinstall: _SCRIPTSINS_${script:T}
170 _SCRIPTSINS_${script:T}: ${script}
171         ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
172             -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
173             ${.ALLSRC} \
174             ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
175 .endfor
176 .endif
177
178 NLSNAME?=       ${PROG}
179 .include <bsd.nls.mk>
180
181 .include <bsd.files.mk>
182 .include <bsd.incs.mk>
183 .include <bsd.links.mk>
184
185 .if ${MK_MAN} != "no"
186 realinstall: _maninstall
187 .ORDER: beforeinstall _maninstall
188 .endif
189
190 .endif
191
192 .if !target(lint)
193 lint: ${SRCS:M*.c}
194 .if defined(PROG)
195         ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC}
196 .endif
197 .endif
198
199 .if ${MK_MAN} != "no"
200 .include <bsd.man.mk>
201 .endif
202
203 .include <bsd.dep.mk>
204
205 .if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
206 ${OBJS}: ${SRCS:M*.h}
207 .endif
208
209 .include <bsd.obj.mk>
210
211 .include <bsd.sys.mk>
212
213 .if defined(PORTNAME)
214 .include <bsd.pkg.mk>
215 .endif