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