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