|
1 #!/bin/bash |
|
2 # |
|
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
4 # |
|
5 # Copyright 2011 Olaf Wintermann. All rights reserved. |
|
6 # |
|
7 # Redistribution and use in source and binary forms, with or without |
|
8 # modification, are permitted provided that the following conditions are met: |
|
9 # |
|
10 # 1. Redistributions of source code must retain the above copyright notice, |
|
11 # this list of conditions and the following disclaimer. |
|
12 # |
|
13 # 2. Redistributions in binary form must reproduce the above copyright |
|
14 # notice, this list of conditions and the following disclaimer in the |
|
15 # documentation and/or other materials provided with the distribution. |
|
16 # |
|
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 # POSSIBILITY OF SUCH DAMAGE. |
|
28 # |
|
29 |
|
30 OS=`uname -s` |
|
31 OS_VERSION=`uname -r` |
|
32 PREFIX=/opt/mk12 |
|
33 |
|
34 # |
|
35 # parse arguments |
|
36 # |
|
37 for ARG in $@ |
|
38 do |
|
39 if [[ $ARG == --prefix=* ]]; then |
|
40 PREFIX=${ARG:9} |
|
41 elif [[ $ARG == --toolkit=* ]]; then |
|
42 # todo: check for invalid toolkit |
|
43 TOOLKIT=${ARG:10} |
|
44 elif [ $ARG = "--help" ]; then |
|
45 # todo: print help text |
|
46 echo "no help yet" |
|
47 exit 0 |
|
48 fi |
|
49 done |
|
50 |
|
51 # |
|
52 # check_pkgconfig_lib() |
|
53 # |
|
54 # arg1: display package name |
|
55 # arg2: pkg-config package name |
|
56 # |
|
57 check_pkgconfig_lib() |
|
58 { |
|
59 printf "checking for " |
|
60 printf $1 |
|
61 printf "... " |
|
62 pkg-config $2 |
|
63 RESULT=$? |
|
64 if [ $RESULT -eq 0 ]; then |
|
65 echo "ok" |
|
66 else |
|
67 echo "not found" |
|
68 echo |
|
69 echo "missing package" $1 |
|
70 exit -1 |
|
71 fi |
|
72 } |
|
73 |
|
74 |
|
75 # |
|
76 # check OS and libraries |
|
77 # |
|
78 |
|
79 printf "checking for toolchain... " |
|
80 if [ $OS = SunOS ]; then |
|
81 BUILD_CONFIG=suncc |
|
82 echo "suncc" |
|
83 fi |
|
84 |
|
85 if [ $OS = Linux ]; then |
|
86 BUILD_CONFIG=gcc |
|
87 echo "gcc" |
|
88 fi |
|
89 |
|
90 if [ $OS = Darwin ]; then |
|
91 BUILD_CONFIG=osx |
|
92 echo "gcc" |
|
93 fi |
|
94 |
|
95 |
|
96 if [ $OS != Darwin ]; then |
|
97 check_pkgconfig_lib "libxml2" "libxml-2.0" |
|
98 fi |
|
99 |
|
100 if [ -z $TOOLKIT ]; then |
|
101 printf "checking for gui library... " |
|
102 if [ $OS = SunOS ]; then |
|
103 if [ $OS_VERSION = 5.10 ]; then |
|
104 TOOLKIT=gtk2legacy |
|
105 else |
|
106 TOOLKIT=gtk2 |
|
107 fi |
|
108 echo "gtk2" |
|
109 elif [ $OS = Darwin ]; then |
|
110 TOOLKIT=cocoa |
|
111 echo "Cocoa" |
|
112 else |
|
113 pkg-config gtk+-3.0 |
|
114 RESULT=$? |
|
115 if [ $RESULT -eq 0 ]; then |
|
116 TOOLKIT=gtk3 |
|
117 echo "gtk3" |
|
118 else |
|
119 pkg-config gtk+-2.0 |
|
120 RESULT=$? |
|
121 if [ $RESULT -eq 0 ]; then |
|
122 TOOLKIT=gtk2legacy |
|
123 echo "gtk2" |
|
124 else |
|
125 echo "not found" |
|
126 exit 1 |
|
127 fi |
|
128 fi |
|
129 fi |
|
130 fi |
|
131 |
|
132 |
|
133 # generate config.mk |
|
134 |
|
135 cat > config.mk << __EOF__ |
|
136 # |
|
137 # config.mk generated by configure |
|
138 # |
|
139 |
|
140 PREFIX = ${PREFIX} |
|
141 |
|
142 include \$(BUILD_ROOT)/make/${BUILD_CONFIG}.mk |
|
143 |
|
144 __EOF__ |
|
145 |
|
146 # toolkit config |
|
147 make/configure_${TOOLKIT}.sh |
|
148 |
|
149 |
|
150 echo "configure finished" |
|
151 echo |
|
152 echo " PREFIX: $PREFIX" |
|
153 echo " BUILD_CONFIG: $BUILD_CONFIG" |
|
154 echo " TOOLKIT: $TOOLKIT" |
|
155 echo |
|
156 |