1# $NetBSD: bsd.x11.mk,v 1.112 2014/03/31 01:59:36 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 Makefile 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 split in multiple parts otherwise it's 259# too long 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 ${PKGCONFIG_SED_FLAGS} \ 276 -e "s,@prefix@,${X11ROOTDIR},; \ 277 s,@INSTALL_DIR@,${X11ROOTDIR},; \ 278 s,@exec_prefix@,\\$$\{prefix\},; \ 279 s,@libdir@,\\$$\{prefix\}/lib,; \ 280 s,@includedir@,\\$$\{prefix\}/include,; \ 281 s,@datarootdir@,\\$$\{prefix\}/share,; \ 282 s,@datadir@,\\$$\{datarootdir\},; \ 283 s,@appdefaultdir@,\\$$\{libdir}/X11/app-defaults,; \ 284 s,@MAPDIR@,\\$$\{libdir\}/X11/fonts/util,; \ 285 s,@ICONDIR@,\\$$\{datarootdir\}/icons,; \ 286 s,@PACKAGE_VERSION@,$${_pkg_version},; \ 287 s,@VERSION@,$${_pkg_version},; \ 288 s,@COMPOSITEEXT_VERSION@,$${_pkg_version%.*},; \ 289 s,@DAMAGEEXT_VERSION@,$${_pkg_version%.*},; \ 290 s,@FIXESEXT_VERSION@,$${_pkg_version%.*},; \ 291 s,@RANDR_VERSION@,$${_pkg_version%.*},; \ 292 s,@RENDER_VERSION@,$${_pkg_version%.*}," \ 293 -e "s,@LIBS@,,; \ 294 s,@Z_LIBS@,-lz,; \ 295 s,@LIBZ@,-lz,; \ 296 s,@LIBBZ2@,-lbz2,; \ 297 s,@xkb_base@,\\$$\{prefix\}/lib/X11/xkb,; \ 298 s,@xcbincludedir@,\\$$\{prefix\}/share/xcb,; \ 299 s,@fontrootdir@,\\$$\{libdir\}/X11/fonts,; \ 300 s,@LIBXML2_LIBS@,,; \ 301 s,@LIBXML2_CFLAGS@,,; \ 302 s,@ICONV_CFLAGS@,,; \ 303 s,@ICONV_LIBS@,,; \ 304 s,@NEEDED@,,; \ 305 s,@FT2_EXTRA_LIBS@,," \ 306 -e "s,@moduledir@,\\$$\{libdir\}/modules,; \ 307 s,@sdkdir@,\\$$\{includedir\}/xorg,; \ 308 s,@PIXMAN_CFLAGS@,,; \ 309 s,@LIB_DIR@,/lib,; \ 310 s,@INSTALL_LIB_DIR@,\\$$\{prefix\}/lib,; \ 311 s,@INSTALL_INC_DIR@,\\$$\{prefix\}/include,; \ 312 s,@XKBPROTO_REQUIRES@,kbproto,; \ 313 s,@XCBPROTO_VERSION@,1.7,; \ 314 s,@FREETYPE_REQUIRES@,freetype2,; \ 315 s,@EXPAT_LIBS@,-lexpat,; \ 316 s,@FREETYPE_LIBS@,-lfreetype,; \ 317 s,@DEP_CFLAGS@,,; \ 318 s,@DEP_LIBS@,,; \ 319 s,@X11_EXTRA_DEPS@,,; \ 320 s,@XTHREAD_CFLAGS@,-D_REENTRANT,; \ 321 s,@XTHREADLIB@,-lpthread,; \ 322 s,@GL_LIB@,GL,; \ 323 s,@GL_PC_REQ_PRIV@,x11 xext,; \ 324 s,@GL_PC_LIB_PRIV@,-lm -lpthread,; \ 325 s,@GL_PC_CFLAGS@,," \ 326 -e "s,@GLU_LIB@,GLU,; \ 327 s,@GLU_PC_REQ@,gl,; \ 328 s,@GLU_PC_REQ_PRIV@,,; \ 329 s,@GLU_PC_LIB_PRIV@,-lGLU,; \ 330 s,@GLU_PC_CFLAGS@,,; \ 331 s,@GLUT_LIB@,glut,; \ 332 s,@GLUT_PC_REQ_PRIV@,gl glu,; \ 333 s,@GLUT_PC_LIB_PRIV@,-lglut,; \ 334 s,@GLUT_PC_CFLAGS@,,; \ 335 s,@GLW_PC_CFLAGS@,,; \ 336 s,@GLW_PC_REQ_PRIV@,x11 xt,; \ 337 s,@GLW_PC_LIB_PRIV@,,; \ 338 s,@DRI_DRIVER_DIR@,\\$$\{libdir\}/modules/dri,; \ 339 s,@DRI_PC_REQ_PRIV@,,; \ 340 s,@GLW_LIB@,GLw,; \ 341 s,@abi_ansic@,0.4,; \ 342 s,@abi_videodrv@,5.0,; \ 343 s,@abi_xinput@,4.0,; \ 344 s,@abi_extension@,2.0,; \ 345 s,@abi_font@,0.6,; \ 346 s,@fchown_define@,-DHAS_FCHOWN,; \ 347 s,@sticky_bit_define@,-DHAS_STICKY_DIR_BIT," \ 348 -e "s,@PKG_CONFIG_LIBS@,${PKG_CONFIG_LIBS},; \ 349 s,@PACKAGE@,${PKGDIST},; \ 350 s,@PKGCONFIG_REQUIRES@,${PKGCONFIG_REQUIRES},; \ 351 s,@PKGCONFIG_REQUIRES_PRIVATELY@,${PKGCONFIG_REQUIRES_PRIVATELY},; \ 352 s,@ERRORDBDIR@,${X11LIBDIR},; \ 353 s,@EXPAT_CFLAGS@,,; \ 354 s,@FREETYPE_CFLAGS@,-I${X11ROOTDIR}/include/freetype2 -I${X11ROOTDIR}/include,; \ 355 s,@SDK_REQUIRED_MODULES@,xproto >= 7.0.17 randrproto >= 1.2.99.3 renderproto >= 0.11 xextproto >= 7.1.99 inputproto >= 1.9.99.902 kbproto >= 1.0.3 fontsproto," \ 356 -e '/^Libs:/ s%-L\([^ ]*\)%-Wl,-rpath,\1 &%g' \ 357 < ${.IMPSRC} > ${.TARGET}.tmp && \ 358 mv -f ${.TARGET}.tmp ${.TARGET} 359 360CLEANFILES+= ${_PKGCONFIG_FILES} ${_PKGCONFIG_FILES:C/$/.tmp/} 361.endif 362 363# 364# APPDEFS (app defaults) handling 365# 366.if defined(APPDEFS) # { 367appdefsinstall:: .PHONY ${APPDEFS:@S@${DESTDIR}${X11LIBDIR}/app-defaults/${S:T:R}@} 368.PRECIOUS: ${APPDEFS:@S@${DESTDIR}${X11LIBDIR}/app-defaults/${S:T:R}@} 369 370__appdefinstall: .USE 371 ${_MKTARGET_INSTALL} 372 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} \ 373 ${.ALLSRC} ${.TARGET} 374 375.for S in ${APPDEFS:O:u} 376${DESTDIR}${X11LIBDIR}/app-defaults/${S:T:R}: ${S} __appdefinstall 377.endfor 378 379realinstall: appdefsinstall 380.endif # } 381 382 383# 384# .man page handling 385# 386.if (${MKMAN} != "no" && (${MAN:U} != "" || ${PROG:U} != "")) # { 387CLEANDIRFILES+= ${MAN:U${PROG:D${PROG.1}}} 388.endif # } 389 390.SUFFIXES: .man .man.pre .1 .3 .4 .5 .7 391 392_X11MANTRANSFORM= \ 393 __adminmansuffix__ 8 \ 394 __apploaddir__ ${X11ROOTDIR}/lib/X11/app-defaults \ 395 __appmansuffix__ 1 \ 396 __bindir__ ${X11BINDIR} \ 397 __drivermansuffix__ 4 \ 398 __filemansuffix__ 5 \ 399 __LIB_MAN_SUFFIX__ 3 \ 400 __libmansuffix__ 3 \ 401 __logdir__ /var/log \ 402 __mandir__ ${X11MANDIR} \ 403 __miscmansuffix__ 7 \ 404 __oslibmansuffix__ 3 \ 405 __projectroot__ ${X11ROOTDIR} \ 406 ${X11EXTRAMANTRANSFORMS} 407 408# Note the escaping trick for _X11MANTRANSFORM using % to replace spaces 409.if ${X11FLAVOUR} != "Xorg" 410X11VERSION= "XFree86 4.5.0" 411X11MANCPP?= yes 412_X11MANTRANSFORM+= \ 413 __vendorversion__ ${X11VERSION:C/ /%/gW} 414.else 415XORGVERSION= '"X Version 11"' 416X11MANCPP?= no 417_X11MANTRANSFORM+= \ 418 __vendorversion__ ${XORGVERSION:C/ /%/gW} \ 419 __XCONFIGFILE__ xorg.conf \ 420 __xconfigfile__ xorg.conf \ 421 __XCONFIGFILEMAN__ '__XCONFIGFILE__%(__filemansuffix__)' \ 422 __xorgversion__ ${XORGVERSION:C/ /%/gW} \ 423 __XSERVERNAME__ Xorg \ 424 __xservername__ Xorg 425.endif 426 427_X11MANTRANSFORMCMD= ${TOOL_SED} -e 's/\\$$/\\ /' ${.IMPSRC} 428 429.if ${X11MANCPP} != "no" 430_X11MANTRANSFORMCMD+= | ${CC} -E -undef -traditional - 431. for __def__ __value__ in ${_X11MANTRANSFORM} 432_X11MANTRANSFORMCMD+= -D${__def__}=${__value__:C/%/ /gW} 433. endfor 434.else 435_X11MANTRANSFORMCMD+= | ${TOOL_SED} 436. for __def__ __value__ in ${_X11MANTRANSFORM} 437_X11MANTRANSFORMCMD+= -e s,${__def__},${__value__:C/%/ /gW},g 438. endfor 439.endif 440_X11MANTRANSFORMCMD+= ${X11EXTRAMANDEFS} 441 442.man.1 .man.3 .man.4 .man.5 .man.7 .man.pre.1 .man.pre.4 .man.pre.5: 443 ${_MKTARGET_CREATE} 444 rm -f ${.TARGET} 445 ${_X11MANTRANSFORMCMD} | ${X11TOOL_UNXCOMM} > ${.TARGET} 446 447##### Pull in related .mk logic 448.include <bsd.clean.mk> 449