6 if [[ "x$1" == "x" || "x$1" == "x--help" || "x$1" == "x-h" ]]; then
11 The first form typically performs tasks to build a version of lyx from scratch.
13 The second form is used to create a development directory (\$LYXDEVEL)
14 and check out the CVS module 'lyx-devel' from the CVS server.
18 -n Only print commands, do not actually run
19 -f config-file Name of configuration file to use
20 -l log-file Set name of log-file
21 --no-rm Don't remove previous build directory
22 --no-cvs Don't run cvs update and autogen.sh
23 --no-configure Don't run configure
24 --no-make Don't run make
26 --version Report version
29 # Read commands from xforms-devel.cfg
30 $ $0 -f etc/xforms-devel.cfg
32 Note that the configuration file is first looked for in the current
33 directory, and then relative to where the script is located.
35 For further information, see
36 http://wiki.lyx.org/pmwiki.php/DevelScripts/BuildLyx
42 if [[ "x$1" == "x--version" ]]; then printf "$S0 1.0\n"; exit 0; fi
44 # Use: Verbose 1 "Only printed if Verbose >= 1, arg: %s" "an argument"
45 # The first numeric argument can be skipped if the condition is onl that
48 if [[ ${#1} -eq 1 && $Verbosity -lt $1 ]]; then return; fi;
49 if [[ ${#1} -ne 1 && $Verbosity -eq 0 ]]; then return; fi;
50 if [[ ${#1} -eq 1 ]]; then shift; fi;
57 Verbose 0 "# ""$@" | tee --append $LogFile
60 # Use: Error -1 "This argument is wrong: %s" "an argument"
64 printf "%s: Error(%d) " "`basename $0`" $ERROR_CODE
71 # For some reason, 'cd' doesn't work when |tee is used...
73 if (($DO)); then msg=""; else msg="## "; fi;
74 if (($Verbosity >= 1)); then Log "%s%s" "$msg" "$*"; fi;
77 if [[ "$1" == "cd" || "$1" == "pushd" || "$1" == "popd" ]]; then
78 printf "%s\n" "$*" >> $LogFile
82 "$@" | tee --append $LogFile ;
90 function ReadConfiguration() {
91 Verbose 2 "Looking for configuration file"
93 Verbose 3 "Checking for %s" "$FIL"
94 if [[ -r $FIL ]]; then
95 Verbose 1 "Reading %s" "$FIL"
98 elif [[ -r $D0/$FIL ]]; then
99 Verbose 1 "Reading %s/%s" "$D0" "$FIL"
101 let ++ConfigFilesRead
103 Verbose 2 "Configuration file %s not found" "$FIL"
106 if (( $ConfigFilesRead > 0 )); then
107 Verbose 2 "Configuration after reading configuration files:"
108 if (( $Verbosity >= 2 )); then ShowConfiguration; fi
113 # Login to CVS server or checkout a cvs module
114 # Syntax: CVS_Command login
115 # or: CVS_Command checkout <DestDir>
116 # where <DestDir> is the name of the destination directory
117 # (relative to $LYXDEVEL which is created if necessary).
118 # The release tag that's checked out is taken from $LYXTAG
119 # Example: CVS_Command checkout $LYXTAG
120 # will checkout to a directory with the same name as the tag
122 function CVS_Command() {
123 if [[ "$1" == "login" ]]; then
124 Verbose 0 "The anonymous password is 'lyx'"
125 Do cvs -d $LYX_CVS_SERVER login
126 elif [[ "$1" == "checkout" ]]; then
127 Do mkdir -p $LYXDEVEL;
129 Verbose 0 "\n\nGo have coffee or something..."
130 Do cvs -d $LYX_CVS_SERVER co -d $2 -r $LYXTAG $LYX_CVS_MODULE
136 # Set default values of variables
139 Verbosity=0 # Controls the level of verbosity
140 DO=1 # Set to zero if nothing should be done
141 LogFile=`pwd`/build-lyx.log
143 # Script specific variables
144 LYX_CVS_SERVER=":pserver:anoncvs@anoncvs.us.lyx.org:/cvs/lyx"
145 LYX_CVS_MODULE="lyx-devel"
146 MODULE_LYX=lyx/devel/latest-xforms
150 DO_RM=1; # Remove previous build directory?
151 DO_CVS=1; # Do CVS update
152 DO_CONFIGURE=1; # Run configure
153 DO_MAKE=1; # Run make
154 USE_MODULES=0; # Use modules?
156 function ShowConfiguration(){
157 if (( $Verbosity >= 2 )); then
158 Verbose "Variables in the script:"
159 Verbose "DO=%s" "$DO"
160 Verbose "buildDir=%s" "$buildDir"
161 Verbose "BuildPostfix=%s" "$BuildPostfix"
162 Verbose "LYXDEVEL=%s" "$LYXDEVEL"
163 Verbose "LYXTAG=%s, LYXFRONTEND=%s" "$LYXTAG" "$LYXFRONTEND"
168 if (($USE_MODULES)); then
169 . /usr/local/lib/module/default/init/bash
170 module rm lyx gcc # Remove any lyx and gcc modules
175 for ARG in "$@"; do if [[ "$ARG" == "-v" ]]; then let ++Verbosity; fi; done;
177 until [[ $# -eq 0 ]]; do
179 -v) ;; # Already parsed for
182 --no-cvs) DO_CVS=0 ;;
183 --no-make) DO_MAKE=0 ;;
184 --no-configure) DO_CONFIGURE=0 ;;
185 -f) ReadConfiguration $2; shift ;;
186 -l) LogFile=$2; shift ;;
187 -*) Error -1 "Unknown option: %s" "$1" ;;
189 *) Error -2 "Unkown argument: %s" "$1" ;;
194 if (( $ConfigFilesRead == 0 )); then
195 Error -2 "No configuration file specified!"
198 # Initialize log-file
199 Verbose 0 "Log-file=%s\n" "$LogFile"
201 printf "# --------------------------------\n"\
202 "# Log file from executing:\n# %s$ %s %s\n" \
203 "`pwd`" "$0""$savedArgs" > $LogFile
204 Log "Date: %s\n" "`date`"
206 # Verify validity of arguments
207 # if [[ "x$Adr" == "x" ]]; then Error "No address given!"; fi;
210 # -----------------------
211 # Actually do stuff...
214 # Handle initialization
215 if [[ "$1" == "init" ]]; then
217 CVS_Command checkout $LYXTAG
222 if (($USE_MODULES)); then
223 module add $MODULE_LYX $MODULE_GCC 2>&1 1>>$LogFile
224 if (($?)); then Error -1 "While loading modules"; fi;
227 # Create buildDir if necessary
228 if [[ "$buildDir" == "" ]]; then
229 buildDir=$LYXDEVEL/$LYXTAG/build-$LYXFRONTEND
230 if [[ "x$BuildPostfix" != "x" ]]; then
231 buildDir="$buildDir-$BuildPostfix";
234 Log "Build directory=%s" "$buildDir"
237 GCC_VERSION="`gcc --version`"
238 Log "Using %s" "${GCC_VERSION%%Copyright*}"
241 Log "Erasing and recreating build directory: %s" "$buildDir"
242 Do rm -rf $buildDir && Do mkdir -p $buildDir
243 if (($?)); then Error -2 "While erasing/creating build directory"; fi
245 Log "Skipping erasing build directory"
248 if (($DO_RM || $DO_CVS)); then
249 Log "Updating source and then running autogen.sh"
250 cd $LYXDEVEL/$LYXTAG && Do cvs -q update -d && Do ./autogen.sh
251 if (($?)); then Error -3 "While cvs update or autogen.sh"; fi
253 Log "Skipping 'cvs update' and autogen"
256 if (($DO_RM || $DO_CVS || $DO_CONFIGURE)); then
257 Log "Running configure"
258 if (($DO)); then cd $buildDir; fi
259 Do ../configure --prefix=$LYXPREFIX ${OPTS_CONFIGURE[*]}
260 if (($?)); then Error -4 "While running configure"; fi
262 Log "Skipping configure"
265 if (($DO_MAKE)); then
268 if (($?)); then Error -5 "While running make"; fi