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