1#!/bin/bash
2
3#CONFOPT="--disable-xquartz --disable-glx --disable-dri --disable-launchd --enable-kdrive --disable-xsdl --enable-xnest --enable-xvfb"
4#CONFOPT="--enable-xorg --disable-xquartz --disable-kdrive --disable-xnest --disable-xvfb"
5
6CONFOPT="--enable-standalone-xpbproxy"
7#CONFOPT="--disable-shave --without-dtrace"
8
9CONFOPT="${CONFOPT} --with-dtrace"
10
11# Parallel Make.  Change $MAKE if you don't have gmake installed
12MAKE="gnumake"
13MAKE_OPTS="-j10"
14
15. ~/src/strip.sh
16
17#PREFIX=/usr/X11
18#ARCHFLAGS="-arch i386 -arch x86_64"
19
20PREFIX=/opt/X11
21CONFOPT="$CONFOPT --with-apple-application-name=XQuartz --with-launchd-id-prefix=org.macosforge.xquartz"
22ARCHFLAGS="-arch i386 -arch x86_64"
23
24ACLOCAL="aclocal -I ${PREFIX}/share/aclocal -I /usr/local/share/aclocal"
25
26CPPFLAGS="-DNO_ALLOCA -DNO_COMPILER_H -DFAKEIT"
27
28CFLAGS="$CFLAGS -O0 -g3 -pipe"
29CFLAGS="$CFLAGS $ARCHFLAGS"
30CFLAGS="$CFLAGS -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers"
31
32CFLAGS="${CFLAGS} -fdiagnostics-show-category=name"
33
34# Stage 1:
35#    CFLAGS="${CFLAGS} -Werror=clobbered"
36#    CFLAGS="${CFLAGS} -Wlogical-op"
37#    CFLAGS="${CFLAGS} -Wparentheses"
38#    CFLAGS="${CFLAGS} -Wcast-align"
39#    CFLAGS="${CFLAGS} -Wunsafe-loop-optimizations"
40
41OBJCFLAGS="$CFLAGS"
42LDFLAGS="$CFLAGS"
43
44#CC="llvm-gcc"
45#CXX="llvm-g++"
46CC="/opt/local/bin/clang-mp-3.1"
47CXX="/opt/local/bin/clang++-mp-3.1"
48
49OBJC="$CC"
50
51#SCAN_BUILD="scan-build -v -V -o clang.d --use-cc=${CC} --use-c++=${CXX}"
52 
53#CPPFLAGS="$CPPFLAGS -F/Applications/Utilities/XQuartz.app/Contents/Frameworks"
54#LDFLAGS="$LDFLAGS -F/Applications/Utilities/XQuartz.app/Contents/Frameworks"
55#CPPFLAGS="$CPPFLAGS -F/Applications/Utilities/X11.app/Contents/Frameworks"
56#LDFLAGS="$LDFLAGS -F/Applications/Utilities/X11.app/Contents/Frameworks"
57#CONFOPT="${CONFOPT} --enable-sparkle"
58
59# This section is for building release tarballs
60if false ; then
61	CONFOPT="${CONFOPT} --enable-docs --enable-devel-docs --enable-builddocs --with-doxygen --with-xmlto --with-fop"
62	export XMLTO=/opt/local/bin/xmlto
63	export ASCIIDOC=/opt/local/bin/asciidoc
64	export DOXYGEN=/opt/local/bin/doxygen
65	export FOP=/opt/local/bin/fop
66	export FOP_OPTS="-Xmx2048m -Djava.awt.headless=true"
67	export GROFF=/opt/local/bin/groff
68	export PS2PDF=/opt/local/bin/ps2pdf
69fi
70
71export ACLOCAL CPPFLAGS CFLAGS OBJCFLAGS LDFLAGS CC OBJC
72
73PKG_CONFIG_PATH=${PREFIX}/share/pkgconfig:${PREFIX}/lib/pkgconfig:$PKG_CONFIG_PATH
74PATH=${PREFIX}/bin:$PATH
75
76die() {
77	echo "${@}" >&2
78	exit 1
79}
80
81docomp() {
82	autoreconf -fvi || die
83	${SCAN_BUILD} ./configure --prefix=${PREFIX} ${CONFOPT} --disable-dependency-tracking --enable-maintainer-mode --enable-xcsecurity --enable-record --disable-xevie "${@}" || die "Could not configure xserver"
84	${MAKE} clean || die "Unable to make clean"
85	${SCAN_BUILD} ${MAKE} ${MAKE_OPTS} || die "Could not make xserver"
86	#${MAKE} distcheck ${MAKE_OPTS} DESTDIR=/tmp/distcheck || die "distcheck failed"
87	../modular/release.sh .
88}
89
90doinst() {
91	${MAKE} install DESTDIR="$(pwd)/../dist" || die "Could not install xserver"
92}
93
94dosign() {
95	/opt/local/bin/gmd5sum $1 > $1.md5sum
96	/opt/local/bin/gsha1sum $1 > $1.sha1sum
97	DISPLAY="" /opt/local/bin/gpg2 -b $1
98}
99
100dodist() {
101	${MAKE} dist
102	dosign xorg-server-$1.tar.bz2
103
104	cp hw/xquartz/mach-startup/X11.bin X11.bin-$1
105	bzip2 X11.bin-$1
106	dosign X11.bin-$1.bz2 
107}
108
109docomp `[ -f conf_flags ] && cat conf_flags`
110#doinst
111[[ -n $1 ]] && dodist $1
112
113exit 0
114