Home | History | Annotate | Line # | Download | only in mk
bsd.x11.mk revision 1.65
      1 #	$NetBSD: bsd.x11.mk,v 1.65 2008/09/15 02:37:54 cube Exp $
      2 
      3 .include <bsd.init.mk>
      4 
      5 .if make(depend) || make(all) || make(dependall)
      6 .if (${MKX11} != "no" && ${MKXORG} != "no")
      7 .BEGIN:
      8 	@echo
      9 	@echo "ERROR: \$$MKX11 and \$$MKXORG are mutually exclusive."
     10 	@echo
     11 	@false
     12 .endif
     13 .endif
     14 
     15 BINDIR=			${X11BINDIR}
     16 LIBDIR=			${X11USRLIBDIR}
     17 MANDIR=			${X11MANDIR}
     18 
     19 COPTS+=			-fno-strict-aliasing
     20 
     21 .if defined(USE_SSP) && (${USE_SSP} != "no")
     22 CPPFLAGS+=		-DNO_ALLOCA
     23 .endif
     24 
     25 X11FLAGS.VERSION=	-DOSMAJORVERSION=1 -DOSMINORVERSION=6		# XXX
     26 
     27 #	 THREADS_DEFINES
     28 X11FLAGS.THREADS=	-DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API \
     29 			-DXNO_MTSAFE_PWDAPI
     30 
     31 #	 CONNECTION_FLAGS
     32 X11FLAGS.CONNECTION=	-DTCPCONN -DUNIXCONN -DHAS_STICKY_DIR_BIT \
     33 			-DHAS_FCHOWN
     34 
     35 .if (${USE_INET6} != "no")
     36 X11FLAGS.CONNECTION+=	-DIPv6
     37 .endif
     38 
     39 #	 EXT_DEFINES
     40 .if ${MKXORG} != "no"
     41 X11FLAGS.BASE_EXTENSION=	-DMITMISC -DXTEST -DXTRAP -DXSYNC -DXCMISC \
     42 				-DXRECORD -DMITSHM -DBIGREQS -DXF86VIDMODE \
     43 				-DXF86MISC -DDPMSExtension -DEVI \
     44 				-DSCREENSAVER -DXV -DXVMC -DGLXEXT \
     45 				-DFONTCACHE -DRES
     46 
     47 X11FLAGS.PERVASIVE_EXTENSION=	-DSHAPE -DXINPUT -DXKB -DLBX -DXAPPGROUP \
     48 				-DXCSECURITY -DTOGCUP -DXF86BIGFONT \
     49 				-DDPMSExtension -DPIXPRIV -DPANORAMIX \
     50 				-DRENDER -DRANDR -DXFIXES -DDAMAGE \
     51 				-DCOMPOSITE -DXEVIE
     52 X11FLAGS.EXTENSION=	${X11FLAGS.BASE_EXTENSION} \
     53 			${X11FLAGS.PERVASIVE_EXTENSION}
     54 
     55 X11FLAGS.DIX=		-DHAVE_DIX_CONFIG_H -D_BSD_SOURCE -DHAS_FCHOWN \
     56 			-DHAS_STICKY_DIR_BIT -D_POSIX_THREAD_SAFE_FUNCTIONS
     57 X11INCS.DIX=		-I${X11INCSDIR}/freetype2  \
     58 			-I${X11INCSDIR}/pixman-1 \
     59 			-I$(X11SRCDIR.xorg-server)/include \
     60 			-I$(X11SRCDIR.xorg-server)/Xext \
     61 			-I$(X11SRCDIR.xorg-server)/composite \
     62 			-I$(X11SRCDIR.xorg-server)/damageext \
     63 			-I$(X11SRCDIR.xorg-server)/xfixes \
     64 			-I$(X11SRCDIR.xorg-server)/Xi \
     65 			-I$(X11SRCDIR.xorg-server)/mi \
     66 			-I$(X11SRCDIR.xorg-server)/miext/shadow \
     67 			-I$(X11SRCDIR.xorg-server)/miext/damage \
     68 			-I$(X11SRCDIR.xorg-server)/render \
     69 			-I$(X11SRCDIR.xorg-server)/randr \
     70 			-I$(X11SRCDIR.xorg-server)/fb
     71 .else
     72 X11FLAGS.EXTENSION=	-DMITMISC -DXTEST -DXTRAP -DXSYNC -DXCMISC -DXRECORD \
     73 			-DMITSHM -DBIGREQS -DXF86MISC -DDBE -DDPMSExtension \
     74 			-DEVI -DSCREENSAVER -DXV -DXVMC -DGLXEXT \
     75 			-DGLX_USE_MESA -DFONTCACHE -DRES
     76 .endif
     77 
     78 X11FLAGS.DRI=		-DGLXEXT -DXF86DRI -DGLX_DIRECT_RENDERING \
     79 			-DGLX_USE_DLOPEN -DGLX_USE_MESA
     80 
     81 .if ${X11DRI} != "no"
     82 X11FLAGS.EXTENSION+=	${X11FLAGS.DRI}
     83 .endif
     84 
     85 #	 ServerDefines
     86 X11FLAGS.SERVER=	-DSHAPE -DXKB -DLBX -DXAPPGROUP -DXCSECURITY \
     87 			-DTOGCUP -DXF86BIGFONT -DDPMSExtension -DPIXPRIV \
     88 			-DPANORAMIX -DRENDER -DRANDR -DGCCUSESGAS \
     89 			-DAVOID_GLYPHBLT -DSINGLEDEPTH -DXvExtension \
     90 			-DXFree86Server -DXvMCExtension -DSMART_SCHEDULE \
     91 			-DBUILDDEBUG -DXResExtension -DNDEBUG
     92 
     93 #	 OS_DEFINES
     94 X11FLAGS.OS_DEFINES=	-DDDXOSINIT -DSERVER_LOCK -DDDXOSFATALERROR \
     95 			-DDDXOSVERRORF -DDDXTIME -DUSB_HID
     96 
     97 .if !(${MACHINE} == "acorn32"	|| \
     98     ${MACHINE} == "alpha"	|| \
     99     ${MACHINE} == "amiga"	|| \
    100     ${MACHINE} == "pmax"	|| \
    101     ${MACHINE} == "sun3"	|| \
    102     ${MACHINE} == "vax")
    103 #	EXT_DEFINES
    104 X11FLAGS.EXTENSION+=	-DXF86VIDMODE
    105 
    106 #	ServerDefines
    107 X11FLAGS.SERVER+=	-DXINPUT -DXFreeXDGA -DXF86VIDMODE
    108 .endif
    109 
    110 .if ${MACHINE_ARCH} == "alpha"	|| \
    111     ${MACHINE_ARCH} == "sparc64" || \
    112     ${MACHINE_ARCH} == "x86_64"
    113 #	ServerDefines
    114 X11FLAGS.SERVER+=	-D_XSERVER64
    115 X11FLAGS.EXTENSION+=	-D__GLX_ALIGN64
    116 .endif
    117 
    118 .if ${MACHINE} == "amd64"	|| \
    119     ${MACHINE} == "cats"	|| \
    120     ${MACHINE} == "i386"	|| \
    121     ${MACHINE} == "macppc"	|| \
    122     ${MACHINE} == "netwinder"	|| \
    123     ${MACHINE} == "ofppc"	|| \
    124     ${MACHINE} == "sgimips"	|| \
    125     ${MACHINE} == "sparc64"	|| \
    126     ${MACHINE} == "sparc"	|| \
    127     ${MACHINE} == "shark"
    128 #	LOADABLE
    129 X11FLAGS.LOADABLE=	-DXFree86LOADER -DIN_MODULE -DXFree86Module \
    130 			-fno-merge-constants
    131 .endif
    132   
    133 # XXX FIX ME
    134 .if ${MKXORG} != "no"
    135 XVENDORNAMESHORT=	'"X.Org"'
    136 XVENDORNAME=		'"The X.Org Foundation"'
    137 XORG_RELEASE=		'"Release 1.4.2"'
    138 __XKBDEFRULES__=	'"xorg"'
    139 XLOCALE.DEFINES=	-DXLOCALEDIR=\"${X11LIBDIR}/locale\" \
    140 			-DXLOCALELIBDIR=\"${X11LIBDIR}/locale\"
    141 
    142 # XXX oh yeah, fix me later
    143 XORG_VERSION_CURRENT="(((1) * 10000000) + ((4) * 100000) + ((2) * 1000) + 0)"
    144 .endif
    145 
    146 PRINT_PACKAGE_VERSION=	awk '/^PACKAGE_VERSION=/ {			\
    147 				match($$1, "([0-9]+\\.)+[0-9]+");	\
    148 				version = substr($$1, RSTART, RLENGTH);	\
    149 			} END { print version }'
    150 
    151 
    152 # Extract X11VERSION
    153 PRINTX11VERSION=awk '/^\#define XF86_VERSION_MAJOR/ {major = $$3} \
    154 		     /^\#define XF86_VERSION_MINOR/ {minor = $$3} \
    155 		     /^\#define XF86_VERSION_PATCH/ {patch = $$3} \
    156 		     /^\#define XF86_VERSION_SNAP/ {snap = $$3} \
    157 		     END { print "((("major") * 10000000) + (("minor") * 100000) + (("patch") * 1000) + "snap")"}' \
    158 		     ${X11SRCDIR.xc}/programs/Xserver/hw/xfree86/xf86Version.h
    159 
    160 # Commandline to convert 'XCOMM' comments and 'XHASH' to '#', among other
    161 # things. Transformed from the "CppSedMagic" macro from "Imake.rules".
    162 #
    163 X11TOOL_UNXCOMM=    sed	-e '/^\#  *[0-9][0-9]*  *.*$$/d' \
    164 			-e '/^\#line  *[0-9][0-9]*  *.*$$/d' \
    165 			-e '/^[ 	]*XCOMM$$/s/XCOMM/\#/' \
    166 			-e '/^[ 	]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \
    167 			-e '/^[ 	]*XHASH/s/XHASH/\#/' \
    168 			-e '/\@\@$$/s/\@\@$$/\\/'
    169 
    170 
    171 CPPFLAGS+=		-DCSRG_BASED -DFUNCPROTO=15 -DNARROWPROTO
    172 CPPFLAGS+=		-I${DESTDIR}${X11INCDIR}
    173 
    174 .if ${MACHINE_ARCH} == "x86_64"
    175 CPPFLAGS+=		-D__AMD64__
    176 .endif
    177 
    178 LDFLAGS+=		-Wl,-rpath-link,${DESTDIR}${X11USRLIBDIR} \
    179 			-R${X11USRLIBDIR} \
    180 			-L${DESTDIR}${X11USRLIBDIR}
    181 
    182 
    183 #
    184 # .cpp -> "" handling
    185 # CPPSCRIPTS		list of files/scripts to run through cpp
    186 # CPPSCRIPTFLAGS	extra flags to ${CPP}
    187 # CPPSCRIPTFLAGS_fn	extra flags to ${CPP} for file `fn'
    188 #
    189 .if defined(CPPSCRIPTS)						# {
    190 .SUFFIXES:	.cpp
    191 
    192 .cpp:
    193 	${_MKTARGET_CREATE}
    194 	rm -f ${.TARGET}
    195 	${CPP} -undef -traditional \
    196 	    ${CPPSCRIPTFLAGS_${.TARGET}:U${CPPSCRIPTFLAGS}} \
    197 	    < ${.IMPSRC} | ${X11TOOL_UNXCOMM} > ${.TARGET}
    198 
    199 realall: ${CPPSCRIPTS}
    200 
    201 clean: cleancppscripts
    202 cleancppscripts: .PHONY
    203 	rm -f ${CPPSCRIPTS}
    204 .endif								# }
    205 
    206 #
    207 # X.Org pkgconfig files handling
    208 #
    209 # PKGCONFIG is expected to contain a list of pkgconfig module names.
    210 # They will produce the files <module1>.pc, <module2>.pc, etc, to be
    211 # put in X11USRLIBDIR/pkgconfig.
    212 #
    213 # PKGDIST contains the name of a X11SRCDIR subscript where to find the
    214 # source file for the pkgconfig files.
    215 #
    216 # If PKGDIST is not suitable, a consumer can set PKGDIST.<module> with
    217 # the full path to the source file.
    218 #
    219 # Also, the consumer can use PKGDIST alone, and a PKGCONFIG will be
    220 # derived from it.  Many times, PKGDIST is capitalized and PKGCONFIG is
    221 # the lower case version.
    222 #
    223 
    224 .if defined(PKGDIST) && !defined(PKGCONFIG)
    225 PKGCONFIG=	${PKGDIST:tl}
    226 .endif
    227 .if defined(PKGCONFIG)
    228 
    229 .include <bsd.files.mk>
    230 
    231 _PKGCONFIG_FILES=	${PKGCONFIG:C/$/.pc/}
    232 
    233 .PHONY:	pkgconfig-install
    234 pkgconfig-install:
    235 
    236 realall:	${_PKGCONFIG_FILES:O:u}
    237 realinstall:	pkgconfig-install
    238 
    239 .for _pkg in ${PKGCONFIG:O:u}
    240 PKGDIST.${_pkg}?=	${X11SRCDIR.${PKGDIST:U${_pkg}}}
    241 _PKGDEST.${_pkg}=	${DESTDIR}/${X11USRLIBDIR}/pkgconfig/${_pkg}.pc
    242 
    243 .PATH:	${PKGDIST.${_pkg}}
    244 
    245 FILESOWN_${_pkg}.pc=	${BINOWN}
    246 FILESGRP_${_pkg}.pc=	${BINGRP}
    247 FILESMODE_${_pkg}.pc=	${NONBINMODE}
    248 
    249 ${_PKGDEST.${_pkg}}: ${_pkg}.pc __fileinstall
    250 pkgconfig-install: ${_PKGDEST.${_pkg}}
    251 .endfor
    252 
    253 # XXX
    254 # The sed script is very, very ugly.  What we actually need is a
    255 # mknative-xorg script that will generate all the .pc files from
    256 # running the autoconfigure script.
    257 # And yes, it has to be splitted in two otherwise it's too long
    258 # for sed to handle.
    259 
    260 .SUFFIXES:	.pc.in .pc
    261 .pc.in.pc:
    262 	${_MKTARGET_CREATE}
    263 	rm -f ${.TARGET}
    264 	if [ -n '${PKGCONFIG_VERSION.${.PREFIX}}' ]; then \
    265 		_pkg_version='${PKGCONFIG_VERSION.${.PREFIX}}'; \
    266 	else \
    267 		_pkg_version=$$(${PRINT_PACKAGE_VERSION} \
    268 		    ${PKGDIST.${.PREFIX}}/configure); \
    269 	fi; \
    270 	${TOOL_SED} -E \
    271 		-e "s,@prefix@,${X11ROOTDIR},; \
    272 		s,@INSTALL_DIR@,${X11ROOTDIR},; \
    273 		s,@exec_prefix@,\\$$\{prefix\},; \
    274 		s,@libdir@,\\$$\{prefix\}/lib,; \
    275 		s,@includedir@,\\$$\{prefix\}/include,; \
    276 		s,@datarootdir@,\\$$\{prefix\}/share,; \
    277 		s,@appdefaultdir@,\\$$\{libdir}/X11/app-default,; \
    278 		s,@MAPDIR@,\\$$\{libdir\}/X11/fonts/util,; \
    279 		s,@ICONDIR@,\\$$\{datarootdir\}/icons,; \
    280 		s,@PACKAGE_VERSION@,$${_pkg_version},; \
    281 		s,@VERSION@,$${_pkg_version},; \
    282 		s,@COMPOSITEEXT_VERSION@,$${_pkg_version%.*},; \
    283 		s,@DAMAGEEXT_VERSION@,$${_pkg_version%.*},; \
    284 		s,@FIXESEXT_VERSION@,$${_pkg_version%.*},; \
    285 		s,@RANDR_VERSION@,$${_pkg_version%.*},; \
    286 		s,@RENDER_VERSION@,$${_pkg_version%.*}," \
    287 		-e "s,@moduledir@,\\$$\{libdir\}/modules,; \
    288 		s,@sdkdir@,\\$$\{includedir\}/xorg,; \
    289 		s,@PIXMAN_CFLAGS@,,; \
    290 		s,@LIB_DIR@,/lib,; \
    291 		s,@XKBPROTO_REQUIRES@,kbproto,; \
    292 		s,@FREETYPE_REQUIRES@,freetype2,; \
    293 		s,@EXPAT_LIBS@,-lexpat,; \
    294 		s,@FREETYPE_LIBS@,-lfreetype,; \
    295 		s,@DEP_CFLAGS@,,; \
    296 		s,@DEP_LIBS@,,; \
    297 		s,@X11_EXTRA_DEPS@,,; \
    298 		s,@XTHREAD_CFLAGS@,-D_POSIX_THREAD_SAFE_FUNCTIONS,; \
    299 		s,@XTHREADLIB@,-lpthread,; \
    300 		s,@fchown_define@,-DHAS_FCHOWN,; \
    301 		s,@sticky_bit_define@,-DHAS_STICKY_DIR_BIT," \
    302 		-e '/^Libs:/ s%-L([^[:space:]]+)%-Wl,-R\1 &%g' \
    303 		< ${.IMPSRC} > ${.TARGET}.tmp && \
    304 	mv -f ${.TARGET}.tmp ${.TARGET}
    305 
    306 CLEANFILES+=	${_PKGCONFIG_FILES} ${_PKGCONFIG_FILES:C/$/.tmp/}
    307 .endif
    308 
    309 #
    310 # APPDEFS (app defaults) handling
    311 #
    312 .if defined(APPDEFS)						# {
    313 appdefsinstall:: .PHONY ${APPDEFS:@S@${DESTDIR}${X11LIBDIR}/app-defaults/${S:T:R}@}
    314 .PRECIOUS:	${APPDEFS:@S@${DESTDIR}${X11LIBDIR}/app-defaults/${S:T:R}@}
    315 
    316 __appdefinstall: .USE
    317 	${_MKTARGET_INSTALL}
    318 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} \
    319 	    ${.ALLSRC} ${.TARGET}
    320 
    321 .for S in ${APPDEFS:O:u}
    322 ${DESTDIR}${X11LIBDIR}/app-defaults/${S:T:R}: ${S} __appdefinstall
    323 .endfor
    324 
    325 realinstall: appdefsinstall
    326 .endif								# }
    327 
    328 
    329 #
    330 # .man page handling
    331 #
    332 .if (${MKMAN} != "no" && (${MAN:U} != "" || ${PROG:U} != ""))	# {
    333 cleandir: cleanx11man
    334 cleanx11man: .PHONY
    335 	rm -f ${MAN:U${PROG:D${PROG.1}}}
    336 .endif								# }
    337 
    338 .SUFFIXES:	.man .1 .3 .4 .5 .7
    339 
    340 .man.1 .man.3 .man.4 .man.5 .man.7:
    341 	${_MKTARGET_CREATE}
    342 	rm -f ${.TARGET}
    343 	sed -e 's/\\$$/\\ /' ${.IMPSRC} \
    344 	| ${CPP} -undef -traditional \
    345 	    -D__apploaddir__=${X11ROOTDIR}/lib/X11/app-defaults \
    346 	    -D__appmansuffix__=1 \
    347 	    -D__libmansuffix__=3 \
    348 	    -D__filemansuffix__=5 \
    349 	    -D__miscmansuffix__=7 \
    350 	    -D__drivermansuffix__=4 \
    351 	    -D__adminmansuffix__=8 \
    352 	    -D__projectroot__=${X11ROOTDIR} \
    353 	    -D__xorgversion__='"Release 6.6" "X Version 11"' \
    354 	    -D__vendorversion__="XFree86 4.5.0" \
    355 	    ${X11EXTRAMANDEFS} \
    356 	| ${X11TOOL_UNXCOMM} > ${.TARGET}
    357