Browse code

rename setup-xcode to xcode, experimentally try to add CFLAGS to cmake and configure projects

Nat! authored on 27-09-2015 14:58:23
Showing 8 changed files
... ...
@@ -3,6 +3,7 @@ mulle-bootstrap-build.sh \
3 3
 mulle-bootstrap-clean.sh \
4 4
 mulle-bootstrap-fetch.sh \
5 5
 mulle-bootstrap-functions.sh \
6
+mulle-bootstrap-gcc.sh \
6 7
 mulle-bootstrap-init.sh \
7 8
 mulle-bootstrap-local-environment.sh \
8 9
 mulle-bootstrap-setup-xcode.sh \
... ...
@@ -24,7 +25,7 @@ mulle-bootstrap.chk:	mulle-bootstrap
24 25
 		- ( shellcheck $(SHELLFLAGS) $< || touch $@ )
25 26
 
26 27
 install:
27
-		./install.sh
28
+	@ ./install.sh
28 29
 
29 30
 clean:
30 31
 	@- rm *.chk
... ...
@@ -3,10 +3,22 @@
3 3
 # (c) 2015, coded by Nat!, Mulle KybernetiK
4 4
 #
5 5
 
6
+# Escape sequence and resets
7
+C_RESET="\033[0m"
8
+
9
+# Foreground colours
10
+C_BLACK="\033[0;30m"   C_RED="\033[0;31m"    C_GREEN="\033[0;32m"
11
+C_YELLOW="\033[0;33m"  C_BLUE="\033[0;34m"   C_MAGENTA="\033[0;35m"
12
+C_CYAN="\033[0;36m"    C_WHITE="\033[0;37m"  C_BR_BLACK="\033[0;90m"
13
+
6 14
 #
7 15
 # restore colors if stuff gets wonky
8 16
 #
9
-trap 'echo "\033[0m"' TERM EXIT
17
+trap 'echo "${C_RESET}"' TERM EXIT
18
+
19
+#
20
+# https://github.com/hoelzro/useful-scripts/blob/master/decolorize.pl
21
+#
10 22
 
11 23
 prefix=${1:-"/usr/local"}
12 24
 shift
... ...
@@ -23,14 +35,14 @@ then
23 35
    exit 1
24 36
 fi
25 37
 
26
-echo "\033[0;37m"
38
+echo "${C_WHITE}"
27 39
 
28 40
 for i in mulle*bootstrap
29 41
 do
30 42
    mkdir -p "${bin}" 2> /dev/null
31 43
    sed "s|/usr/local/libexec/mulle-bootstrap|${libexec}|g" < "${i}" > "${bin}/$i" || exit 1
32 44
    chmod "${mode}" "${bin}/${i}" || exit 1
33
-   echo "installed $bin/$i" >&2
45
+   echo "install: ${C_MAGENTA}$bin/$i${C_WHITE}" >&2
34 46
 done
35 47
 
36 48
 
... ...
@@ -43,8 +55,8 @@ done
43 55
 if [ -d "test" ]
44 56
 then
45 57
    # use attractive colors :)
46
-   echo "\033[0;32mIf you are new to mulle-bootstrap I would suggest checking out" >&2
47
-   echo "the \033[0;33mREADME.md\033[0;32m in \033[0;36m`pwd`/test\033[0;32m and doing the examples." >&2
58
+   echo "${C_GREEN}If you are new to mulle-bootstrap I would suggest checking out" >&2
59
+   echo "the ${C_YELLOW}README.md${C_GREEN} in ${C_CYAN}./test${C_GREEN} and doing the examples." >&2
48 60
 fi
49 61
 
50 62
 # for people who source us
... ...
@@ -103,8 +103,8 @@ case "${command}" in
103 103
       mulle-bootstrap-init.sh "$@" || exit 1
104 104
       ;;
105 105
 
106
-   setup-xcode)
107
-      mulle-bootstrap-setup-xcode.sh "$@"|| exit 1
106
+   setup-xcode|xcode)
107
+      mulle-bootstrap-xcode.sh "$@"|| exit 1
108 108
       ;;
109 109
 
110 110
    tag)
... ...
@@ -119,13 +119,14 @@ case "${command}" in
119 119
       echo    "" >& 2
120 120
       echo    " Common maintainer commands:" >&2
121 121
       echo    "   init      : initializes a bootstrap project" >&2
122
-      echo    "   setup-xcode : sets up the xcodeproj settings" >&2
122
+      echo    "   xcode [o] : sets up the xcodeproj settings" >&2
123
+      echo    "               with [o=remove] removes settings again." >&2
123 124
       echo    "   tag       : tag this project and fetched repositories" >&2
124 125
       echo    "" >& 2
125 126
       echo    " Specialized commands:" >&2
126 127
       echo    "   build     : builds fetched repositories" >&2
127 128
       echo    "   fetch [o] : fetches required repositories recursively." >&2
128
-      echo    "               whith [o=:nonrecursive] fetches non recursively." >&2
129
+      echo    "               whith [o=nonrecursive] fetches non recursively." >&2
129 130
       echo    "   clean [o] : cleans intermediate build files." >&2
130 131
       echo    "               with [o=dist] cleans clones and dependencies too." >&2
131 132
       exit 1
... ...
@@ -30,6 +30,7 @@
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 
32 32
 .  mulle-bootstrap-local-environment.sh
33
+.  mulle-bootstrap-gcc.sh
33 34
 
34 35
 
35 36
 CLEAN_BEFORE_BUILD=`read_local_setting "clean"`
... ...
@@ -134,33 +135,17 @@ determine_suffix()
134 135
 }
135 136
 
136 137
 
137
-gcc_sdk_parameter()
138
+cmake_sdk_parameter()
138 139
 {
139
-   local mode
140
-   local sdk
141
-   local suffix
142 140
    local sdkpath
143 141
 
144
-
145
-   mode="$1"
146
-   sdk="$2"
147
-   suffix="$2"
148
-
149
-   if [ "`uname`" = "Darwin" ]
142
+   sdkpath="`gcc_sdk_parameter \"$1\" \"$2\"`"
143
+   if [ "${sdkpath}" != "" ]
150 144
    then
151
-      if [ "${sdk}" != "Default" ]
152
-      then
153
-         sdkpath="`xcrun --sdk macosx --show-sdk-path`"
154
-         if [ "${sdkpath}" = "" ]
155
-         then
156
-            fail "SDK \"${sdk}\" is not installed"
157
-         fi
158
-         echo '-DCMAKE_OSX_SYSROOT='"${sdkpath}"
159
-      fi
145
+      echo '-DCMAKE_OSX_SYSROOT='"${sdkpath}"
160 146
    fi
161 147
 }
162 148
 
163
-
164 149
 #
165 150
 # remove old builddir, create a new one
166 151
 # depending on mode cmake with flags
... ...
@@ -188,7 +173,15 @@ build_cmake()
188 173
 
189 174
    mapped=`read_build_setting "$name" "cmake-${mode}.map" "${mode}"`
190 175
    suffix=`determine_suffix "${mode}" "${sdk}"`
191
-   sdk=`gcc_sdk_parameter "${mode}" "${sdk}" "${suffix}"`
176
+   sdk=`cmake_sdk_parameter "${mode}" "${sdk}" "${suffix}"`
177
+
178
+   local other_cflags
179
+   local other_cppflags
180
+   local other_ldflags
181
+
182
+   other_cflags=`gcc_cflags_value "${name}"`
183
+   other_cppflags=`gcc_cppflags_value "${name}"`
184
+   other_ldflags=`gcc_ldflags_value "${name}"`
192 185
 
193 186
    owd="${PWD}"
194 187
    # to avoid warning make sure directories are all there
... ...
@@ -204,7 +197,6 @@ build_cmake()
204 197
       [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode}" ] || exit 1
205 198
       [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
206 199
 
207
-
208 200
       #
209 201
       # cmake doesn't seem to "get" CMAKE_CXX_FLAGS or -INCLUDE
210 202
       #
... ...
@@ -217,12 +209,15 @@ build_cmake()
217 209
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
218 210
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
219 211
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
212
+${other_cflags} \
220 213
 ${sdk}" \
221 214
 "-DCMAKE_CXX_FLAGS=\
222 215
 -I${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
223 216
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
224 217
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
225
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}" \
218
+-F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
219
+${other_cppflags} \
220
+${sdk}" \
226 221
 "-DCMAKE_LD_FLAGS=\
227 222
 -L${relative}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}${suffix} \
228 223
 -L${relative}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mode} \
... ...
@@ -230,6 +225,7 @@ ${sdk}" \
230 225
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
231 226
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
232 227
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
228
+${other_ldflags} \
233 229
 ${sdk}" \
234 230
 "${relative}/${srcdir}" 1>&2  || exit 1
235 231
 
... ...
@@ -274,6 +270,14 @@ build_configure()
274 270
    suffix=`determine_suffix "${mode}" "${sdk}"`
275 271
    sdk=`gcc_sdk_parameter "${mode}" "${sdk}" "${suffix}"`
276 272
 
273
+   local other_cflags
274
+   local other_cppflags
275
+   local other_ldflags
276
+
277
+   other_cflags=`gcc_cflags_value "${name}"`
278
+   other_cppflags=`gcc_cppflags_value "${name}"`
279
+   other_ldflags=`gcc_ldflags_value "${name}"`
280
+
277 281
    owd="${PWD}"
278 282
    # to avoid warning make sure directories are all there
279 283
    mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" 2> /dev/null
... ...
@@ -297,12 +301,14 @@ build_configure()
297 301
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
298 302
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
299 303
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
304
+${other_cflags} \
300 305
 ${sdk}" \
301 306
       CPPFLAGS="\
302 307
 -I${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
303 308
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
304 309
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
305 310
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
311
+${other_cppflags} \
306 312
 ${sdk}" \
307 313
       LDFLAGS="\
308 314
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
... ...
@@ -310,7 +316,10 @@ ${sdk}" \
310 316
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
311 317
 -L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}${suffix} \
312 318
 -L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mode} \
313
--L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}" \
319
+-L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH} \
320
+${other_ldflags} \
321
+${sdk}" \
322
+
314 323
       "${owd}/${srcdir}/configure" --prefix "${owd}/${DEPENDENCY_SUBDIR}/tmp" 1>&2  || exit 1
315 324
 
316 325
       make all install 1>&2 || exit 1
... ...
@@ -336,7 +345,10 @@ xcode_get_setting()
336 345
    configuration="$1"
337 346
    shift
338 347
 
339
-   xcodebuild -showBuildSettings -configuration "${configuration}" "$@" | egrep "^[ ]*${key}" | sed 's/^[^=]*=[ ]*\(.*\)/\1/' || exit 1
348
+   xcodebuild -showBuildSettings -configuration "${configuration}" "$@" | \
349
+   egrep "^[ ]*${key}" | \
350
+   sed 's/^[^=]*=[ ]*\(.*\)/\1/' || \
351
+   exit 1
340 352
 }
341 353
 
342 354
 
... ...
@@ -425,8 +437,15 @@ build_xcodebuild()
425 437
 
426 438
    local public_headers
427 439
    local private_headers_subdir
440
+   local header_name
441
+
442
+   header_name="`read_build_setting  \"{name}\" \"header_subdir\" \"${name}\"`"
443
+   if read_yes_no_build_setting "${name}" "mangle_header_dash"
444
+   then
445
+      header_name="`echo \"${header_name}\" | tr '-' '_'`"
446
+   fi
428 447
 
429
-   public_headers=`read_repo_setting "${name}" "public_headers" "${HEADER_PATH}/${name}"`
448
+   public_headers=`read_repo_setting "${name}" "public_headers" "${HEADER_PATH}/${header_name}"`
430 449
    private_headers_subdir=`read_repo_setting "${name}" "private_headers_subdir" "private"`
431 450
 
432 451
    local xcodebuild
... ...
@@ -46,6 +46,48 @@ internal_fail()
46 46
 }
47 47
 
48 48
 
49
+is_yes()
50
+{
51
+   local s
52
+
53
+   s="`echo \"${1}\" | tr '[:lower:]' '[:upper:]'`"
54
+   case "${s}" in
55
+      YES|Y|1)
56
+         return 0
57
+      ;;
58
+      NO|N|0|"")
59
+         return 1
60
+      ;;
61
+
62
+      *)
63
+         fail "$2 should contain YES or NO (or be empty)"
64
+      ;;
65
+   esac
66
+}
67
+
68
+
69
+concat()
70
+{
71
+   local i
72
+   local s
73
+
74
+   for i in "$@"
75
+   do
76
+      if [ "${i}" != "" ]
77
+      then
78
+         if [ "${s}" != "" ]
79
+         then
80
+            s="${s} ${i}"
81
+         else
82
+            s="${i}"
83
+         fi
84
+      fi
85
+   done
86
+
87
+   echo "${s}"
88
+}
89
+
90
+
49 91
 path_depth()
50 92
 {
51 93
    local name
... ...
@@ -195,6 +237,18 @@ find_xcodeproj()
195 237
 }
196 238
 
197 239
 
240
+warn_user_setting()
241
+{
242
+   local name
243
+
244
+   name="$1"
245
+   if [ "${DONT_WARN_RECURSION}" = "" -a "`DONT_WARN_RECURSION=YES read_local_setting \"dont_warn_user_setting\"`" = "" ]
246
+   then
247
+      echo "Using ~/.mulle-bootstrap/${name}" >& 2
248
+   fi
249
+}
250
+
251
+
198 252
 #
199 253
 # this knows intentionally no default, you cant have an empty
200 254
 # local setting
... ...
@@ -221,6 +275,12 @@ _read_local_setting()
221 275
       if [ $? -gt 1 ]
222 276
       then
223 277
          value=`egrep -v '^#|^[ ]*$' "${HOME}/.mulle-bootstrap/${name}" 2> /dev/null`
278
+         if [ "$value" != "" ]
279
+         then
280
+             warn_user_setting "${name}"
281
+         fi
282
+      else
283
+         warn_local_setting "${name}"
224 284
       fi
225 285
    fi
226 286
 
... ...
@@ -287,7 +347,7 @@ warn_local_setting()
287 347
    local name
288 348
 
289 349
    name="$1"
290
-   if [ "`read_local_setting \"dont_warn_local_setting\"`" = "" ]
350
+   if [ "${DONT_WARN_RECURSION}" = "" -a "`DONT_WARN_RECURSION=YES read_local_setting \"dont_warn_local_setting\"`" = "" ]
291 351
    then
292 352
       echo "Using ${BOOTSTRAP_SUBDIR}.local/${name}" >& 2
293 353
    fi
... ...
@@ -440,6 +500,15 @@ read_fetch_setting()
440 500
 }
441 501
 
442 502
 
503
+read_yes_no_build_setting()
504
+{
505
+   local value
506
+
507
+   value="`read_build_setting \"$1\" \"$2\" \"$3\"`"
508
+   is_yes "$value" "$1/$2"
509
+}
510
+
511
+
443 512
 all_build_flag_keys()
444 513
 {
445 514
    local keys1
446 515
new file mode 100644
... ...
@@ -0,0 +1,109 @@
1
+#! /bin/sh
2
+#
3
+#   Copyright (c) 2015 Nat! - Mulle kybernetiK
4
+#   All rights reserved.
5
+#
6
+#   Redistribution and use in source and binary forms, with or without
7
+#   modification, are permitted provided that the following conditions are met:
8
+#
9
+#   Redistributions of source code must retain the above copyright notice, this
10
+#   list of conditions and the following disclaimer.
11
+#
12
+#   Redistributions in binary form must reproduce the above copyright notice,
13
+#   this list of conditions and the following disclaimer in the documentation
14
+#   and/or other materials provided with the distribution.
15
+#
16
+#   Neither the name of Mulle kybernetiK nor the names of its contributors
17
+#   may be used to endorse or promote products derived from this software
18
+#   without specific prior written permission.
19
+#
20
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+#   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+#   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
+#   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+#   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+#   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+#   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+#   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+#   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+#
31
+
32
+gcc_sdk_parameter()
33
+{
34
+   local mode
35
+   local sdk
36
+   local sdkpath
37
+
38
+
39
+   mode="$1"
40
+   sdk="$2"
41
+
42
+   if [ "`uname`" = "Darwin" ]
43
+   then
44
+      if [ "${sdk}" != "Default" ]
45
+      then
46
+         sdkpath="`xcrun --sdk macosx --show-sdk-path`"
47
+         if [ "${sdkpath}" = "" ]
48
+         then
49
+            fail "SDK \"${sdk}\" is not installed"
50
+         fi
51
+         echo "${sdkpath}"
52
+      fi
53
+   fi
54
+}
55
+
56
+
57
+# Mash some known settings from xcodebuild together for regular
58
+# OTHER_CFLAGS
59
+# WARNING_CFLAGS
60
+# GCC_PREPROCESSOR_DEFINITIONS
61
+
62
+gcc_cflags_value()
63
+{
64
+   local value
65
+   local result
66
+   local name
67
+
68
+   name="${1}"
69
+
70
+   result=`get_build_setting "${name}" "OTHER_CFLAGS"`
71
+   value=`get_build_setting "${name}"  "WARNING_CFLAGS"`
72
+   result="`concat  \"$result\" \"$value\"`"
73
+   for i  in `get_build_setting "${name}" "GCC_PREPROCESSOR_DEFINITIONS"`
74
+   do
75
+      result="`concat \"$result\" \"-D${value}\"`"
76
+   done
77
+
78
+   echo "${result}"
79
+}
80
+
81
+
82
+gcc_cppflags_value()
83
+{
84
+   local value
85
+   local result
86
+   local name
87
+
88
+   name="${1}"
89
+
90
+   result=`get_build_setting "${name}" "OTHER_CPPFLAGS"`
91
+   value=`gcc_cflags_value "${name}"`
92
+   result="`concat  \"$result\" \"$value\"`"
93
+
94
+   echo "${result}"
95
+}
96
+
97
+
98
+gcc_ldflags_value()
99
+{
100
+   local result
101
+   local name
102
+
103
+   name="${1}"
104
+   result=`get_build_setting "${name}" "OTHER_LDFLAGS"`
105
+
106
+   echo "${result}"
107
+}
108
+
109
+
0 110
similarity index 67%
1 111
rename from mulle-bootstrap-setup-xcode.sh
2 112
rename to mulle-bootstrap-xcode.sh
... ...
@@ -5,6 +5,8 @@
5 5
 # this script patches the xcodeproj so that the headers and
6 6
 # lib files can be added in a sensible order
7 7
 #
8
+COMMAND="${1:-add}"
9
+shift
8 10
 
9 11
 . mulle-bootstrap-local-environment.sh
10 12
 
... ...
@@ -12,6 +14,18 @@ HEADER_PATH=`read_local_setting "header_path" "/include"`
12 14
 LIBRARY_PATH=`read_local_setting "library_path" "/lib"`
13 15
 FRAMEWORK_PATH=`read_local_setting "framework_path" "/Frameworks"`
14 16
 
17
+case "$COMMAND" in
18
+   add)
19
+   ;;
20
+   remove)
21
+   ;;
22
+   *)
23
+   echo "usage: mulle-bootstrap-setup-xcode.sh [add|remove]" 2>&1
24
+   exit 1
25
+   ;;
26
+esac
27
+
28
+
15 29
 
16 30
 list_configurations()
17 31
 {
... ...
@@ -55,7 +69,6 @@ check_for_python()
55 69
 }
56 70
 
57 71
 
58
-
59 72
 check_for_pip()
60 73
 {
61 74
    local pip
... ...
@@ -74,7 +87,6 @@ check_for_pip()
74 87
 }
75 88
 
76 89
 
77
-
78 90
 check_for_mod_pbxproj()
79 91
 {
80 92
    local installed
... ...
@@ -111,6 +123,59 @@ check_for_mod_pbxproj()
111 123
 }
112 124
 
113 125
 
126
+patch_library_configuration()
127
+{
128
+   local xcode_configurations
129
+   local mode
130
+   local i
131
+   local j
132
+   local mapped
133
+
134
+   xcode_configurations="$1"
135
+   project="$2"
136
+   flag="$3"
137
+   mode="$4"
138
+
139
+   for i in ${xcode_configurations}
140
+   do
141
+      mapped=""
142
+
143
+      for j in ${configurations}
144
+      do
145
+         if [ "$j" = "$i" ]
146
+         then
147
+            mapped="${i}"
148
+         fi
149
+      done
150
+
151
+      if [ "$mapped" = "" ]
152
+      then
153
+      case i in
154
+         *ebug*)
155
+            mapped="Debug"
156
+            ;;
157
+         *rofile*)
158
+            mapped="Release"
159
+            ;;
160
+         *eleas*)
161
+            mapped="Release"
162
+            ;;
163
+         *)
164
+            mapped="${default}"
165
+            ;;
166
+      esac
167
+      fi
168
+
169
+      if [ "${mode}" = "modify" ]
170
+      then
171
+         python -m mod_pbxproj -b "${flag}" 'LIBRARY_CONFIGURATION='"${mapped}" "${project}" "${i}" || exit 1
172
+      else
173
+         echo "${i}: LIBRARY_CONFIGURATION=${mapped}"
174
+      fi
175
+   done
176
+}
177
+
178
+
114 179
 patch_xcode_project()
115 180
 {
116 181
    local name
... ...
@@ -134,9 +199,6 @@ patch_xcode_project()
134 199
    echo "The nearest Xcode project found is:" >&2
135 200
    echo "${project}" >&2
136 201
 
137
-   user_say_yes "Add \"${DEPENDENCY_SUBDIR}\" to search paths of ${projectname} ?"
138
-   [ $? -eq 0 ] || exit 1
139
-
140 202
    check_for_mod_pbxproj
141 203
 
142 204
    configurations=`read_local_setting "configurations"`
... ...
@@ -158,46 +220,21 @@ Release"`
158 220
 Release"
159 221
    fi
160 222
 
161
-   #     012345678901234567890123456789012345678901234567890123456789
162
-   echo "Settings added to ${projectname} and each contained target." >&2
163
-   echo "You may want to delete the target settings, which have been" >&2
164
-   echo "(redundantly) added by mod_pbxproj." >&2
165
-   echo  "-----------------------------------------" >&2
166
-
167
-   for i in ${xcode_configurations}
168
-   do
169
-      mapped=""
170
-
171
-      for j in ${configurations}
172
-      do
173
-         if [ "$j" = "$i" ]
174
-         then
175
-            mapped="${i}"
176
-         fi
177
-      done
178
-
179
-      if [ "$mapped" = "" ]
180
-      then
181
-      case i in
182
-         *ebug*)
183
-            mapped="Debug"
184
-            ;;
185
-         *rofile*)
186
-            mapped="Release"
187
-            ;;
188
-         *eleas*)
189
-            mapped="Release"
190
-            ;;
191
-         *)
192
-            mapped="${default}"
193
-            ;;
194
-      esac
195
-      fi
196
-
197
-      python -m mod_pbxproj -b -af 'LIBRARY_CONFIGURATION='"${mapped}" "${project}" "${i}" || exit 1
198
-      echo "${i}: LIBRARY_CONFIGURATION=${mapped}"
199
-   done
223
+   local flag
200 224
 
225
+   if [ "$COMMAND" = "add" ]
226
+   then
227
+      flag="-af"
228
+      #     012345678901234567890123456789012345678901234567890123456789
229
+      echo "Settings will be added to ${projectname} and each contained target." >&2
230
+      echo  "-----------------------------------------" >&2
231
+   else
232
+      flag="-rf"
233
+      #     012345678901234567890123456789012345678901234567890123456789
234
+      echo "Settings will be removed from ${projectname} and each contained target." >&2
235
+      echo "You may want to check afterwards, that this has worked out OK :)." >&2
236
+      echo  "-----------------------------------------" >&2
237
+   fi
201 238
 
202 239
    local dependencies_dir
203 240
    local header_search_paths
... ...
@@ -208,6 +245,7 @@ Release"
208 245
 
209 246
    header_search_paths="\$(DEPENDENCIES_DIR)${HEADER_PATH}"
210 247
    header_search_paths="${header_search_paths} /usr/local/include"
248
+   header_search_paths="${header_search_paths} \$(inherited)"
211 249
 
212 250
    library_search_paths="\$(DEPENDENCIES_DIR)${LIBRARY_PATH}/\$(LIBRARY_CONFIGURATION)\$(EFFECTIVE_PLATFORM_NAME)"
213 251
    library_search_paths="${library_search_paths} \$(DEPENDENCIES_DIR)${LIBRARY_PATH}/\$(LIBRARY_CONFIGURATION)"
... ...
@@ -215,6 +253,7 @@ Release"
215 253
    library_search_paths="${library_search_paths} \$(DEPENDENCIES_DIR)${LIBRARY_PATH}/${default}"
216 254
    library_search_paths="${library_search_paths} \$(DEPENDENCIES_DIR)${LIBRARY_PATH}"
217 255
    library_search_paths="${library_search_paths} /usr/local/lib"
256
+   library_search_paths="${library_search_paths} \$(inherited)"
218 257
 
219 258
 
220 259
    framework_search_paths="\$(DEPENDENCIES_DIR)${FRAMEWORK_PATH}/\$(LIBRARY_CONFIGURATION)\$(EFFECTIVE_PLATFORM_NAME)"
... ...
@@ -222,14 +261,9 @@ Release"
222 261
    framework_search_paths="${framework_search_paths} \$(DEPENDENCIES_DIR)${FRAMEWORK_PATH}/${default}\$(EFFECTIVE_PLATFORM_NAME)"
223 262
    framework_search_paths="${framework_search_paths} \$(DEPENDENCIES_DIR)${FRAMEWORK_PATH}/${default}"
224 263
    framework_search_paths="${framework_search_paths} \$(DEPENDENCIES_DIR)${FRAMEWORK_PATH}"
264
+   framework_search_paths="${framework_search_paths} \$(inherited)"
225 265
 
226
-   # in paths to the dependency folder into xcodeproj
227
-   # add /usr/local/lib and /usr/local/include for brew stuff
228
-   #
229
-   python -m mod_pbxproj -b -af "DEPENDENCIES_DIR=${dependencies_dir}" "${project}" "All" || exit 1
230
-   python -m mod_pbxproj -b -af "HEADER_SEARCH_PATHS=${header_search_paths}" "${project}" "All" || exit 1
231
-   python -m mod_pbxproj -b -af "LIBRARY_SEARCH_PATHS=${library_search_paths}" "${project}" "All" || exit 1
232
-   python -m mod_pbxproj -b -af "FRAMEWORK_SEARCH_PATHS=${framework_search_paths}" "${project}" "All" || exit 1
266
+   patch_library_configuration "${xcode_configurations}" "${project}" "${flag}" "show"
233 267
 
234 268
    prefix=`echo "${xcode_configurations}" | tr '\n' ',' `
235 269
    #     012345678901234567890123456789012345678901234567890123456789
... ...
@@ -238,14 +272,44 @@ Release"
238 272
    echo "${prefix}: LIBRARY_SEARCH_PATHS=${library_search_paths}"
239 273
    echo "${prefix}: FRAMEWORK_SEARCH_PATHS=${framework_search_paths}"
240 274
    echo  "-----------------------------------------" >&2
241
-   #     012345678901234567890123456789012345678901234567890123456789
242
-   echo "" >&2
243
-   echo "If you add a configuration to your project, rememeber to edit" >&2
244
-   echo "the LIBRARY_CONFIGURATION setting for that configuration." >&2
245
-   echo "" >&2
246
-   echo "You can rerun setup-xcode at later times and it should not" >&2
247
-   echo "unduly duplicate setting contents." >&2
248
-   echo "" >&2
275
+
276
+   # in paths to the dependency folder into xcodeproj
277
+   # add /usr/local/lib and /usr/local/include for brew stuff
278
+   #
279
+   local query
280
+
281
+   if [ "$COMMAND" = "add" ]
282
+   then
283
+      query="Add \"${DEPENDENCY_SUBDIR}\" to search paths of ${projectname} ?"
284
+   else
285
+      query="Remove \"${DEPENDENCY_SUBDIR}\" from search paths of ${projectname} ?"
286
+   fi
287
+
288
+   user_say_yes "$query"
289
+   [ $? -eq 0 ] || exit 1
290
+
291
+
292
+   patch_library_configuration "${xcode_configurations}" "${project}" "${flag}" "modify"
293
+
294
+   python -m mod_pbxproj -b "${flag}" "DEPENDENCIES_DIR=${dependencies_dir}" "${project}" "All" || exit 1
295
+   python -m mod_pbxproj -b "${flag}" "HEADER_SEARCH_PATHS=${header_search_paths}" "${project}" "All" || exit 1
296
+   python -m mod_pbxproj -b "${flag}" "LIBRARY_SEARCH_PATHS=${library_search_paths}" "${project}" "All" || exit 1
297
+   python -m mod_pbxproj -b "${flag}" "FRAMEWORK_SEARCH_PATHS=${framework_search_paths}" "${project}" "All" || exit 1
298
+
299
+
300
+   if [ "$COMMAND" = "add" ]
301
+   then
302
+      #     012345678901234567890123456789012345678901234567890123456789
303
+      echo "You may want to delete the target settings, which have been" >&2
304
+      echo "(redundantly) added by mod_pbxproj. The project settings suffice." >&2
305
+      echo "" >&2
306
+      echo "If you add a configuration to your project, remember to edit" >&2
307
+      echo "the LIBRARY_CONFIGURATION setting for that configuration." >&2
308
+      echo "" >&2
309
+      echo "You can rerun setup-xcode at later times and it should not" >&2
310
+      echo "unduly duplicate setting contents." >&2
311
+      echo "" >&2
312
+   fi
249 313
 }
250 314
 
251 315
 main()
... ...
@@ -16,13 +16,16 @@ This should create a `dependencies` folder with the stuff you need in `C`:
16 16
 ls -R dependencies
17 17
 ```
18 18
 
19
-Building the project **C** itself won't work yet, because the `dependencies` folder is not yet known to the project `C.xcodeproj`.
19
+Building the project **C** itself won't work yet, because the `dependencies`
20
+folder is not yet known to the project `C.xcodeproj`.
20 21
 
21 22
 ```console
22 23
 xcodebuild  # fails
23 24
 ```
24 25
 
25
-You could add the search paths to HEADER_SEARCH_PATHS, LIBRATY_SEARCH_PATHS and FRAMEWORK_SEARCH_PATHS manually, but why bother, when **mulle-bootstrap** can do it for you:
26
+You could add the search paths to HEADER_SEARCH_PATHS, LIBRATY_SEARCH_PATHS and
27
+FRAMEWORK_SEARCH_PATHS manually, but why bother, when **mulle-bootstrap** can
28
+do it for you:
26 29
 
27 30
 ```console
28 31
 mulle-bootstrap  setup-xcode
... ...
@@ -32,7 +35,8 @@ cd ..
32 35
 
33 36
 ## Using cmake
34 37
 
35
-Then try it again with cmake. Here we set up **mulle-bootstrap** to fetch cmake if not present and to use cmake as the only build tool:
38
+Then try it again with cmake. Here we set up **mulle-bootstrap** to fetch cmake
39
+if not present and to use cmake as the only build tool:
36 40
 
37 41
 ```console
38 42
 cd C
... ...
@@ -42,11 +46,20 @@ echo "cmake" >> .bootstrap/preferences
42 46
 mulle-bootstrap
43 47
 ```
44 48
 
45
-Now at this point it can be assumed that C.xcodeproj already has the proper settings, from doing the example above, but doing it again should be harmless:
49
+Now at this point it can be assumed that C.xcodeproj already has the proper
50
+settings, from doing the example above, but doing it again should be harmless:
46 51
 
47 52
 ```console
48
-mulle-bootstrap setup-xcode
53
+mulle-bootstrap xcode
49 54
 xcodebuild
55
+```
56
+
57
+In many cases, especially if you didn't change any mulle-bootstrap settings,
58
+you can also easily remove the added settings again:
59
+
60
+```console
61
+mulle-bootstrap xcode remove
62
+xcodebuild  # fails again
50 63
 cd ..
51 64
 ```
52 65
 
... ...
@@ -65,7 +78,9 @@ mulle-bootstrap
65 78
 
66 79
 # Big
67 80
 
68
-This shows a more complicated setup, where **mulle-bootstrap** clones and builds a xcodebuild based projeczt, a cmake make based project and a configure based project.
81
+This shows a more complicated setup, where **mulle-bootstrap** clones and
82
+builds a xcodebuild based projeczt, a cmake make based project and a configure
83
+based project.
69 84
 
70 85
 ```console
71 86
 cd Big