Wed, 05 Aug 2009 15:02:31 +0100
PTdecode: add support for uncompressed data (NOTE: *NOT* supported by the PT-2450DX)
1 #!/bin/bash
2 #
3 # File : cimg_buildpackage
4 # ( Bash script )
5 #
6 # Description : Build .zip, .tar.gz and .deb package files
7 # of the CImg Library, from the current CImg/
8 # directory. Must be run from ../CImg
9 # This file is a part of the CImg Library project.
10 # ( http://cimg.sourceforge.net )
11 #
12 # Usage : ./cimg_buildpackage [beta] [compile]
13 #
14 # Copyright : David Tschumperle
15 # ( http://www.greyc.ensicaen.fr/~dtschump/ )
16 #
17 # License : CeCILL v2.0
18 # ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
19 #
20 # This software is governed by the CeCILL license under French law and
21 # abiding by the rules of distribution of free software. You can use,
22 # modify and/ or redistribute the software under the terms of the CeCILL
23 # license as circulated by CEA, CNRS and INRIA at the following URL
24 # "http://www.cecill.info".
25 #
26 # As a counterpart to the access to the source code and rights to copy,
27 # modify and redistribute granted by the license, users are provided only
28 # with a limited warranty and the software's author, the holder of the
29 # economic rights, and the successive licensors have only limited
30 # liability.
31 #
32 # In this respect, the user's attention is drawn to the risks associated
33 # with loading, using, modifying and/or developing or reproducing the
34 # software by the user in light of its specific status of free software,
35 # that may mean that it is complicated to manipulate, and that also
36 # therefore means that it is reserved for developers and experienced
37 # professionals having in-depth computer knowledge. Users are therefore
38 # encouraged to load and test the software's suitability as regards their
39 # requirements in conditions enabling the security of their systems and/or
40 # data to be ensured and, more generally, to use and operate it in the
41 # same conditions as regards security.
42 #
43 # The fact that you are presently reading this means that you have had
44 # knowledge of the CeCILL license and that you accept its terms.
45 #
47 # Define release number.
48 RELEASE0=`grep "#define cimg_version" CImg/CImg.h | tail -c 4`
49 RELEASE1=`echo $RELEASE0 | head -c 1`
50 RELEASE2=`echo $RELEASE0 | head -c 2 | tail -c 1`
51 RELEASE3=`echo $RELEASE0 | head -c 3 | tail -c 1`
52 RELEASE=$RELEASE1.$RELEASE2.$RELEASE3
54 # Read command line options.
55 if [ "$1" == "beta" -o "$2" == "beta" ]; then BETA="yes"; RELEASE=${RELEASE}beta; else BETA="no"; fi
56 if [ "$1" == "compile" -o "$2" == "compile" ]; then COMPILE="yes"; else COMPILE="no"; fi
58 # Define the different paths and filenames used in this script.
59 BASE_DIR=`pwd`
60 cd ${BASE_DIR}
61 SRC_DIR=${BASE_DIR}/CImg
62 DEST_DIR=/tmp/CImg-${RELEASE}
63 ZIP_FILE=CImg-${RELEASE}.zip
64 TAR_FILE=CImg_${RELEASE}.tar
65 DEB_DIR=cimg-${RELEASE}
66 DEB_FILE=cimg-dev_${RELEASE}-1_all.deb
67 LOG_FILE=${BASE_DIR}/LOG_`basename $DEST_DIR`.txt
68 rm -rf $LOG_FILE
70 echo
71 echo " - Release number : $RELEASE"
72 echo " - Base directory : $BASE_DIR/"
73 echo " - Source directory : $SRC_DIR/"
74 echo " - Build directory : $DEST_DIR/"
75 echo " - ZIP package filename : $ZIP_FILE"
76 echo " - TAR.GZ package filename : $TAR_FILE.gz"
77 echo " - DEB package filename : $DEB_FILE"
78 echo " - LOG file : $LOG_FILE"
79 echo " - Compile examples : $COMPILE"
81 # Create archive structure
82 echo " - Create package structure."
83 rm -rf $DEST_DIR
84 mkdir $DEST_DIR
85 cd $SRC_DIR
86 cp -f CHANGES.txt CImg.h Licence_CeCILL-C_V1-en.txt Licence_CeCILL_V2-en.txt README.txt $DEST_DIR
88 mkdir $DEST_DIR/examples
89 cd $SRC_DIR/examples
90 cp -f *.cpp *.h *_def.raw Makefile *.m $DEST_DIR/examples/
91 mkdir $DEST_DIR/examples/img
92 cd $SRC_DIR/examples/img
93 cp -f *.pgm *.ppm *.bmp *.h $DEST_DIR/examples/img/
95 mkdir $DEST_DIR/html
96 cd $SRC_DIR/html
97 cp -f *.shtml *.html *.doxygen *.h favicon.* $DEST_DIR/html/
98 mkdir $DEST_DIR/html/img
99 cd $SRC_DIR/html/img
100 cp -f *.html *.jpg *.gif *.png *.ppm $DEST_DIR/html/img/
102 mkdir $DEST_DIR/plugins
103 cd $SRC_DIR/plugins
104 cp -f *.h $DEST_DIR/plugins/
106 mkdir $DEST_DIR/resources
107 cd $SRC_DIR/resources
108 cp -rf *.bat *.txt cimg_buildpackage debian project_* $DEST_DIR/resources/
110 # Clean directory
111 echo " - Clean package directory."
112 cd $DEST_DIR
113 for i in `find . -name "\#*"`; do rm -rf $i; done
114 for i in `find . -name "*~"`; do rm -rf $i; done
115 for i in `find . -name "core*"`; do rm -rf $i; done
116 for i in `find . -name "CVS"`; do rm -rf $i; done
117 for i in `find . -name "*.plg"`; do rm -rf $i; done
118 for i in `find . -name "*.ncb"`; do rm -rf $i; done
119 for i in `find . -name "*.layout"`; do rm -rf $i; done
120 for i in `find . -name "*.win"`; do rm -rf $i; done
121 for i in `find . -name "Debug"`; do rm -rf $i; done
122 for i in `find . -name "Release"`; do rm -rf $i; done
123 for i in `find . -name "*.h"`; do col -x <$i >tmp; mv tmp $i; done
124 for i in `find . -name "*.cpp"`; do col -x <$i >tmp; mv tmp $i; done
125 for i in `find . ! -type d`; do chmod a-x $i; done
126 for i in `find . -name "*.sh"`; do chmod a+x $i; done
127 for i in `find . -name "rules"`; do chmod a+x $i; done
128 iconv -t utf8 -f latin1 resources/debian/changelog > /tmp/foo.changelog
129 mv /tmp/foo.changelog resources/debian/changelog
130 iconv -t utf8 -f latin1 resources/debian/control > /tmp/foo.control
131 mv /tmp/foo.control resources/debian/control
132 chmod a+x $DEST_DIR/resources/cimg_buildpackage
134 # Generate special files 'gmic.h' and 'gmic4gimp.h'
135 # (gmic must be installed !)
136 cd $DEST_DIR/examples
137 make gmic_def >>$LOG_FILE 2>&1
138 make gmic4gimp_def >>$LOG_FILE 2>&1
140 # Generate Documentation with doxygen
141 echo " - Generate reference documentation using Doxygen."
142 cd $DEST_DIR/html
143 echo -e "\n** Log generated by 'doxygen' **\n\n">>$LOG_FILE
144 doxygen CImg.doxygen>>$LOG_FILE 2>&1
146 echo " - Build reference documentation in PDF format."
147 cd $DEST_DIR/html/latex
148 echo -e "\n** Log generated by 'latex' **\n\n">>$LOG_FILE
149 make>>$LOG_FILE 2>&1
150 cp -f refman.pdf ../CImg_reference.pdf
151 rm -rf ../latex
153 # Create ZIP archive
154 echo " - Build ZIP archive file '$ZIP_FILE'."
155 cd $DEST_DIR/..
156 rm -f $ZIP_FILE
157 echo -e "\n** Log generated by 'zip' **\n\n">>$LOG_FILE
158 zip -r -9 $ZIP_FILE `basename $DEST_DIR`>>$LOG_FILE 2>&1
160 # Create TAR.GZ archive
161 echo " - Build TAR.GZ archive file '$TAR_FILE.gz'."
162 cd $DEST_DIR/..
163 rm -f $TAR_FILE $TAR_FILE.gz
164 echo -e "\n** Log generated by 'tar' **\n\n">>$LOG_FILE
165 tar cvf $TAR_FILE `basename $DEST_DIR`>>$LOG_FILE 2>&1
166 gzip --best $TAR_FILE
168 # Compile examples
169 if [ $COMPILE == "yes" ]; then
170 echo " - Compile CImg examples."
171 cd $DEST_DIR/examples/
172 mkdir -p ../bin
173 echo -e "\n** Log generated by 'CImg compilation' **\n\n">>$LOG_FILE
174 make -j "CC=g++ -Dcimg_imagepath=\"\\\"/usr/share/CImg/examples/img/\\\"\"" EXEPFX=../bin/cimg_ olinux
175 rm -f *.o
176 cd $DEST_DIR/resources/debian
177 echo "bin/* usr/bin/" >> cimg-dev.install
178 fi
180 # Create Debian package
181 echo " - Build Debian package file '$DEB_FILE'."
182 cd $DEST_DIR/..
183 rm -rf $DEB_DIR.tar $DEB_DIR.tar.gz
184 mv $DEST_DIR $DEB_DIR
185 tar cvf $DEB_DIR.tar $DEB_DIR>>$LOG_FILE 2>&1
186 gzip $DEB_DIR.tar
187 cp -f $DEB_DIR.tar.gz cimg_$RELEASE.orig.tar.gz
189 cd $DEB_DIR
190 cp -f CHANGES.txt changelog
191 cp -rf resources/debian .
192 export DEBNAME=$DEB_FILE
193 export DEBFULLNAME="David Tschumperlé"
194 export DEBEMAIL="David.Tschumperle@greyc.ensicaen.fr"
195 echo -e "\n** Log generated by 'Debian packaging tools' **\n\n">>$LOG_FILE
196 dpkg-buildpackage -rfakeroot>>$LOG_FILE 2>&1
197 cd ../
198 mv $DEB_DIR $DEST_DIR
200 # Clean temporary files and directories
201 echo " - Clean temporary files and directories."
202 cd $DEST_DIR/..
203 mv $ZIP_FILE $TAR_FILE.gz $DEB_FILE $BASE_DIR
205 # End of build script
206 echo -e " - All done, you should look at the LOG file '$LOG_FILE'.\n"