summaryrefslogtreecommitdiff
path: root/mk/bsd.prefs.mk
blob: e0e4b923902cc34fce28e61714d2c16996422737 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# $NetBSD: bsd.prefs.mk,v 1.74 2002/08/01 05:36:33 jlam Exp $
#
# Make file, included to get the site preferences, if any.  Should
# only be included by package Makefiles before any .if defined()
# statements or modifications to "passed" variables (CFLAGS, LDFLAGS, ...),
# to make sure any variables defined in /etc/mk.conf, $MAKECONF, or
# the system defaults (sys.mk and bsd.own.mk) are used.

# Do not recursively include mk.conf, redefine OPSYS, include bsd.own.mk, etc.
.ifndef BSD_PKG_MK

# Let mk.conf know that this is pkgsrc.
BSD_PKG_MK=1 
__PREFIX_SET__:=${PREFIX}

# Define a symbol BSD_PREFS_MK that may be checked by Makefile fragments to
# test whether they are being included from within bsd.prefs.mk or from
# without.
#
.ifndef BSD_PREFS_MK
BSD_PREFS_MK=1
.endif

.if exists(/usr/bin/uname)
UNAME=/usr/bin/uname
.elif exists(/bin/uname)
UNAME=/bin/uname
.else
UNAME=echo Unknown
.endif

.ifndef OPSYS
OPSYS!=			${UNAME} -s
.endif
MAKEFLAGS+=		OPSYS=${OPSYS}
.ifndef OS_VERSION
OS_VERSION!=		${UNAME} -r
.endif
.ifndef LOWER_OS_VERSION
LOWER_OS_VERSION!=	echo ${OS_VERSION} | tr A-Z a-z
.endif
MAKEFLAGS+=		OS_VERSION=${OS_VERSION}

# Preload these for architectures not in all variations of bsd.own.mk.
GNU_ARCH.alpha?=	alpha
GNU_ARCH.arm26?=	arm
GNU_ARCH.arm32?=	arm
GNU_ARCH.i386?=		i386
GNU_ARCH.i486?=		i386
GNU_ARCH.i586?=		i386
GNU_ARCH.i686?=		i386
GNU_ARCH.m68000?=	m68010
GNU_ARCH.m68k?=		m68k
GNU_ARCH.mips?=		mipsel
GNU_ARCH.mipseb?=	mipseb
GNU_ARCH.mipsel?=	mipsel
GNU_ARCH.ns32k?=	ns32k
GNU_ARCH.powerpc?=	powerpc
GNU_ARCH.sh3eb?=	sh
GNU_ARCH.sh3el?=	shle
GNU_ARCH.sparc?=	sparc
GNU_ARCH.sparc64?=	sparc64
GNU_ARCH.vax?=		vax
MACHINE_GNU_ARCH?=	${GNU_ARCH.${MACHINE_ARCH}}

.if ${OPSYS} == "NetBSD"
LOWER_OPSYS?=		netbsd

.elif ${OPSYS} == "SunOS"
. if ${MACHINE_ARCH} == "unknown"
.  if !defined(LOWER_ARCH)
LOWER_ARCH!=		${UNAME} -p
.  endif	# !defined(LOWER_ARCH)
MAKEFLAGS+=		LOWER_ARCH=${LOWER_ARCH}
. endif
LOWER_VENDOR?=		sun
LOWER_OPSYS?=		solaris
. if (${MACHINE_ARCH} == sparc)
SPARC_TARGET_ARCH?=	sparcv7
. endif
# We need to set this early to get "USE_MESA" and "USE_XPM" working.
X11BASE?=               ${DESTDIR}/usr/openwin

.elif ${OPSYS} == "Linux"
LOWER_OPSYS?=		linux
. if ${MACHINE_ARCH} == "unknown"
.  if !defined(LOWER_ARCH)
LOWER_ARCH!=		${UNAME} -m | sed -e 's/[456]86/386/'
.  endif # !defined(LOWER_ARCH)
MACHINE_ARCH=		${LOWER_ARCH}
MAKEFLAGS+=		LOWER_ARCH=${LOWER_ARCH}
.  if ${LOWER_ARCH} == "i386"
LOWER_VENDOR?=		pc
.  else
LOWER_VENDOR?=		unknown
.  endif
. endif

.elif ${OPSYS} == "Darwin"
LOWER_OPSYS?=		darwin
LOWER_ARCH!=		${UNAME} -p
MACHINE_ARCH=		${LOWER_ARCH}
MAKEFLAGS+=		LOWER_ARCH=${LOWER_ARCH}
LOWER_VENDOR?=		apple

.elif !defined(LOWER_OPSYS)
LOWER_OPSYS!=		echo ${OPSYS} | tr A-Z a-z
.endif

MAKEFLAGS+=		LOWER_OPSYS=${LOWER_OPSYS}

LOWER_VENDOR?=
LOWER_ARCH?=		${MACHINE_GNU_ARCH}

MACHINE_PLATFORM?=	${OPSYS}-${OS_VERSION}-${MACHINE_ARCH}
MACHINE_GNU_PLATFORM?=	${LOWER_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS}${APPEND_ELF}

# Needed on NetBSD and SunOS (zoularis) to prevent an "install:" target
# from being created in bsd.own.mk.
NEED_OWN_INSTALL_TARGET=no

# This prevents default use of the cross-tool harness in the "src" tree,
# in the odd possible case of someone extracting "pkgsrc" underneath "src".
USETOOLS=		no
MAKE_ENV+=		USETOOLS=no

# Set this before <bsd.own.mk> does, since it doesn't know about Darwin
.if ${OPSYS} == "Darwin"
OBJECT_FMT?=		Mach-O
.endif

.include <bsd.own.mk>

# /usr/share/mk/bsd.own.mk on NetBSD 1.3 does not define OBJECT_FMT
.if ${MACHINE_PLATFORM:MNetBSD-1.3*} != ""
.if ${MACHINE_ARCH} == "alpha" || \
${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "sparc64"
OBJECT_FMT?=		ELF
.else
OBJECT_FMT?=		a.out
.endif
.endif

# include the defaults file
.if exists(${.CURDIR}/../../mk/bsd.pkg.defaults.mk)
.include "${.CURDIR}/../../mk/bsd.pkg.defaults.mk"
.elif exists(${.CURDIR}/../mk/bsd.pkg.defaults.mk)
.include "${.CURDIR}/../mk/bsd.pkg.defaults.mk"
.elif exists(${.CURDIR}/mk/bsd.pkg.defaults.mk)
.include "${.CURDIR}/mk/bsd.pkg.defaults.mk"
.endif

.if ${OPSYS} == "NetBSD"
. if ${OBJECT_FMT} == "ELF" && \
    (${MACHINE_GNU_ARCH} == "arm" || \
     ${MACHINE_ARCH} == "i386" || \
     ${MACHINE_ARCH} == "m68k" || \
     ${MACHINE_ARCH} == "m68000" || \
     ${MACHINE_GNU_ARCH} == "sh" || \
     ${MACHINE_GNU_ARCH} == "shle" || \
     ${MACHINE_ARCH} == "sparc" || \
     ${MACHINE_ARCH} == "vax")
APPEND_ELF=		elf
. endif
.endif

SHAREOWN?=		${DOCOWN}
SHAREGRP?=		${DOCGRP}
SHAREMODE?=		${DOCMODE}

.if defined(PREFIX) && (${PREFIX} != ${__PREFIX_SET__})
.BEGIN:
	@${ECHO_MSG} "You can NOT set PREFIX manually or in mk.conf.  Set LOCALBASE or X11BASE"
	@${ECHO_MSG} "depending on your needs.  See the pkg system documentation for more info."
	@${FALSE}
.endif

# if the system is IPv6-ready NetBSD, compile with IPv6 support turned on.
.if (${OPSYS} == "NetBSD") && !defined(USE_SOCKS) && \
    exists(/usr/include/netinet6)
USE_INET6?=		YES
.else
USE_INET6?=		NO
.endif

# Preload all default values for CFLAGS, LDFLAGS, etc. before bsd.pkg.mk
# or a pkg Makefile modifies them.
.include <sys.mk>

# Load the OS-specific definitions for program variables.  Default to loading
# the NetBSD ones if an OS-specific file doesn't exist.
.if exists(${.CURDIR}/../../mk/defs.${OPSYS}.mk)
.include "${.CURDIR}/../../mk/defs.${OPSYS}.mk"
.elif exists(${.CURDIR}/../mk/defs.${OPSYS}.mk)
.include "${.CURDIR}/../mk/defs.${OPSYS}.mk"
.elif exists(${.CURDIR}/mk/defs.${OPSYS}.mk)
.include "${.CURDIR}/mk/defs.${OPSYS}.mk"
.elif exists(${.CURDIR}/../../mk/defs.NetBSD.mk)
.include "${.CURDIR}/../../mk/defs.NetBSD.mk"
.elif exists(${.CURDIR}/../mk/defs.NetBSD.mk)
.include "${.CURDIR}/../mk/defs.NetBSD.mk"
.else exists(${.CURDIR}/mk/defs.NetBSD.mk)
.include "${.CURDIR}/mk/defs.NetBSD.mk"
.endif

# Set default type of libXaw used during package builds.
.if defined(USE_XAW)
XAW_TYPE?=		standard
.endif

# Check if we got Mesa distributed with XFree86 4.x or if we need to
# depend on the Mesa package.
# XFree86 starting with 4.1.0 contains now a libGLU, so also check for it.
.if (defined(CHECK_MESA) || defined(USE_MESA))
X11BASE?=		/usr/X11R6
.if exists(${X11BASE}/include/GL/glx.h) && \
    exists(${X11BASE}/lib/X11/config/X11.tmpl)
__BUILTIN_MESA!=	${EGREP} -c BuildGLXLibrary ${X11BASE}/lib/X11/config/X11.tmpl || ${TRUE}
.else
__BUILTIN_MESA=		0
.endif
.if exists(${X11BASE}/include/GL/glu.h) && \
    exists(${X11BASE}/lib/X11/config/X11.tmpl)
__BUILTIN_GLU!=		egrep -c BuildGLULibrary ${X11BASE}/lib/X11/config/X11.tmpl || true
.else
__BUILTIN_GLU=		0
.endif
.if ${__BUILTIN_MESA} == "0"
HAVE_BUILTIN_MESA=	NO
.else
HAVE_BUILTIN_MESA=	YES
.endif
.if ${__BUILTIN_GLU} == "0"
HAVE_BUILTIN_GLU=	NO
.else
HAVE_BUILTIN_GLU=	YES
.endif
.undef __BUILTIN_MESA
.undef __BUILTIN_GLU
.endif	# CHECK_MESA

# Check if we got FreeType2 distributed with XFree86 4.x or if we need to
# depend on the freetype2 package.
.if (defined(CHECK_FREETYPE2) || defined(USE_FREETYPE2))
X11BASE?=		/usr/X11R6
.if exists(${X11BASE}/include/freetype2/freetype/freetype.h)
__BUILTIN_FREETYPE2!=	${EGREP} -c BuildFreetype2Library ${X11BASE}/lib/X11/config/X11.tmpl || ${TRUE}
.else
__BUILTIN_FREETYPE2=	0
.endif
.if ${__BUILTIN_FREETYPE2} == "0"
HAVE_BUILTIN_FREETYPE2=	NO
.else
HAVE_BUILTIN_FREETYPE2=	YES
.endif
.undef __BUILTIN_FREETYPE2
.endif	# CHECK_FREETYPE2

# Check if we got Xpm distributed with XFree86 4.x or if we need to
# depend on the Xpm package.
.if (defined(CHECK_XPM) || defined(USE_XPM))
X11BASE?=		/usr/X11R6
.if exists(${X11BASE}/include/X11/xpm.h) && exists(${X11BASE}/lib/X11/config/X11.tmpl)
__BUILTIN_XPM!=		${EGREP} -c NormalLibXpm ${X11BASE}/lib/X11/config/X11.tmpl || ${TRUE}
.else
__BUILTIN_XPM=		0
.endif
.if ${__BUILTIN_XPM} == "0"
HAVE_BUILTIN_XPM=	NO
.else
HAVE_BUILTIN_XPM=	YES
.endif
.undef __BUILTIN_XPM
.endif	# CHECK_XPM

LOCALBASE?=		${DESTDIR}/usr/pkg
X11BASE?=		${DESTDIR}/usr/X11R6
CROSSBASE?=		${LOCALBASE}/cross

.ifndef DIGEST
DIGEST:=		${LOCALBASE}/bin/digest
MAKEFLAGS+=		DIGEST=${DIGEST}
.endif

# Only add the DIGEST_VERSION value to MAKEFLAGS when we know
# we've got a valid version number, retrieved from the digest(1)
# binary. This is different to PKGTOOLS_VERSION, since, in that
# case, the build dies when pkg_info(1) is out of date. 

.if !exists(${DIGEST})
DIGEST_VERSION=		20010301
.elif !defined(DIGEST_VERSION)
DIGEST_VERSION!= 	${DIGEST} -V 2>/dev/null
MAKEFLAGS+=		DIGEST_VERSION="${DIGEST_VERSION}"
.endif

.ifndef PKGTOOLS_VERSION
PKGTOOLS_VERSION!=${PKG_TOOLS_BIN}/pkg_info -V 2>/dev/null || echo 20010302
MAKEFLAGS+=	PKGTOOLS_VERSION="${PKGTOOLS_VERSION}"
.endif

.if (${OPSYS} == SunOS) && !defined(ZOULARIS_VERSION)
.if !exists(${ZOULARISBASE}/share/mk/zoularis.mk)
ZOULARIS_VERSION=	20000522
.else
.include "${ZOULARISBASE}/share/mk/zoularis.mk"
.endif
MAKEFLAGS+=		ZOULARIS_VERSION="${ZOULARIS_VERSION}"
.endif

.ifdef BSD_PREFS_MK
.undef BSD_PREFS_MK
.endif

.endif	# BSD_PKG_MK