1#!/bin/sh
2#
3# Script used to generate the sswf (Script to SWF) tar balls
4# Written by Alexis Wilke for Made to Order Software Corp. (c) 2002-2009
5#
6# Copyright (c) 2002-2009 Made to Order Software Corp.
7#
8# Permission is hereby granted, free of charge, to any
9# person obtaining a copy of this software and
10# associated documentation files (the "Software"), to
11# deal in the Software without restriction, including
12# without limitation the rights to use, copy, modify,
13# merge, publish, distribute, sublicense, and/or sell
14# copies of the Software, and to permit persons to whom
15# the Software is furnished to do so, subject to the
16# following conditions:
17#
18# The above copyright notice and this permission notice
19# shall be included in all copies or substantial
20# portions of the Software.
21#
22# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
23# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
25# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
26# EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29# ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31# SOFTWARE.
32#
33
34set -e
35
36
37if test "$1" = "-h" -o "$1" = "--help"
38then
39	echo "Usage: $0 [-opt]"
40	echo "Where -opt is one or more of the following:"
41	echo "  -keeparchive   don't test whether the archive already exist and"
42	echo "                 if it does don't delete it (useful when you don't"
43	echo "                 want to recreate the source and documentation packages)"
44	echo "  -OVERWRITE     don't ask whether to overwrite the existing packages"
45	echo "  -remove_arch   to force all the architectures to be rebuilt"
46	echo "  -nothing       don't do any of the following (-notest, -nosrc, ...)"
47	echo "                 you can then turn on just what you want to do with"
48	echo "                    -dotest, -dosrc, -dodoc, -doforeign, ..."
49	echo "  -notest        don't run amake to make sure the packages compile"
50	echo "                 and the samples work"
51	echo "  -nosrc         don't regenerate the source package if it exists"
52	echo "                 (this option requires the -keeparchive)"
53	echo "  -nodoc         don't regenerate the documentation package if it exists"
54	echo "                 (this option requires the -keeparchive)"
55	echo "  -noforeign     skip generation of foreign modules (Mac, Win, SGI)"
56	echo "                 [note that a -do<name> implies -doforeign]"
57	echo "    -nowin       skip generation of Win/MinGW modules"
58	echo "    -nomac       skip generation of Mac OS/X modules"
59	echo "    -nosgi       skip generation of SGI modules"
60	echo "    -nolinuxonpower  skip generation of Linux on Power module (default true now)"
61	echo "  -nolinux       don't generate the linux packages"
62	echo "  -norpm         don't generate the RedHat RPM package"
63	echo "  -nodebian      don't generate the Debian package"
64	echo "  -noslackware   don't generate the Slackware package"
65	echo "  -nocleanup     don't do any cleanup at the end"
66	exit 1;
67fi
68
69
70
71
72
73start_date=`date +%H:%M:%S`
74keeparchive=false
75OVERWRITE=false
76remove_arch=false
77notest=false
78nosrc=false
79nodoc=false
80noforeign=false
81nowin=false
82nomac=false
83nosgi=false
84nolinuxonpower=true
85nolinux=false
86norpm=false
87nodebian=false
88noslackware=false
89nocleanup=false
90while ! test "$1" = ""
91do
92	case "$1" in
93	-keeparchive*|--keeparchive*) keeparchive=true;;
94	-OVERWRITE|--OVERWRITE) OVERWRITE=true;;
95	-remove_arch*|--remove_arch*) remove_arch=true;;
96	-nothing*|--nothing*)
97			notest=true;
98
99			nosrc=true; nodoc=true;
100
101			noforeign=true;
102				nowin=true; nomac=true; nosgi=true;
103				nolinuxonpower=true;
104
105			nolinux=true; norpm=true; nodebian=true;
106			noslackware=true;
107
108			nocleanup=true;
109			;;
110	-notest*|--notest*) notest=true;;
111	-dotest*|--dotest*) notest=false;;
112	-nosrc*|--nosrc*) nosrc=true;;
113	-dosrc*|--dosrc*) nosrc=false;;
114	-nodoc*|--nodoc*) nodoc=true;;
115	-dodoc*|--dodoc*) nodoc=false;;
116	-noforeign*|--noforeign*) noforeign=true;;
117	-doforeign*|--doforeign*) noforeign=false;;
118	-nowin*|--nowin*) nowin=true;;
119	-dowin*|--dowin*) noforeign=false; nowin=false;;
120	-nomac*|--nomac*) nomac=true;;
121	-domac*|--domac*) noforeign=false; nomac=false;;
122	-nosgi*|--nosgi*) nosgi=true;;
123	-dosgi*|--dosgi*) noforeign=false; nosgi=false;;
124	-nolinuxonpower*|--nolinuxonpower*) nolinuxonpower=true;;
125	-dolinuxonpower*|--dolinuxonpower*) noforeign=false; nolinuxonpower=false;;
126	-nolinux*|--nolinux*) nolinux=true;;
127	-dolinux*|--dolinux*) nolinux=false;;
128	-norpm*|--norpm*) norpm=true;;
129	-dorpm*|--dorpm*) norpm=false;;
130	-nodebian*|--nodebian*) nodebian=true;;
131	-dodebian*|--dodebian*) nodebian=false;;
132	-noslackware*|--noslackware*) noslackware=true;;
133	-doslackware*|--doslackware*) noslackware=false;;
134	-nocleanup*|--nocleanup*) nocleanup=true;;
135	-docleanup*|--docleanup*) nocleanup=false;;
136	*) echo "ERROR: unknown option \"$1\"."; exit 1;;
137	esac
138	shift
139done
140
141
142echo "Initialization"
143
144
145COPY="cp --recursive --no-dereference --preserve=links"
146
147
148package_date=`date -u`
149
150##############################
151# Ensure all the necessary targets
152# 1) can be compiled properly
153#    (this is also done when creating the RPM)
154# 2) do generate all the flash movie samples
155#    (if the samples fail, we need to look into it!)
156##############################
157
158if $notest
159then
160	echo "Skipping SSWF samples test"
161else
162
163	test_make() {
164		# Now we do a clean to make sure we can compile in RELEASE
165		# and DEBUG modes
166		amake -s clean
167		amake -s all
168		amake -s samples
169	}
170
171	# Now we do the DEBUG version first and distribute the RELEASE
172	# (afterall, it works great, in most cases)
173	(
174		export DEBUG=1
175		export YYDEBUG=1
176		test_make
177	)
178	test_make
179
180	echo "Sample tests passed in RELEASE and DEBUG. Create packages now."
181
182	## We need to clean before to go on
183	for mf in `ls samples/*/*makefile`
184	do
185		amake -s -C `dirname $mf` clean
186	done
187
188	## We want the notes and changes in HTML
189	amake -s tmp/NOTES.html tmp/CHANGES.html
190
191
192fi
193
194
195
196##############################
197# Get the current packages version
198##############################
199VERSION=`grep "^.define.*\\<SSWF_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9]\\+\\.[0-9]\\+\\.[0-9]\\+\\).*/\\1/'`
200LIBSSWF_VERSION=`grep "^.define.*\\<LIBSSWF_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9]\\+:[0-9]\\+:[0-9]\\+\\).*/\\1/'`
201LIBSSWFC_VERSION=`grep "^.define.*\\<LIBSSWFC_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9]\\+:[0-9]\\+:[0-9]\\+\\).*/\\1/'`
202LIBSSWFAS_VERSION=`grep "^.define.*\\<LIBSSWFAS_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9]\\+:[0-9]\\+:[0-9]\\+\\).*/\\1/'`
203LIBSSWFASAS_VERSION=`grep "^.define.*\\<LIBSSWFASAS_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9]\\+:[0-9]\\+:[0-9]\\+\\).*/\\1/'`
204LIBSSWFASC_VERSION=`grep "^.define.*\\<LIBSSWFASC_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9]\\+:[0-9]\\+:[0-9]\\+\\).*/\\1/'`
205PROJECT_PATH=`pwd`
206CHECK_VERSION=`basename $PROJECT_PATH`
207
208if test "sswf-$VERSION" != "$CHECK_VERSION"
209then
210	echo "ERROR: the current version in libsswf-version.h ($VERSION)"
211	echo "       doesn't match the directory name: $PROJECT_PATH"
212	echo
213	echo "This usually means you are creating a newer version but"
214	echo "forgot to either update the version or rename the directory."
215	echo "The former could lead to duplicate versions. The later doesn't"
216	echo "matter much but this script will fail anyway."
217	echo
218	echo "Please, rename the directory or fix the version in the header."
219	exit 1;
220fi
221
222
223
224
225##############################
226# Different installation info
227##############################
228INSTALL_DIR="/usr"
229DST="sswf-$VERSION"
230MAKEFILE_INSTALL="tmp/makefile.install"
231MAKEFILE_TMP="tmp/makefile.tmp"
232MAKEFILE_HEADER="tmp/makefile.header"
233RPM_TMP="tmp/sswf"
234CONFIGURE_AC="configure.ac"
235FINK_INFO="sswf-fink.info"
236FINKINFO_REVISION=7
237WIN32_NSI="sswf-win32.nsi"
238ARCHIVE="../packages/sswf-$VERSION"
239TAR_TMP="tmp/tmp.tar"
240MINGW_PATH="tmp/mingw"
241
242
243
244# Before to generate the new packages, check to know whether it
245# already exists, if so, the user is possibly making a mistake
246# (i.e. forgot to increase the version)
247need_source=true
248
249#echo $keeparchive AND $OVERWRITE
250
251want_to_delete_archive=false
252if $keeparchive
253then
254	if test -d $ARCHIVE
255	then
256		echo "Archive $ARCHIVE already exist but it will be kept as is."
257		# In this case we assume the sources & docs are valid
258		need_source=false
259	else
260		echo "Archive $ARCHIVE doesn't exist yet, it will be created."
261	fi
262elif $OVERWRITE
263then
264	if test -d $ARCHIVE
265	then
266		echo "WARNING: this version ($VERSION) existed, it will be replaced now."
267	fi
268	want_to_delete_archive=true
269else
270	if test -d $ARCHIVE
271	then
272		echo "WARNING: this version ($VERSION) has already been packed."
273		echo "WARNING: continuing will force a deletion of the existing packages."
274		echo -n "WARNING: are you sure you want to overwrite it? (y/[n]) "
275		read answer
276		if test "$answer" != "y" -a "$answer" != "Y"
277		then
278			echo "WARNING: packaging cancelled"
279			exit 1;
280		fi
281		echo
282		echo
283		# Remove the destination folder at once!
284		want_to_delete_archive=true
285	fi
286fi;
287
288if $want_to_delete_archive && test -d $ARCHIVE
289then
290	# Only delete the SSWF files; keep the repository files!
291	rm -rf $ARCHIVE/sswf*
292fi
293
294
295
296
297if $remove_arch
298then
299	rm -rf arch
300	echo "The directory arch was removed. All packages need to be rebuilt"
301else
302	echo "WARNING: when changing version you must remove the \"arch\" directory"
303	echo "         at least once; did you do it? (-remove_arch command line option)"
304fi
305
306
307echo "Packaging SSWF version V$VERSION"
308
309(
310	echo "***********************************************"
311	echo "*** SSWF V$VERSION"
312	echo "***********************************************"
313	echo
314	echo "Package created on $package_date"
315	echo "                on computer $HOSTNAME"
316	echo "                with `uname -s -r -m -o`"
317	echo "                by $USER"
318	echo
319	echo "This file was auto-generated by the dotar script"
320	echo
321) >misc/package_creation_date.txt
322
323##############################
324# All the files to be packed
325##############################
326COPYRIGHT_FILES="doc/AUTHORS.txt doc/CHANGES.txt doc/LICENSE.txt doc/LINKS.txt doc/NOTES.txt README.txt"
327TOPACK_ALWAYS="$COPYRIGHT_FILES doc/INSTALL*.txt doc/TODO.txt doc/ASC-TODO.txt"
328TOPACK_SRC="$TOPACK_ALWAYS
329	amakefile dosamakefile dosamakefile.cl
330	configure.ac Makefile.am doc/Makefile.am
331	*.pc.in misc dev samples VC/sswf
332	dotar sendall include src"
333TOSTRIP_BIN="bin/asc bin/sswf bin/swf_dump bin/ft2sswf bin/jpg2swf"
334TOPACK_BIN="$TOPACK_ALWAYS include/sswf/scripts doc/man $TOSTRIP_BIN misc samples"
335TOPACK_LIB="$TOPACK_ALWAYS lib include/sswf/*.h"
336TOPACK_DOC="$TOPACK_ALWAYS doc"
337#TOPACK_DEV="notes-to-html.c run
338#	web-page/index.html web-page/sendall sf-dir/sf-compare showman
339#	packages/*"
340
341
342##############################
343# Some preparation
344##############################
345
346	# Make sure the destination directories exist
347mkdir -p $ARCHIVE
348
349
350	# Create the makefile header (date of auto-generation, copyright, etc.)
351	# The specific install commands are added later
352(
353	echo "#"
354	echo "# Makefile auto-generated on $package_date"
355	echo "# Use it to install SSWF on your system"
356	echo "#" >>$MAKEFILE_HEADER
357		# Add the copyright
358	sed -e '/^#!amake$/,/^$/ p' -e d amakefile >$MAKEFILE_TMP
359	sed -e '4,$ p' -e d $MAKEFILE_TMP
360		# Add the version and installation directory
361	echo 'VERSION="'$VERSION'"'
362	echo 'INSTALL_DIR="'$INSTALL_DIR'"'
363	echo
364	echo 'install:'
365) >$MAKEFILE_HEADER
366
367	# Create the configure.ac with the correct version
368sed -e "s/<VERSION>/$VERSION/g" \
369	-e "s/<LIBSSWF_VERSION>/$LIBSSWF_VERSION/g" \
370	-e "s/<LIBSSWFC_VERSION>/$LIBSSWFC_VERSION/g" \
371	-e "s/<LIBSSWFAS_VERSION>/$LIBSSWFAS_VERSION/g" \
372	-e "s/<LIBSSWFASAS_VERSION>/$LIBSSWFASAS_VERSION/g" \
373	-e "s/<LIBSSWFASC_VERSION>/$LIBSSWFASC_VERSION/g" \
374		dev/configure.ac >$CONFIGURE_AC
375
376
377
378##############################
379# Common functions
380##############################
381
382
383xtar() {
384	if test "$1" = "-k"
385	then
386		x=exclude.txt
387		shift
388	else
389		x=exclude-all.txt
390	fi
391	if test "$1" = "-i"
392	then
393		inside=true
394		shift
395	else
396		inside=false
397	fi
398	if test "$1" = ""
399	then
400		src=$DST
401	else
402		src=$1
403	fi
404	tar cf $TAR_TMP $src -X dev/$x
405	# the following extraction won't include the excluded files
406	# which would otherwise be included in the .zip version!
407	rm -rf $src
408	tar xf $TAR_TMP
409	if $inside; then
410		main=`pwd`
411		(cd $src; tar cf $main/$TAR_TMP *)
412	else
413		tar cf $TAR_TMP $src
414	fi
415}
416
417
418create_makefile_install() {
419	rm -rf $MAKEFILE_TMP
420	for section in $*
421	do
422		sed -e "/# start install $section/,/end install $section/ p" -e d amakefile >>$MAKEFILE_TMP
423	done
424	cp $MAKEFILE_HEADER $MAKEFILE_INSTALL
425	grep -v "# start" $MAKEFILE_TMP | grep -v "# end" >>$MAKEFILE_INSTALL
426	echo >>$MAKEFILE_INSTALL
427	mv $MAKEFILE_INSTALL $DST/makefile-$1.install
428}
429
430
431
432create_packages() {
433	if test "$1" = "-k";
434	then
435		keep_swf=-k
436		shift
437	else
438		keep_swf=
439	fi
440	if test "$1" = "-o";
441	then
442		all=false
443		shift
444	else
445		all=true
446	fi
447	if test "$2" = "";
448	then
449		xtar $keep_swf
450	else
451		xtar $keep_swf -i $2
452	fi
453	echo -e "\tDestination: `pwd`/$ARCHIVE/$DST-$1.tar.bz2"
454	bzip2 -c9 $TAR_TMP >$ARCHIVE/$DST-$1.tar.bz2
455	if $all; then
456		gzip -c9 $TAR_TMP >$ARCHIVE/$DST-$1.tar.gz
457
458		# zip updates requires the current zip file to be
459		# deleted and the xtar so the source directory has
460		# the excluded files already removed
461		rm -rf $ARCHIVE/$DST-$1.zip
462		if test "$2" = "";
463		then
464			zip -qr9 $ARCHIVE/$DST-$1.zip $DST
465		else
466			main=`pwd`
467			(cd $2; zip -qr9 $main/$ARCHIVE/$DST-$1.zip *)
468		fi
469	fi
470}
471
472
473
474
475
476######################################################################
477#
478#    Create the Source Archives
479#    (which are necessary to create binaries on other systems)
480#
481######################################################################
482
483
484	###########
485	# Source code
486	###########
487
488create_source_packages() {
489	echo "Creating source code package"
490	WARN=$1
491	rm -rf $DST
492	mkdir -p $DST/VC
493	$COPY --parents $TOPACK_SRC $DST
494	rm -rf $DST/dev/tmp
495	(
496		cd $DST/VC
497		for f in ../src/*/*.c++ ../samples/*/*.c++
498		do
499			echo "rename \"`echo $f | sed -e 'sX/X\\\\Xg'`\" \"`basename $f .c++`.cpp\"" >>rename_all.bat
500		done
501	) || exit 1
502	if test -f modules/win32-$VERSION-bin.tar.bz2
503	then
504		tar xjf modules/win32-$VERSION-bin.tar.bz2
505		chmod -R 777 arch
506		$COPY arch/win32/VC $DST
507	elif test "$WARN" = "warn"
508	then
509		echo "WARNING: no grammar or lexical for MS-Windows environment"
510	fi
511	create_packages dev
512
513	# Copy in destination for people who don't have bison
514	# (some people only have byacc or yacc which may not work as expected)
515	if ! test -f tmp/object/src/sswf/sswf_grammar.c \
516	       -a -f tmp/object/src/sswf/sswf_grammar.h;
517	then
518		echo "WARNING: the grammar .c/.h files do not seem available for the source package."
519	else
520		cp tmp/object/src/sswf/sswf_grammar.c tmp/object/src/sswf/sswf_grammar.h $DST/src/sswf/.
521	fi
522
523	(
524		cd $DST
525		# This is a bit more GNU like...
526		cp doc/AUTHORS.txt AUTHORS
527		cp doc/LICENSE.txt COPYING
528		cp doc/CHANGES.txt NEWS
529		cp doc/CHANGES.txt ChangeLog
530		cp doc/INSTALL.txt INSTALL
531		cp README.txt README
532
533		# This needs to come after we tweak the destination
534		PATH=/usr/local/bin:/bin:/usr/bin
535		autoreconf -i -f -v || exit 1
536
537		# remove the cache used to create the Makefile.in & configure
538		rm -rf auto*.cache
539		echo "NOTE: the 'configure' script was created"
540	) || exit 1
541	create_packages src
542}
543
544# Use -nosrc on the command line to skip this part
545# However, if there isn't already an src package, create it anyway
546if ! $need_source && $nosrc && test -f $ARCHIVE/$DST-src.tar.bz2
547then
548	echo "Skipping the pre-creation of the source packages"
549else
550	echo "***"
551	echo "*** SOURCE PACKAGES (pre-creation)"
552	echo "***"
553	create_source_packages
554fi
555
556#echo "Stopping right after source packages..."
557#exit 1;
558
559
560	###########
561	# Documentation
562	###########
563
564# Use -nodoc on the command line to skip this part
565# However, if there isn't already a doc package, create it anyway
566if ! $need_source && $nodoc && test -f $ARCHIVE/$DST-doc.tar.bz2
567then
568	echo "Skipping the creation of the documentation package."
569else
570	echo "***"
571	echo "*** Creating documentation package (including Doxygen)"
572	echo "***"
573	rm -rf $DST
574	mkdir -p $DST
575
576	# We want to automatically put the version in the manual pages
577	for file in dev/man/*.*
578	do
579		# extract the extension
580		f=`basename $file`
581		e=`echo $f | sed -e 's/.*\.\([0-9]\+\)$/\1/'`
582		mkdir -p doc/man/man$e
583		sed -e "s/<VERSION>/$VERSION/" -e "s/<DATE>/`date -r $file`/" $file >doc/man/man$e/$f
584	done
585
586	# We want the HTML of the manual pages so anyone can read those.
587	# Note that we avoid re-generating these files if they didn't
588	# change since the last invocation of dotar.
589	for file in doc/man/man1/*.*
590	do
591		mkdir -p tmp/backup/`dirname $file`
592		if ! cmp -s $file tmp/backup/$file
593		then
594			# This is a `basename $file <whatever extension>`
595			html=`echo $file | sed -e 's/.*\///' -e 's/\.[^.]*$//'`
596			echo "Creating file: $html.html"
597			if groff -m andoc -Thtml $file \
598			| sed -e 'sXhttp:[a-zA-Z/.0-9]\+X<a href="&">&</a>X' \
599			| sed -e 's/<body>/&<a href="index.html">Back to the documentations index<\/a><br\/>/' \
600			| sed -e 's/<\/body>/<br\/><a href="index.html">Back to the documentations index<\/a>&/' \
601					>doc/html/$html.html
602			then
603				cp -f $file tmp/backup/$file
604			fi
605		fi
606	done
607
608	# Generate the different Doxygen files (html & man/man3)
609	dev/dolibdocs
610
611	$COPY --parents $TOPACK_DOC $DST
612
613	create_makefile_install doc manual
614	create_packages -k doc
615fi
616
617
618#echo "Stopping right after the documentation packages..."
619#exit 1;
620
621
622
623##############################
624#
625#	Non-Linux Binary Generation
626#
627##############################
628
629
630echo
631echo
632
633
634
635## I call modules the tar.bz2 files from other systems
636## These are later extracted to create the actual packages
637## (except for those which already are packages such as .deb files)
638mkdir -p modules
639
640
641## WARNING: we first build the windows packages for it will change
642##	    the source package -- we want to save some of the
643##	    generated files in the final source package, and
644##	    since the source package MD5 is used in some other
645##	    packages, we need to do this first. Then the source
646##	    package is not allowed to change anymore.
647
648if ! $noforeign
649then
650	## NOTE: no message about skipping foreign modules here
651	##	 we will get that one on the next large if block!
652
653	##################
654	# MS-Windows (MinGW & Win32)
655	##################
656
657	if $nowin
658	then
659		echo "Skipping MS-Windows module and package generation (MinGW/Win32)"
660	else
661		## One of my Win32 box available?
662		if ping -c1 -r -q -w3 helene >/dev/null
663		then
664			MINGW=helene
665			export SSWF_DRIVE=F
666		elif ping -c1 -r -q -w3 complex >/dev/null
667		then
668			MINGW=complex
669			export SSWF_DRIVE=E
670		else
671			MINGW=""
672		fi
673		## NOTE: atelnet is one of my tool, it is available along with aftp.sf.net
674		if test ! -z "$MINGW"
675		then
676			echo "Creating the Windows modules $VERSION from $MINGW"
677			export SSWF_VERSION=$VERSION
678
679			(
680			# We already have the VERSION variable set
681			MAJOR=`echo $VERSION | sed -e 's/\.[0-9]*\.[0-9]*//'`
682			RELEASE=`echo $VERSION | sed -e 's/[0-9]*\.\([0-9]*\)\.[0-9]*/\1/'`
683			MINOR=`echo $VERSION | sed -e 's/[0-9]*\.[0-9]*\.//'`
684			# In order to define the samples and sources
685			# we want in the win32 package we simulate the
686			# creation of a tar file
687			tar -cvf /dev/null samples -X dev/exclude-win32.txt \
688				| grep -v '\/$' | sed -e 's/\//\\/g' \
689				| sed -e 's%\(.\+\)\\\([^\/]\+\)%        SetOutPath "$INSTDIR\\${VERSION}\\\1"\r\n        File \"\1\\\2\"%' >tmp/samples.txt
690			tar -cvf /dev/null src -X dev/exclude-win32.txt \
691				| grep -v '\/$' | sed -e 's/\//\\/g' \
692				| sed -e 's%\(.\+\)\\\([^\/]\+\)%        SetOutPath "$INSTDIR\\${VERSION}\\\1"\r\n        File \"\1\\\2\"%' >tmp/sources.txt
693			sed -e "s/<VERSION>/$VERSION/" -e "s/<MAJOR>/$MAJOR/" \
694				-e "s/<RELEASE>/$RELEASE/" -e "s/<MINOR>/$MINOR/" \
695				-e "/<SAMPLES>/ r tmp/samples.txt" -e "/<SAMPLES>/ d" \
696				-e "/<SOURCES>/ r tmp/sources.txt" -e "/<SOURCES>/ d" \
697					dev/$WIN32_NSI >tmp/$WIN32_NSI
698			)
699
700			atelnet --show-cmd --nosize -c dev/mingw-build.atelnet $MINGW >tmp/mingw.txt 2>&1
701			echo "NOTE: windows modules created; you can find the output in tmp/mingw.txt"
702		else
703			echo "WARNING: no Windows box running!"
704			echo "WARNING: the current modules will be used..."
705		fi
706	fi
707fi
708
709
710###########
711# Sources
712###########
713# Because the MS-Windows version adds a few files to the source
714# package, we have to re-generate it now.
715# (NOTE: it may not really be necessary, but that's a good way
716# to make sure it's correct!)
717# Below, this final version of the source package is used in the
718# Mac OS/X packages and an MD5 for it is generated. Thus we must
719# make sure that the source package doesn't change after this.
720if ! $nosrc
721then
722	create_source_packages warn
723fi
724
725#echo "Stopping right after the source packages are created for the second time..."
726#exit 1;
727
728
729if $noforeign
730then
731	echo "Skipping the generation of all foreign modules and packages at once"
732else
733	##################
734	# Mac OS/X
735	##################
736	## Now that we have the source and documentation we can
737	## generate the proper info file for fink (we need the
738	## MD5 for debian packages.)
739	if $nomac
740	then
741		echo "Skipping Mac module and packages generation (Mac OS/X)"
742	else
743		## My iMac box available?
744		if ping -c1 -r -q -w3 iMac >/dev/null
745		then
746			MACOSX=iMac
747		else
748			MACOSX=
749		fi
750		if test ! -z "$MACOSX"
751		then
752			echo "Creating the Mac modules $VERSION-$FINKINFO_REVISION from $MACOSX"
753
754			# We put the set in sub-shells to make sure
755			# we don't destroy the command line $1, $2...
756			(
757			set `md5sum $ARCHIVE/$DST-src.tar.gz`
758			MD5SRC=$1
759			set `md5sum $ARCHIVE/$DST-doc.tar.gz`
760			MD5DOC=$1
761			sed -e "s/<VERSION>/$VERSION/" -e "s/<REVISION>/$FINKINFO_REVISION/" \
762				-e "s/<SRCMD5>/$MD5SRC/" -e "s/<DOCMD5>/$MD5DOC/" \
763				-e "s%<DOCFILES>%$COPYRIGHT_FILES%" \
764					dev/$FINK_INFO >modules/$FINK_INFO
765			)
766
767			## Make sure I have the sswf directory
768			echo "Creating the Mac OS/X modules"
769			(
770			echo "Start date: `date`"
771			ssh -l alexiswilke $MACOSX mkdir -p sswf
772			scp $ARCHIVE/$DST-src.tar.gz alexiswilke@$MACOSX:/sw/src
773			scp $ARCHIVE/$DST-doc.tar.gz alexiswilke@$MACOSX:/sw/src
774			scp modules/$FINK_INFO alexiswilke@$MACOSX:/sw/fink/dists/local/main/finkinfo/$DST-$FINKINFO_REVISION.info
775			ssh -l alexiswilke $MACOSX ". ./.profile;
776				set -e -v;
777				cd sswf;
778				sleep 1;
779				fink -k rebuild $DST-$FINKINFO_REVISION;
780				fink -v validate /sw/fink/dists/local/main/finkinfo/$DST-$FINKINFO_REVISION.info
781				fink -v validate /sw/fink/debs/sswf*$VERSION-${FINKINFO_REVISION}_*.deb
782				echo 'Packages content:'
783				for f in /sw/fink/debs/sswf*$VERSION-${FINKINFO_REVISION}_*.deb
784				do
785					echo
786					echo '------------------------------------------------------------'
787					echo \"--- \$f\"
788					echo '------------------------------------------------------------'
789					dpkg -c \$f
790					echo '------------------------------------------------------------'
791					echo
792				done
793				if test -d $DST; then
794					chmod -R 777 $DST;
795					rm -rf $DST;
796				fi;
797				tar xzf /sw/src/$DST-src.tar.gz;
798				tar xzf /sw/src/$DST-doc.tar.gz;
799				find $DST -exec touch {} \;
800				cd $DST;
801				amake macinstall;
802				rm -rf arch;
803				mkdir -p arch/darwin/bin;
804				mkdir -p arch/darwin/lib;
805				mkdir -p arch/darwin/packages;
806				cp /sw/fink/debs/sswf*$VERSION-${FINKINFO_REVISION}_*.deb arch/darwin/packages;
807				cp sswf-$VERSION-darwin-powerpc.dmg arch/darwin/packages;
808				cp bin/* arch/darwin/bin;
809				strip arch/darwin/bin/*;
810				cp lib/libsswf.a arch/darwin/lib;
811				cp lib/libsswf.dylib arch/darwin/lib/libsswf-$VERSION.dylib;
812				cp lib/libsswf_as.a arch/darwin/lib;
813				cp lib/libsswf_as.dylib arch/darwin/lib/libsswf_as-$VERSION.dylib;
814				cp lib/libsswf_asas.a arch/darwin/lib;
815				cp lib/libsswf_asas.dylib arch/darwin/lib/libsswf_asas-$VERSION.dylib;
816				tar cjf ../darwin-$VERSION-bin.tar.bz2 arch"
817			scp alexiswilke@$MACOSX:sswf/darwin-$VERSION-bin.tar.bz2 modules
818			echo "End date: `date`"
819			) >tmp/darwin.txt 2>&1
820			echo "NOTE: Mac OS/X modules created; you can find the output in tmp/darwin.txt"
821		else
822			echo "WARNING: no Mac OS/X box running!"
823			echo "WARNING: the current modules will be used..."
824		fi
825	fi
826
827
828	##################
829	# IRIX
830	##################
831	## My SGI box available?
832	if $nosgi
833	then
834		echo "Skipping SGI module and package generation (IRIX)"
835	else
836		if ping -c1 -r -q -w3 oxygen >/dev/null
837		then
838			IRIX=oxygen
839		else
840			IRIX=
841		fi
842		if test ! -z "$IRIX"
843		then
844			echo "Creating the IRIX modules $VERSION from $IRIX"
845
846			(
847			echo "Removing old folder and tarballs"
848			rsh $IRIX "rm -rf tools/sswf/sswf-$VERSION-*.tar.bz2 tools/sswf/sswf-$VERSION"
849			echo "Sending tarballs"
850			rcp ../packages/sswf-$VERSION/sswf-$VERSION-src.tar.bz2 $IRIX:tools/sswf
851			rcp ../packages/sswf-$VERSION/sswf-$VERSION-doc.tar.bz2 $IRIX:tools/sswf
852			echo "Extracting and recompiling sswf"
853			rsh $IRIX "cd tools/sswf;
854				bunzip2 -c sswf-$VERSION-src.tar.bz2 | tar xf -;
855				bunzip2 -c sswf-$VERSION-doc.tar.bz2 | tar xf -;
856				find sswf-$VERSION -exec touch {} \;
857				cd sswf-$VERSION;
858				pwd;
859				amake -f amakefile irix-tar"
860			echo "Retrieving the result"
861			rcp $IRIX:tools/sswf/sswf-$VERSION/modules/irix-$VERSION-bin.tar.bz2 modules
862			echo "Done!"
863			) >tmp/irix.txt 2>&1
864			echo "NOTE: irix modules created; you can find the output in tmp/irix.txt"
865		else
866			echo "WARNING: no IRIX box running!"
867			echo "WARNING: the current modules will be used..."
868		fi
869	fi
870
871
872	##################
873	# Linux on Power RPM
874	##################
875	## Create an RPM distribution for Linux on Power
876
877	if $nolinuxonpower
878	then
879		echo "Skipping the generation of the RPM packages for Linux on Power"
880	else
881		## Is the Linux on Power box available?
882		## We can't use ping because they don't echo those...
883		## if ping -c1 -r -q -w3 upegr.up.edu >/dev/null
884		LINUXONPOWER=upegr.up.edu
885		LOPPORT=2222
886		if test ! -z "$LINUXONPOWER"
887		then
888			echo "Creating the LinuxOnPower modules $VERSION from $LINUXONPOWER"
889
890			RPM_ARCH=ppc
891
892			sed -e "s/<VERSION>/$VERSION/" -e "s@<FREETYPE>@freetype2@" dev/sswf-rpm.spec >tmp/sswf.spec
893
894			(
895			# Send files over
896			echo "=================================================="
897			echo "Sending files over..."
898			ssh -l alexis_wilke -p $LOPPORT $LINUXONPOWER "mkdir -p sswf tmp"
899			scp -P $LOPPORT $ARCHIVE/$DST-src.tar.gz alexis_wilke@$LINUXONPOWER:sswf/.
900			scp -P $LOPPORT $ARCHIVE/$DST-doc.tar.gz alexis_wilke@$LINUXONPOWER:sswf/.
901			scp -P $LOPPORT tmp/sswf.spec alexis_wilke@$LINUXONPOWER:sswf/.
902			scp -P $LOPPORT dev/_rpmmacros alexis_wilke@$LINUXONPOWER:sswf/.
903
904			# Build RPM
905			echo "=================================================="
906			echo "Start RPM build..."
907			ssh -l alexis_wilke -p $LOPPORT $LINUXONPOWER ". ./.profile;
908				set -e -v;
909				sed -e \"s@<TOPDIR>@\`pwd\`/sswf@\" -e \"s@<SOURCEDIR>@\`pwd\`/sswf@\" \\
910				    -e \"s@<TMPPATH>@\`pwd\`/tmp@\" sswf/_rpmmacros >\$HOME/.rpmmacros;
911				cd sswf;
912				mkdir -p {sswf-root,BUILD,$RPM_ARCH};
913				if ! rpmbuild -bb --quiet --target $RPM_ARCH-m2osw-linux sswf.spec;
914				then
915					exit 1;
916				fi"
917
918			# Retrieve result
919			echo "=================================================="
920			echo "Getting result..."
921			scp -P $LOPPORT alexis_wilke@$LINUXONPOWER:sswf/$RPM_ARCH/$DST-3.$RPM_ARCH.rpm modules/$DST-3.$RPM_ARCH.linuxonpower.rpm
922
923			# We don't need to keep anything on that system...
924			ssh -l alexis_wilke -p $LOPPORT $LINUXONPOWER "rm -rf sswf tmp"
925			) >tmp/linuxonpower.txt 2>&1
926
927			if test -f modules/$DST-3.$RPM_ARCH.linuxonpower.rpm
928			then
929				echo "NOTE: the Linux on Power RPM package was created;"
930				echo "      you can find the output in tmp/linuxonpower.txt"
931			else
932				echo "WARNING: Linux on Power RPM build failed"
933			fi
934		fi
935	fi
936
937
938
939fi
940
941
942if test ! -f modules/mingw-$VERSION-bin.tar.bz2 -o ! -f modules/win32-$VERSION-bin.tar.bz2 -o ! -f modules/mingw-3.3_sswf-$VERSION-src.tar.bz2
943then
944	echo "WARNING:"
945	echo "WARNING: there is no Windows modules available"
946	echo "WARNING:"
947fi
948
949
950if test ! -f modules/irix-$VERSION-bin.tar.bz2
951then
952	echo "WARNING:"
953	echo "WARNING: there is no IRIX modules available"
954	echo "WARNING:"
955fi
956
957if test ! -f modules/darwin-$VERSION-bin.tar.bz2
958then
959	echo "WARNING:"
960	echo "WARNING: there is no Mac OS/X modules available"
961	echo "WARNING:"
962fi
963
964
965if test ! -f modules/$DST-3.ppc.linuxonpower.rpm
966then
967	echo "WARNING:"
968	echo "WARNING: there is no Linux on Power module available"
969	echo "WARNING:"
970fi
971
972
973######################################################################
974#
975#    Regenerate the Source Packages
976#    Create the Binary Packages
977#    Create the Library Packages
978#
979######################################################################
980
981
982if $nolinux
983then
984	echo "Skipping the generation of the Linux packages"
985else
986
987
988
989	###########
990	# Binaries
991	###########
992	echo "Creating package with binaries"
993	rm -rf $DST
994	mkdir -p $DST
995	$COPY --parents $TOPACK_BIN $DST
996	(cd $DST; strip $TOSTRIP_BIN)
997	create_makefile_install bin script manual
998	create_packages bin-linux-i486
999
1000
1001
1002	###########
1003	# Library
1004	###########
1005	echo "Creating package with libraries"
1006	rm -rf $DST
1007	mkdir -p $DST
1008	$COPY --parents $TOPACK_LIB $DST
1009	# The links are created by the amakefile now
1010	#mv $DST/lib/libsswf.so $DST/lib/libsswf-$VERSION.so
1011	#ln -s libsswf-$VERSION.so $DST/lib/libsswf.so
1012	create_makefile_install lib
1013	create_packages lib-linux-i486
1014
1015fi
1016
1017
1018
1019
1020
1021
1022##################
1023# RPM
1024##################
1025## Create an RPM distribution
1026
1027
1028if $norpm
1029then
1030	echo "Skipping the generation of the RPM packages"
1031else
1032	RPM_ARCH=i486
1033	rm -rf $RPM_TMP
1034	mkdir -p $RPM_TMP/{sswf-root,BUILD,$RPM_ARCH}
1035
1036	# On my RedHat there was a bug and freetype2 is shown as just freetype
1037	# On my Debian, there is nothing in the RPM database so I use --nodeps now
1038	# Just in case, on debian, to install RPM, do this:
1039	#
1040	#	apt-get install rpm
1041	#	apt-get install alien
1042	#	mkdir -p /var/lib/rpm
1043	#	chown myself.myself /var/lib/rpm
1044	#	chmod 700 /var/lib/rpm
1045	#	rpm --initdb
1046	#
1047	# Note: alien is probably not necessary
1048	#
1049	# Note: I make that /var/lib/rpm folder accessible for myself so I can
1050	#	use it without being root. I do NOT recommend you do the same!
1051	#
1052	sed -e "s/<VERSION>/$VERSION/" -e "s@<FREETYPE>@freetype@" dev/sswf-rpm.spec >$RPM_TMP/sswf.spec
1053	sed -e "s@<TOPDIR>@`pwd`/$RPM_TMP@" -e "s@<SOURCEDIR>@`pwd`/$ARCHIVE@" \
1054		-e "s@<TMPPATH>@`pwd`/tmp@" dev/_rpmmacros >$HOME/.rpmmacros
1055	(
1056		cd $RPM_TMP
1057		if ! rpmbuild -ba --quiet --nodeps --target $RPM_ARCH-m2osw-linux sswf.spec >../rpm.txt
1058		then
1059			echo "ERROR: the RPM package was NOT created; you can find the output in tmp/rpm.txt"
1060			exit 1;
1061		fi
1062		# Signing requires interaction at this time... (for the passphrase)
1063		#rpm --addsign $RPM_ARCH/sswf-$VERSION-1.$RPM_ARCH.rpm
1064		echo "NOTE: the RPM package was created; you can find the output in tmp/rpm.txt"
1065	)
1066	mv $RPM_TMP/$RPM_ARCH/sswf-$VERSION-3.$RPM_ARCH.rpm $ARCHIVE/
1067	# Somehow the Debian rpmbuild does not seem to generate the debuginfo right now...
1068	# Am I missing some option somewhere?!
1069	if test -f $RPM_TMP/$RPM_ARCH/sswf-debuginfo-$VERSION-3.$RPM_ARCH.rpm
1070	then
1071		mv $RPM_TMP/$RPM_ARCH/sswf-debuginfo-$VERSION-3.$RPM_ARCH.rpm $ARCHIVE/
1072	fi
1073	mv $RPM_TMP/sswf-$VERSION-3.src.rpm $ARCHIVE/
1074fi
1075
1076
1077
1078##################
1079# Debian
1080##################
1081## Create a Debian distribution
1082
1083if $nodebian
1084then
1085	echo "Skipping the generation of the Debian package"
1086else
1087	failed=false
1088	rm -rf $DST
1089	mkdir -p $DST/usr
1090	# Copy everything we want in the output package
1091	$COPY --parents $TOPACK_BIN $DST/usr
1092	$COPY --force --parents $TOPACK_LIB $DST/usr
1093	# Remove the .swf except from the documentation
1094	find $DST/usr -name '*.swf' -exec rm -f {} \;
1095	$COPY --force --parents $TOPACK_DOC $DST/usr
1096	# Remove what we don't want & fix what we keep
1097	(
1098		failed=true
1099		set -e
1100		cd $DST/usr
1101
1102		# Rename the libraries so they includes the version
1103		echo "*** Create library links"
1104		# The links are created by the amakefile now
1105		#mv lib/libsswf.so lib/libsswf-$VERSION.so
1106		#ln -s libsswf-$VERSION.so lib/libsswf.so
1107		#mv lib/libsswf_as.so lib/libsswf_as-$VERSION.so
1108		#ln -s libsswf_as-$VERSION.so lib/libsswf_as.so
1109		#mv lib/libsswf_asas.so lib/libsswf_asas-$VERSION.so
1110		#ln -s libsswf_asas-$VERSION.so lib/libsswf_asas.so
1111
1112		# Rework the bin directory content as required
1113		# First we want to relink to put the correct version
1114		# libraries and an rpath as expected on Slackware
1115		# WARNING: we need to still have the object files
1116		#	   available... (also, not too sure if that's
1117		#	   really gonna work to "share" versions like
1118		#	   this since the objects will have been compiled
1119		#	   with one version and linked with another!)
1120		# At this time, I don't want this... because it just
1121		# doesn't work on my new system!
1122		#echo "*** Recompile with 3.4.3 libraries"
1123		#g++ -nostdlib -Wl,-rpath,/usr/lib/. \
1124		#	/usr/lib/crt1.o /usr/lib/crti.o \
1125		#	/usr/lib/gcc/i686-linux-gnu/3.4.6/crtbegin.o \
1126		#	-o bin/sswf ../../tmp/object/src/sswf/*.o \
1127		#	-Llib -lsswf-$VERSION -lsswf_as-$VERSION \
1128		#	-lsswf_asas-$VERSION \
1129		#	/usr/lib/libstdc++.so.5 -lz -ljpeg -lm -lgcc -lgcc_s -lc \
1130		#	/usr/lib/gcc/i686-linux-gnu/3.4.6/crtend.o \
1131		#	/usr/lib/crtn.o
1132		strip $TOSTRIP_BIN
1133
1134		# Don't need the special installs
1135		echo "*** Delete some non-debian related documents"
1136		rm -f doc/INSTALL-*.txt
1137		rm -f doc/Makefile.am
1138
1139		# Fix the makefiles in the samples directories
1140		echo "*** Fixing the sample makefiles"
1141		for m in samples/*/*makefile
1142		do
1143			sed -e 'sX\.\./\.\./libX../../../../libXg' \
1144			    -e 'sX\.\./\.\./include/sswf/scriptsX../../scriptsXg' \
1145			    -e 'sX\.\./\.\./includeX../../../../includeXg' \
1146			    -e 'sX\.\./\.\./bin/sswfX../../../../bin/sswfXg' \
1147			    -e "s/libsswf\.so/libsswf-$VERSION.so/" \
1148				    $m >../../tmp/makefile.tmp
1149			cp ../../tmp/makefile.tmp $m
1150		done
1151
1152		# Move things which need to be in the share directory
1153		echo "*** Moving files around"
1154		mkdir -p share/{doc/sswf,sswf}
1155		mv doc/man share
1156		mv doc/html share/sswf
1157		mv doc/*.txt share/sswf
1158		rm -rf doc
1159		cp README.txt share/sswf
1160		mv README.txt share/doc/sswf
1161		cp share/sswf/CHANGES.txt share/doc/sswf/changelog
1162		sed -e "s/<VERSION>/$VERSION/" ../../dev/changelog.Debian >share/doc/sswf/changelog.Debian
1163		gzip -9 share/doc/sswf/{R*,ch*}
1164		cat ../../dev/copyright.Debian share/sswf/LICENSE.txt >share/doc/sswf/copyright
1165		mv include/sswf/scripts misc samples share/sswf
1166
1167		# Compress a few things
1168		gzip -9f share/man/man?/*.?
1169		failed=false
1170	) >tmp/debian.txt || exit 1
1171	(
1172		failed=true
1173		set -e
1174		cd $DST
1175
1176		SIZE=`du -ks usr | sed -e 's/[ \t]*usr//'`
1177
1178		sed -e "s/<VERSION>/$VERSION/" ../dev/libsswf-debian.la >usr/lib/libsswf.la
1179		sed -e "s/<VERSION>/$VERSION/" ../dev/libsswf_as-debian.la >usr/lib/libsswf_as.la
1180		sed -e "s/<VERSION>/$VERSION/" ../dev/libsswf_asas-debian.la >usr/lib/libsswf_asas.la
1181		sed -e "s/<VERSION>/$VERSION/" -e "s/<SIZE>/$SIZE/" \
1182			../dev/control-debian.txt >control
1183		echo "2.0" >debian-binary
1184
1185		find usr -type f -name '*run.bat' -exec rm {} \;
1186		find usr -type f -name '*.bak' -exec rm {} \;
1187		find usr -type f -name '*~' -exec rm {} \;
1188		find usr/share/sswf/samples -type f -name '*.swf' -exec rm {} \;
1189		md5sum `find usr -type f` >md5sums
1190		chmod -R go-w usr md5sums control debian-binary
1191
1192		tar czf control.tar.gz ./md5sums ./control
1193		tar czf data.tar.gz ./usr -X ../dev/exclude.txt --exclude '*run.bat'
1194		rm -rf ../$ARCHIVE/sswf_$VERSION-*_i386.deb
1195		ar cqS ../$ARCHIVE/sswf_$VERSION-2_i386.deb debian-binary control.tar.gz data.tar.gz
1196		failed=false
1197	) || exit 1
1198
1199
1200	if $failed;
1201	then
1202		echo "ERROR: the Debian package creation failed."
1203	else
1204		echo "NOTE: the Debian package was created."
1205	fi
1206	echo "NOTE: the output was saved in tmp/debian.txt"
1207fi
1208
1209
1210
1211
1212##################
1213# Slackware
1214##################
1215## Create a Slackware distribution
1216
1217if $noslackware
1218then
1219	echo "Skipping the generation of the Slackware package"
1220else
1221	failed=false
1222	rm -rf $DST
1223	mkdir -p $DST/usr
1224	# Copy everything we want in the output package
1225	$COPY --parents $TOPACK_BIN $DST/usr
1226	$COPY --force --parents $TOPACK_LIB $DST/usr
1227	# Remove the .swf except from the documentation
1228	find $DST/usr -name '*.swf' -exec rm -f {} \;
1229	$COPY --force --parents $TOPACK_DOC $DST/usr
1230	sed -e "s/<VERSION>/$VERSION/" dev/libsswf-slackware.la >$DST/usr/lib/libsswf.la
1231	sed -e "s/<VERSION>/$VERSION/" dev/libsswf_as-slackware.la >$DST/usr/lib/libsswf_as.la
1232	sed -e "s/<VERSION>/$VERSION/" dev/libsswf_asas-slackware.la >$DST/usr/lib/libsswf_asas.la
1233	# Remove what we don't want & fix what we keep
1234	(
1235		failed=true
1236		cd $DST
1237
1238		# Create the install directory content
1239		mkdir install
1240		sed -e "s/<VERSION>/$VERSION/" ../dev/slack-desc >install/slack-desc
1241		sed -e "s/<VERSION>/$VERSION/" ../dev/doinst-slackware.sh >install/doinst.sh
1242
1243		cd usr
1244
1245		# Now this is done in the amakefile
1246		# Rename the libraries so they include the version
1247		#mv lib/libsswf.so lib/libsswf-$VERSION.so
1248		#mv lib/libsswf_as.so lib/libsswf_as-$VERSION.so
1249		#mv lib/libsswf_asas.so lib/libsswf_asas-$VERSION.so
1250
1251		# Rework the bin directory content as required
1252		# First we want to relink to put the correct version
1253		# libraries and an rpath as expected on Slackware
1254		# WARNING: we need to still have the object files
1255		#	   available... (also, not too sure if that's
1256		#	   really gonna work to "share" versions like
1257		#	   this since the objects will have been compiled
1258		#	   with one version and linked with another!)
1259		# At this time, I don't want this... because it just
1260		# doesn't work on my new system!
1261		#g++ -nostdlib -Wl,-rpath,/usr/lib/. \
1262		#	/usr/lib/crt1.o /usr/lib/crti.o \
1263		#	/usr/local/lib/gcc/i486-linux-gnu/3.4.6/crtbegin.o \
1264		#	-o bin/sswf ../../tmp/object/src/sswf/*.o \
1265		#	-Llib -lsswf-$VERSION -lsswf_as-$VERSION \
1266		#	-lsswf_asas-$VERSION \
1267		#	/usr/lib/libstdc++.so.5 -lz -ljpeg -lm -lgcc -lgcc_s -lc \
1268		#	/usr/local/lib/gcc/i486-linux-gnu/3.4.6/crtend.o \
1269		#	/usr/lib/crtn.o
1270		strip $TOSTRIP_BIN
1271
1272		# Keep only the INSTALL-SLACKWARE info file
1273		mv doc/INSTALL-SLACKWARE.txt .
1274		rm -f doc/INSTALL-*.txt
1275		rm -f doc/Makefile.am
1276		mv INSTALL-SLACKWARE.txt doc
1277
1278		# Fix the makefiles in the samples directories
1279		for m in samples/*/*makefile
1280		do
1281			sed -e 'sX\.\./\.\./libX../../../../libXg' \
1282			    -e 'sX\.\./\.\./include/sswf/scriptsX../../scriptsXg' \
1283			    -e 'sX\.\./\.\./includeX../../../../includeXg' \
1284			    -e 'sX\.\./\.\./bin/sswfX../../../../bin/sswfXg' \
1285			    -e "s/libsswf\.so/libsswf-$VERSION.so/" \
1286				    $m >../../tmp/makefile.tmp
1287			cp ../../tmp/makefile.tmp $m
1288		done
1289
1290		# Move things which need to be in the share directory
1291		mkdir -p share/sswf
1292		mv doc/man share
1293		mv doc/html share/sswf
1294		cp doc/*.txt share/sswf
1295		mkdir doc/sswf-$VERSION
1296		mv doc/*.txt doc/sswf-$VERSION
1297		cp README.txt share/sswf
1298		mv README.txt doc/sswf-$VERSION
1299		mv include/sswf/scripts misc samples share/sswf
1300
1301		find . -type f -name '*run.bat' -exec rm {} \;
1302		find . -type f -name '*.bak' -exec rm {} \;
1303		find . -type f -name '*~' -exec rm {} \;
1304		find share/sswf/samples -type f -name '*.swf' -exec rm {} \;
1305
1306		# Compress the manual pages
1307		gzip -9f share/man/man?/*.?
1308		failed=false
1309	) >tmp/slackware.txt || exit 1
1310	(
1311		cd $DST
1312		chmod -R go-w usr install
1313		tar czf ../$ARCHIVE/$DST-i486-1will.tgz install ./usr -X ../dev/exclude.txt --exclude '*run.bat'
1314	) || exit 1
1315
1316	if $failed;
1317	then
1318		echo "ERROR: the Slackware package creation failed."
1319	else
1320		echo "NOTE: the Slackware package was created."
1321	fi
1322	echo "NOTE: the output was saved in tmp/slackware.txt"
1323fi
1324
1325
1326
1327
1328######################################################################
1329# Function to create non-linux packages
1330#
1331# Parameter:	$1	system name (mingw, etc.)
1332#
1333######################################################################
1334
1335pack_system() {
1336	# Get the modules files (in case it wasn't extracted yet)
1337	NAME="`echo $1 | sed -e 'sX/$XX'`"
1338	tar xjf modules/$NAME-$VERSION-bin.tar.bz2
1339	chmod -R 777 arch
1340
1341	#######################
1342	# Check parameter validity
1343	#######################
1344	if ! test -d "arch/$1"
1345	then
1346		echo "ERROR: can't access system (directory) $1"
1347		exit 1;
1348	fi
1349	SRC="arch/$NAME"
1350
1351	SYS=`grep system:$NAME: dev/arch.txt | sed -e "s/system:$NAME://"`
1352	EXE=`grep extension:$NAME: dev/arch.txt | sed -e "s/extension:$NAME://"`
1353
1354
1355	#######################
1356	# Binaries (must already be stripped on the source system)
1357	#######################
1358	if test -z "$EXE"
1359	then
1360		EXEMSG=""
1361	else
1362		EXEMSG=" (with \"$EXE\" as the extension of binaries)"
1363	fi
1364	echo "Creating bin-$SYS module$EXEMSG"
1365	rm -rf $DST
1366	mkdir -p $DST
1367	$COPY --parents $TOPACK_BIN $DST
1368	# remove the linux version and replace with specific arch version
1369	rm -rf $DST/bin
1370	$COPY $SRC/bin $DST
1371	create_packages bin-$SYS
1372
1373	#######################
1374	# Library
1375	#######################
1376	echo "Creating lib-$SYS module"
1377	rm -rf $DST
1378	mkdir -p $DST
1379	$COPY --parents $TOPACK_LIB $DST
1380	# remove the linux version and replace with specific arch version
1381	rm -rf $DST/lib
1382	$COPY $SRC/lib $DST
1383	create_packages lib-$SYS
1384}
1385
1386
1387
1388##############################
1389# Check if the other distributions
1390# are available - if so, run the
1391# extrapack command on them
1392##############################
1393
1394# Uncomment this function if you don't need packages
1395# other than Linux packages
1396#skip_func6() {
1397
1398if test -f modules/mingw-$VERSION-bin.tar.bz2
1399then
1400	# MinGW systems get their own version using
1401	# the MinGW directory tree as expected by the
1402	# MinGW users
1403	SYS=mingw-i686
1404
1405	# Get the modules files (in case it wasn't extracted yet)
1406	tar xjf modules/mingw-$VERSION-bin.tar.bz2
1407	chmod -R 777 arch
1408
1409	############
1410	# Binaries
1411	############
1412	echo "Creating bin-$SYS package (with \".exe\" as the extension of binaries)"
1413	rm -rf $MINGW_PATH
1414	mkdir -p $MINGW_PATH/{bin,contrib/sswf,include/sswf,share/sswf}
1415	echo "$COPY arch/mingw/bin $MINGW_PATH"
1416	$COPY arch/mingw/bin $MINGW_PATH
1417	echo "$COPY $TOPACK_ALWAYS $MINGW_PATH/contrib/sswf"
1418	$COPY $TOPACK_ALWAYS $MINGW_PATH/contrib/sswf
1419	echo "$COPY --parents include/sswf/scripts $MINGW_PATH"
1420	$COPY --parents include/sswf/scripts $MINGW_PATH
1421	echo "$COPY --parents doc/man $MINGW_PATH"
1422	$COPY --parents doc/man $MINGW_PATH
1423	echo "$COPY --parents samples misc $MINGW_PATH/share/sswf"
1424	$COPY --parents samples misc $MINGW_PATH/share/sswf
1425
1426	create_packages bin-$SYS $MINGW_PATH
1427
1428	############
1429	# Library
1430	############
1431	echo "Creating lib-$SYS package"
1432	rm -rf $MINGW_PATH
1433	mkdir -p $MINGW_PATH/{contrib/sswf,include/sswf,lib}
1434	cp -rf arch/mingw/lib $MINGW_PATH
1435	cp -rf arch/mingw/include $MINGW_PATH
1436	cp -rf $TOPACK_ALWAYS $MINGW_PATH/contrib/sswf
1437
1438	create_packages lib-$SYS $MINGW_PATH
1439
1440	# Documentation
1441	echo "Creating doc-mingw package"
1442	rm -rf $MINGW_PATH
1443	mkdir -p $MINGW_PATH/{contrib/sswf,doc/sswf-$VERSION}
1444
1445	cp -rf doc/html/*.{html,pdf} doc/html/images doc/html/tutorial $MINGW_PATH/doc/sswf-$VERSION
1446	cp -rf doc/man $MINGW_PATH
1447	cp -rf $TOPACK_ALWAYS $MINGW_PATH/contrib/sswf
1448
1449	create_packages -k doc-mingw $MINGW_PATH
1450fi
1451
1452if test -f modules/win32-$VERSION-bin.tar.bz2
1453then
1454	pack_system win32
1455	cp -f arch/win32/installer/sswf-$VERSION-win32-i686.exe $ARCHIVE
1456fi
1457
1458if test -f modules/irix-$VERSION-bin.tar.bz2
1459then
1460	pack_system irix
1461	cp arch/irix/dist/* $ARCHIVE/
1462fi
1463
1464if test -f modules/darwin-$VERSION-bin.tar.bz2
1465then
1466	pack_system darwin
1467	cp arch/darwin/packages/* $ARCHIVE/
1468	cp modules/$FINK_INFO $ARCHIVE/sswf-fink-$VERSION.info
1469fi
1470
1471
1472if test -f modules/$DST-3.ppc.linuxonpower.rpm
1473then
1474	cp modules/$DST-3.ppc.linuxonpower.rpm $ARCHIVE/
1475fi
1476
1477#}
1478
1479
1480##############################
1481# Cleanup
1482##############################
1483
1484if $nocleanup
1485then
1486	echo "NOTE: cleanup step skipped; many intermediate files will still be available."
1487else
1488	rm -rf $DST $TAR_TMP $RPM_TMP $MAKEFILE_TMP $MAKEFILE_HEADER \
1489		$MINGW_PATH $CONFIGURE_AC tmp/amake* tmp/makefile.tmp
1490fi
1491
1492
1493##############################
1494# Stats
1495##############################
1496
1497echo "***"
1498echo "*** Started at $start_date and finised at `date +%H:%M:%S`"
1499echo "***"
1500
1501
1502# vim: ts=8
1503