xref: /freebsd/contrib/bmake/mk/own.mk (revision 4d293dd8dcde59fc9842a0ce1125fef8fcf83a8c)
1# $Id: own.mk,v 1.29 2015/09/08 06:15:31 sjg Exp $
2
3.if !target(__${.PARSEFILE}__)
4__${.PARSEFILE}__:
5
6.if !target(__init.mk__)
7.include "init.mk"
8.endif
9
10.ifndef NOMAKECONF
11MAKECONF?=	/etc/mk.conf
12.-include "${MAKECONF}"
13.endif
14
15.include <host-target.mk>
16
17TARGET_OSNAME?= ${_HOST_OSNAME}
18TARGET_OSREL?= ${_HOST_OSREL}
19TARGET_OSTYPE?= ${HOST_OSTYPE}
20TARGET_HOST?= ${HOST_TARGET}
21
22# these may or may not exist
23.-include "${TARGET_HOST}.mk"
24.-include "config.mk"
25
26RM?= rm
27LN?= ln
28INSTALL?= install
29
30prefix?=	/usr
31.if exists(${prefix}/lib)
32libprefix?=	${prefix}
33.else
34libprefix?=	/usr
35.endif
36
37# FreeBSD at least does not set this
38MACHINE_ARCH?=${MACHINE}
39# we need to make sure these are defined too in case sys.mk fails to.
40COMPILE.s?=	${CC} ${AFLAGS} -c
41LINK.s?=	${CC} ${AFLAGS} ${LDFLAGS}
42COMPILE.S?=	${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
43LINK.S?=	${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
44COMPILE.c?=	${CC} ${CFLAGS} ${CPPFLAGS} -c
45LINK.c?=	${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
46CXXFLAGS?=	${CFLAGS}
47COMPILE.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
48LINK.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
49COMPILE.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
50LINK.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
51COMPILE.f?=	${FC} ${FFLAGS} -c
52LINK.f?=	${FC} ${FFLAGS} ${LDFLAGS}
53COMPILE.F?=	${FC} ${FFLAGS} ${CPPFLAGS} -c
54LINK.F?=	${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
55COMPILE.r?=	${FC} ${FFLAGS} ${RFLAGS} -c
56LINK.r?=	${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
57LEX.l?=		${LEX} ${LFLAGS}
58COMPILE.p?=	${PC} ${PFLAGS} ${CPPFLAGS} -c
59LINK.p?=	${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
60YACC.y?=	${YACC} ${YFLAGS}
61
62# for suffix rules
63IMPFLAGS?=	${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}}
64.for s in .c .cc
65COMPILE.$s += ${IMPFLAGS}
66LINK.$s +=  ${IMPFLAGS}
67.endfor
68
69PRINT.VAR.MAKE = MAKESYSPATH=${MAKESYSPATH:U${.PARSEDIR}} ${.MAKE}
70.if empty(.MAKEFLAGS:M-V*)
71.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
72PRINTOBJDIR=	${PRINT.VAR.MAKE} -r -V .OBJDIR -f /dev/null xxx
73.else
74PRINTOBJDIR=	${PRINT.VAR.MAKE} -V .OBJDIR
75.endif
76.else
77PRINTOBJDIR=	echo # prevent infinite recursion
78.endif
79
80# we really like to have SRCTOP and OBJTOP defined...
81.if !defined(SRCTOP) || !defined(OBJTOP)
82.-include "srctop.mk"
83.endif
84
85.if !defined(SRCTOP) || !defined(OBJTOP)
86# dpadd.mk is rather pointless without these
87OPTIONS_DEFAULT_NO+= DPADD_MK
88.endif
89
90# process options
91OPTIONS_DEFAULT_NO+= \
92	AUTO_OBJ \
93	INSTALL_AS_USER \
94	GPROF \
95	LIBTOOL \
96	LINT \
97	META_MODE \
98
99OPTIONS_DEFAULT_YES+= \
100	ARCHIVE \
101	AUTODEP \
102	CRYPTO \
103	DOC \
104	DPADD_MK \
105	GDB \
106	KERBEROS \
107	LINKLIB \
108	MAN \
109	NLS \
110	OBJ \
111	PIC \
112	SHARE \
113	SKEY \
114	YP \
115
116OPTIONS_DEFAULT_DEPENDENT+= \
117	CATPAGES/MAN \
118	OBJDIRS/OBJ \
119	PICINSTALL/LINKLIB \
120	PICLIB/PIC \
121	PROFILE/LINKLIB \
122
123.include <options.mk>
124
125.if ${MK_INSTALL_AS_USER} == "yes"
126# We ignore this if user is root.
127_uid!=  id -u
128.if ${_uid} != 0
129.if !defined(USERGRP)
130USERGRP!=  id -g
131.export USERGRP
132.endif
133.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
134$xOWN=  ${USER}
135$xGRP=  ${USERGRP}
136$x_INSTALL_OWN=
137.endfor
138PROG_INSTALL_OWN=
139.endif
140.endif
141
142# override this in sys.mk
143ROOT_GROUP?=	wheel
144BINGRP?=	${ROOT_GROUP}
145BINOWN?=	root
146BINMODE?=	555
147NONBINMODE?=	444
148DIRMODE?=	755
149
150# Define MANZ to have the man pages compressed (gzip)
151#MANZ=		1
152
153MANTARGET?= cat
154MANDIR?=	${prefix}/share/man/${MANTARGET}
155MANGRP?=	${BINGRP}
156MANOWN?=	${BINOWN}
157MANMODE?=	${NONBINMODE}
158
159LIBDIR?=	${libprefix}/lib
160SHLIBDIR?=	${libprefix}/lib
161.if ${USE_SHLIBDIR:Uno} == "yes"
162_LIBSODIR?=	${SHLIBDIR}
163.else
164_LIBSODIR?=	${LIBDIR}
165.endif
166# this is where ld.*so lives
167SHLINKDIR?=	/usr/libexec
168LINTLIBDIR?=	${libprefix}/libdata/lint
169LIBGRP?=	${BINGRP}
170LIBOWN?=	${BINOWN}
171LIBMODE?=	${NONBINMODE}
172
173DOCDIR?=        ${prefix}/share/doc
174DOCGRP?=	${BINGRP}
175DOCOWN?=	${BINOWN}
176DOCMODE?=       ${NONBINMODE}
177
178NLSDIR?=	${prefix}/share/nls
179NLSGRP?=	${BINGRP}
180NLSOWN?=	${BINOWN}
181NLSMODE?=	${NONBINMODE}
182
183KMODDIR?=	${prefix}/lkm
184KMODGRP?=	${BINGRP}
185KMODOWN?=	${BINOWN}
186KMODMODE?=	${NONBINMODE}
187
188COPY?=		-c
189STRIP_FLAG?=	-s
190
191.if ${TARGET_OSNAME} == "NetBSD"
192.if exists(/usr/libexec/ld.elf_so)
193OBJECT_FMT=ELF
194.endif
195OBJECT_FMT?=a.out
196.endif
197# sys.mk should set something appropriate if need be.
198OBJECT_FMT?=ELF
199
200.if (${_HOST_OSNAME} == "FreeBSD")
201CFLAGS+= ${CPPFLAGS}
202.endif
203
204# allow for per target flags
205# apply the :T:R first, so the more specific :T can override if needed
206CPPFLAGS += ${CPPFLAGS_${.TARGET:T:R}} ${CPPFLAGS_${.TARGET:T}}
207CFLAGS += ${CFLAGS_${.TARGET:T:R}} ${CFLAGS_${.TARGET:T}}
208
209# Define SYS_INCLUDE to indicate whether you want symbolic links to the system
210# source (``symlinks''), or a separate copy (``copies''); (latter useful
211# in environments where it's not possible to keep /sys publicly readable)
212#SYS_INCLUDE= 	symlinks
213
214# don't try to generate PIC versions of libraries on machines
215# which don't support PIC.
216.if  (${MACHINE_ARCH} == "vax") || \
217    ((${MACHINE_ARCH} == "mips") && defined(STATIC_TOOLCHAIN)) || \
218    ((${MACHINE_ARCH} == "alpha") && defined(ECOFF_TOOLCHAIN))
219MK_PIC=no
220.endif
221
222# No lint, for now.
223NOLINT=
224
225
226.if ${MK_LINKLIB} == "no"
227MK_PICINSTALL=	no
228MK_PROFILE=	no
229.endif
230
231.if ${MK_MAN} == "no"
232MK_CATPAGES=	no
233.endif
234
235.if ${MK_OBJ} == "no"
236MK_OBJDIRS=	no
237MK_AUTO_OBJ=	no
238.endif
239
240.if ${MK_SHARE} == "no"
241MK_CATPAGES=	no
242MK_DOC=		no
243MK_INFO=	no
244MK_MAN=		no
245MK_NLS=		no
246.endif
247
248.endif
249