No empty .Rs/.Re
[netbsd-mini2440.git] / share / mk / bsd.x11.mk
blob9520906a3f35e89d48c53c0141053ecbe18ec4ad
1 # $NetBSD: bsd.x11.mk,v 1.80 2009/11/11 16:35:45 tron Exp $
3 .include <bsd.init.mk>
5 BINDIR= ${X11BINDIR}
6 LIBDIR= ${X11USRLIBDIR}
7 MANDIR= ${X11MANDIR}
9 COPTS+= -fno-strict-aliasing
11 .include <bsd.sys.mk>
13 .if defined(USE_SSP) && (${USE_SSP} != "no")
14 CPPFLAGS+= -DNO_ALLOCA
15 .endif
17 X11FLAGS.VERSION= -DOSMAJORVERSION=1 -DOSMINORVERSION=6 # XXX
19 # THREADS_DEFINES
20 X11FLAGS.THREADS= -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API \
21 -DXNO_MTSAFE_PWDAPI
23 # CONNECTION_FLAGS
24 X11FLAGS.CONNECTION= -DTCPCONN -DUNIXCONN -DHAS_STICKY_DIR_BIT \
25 -DHAS_FCHOWN
27 .if (${USE_INET6} != "no")
28 X11FLAGS.CONNECTION+= -DIPv6
29 .endif
31 # EXT_DEFINES
32 .if ${X11FLAVOUR} == "Xorg"
33 X11FLAGS.BASE_EXTENSION= -DMITMISC -DXTEST -DXTRAP -DXSYNC -DXCMISC \
34 -DXRECORD -DMITSHM -DBIGREQS -DXF86VIDMODE \
35 -DXF86MISC -DDPMSExtension -DEVI \
36 -DSCREENSAVER -DXV -DXVMC -DGLXEXT \
37 -DRES
39 X11FLAGS.PERVASIVE_EXTENSION= -DSHAPE -DXINPUT -DXKB -DLBX -DXAPPGROUP \
40 -DXCSECURITY -DTOGCUP -DXF86BIGFONT \
41 -DDPMSExtension -DPIXPRIV -DPANORAMIX \
42 -DRENDER -DRANDR -DXFIXES -DDAMAGE \
43 -DCOMPOSITE -DXEVIE
44 X11FLAGS.EXTENSION= ${X11FLAGS.BASE_EXTENSION} \
45 ${X11FLAGS.PERVASIVE_EXTENSION}
47 X11FLAGS.DIX= -DHAVE_DIX_CONFIG_H -D_BSD_SOURCE -DHAS_FCHOWN \
48 -DHAS_STICKY_DIR_BIT -D_POSIX_THREAD_SAFE_FUNCTIONS
49 X11INCS.DIX= -I${X11INCSDIR}/freetype2 \
50 -I${X11INCSDIR}/pixman-1 \
51 -I$(X11SRCDIR.xorg-server)/include \
52 -I$(X11SRCDIR.xorg-server)/Xext \
53 -I$(X11SRCDIR.xorg-server)/composite \
54 -I$(X11SRCDIR.xorg-server)/damageext \
55 -I$(X11SRCDIR.xorg-server)/xfixes \
56 -I$(X11SRCDIR.xorg-server)/Xi \
57 -I$(X11SRCDIR.xorg-server)/mi \
58 -I$(X11SRCDIR.xorg-server)/miext/shadow \
59 -I$(X11SRCDIR.xorg-server)/miext/damage \
60 -I$(X11SRCDIR.xorg-server)/render \
61 -I$(X11SRCDIR.xorg-server)/randr \
62 -I$(X11SRCDIR.xorg-server)/fb
63 .else
64 X11FLAGS.EXTENSION= -DMITMISC -DXTEST -DXTRAP -DXSYNC -DXCMISC -DXRECORD \
65 -DMITSHM -DBIGREQS -DXF86MISC -DDBE -DDPMSExtension \
66 -DEVI -DSCREENSAVER -DXV -DXVMC -DGLXEXT \
67 -DGLX_USE_MESA -DFONTCACHE -DRES
68 .endif
70 X11FLAGS.DRI= -DGLXEXT -DXF86DRI -DGLX_DIRECT_RENDERING \
71 -DGLX_USE_DLOPEN -DGLX_USE_MESA
73 .if ${X11DRI} != "no"
74 X11FLAGS.EXTENSION+= ${X11FLAGS.DRI}
75 .endif
77 # ServerDefines
78 X11FLAGS.SERVER= -DSHAPE -DXKB -DLBX -DXAPPGROUP -DXCSECURITY \
79 -DTOGCUP -DXF86BIGFONT -DDPMSExtension -DPIXPRIV \
80 -DPANORAMIX -DRENDER -DRANDR -DGCCUSESGAS \
81 -DAVOID_GLYPHBLT -DSINGLEDEPTH -DXvExtension \
82 -DXFree86Server -DXvMCExtension -DSMART_SCHEDULE \
83 -DBUILDDEBUG -DXResExtension -DNDEBUG
85 # OS_DEFINES
86 X11FLAGS.OS_DEFINES= -DDDXOSINIT -DSERVER_LOCK -DDDXOSFATALERROR \
87 -DDDXOSVERRORF -DDDXTIME -DUSB_HID
89 .if !(${MACHINE} == "acorn32" || \
90 (${MACHINE} == "alpha" && ${X11FLAVOUR} != "Xorg") || \
91 ${MACHINE} == "amiga" || \
92 ${MACHINE} == "pmax" || \
93 ${MACHINE} == "sun3" || \
94 ${MACHINE} == "vax")
95 # EXT_DEFINES
96 X11FLAGS.EXTENSION+= -DXF86VIDMODE
98 # ServerDefines
99 X11FLAGS.SERVER+= -DXINPUT -DXFreeXDGA -DXF86VIDMODE
100 .endif
102 .if ${MACHINE_ARCH} == "alpha" || \
103 ${MACHINE_ARCH} == "sparc64" || \
104 ${MACHINE_ARCH} == "x86_64"
105 # ServerDefines
106 X11FLAGS.SERVER+= -D_XSERVER64
107 X11FLAGS.EXTENSION+= -D__GLX_ALIGN64
108 .endif
110 .if ${MACHINE} == "amd64" || \
111 ${MACHINE} == "cats" || \
112 ${MACHINE} == "i386" || \
113 ${MACHINE} == "macppc" || \
114 ${MACHINE} == "netwinder" || \
115 ${MACHINE} == "ofppc" || \
116 ${MACHINE} == "sgimips" || \
117 ${MACHINE} == "sparc64" || \
118 ${MACHINE} == "sparc" || \
119 ${MACHINE} == "shark" || \
120 ${MACHINE} == "zaurus"
121 # LOADABLE
122 X11FLAGS.LOADABLE= -DXFree86LOADER -DIN_MODULE -DXFree86Module \
123 -fno-merge-constants
124 .endif
126 # XXX FIX ME
127 .if ${X11FLAVOUR} == "Xorg"
128 XVENDORNAMESHORT= '"X.Org"'
129 XVENDORNAME= '"The X.Org Foundation"'
130 XORG_RELEASE= '"Release 1.6.5"'
131 __XKBDEFRULES__= '"xorg"'
132 XLOCALE.DEFINES= -DXLOCALEDIR=\"${X11LIBDIR}/locale\" \
133 -DXLOCALELIBDIR=\"${X11LIBDIR}/locale\"
135 # XXX oh yeah, fix me later
136 XORG_VERSION_CURRENT="(((1) * 10000000) + ((6) * 100000) + ((5) * 1000) + 0)"
137 .endif
139 PRINT_PACKAGE_VERSION= awk '/^PACKAGE_VERSION=/ { \
140 match($$1, "([0-9]+\\.)+[0-9]+"); \
141 version = substr($$1, RSTART, RLENGTH); \
142 } END { print version }'
145 # Extract X11VERSION
146 PRINTX11VERSION=${TOOL_AWK} ' \
147 /^\#define XF86_VERSION_MAJOR/ {major = $$3} \
148 /^\#define XF86_VERSION_MINOR/ {minor = $$3} \
149 /^\#define XF86_VERSION_PATCH/ {patch = $$3} \
150 /^\#define XF86_VERSION_SNAP/ {snap = $$3} \
151 END { print "((("major") * 10000000) + (("minor") * 100000) + (("patch") * 1000) + "snap")"}' \
152 ${X11SRCDIR.xc}/programs/Xserver/hw/xfree86/xf86Version.h
154 # Commandline to convert 'XCOMM' comments and 'XHASH' to '#', among other
155 # things. Transformed from the "CppSedMagic" macro from "Imake.rules".
157 X11TOOL_UNXCOMM= ${TOOL_SED} -e '/^\# *[0-9][0-9]* *.*$$/d' \
158 -e '/^\#line *[0-9][0-9]* *.*$$/d' \
159 -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \
160 -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \
161 -e '/^[ ]*XHASH/s/XHASH/\#/' \
162 -e '/\@\@$$/s/\@\@$$/\\/'
165 CPPFLAGS+= -DCSRG_BASED -DFUNCPROTO=15 -DNARROWPROTO
166 CPPFLAGS+= -I${DESTDIR}${X11INCDIR}
168 .if ${MACHINE_ARCH} == "x86_64"
169 CPPFLAGS+= -D__AMD64__
170 .endif
172 LDFLAGS+= -Wl,-rpath-link,${DESTDIR}${X11USRLIBDIR} \
173 -R${X11USRLIBDIR} \
174 -L${DESTDIR}${X11USRLIBDIR}
178 # .cpp -> "" handling
179 # CPPSCRIPTS list of files/scripts to run through cpp
180 # CPPSCRIPTFLAGS extra flags to ${CPP}
181 # CPPSCRIPTFLAGS_fn extra flags to ${CPP} for file `fn'
183 .if defined(CPPSCRIPTS) # {
184 .SUFFIXES: .cpp
186 .cpp:
187 ${_MKTARGET_CREATE}
188 rm -f ${.TARGET}
189 ${CPP} -undef -traditional \
190 ${CPPSCRIPTFLAGS_${.TARGET}:U${CPPSCRIPTFLAGS}} \
191 < ${.IMPSRC} | ${X11TOOL_UNXCOMM} > ${.TARGET}
193 realall: ${CPPSCRIPTS}
195 clean: cleancppscripts
196 cleancppscripts: .PHONY
197 rm -f ${CPPSCRIPTS}
198 .endif # }
201 # X.Org pkgconfig files handling
203 # PKGCONFIG is expected to contain a list of pkgconfig module names.
204 # They will produce the files <module1>.pc, <module2>.pc, etc, to be
205 # put in X11USRLIBDIR/pkgconfig.
207 # PKGDIST contains the name of a X11SRCDIR subscript where to find the
208 # source file for the pkgconfig files.
210 # If PKGDIST is not suitable, a consumer can set PKGDIST.<module> with
211 # the full path to the source file.
213 # Also, the consumer can use PKGDIST alone, and a PKGCONFIG will be
214 # derived from it. Many times, PKGDIST is capitalized and PKGCONFIG is
215 # the lower case version.
218 .if defined(PKGDIST) && !defined(PKGCONFIG)
219 PKGCONFIG= ${PKGDIST:tl}
220 .endif
221 .if defined(PKGCONFIG)
223 .include <bsd.files.mk>
225 _PKGCONFIG_FILES= ${PKGCONFIG:C/$/.pc/}
227 .PHONY: pkgconfig-install
228 pkgconfig-install:
230 realall: ${_PKGCONFIG_FILES:O:u}
231 realinstall: pkgconfig-install
233 .for _pkg in ${PKGCONFIG:O:u}
234 PKGDIST.${_pkg}?= ${X11SRCDIR.${PKGDIST:U${_pkg}}}
235 _PKGDEST.${_pkg}= ${DESTDIR}/${X11USRLIBDIR}/pkgconfig/${_pkg}.pc
237 .PATH: ${PKGDIST.${_pkg}}
239 FILESOWN_${_pkg}.pc= ${BINOWN}
240 FILESGRP_${_pkg}.pc= ${BINGRP}
241 FILESMODE_${_pkg}.pc= ${NONBINMODE}
243 ${_PKGDEST.${_pkg}}: ${_pkg}.pc __fileinstall
244 pkgconfig-install: ${_PKGDEST.${_pkg}}
245 .endfor
247 # XXX
248 # The sed script is very, very ugly. What we actually need is a
249 # mknative-xorg script that will generate all the .pc files from
250 # running the autoconfigure script.
251 # And yes, it has to be splitted in two otherwise it's too long
252 # for sed to handle.
254 .SUFFIXES: .pc.in .pc
255 .pc.in.pc:
256 ${_MKTARGET_CREATE}
257 rm -f ${.TARGET}
258 if [ -n '${PKGCONFIG_VERSION.${.PREFIX}}' ]; then \
259 _pkg_version='${PKGCONFIG_VERSION.${.PREFIX}}'; \
260 else \
261 _pkg_version=$$(${PRINT_PACKAGE_VERSION} \
262 ${PKGDIST.${.PREFIX}}/configure); \
263 fi; \
264 ${TOOL_SED} \
265 -e "s,@prefix@,${X11ROOTDIR},; \
266 s,@INSTALL_DIR@,${X11ROOTDIR},; \
267 s,@exec_prefix@,\\$$\{prefix\},; \
268 s,@libdir@,\\$$\{prefix\}/lib,; \
269 s,@includedir@,\\$$\{prefix\}/include,; \
270 s,@datarootdir@,\\$$\{prefix\}/share,; \
271 s,@appdefaultdir@,\\$$\{libdir}/X11/app-default,; \
272 s,@MAPDIR@,\\$$\{libdir\}/X11/fonts/util,; \
273 s,@ICONDIR@,\\$$\{datarootdir\}/icons,; \
274 s,@PACKAGE_VERSION@,$${_pkg_version},; \
275 s,@VERSION@,$${_pkg_version},; \
276 s,@COMPOSITEEXT_VERSION@,$${_pkg_version%.*},; \
277 s,@DAMAGEEXT_VERSION@,$${_pkg_version%.*},; \
278 s,@FIXESEXT_VERSION@,$${_pkg_version%.*},; \
279 s,@RANDR_VERSION@,$${_pkg_version%.*},; \
280 s,@RENDER_VERSION@,$${_pkg_version%.*}," \
281 -e "s,@moduledir@,\\$$\{libdir\}/modules,; \
282 s,@sdkdir@,\\$$\{includedir\}/xorg,; \
283 s,@PIXMAN_CFLAGS@,,; \
284 s,@LIB_DIR@,/lib,; \
285 s,@INSTALL_LIB_DIR@,\\$$\{prefix\}/lib,; \
286 s,@INSTALL_INC_DIR@,\\$$\{prefix\}/include,; \
287 s,@XKBPROTO_REQUIRES@,kbproto,; \
288 s,@FREETYPE_REQUIRES@,freetype2,; \
289 s,@EXPAT_LIBS@,-lexpat,; \
290 s,@FREETYPE_LIBS@,-lfreetype,; \
291 s,@DEP_CFLAGS@,,; \
292 s,@DEP_LIBS@,,; \
293 s,@X11_EXTRA_DEPS@,,; \
294 s,@XTHREAD_CFLAGS@,-D_REENTRANT,; \
295 s,@XTHREADLIB@,-lpthread,; \
296 s,@GL_PC_REQ_PRIV@,x11 xext,; \
297 s,@GL_PC_LIB_PRIV@,-lm -lpthread,; \
298 s,@GL_PC_CFLAGS@,,; \
299 s,@GLU_PC_REQ_PRIV@,,; \
300 s,@GLU_PC_LIB_PRIV@,-lGLU,; \
301 s,@GLU_PC_CFLAGS@,,; \
302 s,@GLUT_PC_REQ_PRIV@,gl glu,; \
303 s,@GLUT_PC_LIB_PRIV@,-lglut,; \
304 s,@GLUT_PC_CFLAGS@,,; \
305 s,@abi_ansic@,0.4,; \
306 s,@abi_videodrv@,5.0,; \
307 s,@abi_xinput@,4.0,; \
308 s,@abi_extension@,2.0,; \
309 s,@abi_font@,0.6,; \
310 s,@fchown_define@,-DHAS_FCHOWN,; \
311 s,@sticky_bit_define@,-DHAS_STICKY_DIR_BIT," \
312 -e '/^Libs:/ s%-L\([^ ]*\)%-Wl,-R\1 &%g' \
313 < ${.IMPSRC} > ${.TARGET}.tmp && \
314 mv -f ${.TARGET}.tmp ${.TARGET}
316 CLEANFILES+= ${_PKGCONFIG_FILES} ${_PKGCONFIG_FILES:C/$/.tmp/}
317 .endif
320 # APPDEFS (app defaults) handling
322 .if defined(APPDEFS) # {
323 appdefsinstall:: .PHONY ${APPDEFS:@S@${DESTDIR}${X11LIBDIR}/app-defaults/${S:T:R}@}
324 .PRECIOUS: ${APPDEFS:@S@${DESTDIR}${X11LIBDIR}/app-defaults/${S:T:R}@}
326 __appdefinstall: .USE
327 ${_MKTARGET_INSTALL}
328 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} \
329 ${.ALLSRC} ${.TARGET}
331 .for S in ${APPDEFS:O:u}
332 ${DESTDIR}${X11LIBDIR}/app-defaults/${S:T:R}: ${S} __appdefinstall
333 .endfor
335 realinstall: appdefsinstall
336 .endif # }
340 # .man page handling
342 .if (${MKMAN} != "no" && (${MAN:U} != "" || ${PROG:U} != "")) # {
343 cleandir: cleanx11man
344 cleanx11man: .PHONY
345 rm -f ${MAN:U${PROG:D${PROG.1}}}
346 .endif # }
348 .SUFFIXES: .man .man.pre .1 .3 .4 .5 .7
350 _X11MANTRANSFORM= \
351 __adminmansuffix__ 8 \
352 __apploaddir__ ${X11ROOTDIR}/lib/X11/app-defaults \
353 __appmansuffix__ 1 \
354 __bindir__ ${X11BINDIR} \
355 __drivermansuffix__ 4 \
356 __filemansuffix__ 5 \
357 __LIB_MAN_SUFFIX__ 3 \
358 __libmansuffix__ 3 \
359 __logdir__ /var/log \
360 __mandir__ ${X11MANDIR} \
361 __miscmansuffix__ 7 \
362 __oslibmansuffix__ 3 \
363 __projectroot__ ${X11ROOTDIR} \
364 ${X11EXTRAMANTRANSFORMS}
366 # Note the escaping trick for _X11MANTRANSFORM using % to replace spaces
367 .if ${X11FLAVOUR} != "Xorg"
368 X11VERSION= "XFree86 4.5.0"
369 X11MANCPP?= yes
370 _X11MANTRANSFORM+= \
371 __vendorversion__ ${X11VERSION:C/ /%/gW}
372 .else
373 XORGVERSION= '"X.Org 7.3nb20081014" "X Version 11"'
374 X11MANCPP?= no
375 _X11MANTRANSFORM+= \
376 __vendorversion__ ${XORGVERSION:C/ /%/gW} \
377 __XCONFIGFILE__ xorg.conf \
378 __xconfigfile__ xorg.conf \
379 __xorgversion__ ${XORGVERSION:C/ /%/gW} \
380 __XSERVERNAME__ Xorg \
381 __xservername__ Xorg
382 .endif
384 _X11MANTRANSFORMCMD= ${TOOL_SED} -e 's/\\$$/\\ /' ${.IMPSRC}
386 .if ${X11MANCPP} != "no"
387 _X11MANTRANSFORMCMD+= | ${CPP} -undef -traditional
388 . for __def__ __value__ in ${_X11MANTRANSFORM}
389 _X11MANTRANSFORMCMD+= -D${__def__}=${__value__:C/%/ /gW}
390 . endfor
391 .else
392 _X11MANTRANSFORMCMD+= | ${TOOL_SED}
393 . for __def__ __value__ in ${_X11MANTRANSFORM}
394 _X11MANTRANSFORMCMD+= -e s,${__def__},${__value__:C/%/ /gW},g
395 . endfor
396 .endif
397 _X11MANTRANSFORMCMD+= ${X11EXTRAMANDEFS}
399 .man.1 .man.3 .man.4 .man.5 .man.7 .man.pre.1 .man.pre.4 .man.pre.5:
400 ${_MKTARGET_CREATE}
401 rm -f ${.TARGET}
402 ${_X11MANTRANSFORMCMD} | ${X11TOOL_UNXCOMM} > ${.TARGET}