1 | #!/bin/sh |
---|
2 | |
---|
3 | NAME="[main]" |
---|
4 | |
---|
5 | if [ $# -eq 1 ] && [ $1 = "list" ] |
---|
6 | then |
---|
7 | DO_LIST=1 |
---|
8 | DO_CLEAN=0 |
---|
9 | DO_BUILD=0 |
---|
10 | |
---|
11 | echo "${NAME} Listing all build targets..." |
---|
12 | echo "${NAME} Special targets:" |
---|
13 | echo "${NAME} all" |
---|
14 | echo "${NAME}" |
---|
15 | echo "${NAME} Build targets:" |
---|
16 | elif [ $# -eq 2 ] && [ $1 = "clean" ] |
---|
17 | then |
---|
18 | DO_LIST=0 |
---|
19 | DO_CLEAN=1 |
---|
20 | DO_BUILD=0 |
---|
21 | TARGET=$2 |
---|
22 | |
---|
23 | if [ $TARGET = "all" ] |
---|
24 | then |
---|
25 | echo "${NAME} Cleaning all..." |
---|
26 | DO_ALL=1 |
---|
27 | else |
---|
28 | echo "${NAME} Cleaning '${TARGET}'..." |
---|
29 | DO_ALL=0 |
---|
30 | fi |
---|
31 | elif [ $# -eq 4 ] |
---|
32 | then |
---|
33 | DO_LIST=0 |
---|
34 | DO_CLEAN=0 |
---|
35 | DO_BUILD=1 |
---|
36 | TARGET=$2 |
---|
37 | ARCHITECTURE=$3 # 32 or 64 (bit) |
---|
38 | TARGET_DIR=$4 # where to put the resulting headers and binaries? |
---|
39 | |
---|
40 | if [ $TARGET = "all" ] |
---|
41 | then |
---|
42 | echo "${NAME} Build all dependencies into '${TARGET_DIR}'" |
---|
43 | DO_ALL=1 |
---|
44 | else |
---|
45 | echo "${NAME} Build '${TARGET}' into '${TARGET_DIR}'" |
---|
46 | DO_ALL=0 |
---|
47 | fi |
---|
48 | else |
---|
49 | echo "${NAME} Usage:" |
---|
50 | echo "${NAME} List targets: $0 list" |
---|
51 | echo "${NAME} Clean targets: $0 clean <TARGET>" |
---|
52 | echo "${NAME} Build targets: $0 build <TARGET> <[32|64]> <TARGET_DIR>" |
---|
53 | exit 1 |
---|
54 | fi |
---|
55 | |
---|
56 | check_result() { |
---|
57 | if [ $1 -ne 0 ] |
---|
58 | then |
---|
59 | echo "${NAME} $2 failed: $1" |
---|
60 | echo "${NAME} Exiting..." |
---|
61 | exit 1 |
---|
62 | fi |
---|
63 | } |
---|
64 | |
---|
65 | if [ $DO_CLEAN -eq 1 ] || [ $DO_BUILD -eq 1 ] |
---|
66 | then |
---|
67 | SLEEP=0 # sleep between builds? |
---|
68 | TEMP_DIR="${TARGET_DIR}/_temp" |
---|
69 | fi |
---|
70 | |
---|
71 | # ---------- Clean ---------- |
---|
72 | #if [ $DO_CLEAN -eq 1 ] && [ $DO_ALL -eq 1 ] |
---|
73 | #then |
---|
74 | # rm -rf $TEMP_DIR |
---|
75 | # check_result $? "clean temp directory" |
---|
76 | #fi |
---|
77 | |
---|
78 | # ---------- Build target directory ---------- |
---|
79 | if [ $DO_BUILD -eq 1 ] |
---|
80 | then |
---|
81 | if [ $ARCHITECTURE = "32" ] |
---|
82 | then |
---|
83 | echo "${NAME} Building for 32bit architecture" |
---|
84 | TOOLCHAIN_NAME="mingw-x86" |
---|
85 | elif [ $ARCHITECTURE = "64" ] |
---|
86 | then |
---|
87 | echo "${NAME} Building for 64bit architecture" |
---|
88 | TOOLCHAIN_NAME="mingw-x64" |
---|
89 | else |
---|
90 | echo "${NAME} Unsupported architecture $ARCHITECTURE (must be either 32 or 64)" |
---|
91 | exit 1 |
---|
92 | fi |
---|
93 | |
---|
94 | echo "${NAME} Preparing target directory..." |
---|
95 | |
---|
96 | TARGET_BIN_DIR="${TARGET_DIR}/bin/${TOOLCHAIN_NAME}" |
---|
97 | TARGET_INC_DIR="${TARGET_DIR}/include" |
---|
98 | TARGET_LIB_DIR="${TARGET_DIR}/lib/${TOOLCHAIN_NAME}" |
---|
99 | |
---|
100 | mkdir -p $TARGET_BIN_DIR |
---|
101 | check_result $? "creating target bin directory" |
---|
102 | mkdir -p $TARGET_INC_DIR |
---|
103 | check_result $? "creating target include directory" |
---|
104 | mkdir -p $TARGET_LIB_DIR |
---|
105 | check_result $? "creating target lib directory" |
---|
106 | |
---|
107 | if [ $ARCHITECTURE -eq 32 ] |
---|
108 | then |
---|
109 | export DXSDK_DIR="/mingw32/i686-w64-mingw32" |
---|
110 | |
---|
111 | cp -a /mingw32/bin/libgcc_s_dw2-1.dll $TARGET_BIN_DIR |
---|
112 | check_result $? "copying libgcc" |
---|
113 | cp -a /mingw32/bin/libstdc++-6.dll $TARGET_BIN_DIR |
---|
114 | check_result $? "copying libstdc++" |
---|
115 | cp -a /mingw32/bin/libwinpthread-1.dll $TARGET_BIN_DIR |
---|
116 | check_result $? "copying libwinpthread" |
---|
117 | else |
---|
118 | export DXSDK_DIR="/mingw64/x86_64-w64-mingw32" |
---|
119 | |
---|
120 | cp -a /mingw64/bin/libgcc_s_seh-1.dll $TARGET_BIN_DIR |
---|
121 | check_result $? "copying libgcc" |
---|
122 | cp -a /mingw64/bin/libstdc++-6.dll $TARGET_BIN_DIR |
---|
123 | check_result $? "copying libstdc++" |
---|
124 | cp -a /mingw64/bin/libwinpthread-1.dll $TARGET_BIN_DIR |
---|
125 | check_result $? "copying libwinpthread" |
---|
126 | fi |
---|
127 | |
---|
128 | mkdir -p $TEMP_DIR |
---|
129 | check_result $? "create _temp" |
---|
130 | |
---|
131 | echo "${NAME} Building libraries..." |
---|
132 | fi |
---|
133 | |
---|
134 | # ---------- Build dependencies ---------- |
---|
135 | run_build() { |
---|
136 | if [ $# -ne 2 ] |
---|
137 | then |
---|
138 | exit 1 |
---|
139 | fi |
---|
140 | |
---|
141 | BUILD_NUM=$1 |
---|
142 | BUILD_NAME=$2 |
---|
143 | BUILD_LABEL="${NAME} ${BUILD_NUM}/${NUMBER_OF_BUILDS}" |
---|
144 | |
---|
145 | if [ $DO_LIST -eq 1 ] |
---|
146 | then |
---|
147 | echo "${NAME} $2" |
---|
148 | elif [ $DO_CLEAN -eq 1 ] |
---|
149 | then |
---|
150 | if [ $DO_ALL -eq 1 ] || [ $TARGET = $BUILD_NAME ] |
---|
151 | then |
---|
152 | ./build_${BUILD_NAME}.sh "clean" |
---|
153 | check_result $? "cleaning $BUILD_NAME" |
---|
154 | echo "${BUILD_LABEL} $BUILD_NAME done" |
---|
155 | else |
---|
156 | echo "${BUILD_LABEL} skipping $BUILD_NAME" |
---|
157 | fi |
---|
158 | elif [ $DO_BUILD -eq 1 ] |
---|
159 | then |
---|
160 | if [ $DO_ALL -eq 1 ] || [ $TARGET = $BUILD_NAME ] |
---|
161 | then |
---|
162 | sleep $SLEEP |
---|
163 | ./build_${BUILD_NAME}.sh $TARGET_BIN_DIR $TARGET_INC_DIR $TARGET_LIB_DIR $TEMP_DIR |
---|
164 | check_result $? "building $BUILD_NAME" |
---|
165 | echo "${BUILD_LABEL} $BUILD_NAME done" |
---|
166 | else |
---|
167 | echo "${BUILD_LABEL} skipping $BUILD_NAME" |
---|
168 | fi |
---|
169 | fi |
---|
170 | } |
---|
171 | |
---|
172 | NUMBER_OF_BUILDS=12 |
---|
173 | |
---|
174 | # note: enable either cegui+toluapp OR cegui-0-7 |
---|
175 | run_build 1 "boost" |
---|
176 | run_build 2 "ogredeps" |
---|
177 | run_build 3 "ogre" |
---|
178 | run_build 4 "xerces" |
---|
179 | run_build 5 "pcre" |
---|
180 | run_build 6 "lua" |
---|
181 | #run_build 7 "toluapp" |
---|
182 | #run_build 8 "cegui" |
---|
183 | run_build 8 "cegui-0-7" |
---|
184 | run_build 9 "ogg" |
---|
185 | run_build 10 "vorbis" |
---|
186 | run_build 11 "freealut" |
---|
187 | run_build 12 "tcl" |
---|
188 | |
---|
189 | if [ $DO_BUILD -eq 1 ] || [ $DO_CLEAN -eq 1 ] |
---|
190 | then |
---|
191 | echo "${NAME} done." |
---|
192 | fi |
---|