mqueues: Mark syscalls as MPSAFE.
[dragonfly.git] / share / mk / bsd.prog.mk
blobfed836ffc616536aaa53360a75adb0299314d595
1 # from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
2 # $FreeBSD: src/share/mk/bsd.prog.mk,v 1.86.2.17 2002/12/23 16:33:37 ru Exp $
3 # $DragonFly: src/share/mk/bsd.prog.mk,v 1.14 2008/05/19 10:26:02 corecode Exp $
5 .include <bsd.init.mk>
7 .SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S
9 CFLAGS+=${COPTS} ${DEBUG_FLAGS}
11 .if !defined(DEBUG_FLAGS)
12 STRIP?= -s
13 .endif
15 .if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" )
16 LDFLAGS+= -static
17 .endif
19 .if defined(PROG_CXX)
20 PROG= ${PROG_CXX}
21 .endif
23 .include <bsd.patch.mk>
25 .if defined(PROG)
26 .if defined(SRCS)
28 # If there are Objective C sources, link with Objective C libraries.
29 .if ${SRCS:M*.m} != ""
30 OBJCLIBS?= -lobjc
31 LDADD+= ${OBJCLIBS}
32 .endif
34 OBJS+= ${SRCS:N*.h:N*.patch:R:S/$/.o/g}
36 ${PROG}: ${OBJS}
37 .if defined(PROG_CXX)
38 ${CXX_LINK} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
39 .else
40 ${CC_LINK} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
41 .endif
43 .else # !defined(SRCS)
45 .if !target(${PROG})
46 .if defined(PROG_CXX)
47 SRCS= ${PROG}.cc
48 .else
49 SRCS= ${PROG}.c
50 .endif
52 # Always make an intermediate object file because:
53 # - it saves time rebuilding when only the library has changed
54 # - the name of the object gets put into the executable symbol table instead of
55 # the name of a variable temporary object.
56 # - it's useful to keep objects around for crunching.
57 OBJS= ${PROG}.o
59 ${PROG}: ${OBJS}
60 .if defined(PROG_CXX)
61 ${CXX_LINK} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
62 .else
63 ${CC_LINK} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
64 .endif
65 .endif
67 .endif
69 .if !defined(NOMAN) && !defined(MAN) && \
70 !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
71 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
72 !defined(MAN7) && !defined(MAN8) && !defined(MAN9)
73 MAN= ${PROG}.1
74 MAN1= ${MAN}
75 .endif
76 .endif
78 all: objwarn ${PROG} ${SCRIPTS}
79 .if !defined(NOMAN)
80 all: _manpages
81 .endif
83 CLEANFILES+= ${PROG} ${OBJS}
85 .if defined(PROG)
86 _EXTRADEPEND:
87 echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
88 .if defined(PROG_CXX)
89 echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
90 .endif
91 .endif
93 .if !target(install)
95 _INSTALLFLAGS:= ${INSTALLFLAGS}
96 .for ie in ${INSTALLFLAGS_EDIT}
97 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
98 .endfor
100 .if !target(realinstall)
101 realinstall: _proginstall
102 .ORDER: beforeinstall _proginstall
103 _proginstall:
104 .if defined(PROG)
105 .if defined(PROGNAME)
106 ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
107 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
108 .else
109 ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
110 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
111 .endif
112 .endif
113 .if defined(HIDEGAME)
114 (cd ${DESTDIR}${ORIGBINDIR}; ${LN} -fs dm ${PROG}; \
115 chown -h ${BINOWN}:${ORIGBINGRP} ${PROG})
116 .endif
117 .endif # !target(realinstall)
119 .if defined(SCRIPTS) && !empty(SCRIPTS)
120 realinstall: _scriptsinstall
121 .ORDER: beforeinstall _scriptsinstall
123 SCRIPTSDIR?= ${BINDIR}
124 SCRIPTSOWN?= ${BINOWN}
125 SCRIPTSGRP?= ${BINGRP}
126 SCRIPTSMODE?= ${BINMODE}
128 .for script in ${SCRIPTS}
129 .if defined(SCRIPTSNAME)
130 SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME}
131 .else
132 SCRIPTSNAME_${script:T}?= ${script:T:R}
133 .endif
134 SCRIPTSDIR_${script:T}?= ${SCRIPTSDIR}
135 SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN}
136 SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP}
137 SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
138 _scriptsinstall: _SCRIPTSINS_${script:T}
139 _SCRIPTSINS_${script:T}: ${script}
140 ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
141 -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
142 ${.ALLSRC} \
143 ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
144 .endfor
145 .endif
147 NLSNAME?= ${PROG}
149 .include <bsd.nls.mk>
150 .include <bsd.files.mk>
151 .include <bsd.incs.mk>
152 .include <bsd.links.mk>
154 .if !defined(NOMAN)
155 realinstall: _maninstall
156 .ORDER: beforeinstall _maninstall
157 .endif
159 .endif
161 .if !target(lint)
162 lint: ${SRCS}
163 .if defined(PROG)
164 @${LINT} ${LINTFLAGS} ${.ALLSRC} | more 2>&1
165 .endif
166 .endif
168 .if !defined(NOMAN)
169 .include <bsd.man.mk>
170 .endif
172 .if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES)
173 .include <bsd.libnames.mk>
174 .endif
176 .include <bsd.dep.mk>
178 .if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
179 ${OBJS}: ${SRCS:M*.h}
180 .endif
182 .include <bsd.obj.mk>
184 .include <bsd.sys.mk>