Initial release of Maemo 5 port of gnuplot
[gnuplot] / config / MacOSX / createdist.sh
1 ## createdist.sh
2 ## This is a shell script to automatically create a gnuplot distribution 
3 ## for Mac OS X. It will download and build a source tarball and create
4 ## a disk image with a standard GUI installer and folders with supporting
5 ## files (ReadMe, docs in PDF and demos).
6 ##
7 ## The utility "freeze" from the application Iceberg is required, see
8 ## http://s.sudre.free.fr/Software/Iceberg.html
9 ##
10 ## 2004-10-21 Per Persson, persquare@users.sf.net
11
12 ## Change as needed
13 VERSION="4.0.0"
14 SHORTVER="4.0"
15 BETA=
16 DISTRO_DIR=`pwd`
17 ## No changes needed below this line
18
19 echo "==== Creating distro of gnuplot $VERSION$BETA"
20
21 TARBALL="gnuplot-$VERSION.tar.gz"
22 WORK_DIR="$DISTRO_DIR/work"
23 SRC_DIR="$WORK_DIR/gnuplot-$VERSION"
24 BUILD_DIR="$DISTRO_DIR/build"
25 PRODUCTS_DIR="$BUILD_DIR/products"
26 DMG_ROOT="$BUILD_DIR/dmg_root"
27
28 ## Always remove product
29 rm -rf $BUILD_DIR/Gnuplot-$VERSION$BETA.dmg 
30
31 if [ "$1" = "pack" ]; then
32     echo "*** Warning skipping build"
33 else
34     echo "Setting up directories"
35     rm -rf build.log
36     rm -rf $BUILD_DIR
37     mkdir $BUILD_DIR
38     if [ ! -d $WORK_DIR ]; then
39         mkdir $WORK_DIR
40     else
41         (cd $WORK_DIR; rm -rf $SRC_DIR)
42     fi
43     mkdir $PRODUCTS_DIR
44     mkdir $DMG_ROOT
45     mkdir $DMG_ROOT/Demo
46     mkdir $DMG_ROOT/Docs
47
48     echo "Fetching tarball to $WORK_DIR"
49     if [ ! -f $WORK_DIR/$TARBALL ]; then 
50         curl -o $WORK_DIR/$TARBALL http://heanet.dl.sourceforge.net/sourceforge/gnuplot/$TARBALL
51     fi
52     ( 
53         cd $WORK_DIR
54         gnutar xvzf $TARBALL
55     )
56
57     echo "Configuring in $SRC_DIR"
58     (
59         cd $SRC_DIR
60         ./configure --prefix=/usr/local \
61             --without-gd --without-png
62     )
63     echo "#undef'ing HAVE_STPCPY which didn't exist prior to 10.3"
64     (
65         cd $SRC_DIR 
66         cp config.h config_10_3.h
67         sed "s/#define HAVE_STPCPY 1/\/\* #undef HAVE_STPCPY \*\//g" < config.h > config_10_2.h
68         cp config_10_2.h config.h
69     )
70
71     echo "Building in $SRC_DIR"
72     (
73         cd $SRC_DIR
74         make
75     )
76     
77     echo "Installing in $PRODUCTS_DIR"
78     (
79         cd $SRC_DIR
80         make install DESTDIR=$PRODUCTS_DIR
81     )
82
83     echo "Copying demo files to $DMGROOT/Demo"
84     cp $SRC_DIR/demo/* $DMG_ROOT/Demo/.
85     rm -f $DMG_ROOT/demo/Make*
86     rm -f $DMG_ROOT/demo/webify.pl
87
88     echo "Building docs"
89     (
90         cd $SRC_DIR/docs
91         make pdf
92         make gpcard.ps
93         dvipdfm -p a4 -x 1.25in gpcard.dvi
94         # cd psdocs
95         # make pdf
96     )
97     (
98         cd $SRC_DIR/tutorial
99         make pdf
100     )
101
102     echo "Copying docs to $DMGROOT/Docs"
103     cp $SRC_DIR/docs/{gnuplot,gpcard}.pdf $DMG_ROOT/Docs/.
104     cp $SRC_DIR/tutorial/tutorial.pdf $DMG_ROOT/Docs/gnuplot_LateX_tutorial.pdf
105     cp $SRC_DIR/{FAQ,README,Copyright} $DMG_ROOT/Docs/.
106 fi ## skip build
107
108 echo "==== Making distro ===="
109 echo "gnuplot $VERSION$BETA for Mac OS X binary distribution" > build.log
110 echo "Dependencies" >> build.log 
111 otool -L $PRODUCTS_DIR/usr/local/bin/gnuplot | tee -a build.log
112 otool -L $PRODUCTS_DIR/usr/local/libexec/gnuplot/$SHORTVER/gnuplot_x11 | tee -a build.log
113 echo "Installer contents" >> build.log 
114 lsbom $DMG_ROOT/gnuplot.pkg/Contents/Archive.bom | tee -a build.log
115
116 echo "---- Packing up ----"
117 freeze gnuplot.packproj
118
119 echo "---- Creating DMG ----"
120 cp $DISTRO_DIR/ReadMe.rtf $DMG_ROOT/.
121 hdiutil create -volname Gnuplot-$VERSION -fs HFS+ -srcfolder $DMG_ROOT $BUILD_DIR/Gnuplot-$VERSION$BETA.dmg
122
123 echo "---- Done ----"