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