1706f2543Smrg#!/bin/bash
2706f2543Smrg
3706f2543Smrg#CONFOPT="--disable-xquartz --disable-glx --disable-dri --disable-launchd --enable-kdrive --disable-xsdl --enable-xnest --enable-xvfb"
4706f2543Smrg#CONFOPT="--enable-xorg --disable-xquartz --disable-kdrive --disable-xnest --disable-xvfb"
5706f2543Smrg
6706f2543SmrgCONFOPT="--enable-standalone-xpbproxy"
7706f2543Smrg#CONFOPT="--disable-shave --without-dtrace"
8706f2543Smrg
9706f2543SmrgCONFOPT="${CONFOPT} --with-dtrace"
10706f2543Smrg
11706f2543Smrg# Parallel Make.  Change $MAKE if you don't have gmake installed
12706f2543SmrgMAKE="gnumake"
13706f2543SmrgMAKE_OPTS="-j10"
14706f2543Smrg
15706f2543Smrg. ~/src/strip.sh
16706f2543Smrg
17706f2543Smrg#PREFIX=/usr/X11
18706f2543Smrg#ARCHFLAGS="-arch i386 -arch x86_64"
19706f2543Smrg
20706f2543SmrgPREFIX=/opt/X11
21706f2543SmrgCONFOPT="$CONFOPT --with-apple-application-name=XQuartz --with-launchd-id-prefix=org.macosforge.xquartz"
22706f2543SmrgARCHFLAGS="-arch i386 -arch x86_64"
23706f2543Smrg
24706f2543SmrgACLOCAL="aclocal -I ${PREFIX}/share/aclocal -I /usr/local/share/aclocal"
25706f2543Smrg
26706f2543SmrgCPPFLAGS="-DNO_ALLOCA -DNO_COMPILER_H -DFAKEIT"
27706f2543Smrg
28706f2543SmrgCFLAGS="$CFLAGS -O0 -g3 -pipe"
29706f2543SmrgCFLAGS="$CFLAGS $ARCHFLAGS"
30706f2543SmrgCFLAGS="$CFLAGS -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers"
31706f2543Smrg
32706f2543SmrgCFLAGS="${CFLAGS} -fdiagnostics-show-category=name"
33706f2543Smrg
34706f2543Smrg# Stage 1:
35706f2543Smrg#    CFLAGS="${CFLAGS} -Werror=clobbered"
36706f2543Smrg#    CFLAGS="${CFLAGS} -Wlogical-op"
37706f2543Smrg#    CFLAGS="${CFLAGS} -Wparentheses"
38706f2543Smrg#    CFLAGS="${CFLAGS} -Wcast-align"
39706f2543Smrg#    CFLAGS="${CFLAGS} -Wunsafe-loop-optimizations"
40706f2543Smrg
41706f2543SmrgOBJCFLAGS="$CFLAGS"
42706f2543SmrgLDFLAGS="$CFLAGS"
43706f2543Smrg
44706f2543Smrg#CC="llvm-gcc"
45706f2543Smrg#CXX="llvm-g++"
46706f2543SmrgCC="/opt/local/bin/clang-mp-3.1"
47706f2543SmrgCXX="/opt/local/bin/clang++-mp-3.1"
48706f2543Smrg
49706f2543SmrgOBJC="$CC"
50706f2543Smrg
51706f2543Smrg#SCAN_BUILD="scan-build -v -V -o clang.d --use-cc=${CC} --use-c++=${CXX}"
52706f2543Smrg 
53706f2543Smrg#CPPFLAGS="$CPPFLAGS -F/Applications/Utilities/XQuartz.app/Contents/Frameworks"
54706f2543Smrg#LDFLAGS="$LDFLAGS -F/Applications/Utilities/XQuartz.app/Contents/Frameworks"
55706f2543Smrg#CPPFLAGS="$CPPFLAGS -F/Applications/Utilities/X11.app/Contents/Frameworks"
56706f2543Smrg#LDFLAGS="$LDFLAGS -F/Applications/Utilities/X11.app/Contents/Frameworks"
57706f2543Smrg#CONFOPT="${CONFOPT} --enable-sparkle"
58706f2543Smrg
59706f2543Smrg# This section is for building release tarballs
60706f2543Smrgif false ; then
61706f2543Smrg	CONFOPT="${CONFOPT} --enable-docs --enable-devel-docs --enable-builddocs --with-doxygen --with-xmlto --with-fop"
62706f2543Smrg	export XMLTO=/opt/local/bin/xmlto
63706f2543Smrg	export ASCIIDOC=/opt/local/bin/asciidoc
64706f2543Smrg	export DOXYGEN=/opt/local/bin/doxygen
65706f2543Smrg	export FOP=/opt/local/bin/fop
66706f2543Smrg	export FOP_OPTS="-Xmx2048m -Djava.awt.headless=true"
67706f2543Smrg	export GROFF=/opt/local/bin/groff
68706f2543Smrg	export PS2PDF=/opt/local/bin/ps2pdf
69706f2543Smrgfi
70706f2543Smrg
71706f2543Smrgexport ACLOCAL CPPFLAGS CFLAGS OBJCFLAGS LDFLAGS CC OBJC
72706f2543Smrg
73706f2543SmrgPKG_CONFIG_PATH=${PREFIX}/share/pkgconfig:${PREFIX}/lib/pkgconfig:$PKG_CONFIG_PATH
74706f2543SmrgPATH=${PREFIX}/bin:$PATH
75706f2543Smrg
76706f2543Smrgdie() {
77706f2543Smrg	echo "${@}" >&2
78706f2543Smrg	exit 1
79706f2543Smrg}
80706f2543Smrg
81706f2543Smrgdocomp() {
82706f2543Smrg	autoreconf -fvi || die
83706f2543Smrg	${SCAN_BUILD} ./configure --prefix=${PREFIX} ${CONFOPT} --disable-dependency-tracking --enable-maintainer-mode --enable-xcsecurity --enable-record --disable-xevie "${@}" || die "Could not configure xserver"
84706f2543Smrg	${MAKE} clean || die "Unable to make clean"
85706f2543Smrg	${SCAN_BUILD} ${MAKE} ${MAKE_OPTS} || die "Could not make xserver"
86706f2543Smrg	#${MAKE} distcheck ${MAKE_OPTS} DESTDIR=/tmp/distcheck || die "distcheck failed"
87706f2543Smrg	../modular/release.sh .
88706f2543Smrg}
89706f2543Smrg
90706f2543Smrgdoinst() {
91706f2543Smrg	${MAKE} install DESTDIR="$(pwd)/../dist" || die "Could not install xserver"
92706f2543Smrg}
93706f2543Smrg
94706f2543Smrgdosign() {
95706f2543Smrg	/opt/local/bin/gmd5sum $1 > $1.md5sum
96706f2543Smrg	/opt/local/bin/gsha1sum $1 > $1.sha1sum
97706f2543Smrg	DISPLAY="" /opt/local/bin/gpg2 -b $1
98706f2543Smrg}
99706f2543Smrg
100706f2543Smrgdodist() {
101706f2543Smrg	${MAKE} dist
102706f2543Smrg	dosign xorg-server-$1.tar.bz2
103706f2543Smrg
104706f2543Smrg	cp hw/xquartz/mach-startup/X11.bin X11.bin-$1
105706f2543Smrg	bzip2 X11.bin-$1
106706f2543Smrg	dosign X11.bin-$1.bz2 
107706f2543Smrg}
108706f2543Smrg
109706f2543Smrgdocomp `[ -f conf_flags ] && cat conf_flags`
110706f2543Smrg#doinst
111706f2543Smrg[[ -n $1 ]] && dodist $1
112706f2543Smrg
113706f2543Smrgexit 0
114