Initial commit
[fillmore] / configure
1 #! /bin/bash
2 #
3 # Copyright 2009 Yorba Foundation
4 #
5 # This software is licensed under the GNU LGPL (version 2.1 or later).
6 # See the COPYING file in this distribution. 
7
8 CONFIG_IN=configure.mk
9
10 configure_help() {
11     printf "\nUsage:\n"
12     printf "\t./configure [OPTIONS]...\n"
13     printf "\n"
14     printf "Options:\n"
15     printf "\t-h, --help\t\tPrint this help and exit.\n"
16     printf "\t--assume-pkgs\t\tTurn off package version checking.\n"
17     printf "\t--build=DIR\t\tBuild secondary files in DIR.\n"
18     printf "\t--debug | --release\tBuild executable for debugging or release.\n"
19     printf "\t\t\t\t[--release]\n"
20     printf "\t--define=SYMBOL\t\tDefine a symbol for the Vala compiler.\n"
21     printf "\n"
22 }
23
24 abort() {
25     printf "%s: Invalid argument %s\n" $0 $1
26     configure_help
27     exit 1
28 }
29
30 while [ $# != 0 ]
31 do
32     option=`echo $1 | sed 's/=.*//'`
33     if [ `echo $1 | grep '='` ]
34     then
35         value=`echo $1 | sed 's/.*=//'`
36     fi
37
38     case $option in
39         -h | --help)        configure_help
40                             exit 0
41                             ;;
42         
43         --assume-pkgs)      variables="${variables}ASSUME_PKGS=1\n"
44                             ;;
45         
46         --build)            if [ ! $value ]
47                             then
48                                 abort $1
49                             fi
50                             
51                             variables="${variables}BUILD_DIR=$value\n"
52                             variables="${variables}MARINA_VAPI=../marina/$value/marina.vapi\n"
53                             ;;
54         
55         --debug)            variables="${variables}BUILD_RELEASE=\nBUILD_DEBUG=1\n"
56                             ;;
57         
58         --release)          variables="${variables}BUILD_DEBUG=\nBUILD_RELEASE=1\n"
59                             ;;
60         
61         --define)           variables="${variables}USER_VALAFLAGS+=--define=$value\n"
62                             ;;
63                             
64
65         *)                  if [ ! $value ]
66                             then
67                                 abort $1
68                             fi
69                             
70                             variables="${variables}${option}=${value}\n"
71                             ;;
72     esac
73     
74     shift
75 done
76
77 rm -f $CONFIG_IN
78 if [ $variables ]
79 then
80     echo -e -n $variables > $CONFIG_IN
81 fi
82 echo "CONFIG_IN=../../${CONFIG_IN}" >> $CONFIG_IN
83
84 printf "Configured.  Type 'make' to build\n"