blob: bf1c661270924e4f990f069f36ba4b549d4a0b23 [file] [log] [blame]
Austin Schuh8c794d52019-03-03 21:17:37 -08001#!/bin/bash
2#
3# File : cimg_buildpackage
4# ( Bash script )
5#
6# Description : Build .zip package file of the CImg Library, from the current CImg/
7# directory. Must be run from ../CImg
8# This file is a part of the CImg Library project.
9# ( http://gmic.eu/CImg )
10#
11# Usage : ./cimg_buildpackage [final]
12#
13# Copyright : David Tschumperle
14# ( http://tschumperle.users.greyc.fr/ )
15#
16# License : CeCILL v2.0
17# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
18#
19# This software is governed by the CeCILL license under French law and
20# abiding by the rules of distribution of free software. You can use,
21# modify and/ or redistribute the software under the terms of the CeCILL
22# license as circulated by CEA, CNRS and INRIA at the following URL
23# "http://www.cecill.info".
24#
25# As a counterpart to the access to the source code and rights to copy,
26# modify and redistribute granted by the license, users are provided only
27# with a limited warranty and the software's author, the holder of the
28# economic rights, and the successive licensors have only limited
29# liability.
30#
31# In this respect, the user's attention is drawn to the risks associated
32# with loading, using, modifying and/or developing or reproducing the
33# software by the user in light of its specific status of free software,
34# that may mean that it is complicated to manipulate, and that also
35# therefore means that it is reserved for developers and experienced
36# professionals having in-depth computer knowledge. Users are therefore
37# encouraged to load and test the software's suitability as regards their
38# requirements in conditions enabling the security of their systems and/or
39# data to be ensured and, more generally, to use and operate it in the
40# same conditions as regards security.
41#
42# The fact that you are presently reading this means that you have had
43# knowledge of the CeCILL license and that you accept its terms.
44#
45
46# Define release number.
47RELEASE0=`grep "#define cimg_version" CImg/CImg.h | tail -c 4`
48RELEASE1=`echo $RELEASE0 | head -c 1`
49RELEASE2=`echo $RELEASE0 | head -c 2 | tail -c 1`
50RELEASE3=`echo $RELEASE0 | head -c 3 | tail -c 1`
51VERSION=${RELEASE1}${RELEASE2}${RELEASE3}
52SVERSION=${RELEASE1}.${RELEASE2}.${RELEASE3}
53
54# Read command line options.
55if [ "$1" == "final" ]; then SUFFIX=""; SSUFFIX=""; else SUFFIX=_pre`date +%m%d%y`; SSUFFIX=_pre; fi
56
57# Define the different paths and filenames used in this script.
58BASE_DIR=`pwd`
59SRC_DIR=${BASE_DIR}/CImg
60DEST_DIR=/tmp/CImg-${SVERSION}${SUFFIX}
61ZIP_FILE=CImg_${SVERSION}${SSUFFIX}.zip
62LOG_FILE=${BASE_DIR}/LOG_`basename $ZIP_FILE .zip`.txt
63rm -rf $LOG_FILE
64
65echo
66echo " - Release number : $SVERSION$SUFFIX"
67echo " - Base directory : $BASE_DIR/"
68echo " - Source directory : $SRC_DIR/"
69echo " - Build directory : $DEST_DIR/"
70echo " - ZIP package filename : $ZIP_FILE"
71echo " - LOG file : $LOG_FILE"
72
73# Create clean archive structure.
74echo " - Create package structure."
75rm -rf $DEST_DIR
76mkdir $DEST_DIR
77cd $SRC_DIR
78cp -f CImg.h Licence_CeCILL-C_V1-en.txt Licence_CeCILL_V2-en.txt $DEST_DIR
79sed s\/_cimg_version\/$SVERSION$SUFFIX\/ README.txt > $DEST_DIR/README.txt
80
81mkdir $DEST_DIR/examples
82cd $SRC_DIR/examples
83cp -f *.cpp *.m CMakeLists.txt Makefile $DEST_DIR/examples/
84
85mkdir $DEST_DIR/examples/img
86cd $SRC_DIR/examples/img
87cp -f *.pgm *.ppm *.bmp *.h $DEST_DIR/examples/img/
88
89mkdir $DEST_DIR/plugins
90cd $SRC_DIR/plugins
91cp -f *.h $DEST_DIR/plugins/
92
93mkdir $DEST_DIR/resources
94cd $SRC_DIR/resources
95cp -rf *.bat $DEST_DIR/resources/
96
97cd $DEST_DIR
98for i in CImg.h examples/*.cpp; do
99 sed -e 's/ *$//' $i >/tmp/cimg_buildpackage$$ && mv /tmp/cimg_buildpackage$$ $i
100done
101for i in `find . -name "\#*"`; do rm -rf $i; done
102for i in `find . -name "*~"`; do rm -rf $i; done
103for i in `find . -name "core*"`; do rm -rf $i; done
104for i in `find . -name "CVS"`; do rm -rf $i; done
105for i in `find . -name ".git"`; do rm -rf $i; done
106for i in `find . -name "*.plg"`; do rm -rf $i; done
107for i in `find . -name "*.ncb"`; do rm -rf $i; done
108for i in `find . -name "*.layout"`; do rm -rf $i; done
109for i in `find . -name "*.win"`; do rm -rf $i; done
110for i in `find . -name "Debug"`; do rm -rf $i; done
111for i in `find . -name "Release"`; do rm -rf $i; done
112for i in `find . -name "*.h"`; do col -x <$i >tmp; mv tmp $i; done
113for i in `find . -name "*.cpp"`; do col -x <$i >tmp; mv tmp $i; done
114for i in `find . ! -type d`; do chmod a-x $i; done
115for i in `find . -name "*.sh"`; do chmod a+x $i; done
116for i in `find . -name "rules"`; do chmod a+x $i; done
117
118# Generate Documentation with doxygen
119echo " - Generate reference documentation using Doxygen."
120cd $SRC_DIR/html
121
122if [ "$1" == "final" ]; then
123 gmic _update_header_html header.html,${VERSION},0
124 gmic _update_header_html header_reference.html,${VERSION},0
125else
126 gmic _update_header_html header.html,${VERSION},1
127 gmic _update_header_html header_reference.html,${VERSION},1
128fi
129
130echo -e "\n** Log generated by 'doxygen' **\n\n">>$LOG_FILE
131( cat CImg.doxygen ; echo "PROJECT_NUMBER=$SVERSION$SUFFIX" ) | doxygen - >>$LOG_FILE 2>&1
132
133echo " - Build reference documentation in PDF format."
134cd $SRC_DIR/html/latex
135echo -e "\n** Log generated by 'latex' **\n\n">>$LOG_FILE
136make>>$LOG_FILE 2>&1
137cp -f refman.pdf ../CImg_reference.pdf
138cp -f refman.pdf $DEST_DIR/resources/CImg_reference.pdf
139rm -rf ../latex
140
141# Commit changes on GIT repository
142echo " - Commit on GIT repository."
143cd $SRC_DIR
144if [ "$1" == "final" ]; then
145 git tag -d v.$SVERSION
146 git tag v.$SVERSION
147 git commit -m "Final release "${SVERSION} >>$LOG_FILE 2>&1
148else
149 git commit -m "Auto-commit for release "${SVERSION}${SUFFIX} >>$LOG_FILE 2>&1
150fi
151git push --tags
152
153# Create ZIP archive
154echo " - Build ZIP archive file '$ZIP_FILE'."
155cd $DEST_DIR/..
156rm -f $ZIP_FILE
157echo -e "\n** Log generated by 'zip' **\n\n">>$LOG_FILE
158zip -r -9 $ZIP_FILE `basename $DEST_DIR`>>$LOG_FILE 2>&1
159
160# Clean temporary files and directories
161echo " - Clean temporary files and directories."
162cd $DEST_DIR/..
163mv $ZIP_FILE $BASE_DIR
164
165# Copy files to CImg server.
166cd $BASE_DIR
167if [ "$1" == "final" ]; then
168 lftp ftp://$GMIC_LOGIN:$GMIC_PASSWD@ftp.gmic.eu -e "put -O /www/CImg/files/ ${ZIP_FILE}; quit";
169fi
170lftp ftp://$GMIC_LOGIN:$GMIC_PASSWD@ftp.gmic.eu -e "put -O /www/CImg/files/ ${ZIP_FILE} -o CImg_latest.zip; quit"
171
172cd $SRC_DIR/html/
173lftp ftp://$GMIC_LOGIN:$GMIC_PASSWD@ftp.gmic.eu -e "mirror -RL . /www/CImg/ ; quit"
174
175# End of build script
176echo -e " - All done, you should look at the LOG file '$LOG_FILE'.\n"