1#!/bin/bash
2
3VERSION="0.9.13"
4
5cd "$(dirname "$0")"
6
7mv configure.ac configure.ac.LibVNCServer
8
9cat configure.ac.LibVNCServer | \
10egrep -v '(AC_CONFIG_COMMANDS|chmod).*libvncserver-config' | \
11egrep -v '^[ 	]*libvncserver-config$' | \
12sed -e "s/LibVNCServer, [^,)]*\([(,]\)*/x11vnc, $VERSION\1/g" \
13    -e "s/\(contrib\|examples\|vncterm\|test\|client_examples\)\/Makefile//g" \
14    -e "s/LibVNCServer.spec/x11vnc.spec/g" \
15    -e "s/AC_PROG_LIBTOOL/AC_PROG_RANLIB/" \
16    -e "s/PKG_CHECK/#PKG_CHECK/" \
17    -e 's/if test "x$with_gnutls/with_gnutls=no; if test "x$with_gnutls/' \
18    -e 's/if test "x$with_ipv6/with_ipv6=no; if test "x$with_ipv6/' \
19> configure.ac
20
21mv Makefile.am Makefile.am.LibVNCServer
22
23echo "EXTRA_DIST=tightvnc-1.3dev5-vncviewer-alpha-cursor.patch RELEASE-NOTES README.LibVNCServer" > Makefile.am
24echo "" >> Makefile.am
25echo "if HAVE_SYSTEM_LIBVNCSERVER" >> Makefile.am
26echo "SUBDIRS=x11vnc classes" >> Makefile.am
27echo "DIST_SUBDIRS=x11vnc classes" >> Makefile.am
28echo "else" >> Makefile.am
29echo "SUBDIRS=libvncserver libvncclient x11vnc classes" >> Makefile.am
30echo "DIST_SUBDIRS=libvncserver libvncclient x11vnc classes" >> Makefile.am
31echo "endif" >> Makefile.am
32echo "" >> Makefile.am
33
34cat Makefile.am.LibVNCServer | \
35sed -e "s/^SUBDIRS.*$/#SUBDIRS=libvncserver libvncclient x11vnc classes/" \
36    -e "s/^DIST_SUBDIRS.*$/#DIST_SUBDIRS=libvncserver libvncclient x11vnc classes/" \
37    -e "/^.*bin_SCRIPTS.*$/d" \
38    -e "s/^include_HEADERS/if HAVE_SYSTEM_LIBVNCSERVER^else^include_HEADERS/" \
39    -e "s/rfbclient\.h/rfbclient.h^endif/" \
40    | tr '^' '\n' \
41>> Makefile.am
42
43mv README README.LibVNCServer
44cp x11vnc/README ./README
45cp x11vnc/RELEASE-NOTES ./RELEASE-NOTES
46
47cat LibVNCServer.spec.in | \
48sed -e "s/Johannes.Schindelin@gmx.de/runge@karlrunge.com/gi" \
49    -e "s/Johannes.Schindelin/Karl Runge/g" \
50    -e "s/a library to make writing a vnc server easy/a VNC server for the current X11 session/" \
51    -e "/^%description$/,/%description devel$/d" \
52    -e 's/^Static libraries.*$/%description\
53x11vnc is to X Window System what WinVNC is to Windows, i.e. a server\
54which serves the current Xwindows desktop via RFB (VNC) protocol\
55to the user.\
56\
57Based on the ideas of x0rfbserver and on LibVNCServer, it has evolved\
58into a versatile and performant while still easy to use program.\
59\
60x11vnc was put together and is (actively ;-) maintained by\
61Karl Runge <runge@karlrunge.com>\
62\
63/i' \
64> x11vnc.spec.in.tmp
65
66perl -e '
67    $s = 0;
68    while (<>) {
69	if ($s) {
70		if (/^\s*$/) {
71			$s = 0;
72		}
73	} else {
74		if (/^%files\s*$/ || /^%files devel/) {
75			$s = 1;
76		}
77	}
78	next if $s;
79	if (/^%files x11vnc/) {
80		print "\%files\n";
81		print "\%doc README x11vnc/ChangeLog\n";
82		next;
83	}
84	print;
85    }' < x11vnc.spec.in.tmp > x11vnc.spec.in
86
87rm -f x11vnc.spec.in.tmp
88
89mv libvncserver/Makefile.am libvncserver/Makefile.am.LibVNCServer
90
91cat libvncserver/Makefile.am.LibVNCServer | \
92sed -e "s/\(include\|LIB\|lib\)_/noinst_/g" \
93    -e "s/_la_/_a_/" \
94    -e "s/\.la/.a/" \
95    -e "s/_LTLIBRARIES/_LIBRARIES/" \
96> libvncserver/Makefile.am
97
98mv libvncclient/Makefile.am libvncclient/Makefile.am.LibVNCServer
99
100cat libvncclient/Makefile.am.LibVNCServer | \
101sed -e "s/\(include\|LIB\|lib\)_/noinst_/g" \
102    -e "s/_la_/_a_/" \
103    -e "s/\.la/.a/" \
104    -e "s/_LTLIBRARIES/_LIBRARIES/" \
105> libvncclient/Makefile.am
106
107mv x11vnc/Makefile.am x11vnc/Makefile.am.LibVNCServer
108
109cat x11vnc/Makefile.am.LibVNCServer | \
110sed -e "s/_la_/_a_/" \
111    -e "s/\.la/.a/g" \
112    -e "s/_LTLIBRARIES/_LIBRARIES/" \
113> x11vnc/Makefile.am
114
115
116cp classes/Makefile.am classes/Makefile.am.LibVNCServer
117echo 'pkgdatadir = $(datadir)/@PACKAGE@/classes' >> classes/Makefile.am
118echo 'pkgdata_DATA=VncViewer.jar index.vnc' >> classes/Makefile.am
119
120cp classes/ssl/Makefile.am classes/ssl/Makefile.am.LibVNCServer
121sed -e 's/EXTRA_DIST=/EXTRA_DIST=tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-tab-traversal.patch /' \
122	classes/ssl/Makefile.am.LibVNCServer > classes/ssl/Makefile.am
123echo 'pkgdatadir = $(datadir)/@PACKAGE@/classes/ssl' >> classes/ssl/Makefile.am
124echo 'pkgdata_DATA=VncViewer.jar index.vnc SignedVncViewer.jar proxy.vnc README UltraViewerSSL.jar SignedUltraViewerSSL.jar ultra.vnc ultrasigned.vnc' >> classes/ssl/Makefile.am
125echo 'pkgdata_SCRIPTS=ss_vncviewer' >> classes/ssl/Makefile.am
126
127chmod 755 classes/ssl/ss_vncviewer
128
129mv acinclude.m4 acinclude.m4.LibVNCServer
130
131cat acinclude.m4.LibVNCServer | \
132sed -e "s/^\(_PKG.*\)\$PACKAGE\(.*\)$/\1LibVNCServer\2/" \
133> acinclude.m4
134
135make x11vnc-${VERSION}.tar.gz
136for f in configure.ac Makefile.am x11vnc/Makefile.am libvncserver/Makefile.am libvncclient/Makefile.am classes/Makefile.am classes/ssl/Makefile.am acinclude.m4 README; do
137	mv -f $f.LibVNCServer $f
138done
139rm -f ./RELEASE-NOTES
140
141