root/tags/mcxtrace_beta/mkdist

Revision 2728, 10.0 KB (checked in by erkn, 2 years ago)

merged branch farhi_configure_100204 into trunk after testing

  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# Simple script for setting up a mcstas/mcxtrace distribution package.
4#
5# To be called with one/two input parameter(s) - distribution tail filename, e.g.
6#
7# ./mkdist version          -> ../mcstas-version.tar.gz
8# ./mkdist version mcxtrace -> ../mcxtrace-version.tar.gz
9#
10# Assumes you have write access to ..
11#
12# PW, risoe, 20030123
13#
14#   This file is part of the McStas neutron ray-trace simulation package
15#   Copyright (C) 1997-2006, All rights reserved
16#   Risoe National Laborartory, Roskilde, Denmark
17#   Institut Laue Langevin, Grenoble, France
18#
19#   This program is free software; you can redistribute it and/or modify
20#   it under the terms of the GNU General Public License as published by
21#   the Free Software Foundation; version 2 of the License.
22#
23#   This program is distributed in the hope that it will be useful,
24#   but WITHOUT ANY WARRANTY; without even the implied warranty of
25#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26#   GNU General Public License for more details.
27#
28#   You should have received a copy of the GNU General Public License
29#   along with this program; if not, write to the Free Software
30#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31
32# define version and symbols that will be replaced in many places
33if [ "y$2" = "ymcxtrace" ]; then
34  MCCODE_TARNAME=mcxtrace
35  MCCODE_NAME=McXtrace
36else
37  MCCODE_TARNAME=mcstas
38  MCCODE_NAME=McStas
39fi
40MCCODE_VERSION=$1
41MONTH=`date +"%b"`
42DAY=`date +"%d"`
43YEAR=`date +"%Y"`
44MCCODE_DATE="$MONTH. $DAY, $YEAR"
45MCCODE_STRING="$MCCODE_NAME $MCCODE_VERSION - $MONTH. $DAY, $YEAR"
46
47# Create temporary workdir:
48PW=`pwd`
49TMPDIR=$PWD/..
50DIST=$TMPDIR/$MCCODE_TARNAME-$MCCODE_VERSION
51
52# Copy current PW checkout to DIST
53cp -rp $PW $DIST
54
55# Create the doc's from tex - if a checkout is avail.
56if [ -d $PW/../../McStasTeX/trunk ] ;
57then
58  cd $PW/../../McStasTeX/trunk
59  ./build $MCCODE_VERSION
60 
61  # copy the doc in DIST/doc. Only use PDF files in distro.
62  mv $MCCODE_TARNAME-$MCCODE_VERSION-manual.pdf $DIST/doc/manuals/$MCCODE_TARNAME-manual.pdf
63  mv $MCCODE_TARNAME-$MCCODE_VERSION-components.pdf $DIST/doc/manuals/$MCCODE_TARNAME-components.pdf
64  cp -r $DIST/doc $DIST/lib
65fi
66
67# Go in DIST, clean up CVS/SVN information
68cd $DIST
69echo "Clean up SVN info"
70find . -name .svn -exec rm -rf \{\} \; 2> /dev/null
71# Make sure that all comps and instrs have unix linefeeds
72echo "Apply dos2unix"
73find . -name \*.comp  -exec dos2unix \{\} \;
74find . -name \*.instr -exec dos2unix \{\} \;
75
76# Put in new version info:
77# MCCODE_STRING="MCCODE_NAME MCCODE_VERSION - MCCODE_DATE"
78echo "Set version $MCCODE_VERSION and date"
79find . -wholename './setversion' -prune -o -type d -prune -o -path ./src/McStasTest -exec ./setversion \{\} $MCCODE_VERSION \;
80find . -wholename './setyear'    -prune -o -type d -prune -o -path ./src/McStasTest -exec ./setyear \{\} \;
81
82# we update all package/version strings
83echo "Set package $MCCODE_VERSION information"
84for iter in 1 2 3;
85do
86for file in configure.in lib/tools/perl/mccode_reconfigure.in src/mccode.h lib/share/mccode-r.h src/mcformat.c doc/man/*.1 support/deb/debcreate support/deb/control support/Win32/install/mcstas.nsi build.bat  ;
87        do
88          sed 's/@MCCODE_STRING@/'$MCCODE_NAME'-'$MCCODE_VERSION' - '$MONTH'. '$DAY', '$YEAR'/' $file > $file.tmp
89    sed 's/@MCCODE_NAME@/'$MCCODE_NAME'/'                                                 $file.tmp > $file
90    sed 's/@MCCODE_TARNAME@/'$MCCODE_TARNAME'/'                                           $file > $file.tmp
91    sed 's/@MCCODE_VERSION@/'$MCCODE_VERSION'/'                                           $file.tmp > $file
92    sed 's/@MCCODE_DATE@/'$MONTH'. '$DAY', '$YEAR'/'                                      $file > $file.tmp
93    mv $file.tmp $file
94        done
95done
96chmod a+x support/deb/debcreate
97
98# Create the doc's from tex - if a checkout is avail.
99cd $DIST
100if [ -d $DIST/doc/install_docs/tex ] ;
101then
102  # Create ps/pdf/html based install info
103  cd $DIST/doc/install_docs/tex
104  latex install
105  latex install
106  whichdvipdf=`which dvipdf`
107  if [ -e "$whichdvipdf" ] ;
108  then
109      echo "Generate install PDF files using dvipdf (better quality than ps2pdf)"
110      dvipdf install.dvi install.pdf
111  else
112      echo "Generate install PDF files using ps2pdf"
113      dvips -o install.ps install.dvi
114      ps2pdf install.ps install.pdf
115  # gzip install.ps
116      rm *.ps *.ps.gz
117  fi
118 
119  mkdir ../html
120  latex2html -local_icons -dir ../html install.tex
121  # clean up
122  rm install.aux
123  rm install.log
124  cd $DIST/doc/tutorial
125  # Update the tutorial files
126  ./update
127  rm update
128  mkdir $DIST/lib/doc
129  cp -r $DIST/doc/install_docs/ $DIST/lib/doc
130  cp -r $DIST/doc/tutorial/ $DIST/lib/doc/
131  cp -r $DIST/doc/man/ $DIST/lib/doc/
132fi 
133cd $DIST
134
135# Create configure
136autoconf -o configure $CONFIGURE_IN
137#chmod a+x configure
138autoconf -o lib/tools/perl/${MCCODE_TARNAME}_reconfigure.in lib/tools/perl/mccode_reconfigure.in
139mv lib/tools/perl/mccode_config.perl.in lib/tools/perl/${MCCODE_TARNAME}_config.perl.in
140rm lib/tools/perl/mccode_reconfigure.in
141
142# run lex, yacc (assuming linux - flex -i & bison -v -d)
143cd src
144flex -i instrument.l
145bison -v -d instrument.y
146cd ..
147
148# Set the INSTALL environment variable to make the src archive
149# default to ./install-sh in the contributed Makefile.
150# Note: the -c is needed to preserve mcdoc.fixpl which is run at make install
151export INSTALL="./install-sh -c"
152
153# Also, do a ./configure to create Makefile and mccode_config.perl
154# These will be dependent on this system, ofcourse...
155./configure
156# Select scilab as default plotter
157make pgplot
158
159# Clean up
160rm TODO.txt
161rm mkdist
162rm setversion
163rm setyear
164rm header
165# Make new runs of configure not dependent of this system...
166rm config.*
167cd ..
168
169# Create tar archive
170tar cfz $PW/../$MCCODE_TARNAME-$MCCODE_VERSION-src.tar.gz $MCCODE_TARNAME-$MCCODE_VERSION
171
172# Do a 'make' for creation of binary version (should apply to 'any' Unix)
173cd $PW
174cd $DIST
175
176# Default again to Linux' /usr/bin/install -c (or whatever ./configure finds)
177export INSTALL=
178./configure
179# Select pgplot as default plotter
180make pgplot
181
182make
183UNAME=`uname`
184MACH=`uname -m`
185# Up to now, this is always done on intel...
186PROC=Intel
187cd ..
188
189# Create tar archive
190tar cfz $PW/../$MCCODE_TARNAME-$MCCODE_VERSION-$MACH-$PROC-$UNAME.tar.gz $MCCODE_TARNAME-$MCCODE_VERSION
191
192# Remove temporary dir
193# rm -rf $TMPDIR
194
195# Create .tar.gz archive for building a binary Windows version
196cd $PW
197cd $DIST
198make clean
199cd src
200flex -i instrument.l
201bison -v -d instrument.y
202cd ..
203./configure
204sed 's/DOZIP="0"/DOZIP="1"/' build.bat > build.bat.new
205sed 's/DONSIS="0"/DONSIS="1"/' build.bat.new > build.bat
206cp support/Win32/install/which.exe .
207cd ..
208tar cfz $PW/../$MCCODE_TARNAME-$MCCODE_VERSION-Win32-src.tar.gz $MCCODE_TARNAME-$MCCODE_VERSION
209echo "  "
210echo "========================================================================="
211echo "mkdist: Distro creation for $MCCODE_STRING"
212if [ `which makensis` ]; then
213    cd -
214    ./configure
215    # Make sure we default to PGPLOT plotter
216    make pgplot
217    make mcstas.win32
218    cp mcstas.ini ..
219    cp mcstas.nsi ..
220    cp mcstas.bmp ..
221    cp LICENSE.rtf ..
222    cd ..
223    zip -r $MCCODE_TARNAME-$MCCODE_VERSION-i686-Intel-Win32.zip $MCCODE_TARNAME-$MCCODE_VERSION
224    cp winsupport/* .
225    makensis mcstas.nsi
226    echo Created Win32 binary packages: `ls *zip *exe`
227else
228    echo Binary versions for Win32 NOT created
229fi
230echo
231echo
232echo Your $MCCODE_STRING dist packages are placed in
233echo ../$MCCODE_TARNAME-$MCCODE_VERSION-src.tar.gz
234echo ../$MCCODE_TARNAME-$MCCODE_VERSION-$MACH-$PROC-$UNAME.tar.gz
235echo ../$MCCODE_TARNAME-$MCCODE_VERSION-Win32-src.tar.gz
236echo
237echo NOTE: Win32 version must be built using \'build.bat\' of the Win32-src package
238echo
239if [ -d $PW/../../McStasTeX/trunk ] ;
240then
241echo Your $MCCODE_STRING doc packages are placed in
242echo ../$MCCODE_TARNAME-$MCCODE_VERSION-manual.ps.gz
243echo ../$MCCODE_TARNAME-$MCCODE_VERSION-manual.pdf
244echo ../$MCCODE_TARNAME-$MCCODE_VERSION-components.ps.gz
245echo ../$MCCODE_TARNAME-$MCCODE_VERSION-components.pdf
246fi
247echo
248echo WARNING: Please install to a test system and run the following tools
249echo before release:
250echo
251echo compiletest.sh \(check if all examples compile\)
252echo mcrun --test \(validation test of selected instruments\)
253echo
254echo Follow instructions in ../adm to publish on the web.
255echo
256
257echo Build packages from `pwd`
258# In case of mkfs.hfsplus available in /sbin we'll create the
259# DMG file for Mac OS X
260if [ -e /sbin/mkfs.hfsplus ]
261then
262    # Note: DMG file needs enough space to hold the support tools plus
263    # our own code. April 2008 this is about 120 megs...
264    dd if=/dev/zero of=./$MCCODE_TARNAME-$MCCODE_VERSION.dmg bs=1M count=130
265    /sbin/mkfs.hfsplus -v $MCCODE_NAME ./$MCCODE_TARNAME-$MCCODE_VERSION.dmg
266    # Likely needs root level access:
267    sudo mkdir /mnt/dmg
268    sudo mount -t hfsplus -o loop ./$MCCODE_TARNAME-$MCCODE_VERSION.dmg /mnt/dmg
269    # Copy the ./adm/OSX/DMG stuff to the mountpoint
270    sudo cp -rp ./adm/OSX/DMG/Applications /mnt/dmg
271    sudo cp ./adm/OSX/DMG/README.TXT /mnt/dmg
272    # Clear out CVS stuff
273    sudo find /mnt/dmg -type d -name CVS -exec rm -rf \{\} \;
274    # Copy McStas there
275    sudo cp ./$MCCODE_TARNAME-$MCCODE_VERSION-src.tar.gz /mnt/dmg/Applications
276    # Unmount
277    sudo umount /mnt/dmg
278    sudo rm -rf /mnt/dmg
279    ls -l ./$MCCODE_TARNAME-$MCCODE_VERSION.dmg
280fi
281
282
283# In case of a debian build host, we also build an .deb
284# (.rpm was tried using alien - did not work too well)
285if [ -e /etc/debian_version ]
286then
287  if [ -e etch-chroot ]
288  then
289    echo Proceeding to .deb build
290    # First, clean up in case of previous McStas installs in the chrooot
291    sudo mkdir -p etch-chroot/build
292    sudo rm -f etch-chroot/usr/local/bin/*
293    sudo rm -rf etch-chroot/usr/local/lib/*
294    sudo rm -rf etch-chroot/usr/local/pgplot
295    sudo cp $MCCODE_TARNAME-$MCCODE_VERSION/deb/debcreate etch-chroot/root
296    sudo cp $MCCODE_TARNAME-$MCCODE_VERSION-src.tar.gz etch-chroot/root
297    sudo chroot etch-chroot /root/debcreate
298    echo
299    echo
300    echo Build packages created:
301    echo
302    cp etch-chroot/build/*deb .
303    ls -lf $MCCODE_TARNAME-$MCCODE_VERSION*.*
304    echo
305  else
306    echo You need a chroot environment based on debootstrap in etch-chroot before building deb packages
307  fi
308fi
Note: See TracBrowser for help on using the browser.