Browse code

Rewrote the setting reader stuff significantly. Experimental grabbing of CFLAGS continued.

Nat! authored on 27-09-2015 21:12:19
Showing 11 changed files
... ...
@@ -1,17 +1,10 @@
1
-layout: post
2
-author: Nat!
3
-title:
4
-open_comments: true
5
-date: 2015-09-26 18:56
6 1
 # FAQ
7 2
 
8 3
 Or rather, stuff I would ask, if I hadn't written it myself :)
9 4
 
10 5
 ## Where is what ?
11 6
 
12
-* `.bootstrap` is the bootstrap configuration of the repository
7
+* `.bootstrap` is the bootstrap configuration of the repository.
13 8
 * `.bootstrap.auto` is generated by mulle-bootstrap fetch, it contains
14 9
 information recursively collected from dependent repostiories, that have their
15 10
 own .bootstrap folder.
... ...
@@ -25,20 +18,45 @@ be safely thrown away
25 18
 * `/usr/local/libexec/mulle-bootstrap` contains scripts for mulle-bootstrap
26 19
 
27 20
 
21
+## Where is what in .bootstrap ?
22
+
23
+* Files in `.bootstrap` itself are used for fetching dependencies and some
24
+configurations.
25
+* Files in `.bootstrap/config` are rarely used options, to change
26
+mulle-bootstrap behavior.
27
+* Files in `.bootstrap/settings` are used for building dependencies. Here you
28
+find compiler flags, targets, sdks et.c.
29
+* Folders in `.bootstrap/repos` are build settings for individual
30
+dependencies. Optimally this folder is empty or non-existant.
31
+
32
+## Where is what in .bootstrap.auto ?
33
+
34
+* Files in `.bootstrap.auto` are an amalgamation of .bootstrap and the contents of
35
+.bootstrap of the dependencies.
36
+* .bootstrap/config should not exist
37
+* .bootstrap/settings should not exist
38
+* Folders in `.bootstrap.auto/repos` are the settings inherited from
39
+.bootstrap.
40
+
41
+
28 42
 ### The default target/scheme is not the one I want ?
29 43
 
30
-Put the target name into `.bootstrap/{reponame}/target`
44
+Put the target name into `.bootstrap/settings/{reponame}/targets`
31 45
 
32 46
 ```console
33
-echo "Finch Demo" > .bootstrap/Finch/target
47
+mkdir -p  ".bootstrap/settings/Finch" 2> /dev/null
48
+echo "Finch Demo" > .bootstrap/Finch/targets
34 49
 ```
35 50
 
51
+Use "schemes" instead of "targets" to specify a scheme.
52
+
36 53
 ### Can it build to various specific SDKs ?
37 54
 
38
-Put the SDK names into ".bootstrap/sdks".
55
+Put the SDK names into ".bootstrap/settings/sdks".
39 56
 
40 57
 ```console
41
-cat <<EOF > .bootstrap/sdks
58
+mkdir -p  ".bootstrap/settings/sdks" 2> /dev/null
59
+cat <<EOF > .bootstrap/settings/sdks
42 60
 iphoneos
43 61
 iphonesimulator
44 62
 EOF
... ...
@@ -104,7 +122,8 @@ compile time. If you know that SKIP_INSTALL is correctly set, set
104 122
 "proper_skip_install" to "YES".
105 123
 
106 124
 ```console
107
-echo "YES" > .bootstrap/{reponame}/proper_skip_install
125
+mkdir -p  ".bootstrap/settings/{reponame}" 2> /dev/null
126
+echo "YES" > .bootstrap/settings/{reponame}/proper_skip_install
108 127
 ```
109 128
 
110 129
 ### How can I tweak some Xcode project settings ?
... ...
@@ -113,7 +132,7 @@ Lots of ways, probably the quickest is:
113 132
 
114 133
 ```console
115 134
 mkdir -p .bootstrap/Foo 2> /dev/null
116
-echo "BrandedFoo" > .bootstrap/Foo/PRODUCT_NAME
135
+echo "BrandedFoo" > .bootstrap/settings/Foo/PRODUCT_NAME
117 136
 ```
118 137
 
119 138
 
... ...
@@ -121,14 +140,16 @@ If you have lots of stuff, you may want to use your own **.xcconfig** file. This
121 140
 is likely to be more useful if placed into the .bootstrap folder directly.
122 141
 
123 142
 ```console
124
-cp myconfig.xcconfig > .bootstrap/xcconfig
143
+mkdir -p  ".bootstrap/settings" 2> /dev/null
144
+cp myconfig.xcconfig > .bootstrap/settings/xcconfig
125 145
 ```
126 146
 
127 147
 
128 148
 Need to add some other magic Xcode build flags ?
129 149
 
130 150
 ```console
131
-echo "-verbose" > .bootstrap/xcodebuild-flags
151
+mkdir -p  ".bootstrap/settings" 2> /dev/null
152
+echo "-verbose" > .bootstrap/settings/xcodebuild-flags
132 153
 ```
133 154
 
134 155
 ### Should I put build settings into .bootstrap/{reponame} or into .bootstrap ?
... ...
@@ -142,5 +163,11 @@ do not.
142 163
 Check that your Xcode project has a **Header Phase** and that the header files
143 164
 are in "public".
144 165
 
166
+### I have a depencency on another library in the same project. The headers of
167
+the dependency library are in `dependencies/usr/local/include`. What now ?
168
+
169
+**mulle-bootstrap*+ can't manage xcodebuild dependencies, so you have to help
170
+it. Specify the targets you want to build.
171
+
145 172
 
146 173
 
... ...
@@ -11,7 +11,7 @@ mulle-bootstrap-tag.sh \
11 11
 mulle-bootstrap-warn-scripts.sh
12 12
 
13 13
 CHECKSTAMPS=$(SCRIPTS:.sh=.chk)
14
-SHELLFLAGS=-e SC2006 -s sh
14
+SHELLFLAGS=-x -e SC2164,SC2166,SC2006 -s sh
15 15
 
16 16
 .PHONY: all
17 17
 .PHONY: clean
... ...
@@ -33,11 +33,10 @@
33 33
 .  mulle-bootstrap-gcc.sh
34 34
 
35 35
 
36
-CLEAN_BEFORE_BUILD=`read_local_setting "clean"`
37
-HEADER_PATH=`read_local_setting "header_path" "/include"`
38
-LIBRARY_PATH=`read_local_setting "library_path" "/lib"`
39
-FRAMEWORK_PATH=`read_local_setting "frameworks_path" "/Frameworks"`
40
-
36
+CLEAN_BEFORE_BUILD=`read_config_setting "clean"`
37
+HEADER_PATH=`read_config_setting "header_path" "/include"`
38
+LIBRARY_PATH=`read_config_setting "library_path" "/lib"`
39
+FRAMEWORK_PATH=`read_config_setting "frameworks_path" "/Frameworks"`
41 40
 
42 41
 #
43 42
 # move stuff produced my cmake and configure to places
... ...
@@ -117,15 +116,15 @@ enforce_build_sanity()
117 116
 
118 117
 determine_suffix()
119 118
 {
120
-   local mode
119
+   local configuration
121 120
    local sdk
122 121
    local suffix
123 122
    local hackish
124 123
 
125
-   mode="$1"
124
+   configuration="$1"
126 125
    sdk="$2"
127 126
 
128
-   suffix="/${mode}"
127
+   suffix="/${configuration}"
129 128
    if [ "${sdk}" != "Default" ]
130 129
    then
131 130
       hackish=`echo "${sdk}" | sed 's/^\([a-zA-Z]*\).*$/\1/g'`
... ...
@@ -139,7 +138,7 @@ cmake_sdk_parameter()
139 138
 {
140 139
    local sdkpath
141 140
 
142
-   sdkpath="`gcc_sdk_parameter \"$1\" \"$2\"`"
141
+   sdkpath=`gcc_sdk_parameter "$1"`
143 142
    if [ "${sdkpath}" != "" ]
144 143
    then
145 144
       echo '-DCMAKE_OSX_SYSROOT='"${sdkpath}"
... ...
@@ -148,13 +147,13 @@ cmake_sdk_parameter()
148 147
 
149 148
 #
150 149
 # remove old builddir, create a new one
151
-# depending on mode cmake with flags
150
+# depending on configuration cmake with flags
152 151
 # build stuff into dependencies
153 152
 #
154 153
 #
155 154
 build_cmake()
156 155
 {
157
-   local mode
156
+   local configuration
158 157
    local srcdir
159 158
    local builddir
160 159
    local relative
... ...
@@ -162,7 +161,7 @@ build_cmake()
162 161
    local sdk
163 162
    local mapped
164 163
 
165
-   mode="$1"
164
+   configuration="$1"
166 165
    srcdir="$2"
167 166
    builddir="$3"
168 167
    relative="$4"
... ...
@@ -171,9 +170,9 @@ build_cmake()
171 170
 
172 171
    enforce_build_sanity
173 172
 
174
-   mapped=`read_build_setting "$name" "cmake-${mode}.map" "${mode}"`
175
-   suffix=`determine_suffix "${mode}" "${sdk}"`
176
-   sdk=`cmake_sdk_parameter "${mode}" "${sdk}" "${suffix}"`
173
+   mapped=`read_build_setting "$name" "cmake-${configuration}.map" "${configuration}"`
174
+   suffix=`determine_suffix "${configuration}" "${sdk}"`
175
+   sdk=`cmake_sdk_parameter "${sdk}"`
177 176
 
178 177
    local other_cflags
179 178
    local other_cppflags
... ...
@@ -186,7 +185,7 @@ build_cmake()
186 185
    owd="${PWD}"
187 186
    # to avoid warning make sure directories are all there
188 187
    mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" 2> /dev/null
189
-   mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode}" 2> /dev/null
188
+   mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" 2> /dev/null
190 189
    mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" 2> /dev/null
191 190
 
192 191
    mkdir -p "${builddir}" 2> /dev/null
... ...
@@ -194,7 +193,7 @@ build_cmake()
194 193
 
195 194
       # check that relative ise right
196 195
       [ -d "${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" ] || exit 1
197
-      [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode}" ] || exit 1
196
+      [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" ] || exit 1
198 197
       [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
199 198
 
200 199
       #
... ...
@@ -207,23 +206,23 @@ build_cmake()
207 206
 "-DCMAKE_C_FLAGS=\
208 207
 -I${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
209 208
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
210
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
209
+-F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
211 210
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
212 211
 ${other_cflags} \
213 212
 ${sdk}" \
214 213
 "-DCMAKE_CXX_FLAGS=\
215 214
 -I${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
216 215
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
217
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
216
+-F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
218 217
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
219 218
 ${other_cppflags} \
220 219
 ${sdk}" \
221 220
 "-DCMAKE_LD_FLAGS=\
222 221
 -L${relative}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}${suffix} \
223
--L${relative}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mode} \
222
+-L${relative}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${configuration} \
224 223
 -L${relative}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH} \
225 224
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
226
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
225
+-F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
227 226
 -F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
228 227
 ${other_ldflags} \
229 228
 ${sdk}" \
... ...
@@ -243,13 +242,13 @@ ${sdk}" \
243 242
 
244 243
 #
245 244
 # remove old builddir, create a new one
246
-# depending on mode cmake with flags
245
+# depending on configuration cmake with flags
247 246
 # build stuff into dependencies
248 247
 #
249 248
 #
250 249
 build_configure()
251 250
 {
252
-   local mode
251
+   local configuration
253 252
    local srcdir
254 253
    local builddir
255 254
    local relative
... ...
@@ -257,7 +256,7 @@ build_configure()
257 256
    local sdk
258 257
    local mapped
259 258
 
260
-   mode="$1"
259
+   configuration="$1"
261 260
    srcdir="$2"
262 261
    builddir="$3"
263 262
    relative="$4"
... ...
@@ -266,9 +265,9 @@ build_configure()
266 265
 
267 266
    enforce_build_sanity
268 267
 
269
-   mapped=`read_build_setting "$name" "configure-${mode}.map" "${mode}"`
270
-   suffix=`determine_suffix "${mode}" "${sdk}"`
271
-   sdk=`gcc_sdk_parameter "${mode}" "${sdk}" "${suffix}"`
268
+   mapped=`read_build_setting "$name" "configure-${configuration}.map" "${configuration}"`
269
+   suffix=`determine_suffix "${configuration}" "${sdk}"`
270
+   sdk=`gcc_sdk_parameter "${sdk}"`
272 271
 
273 272
    local other_cflags
274 273
    local other_cppflags
... ...
@@ -281,7 +280,7 @@ build_configure()
281 280
    owd="${PWD}"
282 281
    # to avoid warning make sure directories are all there
283 282
    mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" 2> /dev/null
284
-   mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode}" 2> /dev/null
283
+   mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" 2> /dev/null
285 284
    mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" 2> /dev/null
286 285
 
287 286
    mkdir -p "${builddir}" 2> /dev/null
... ...
@@ -289,7 +288,7 @@ build_configure()
289 288
 
290 289
       # check that relative ise right
291 290
       [ -d "${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" ] || exit 1
292
-      [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode}" ] || exit 1
291
+      [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" ] || exit 1
293 292
       [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
294 293
 
295 294
       set -f
... ...
@@ -299,27 +298,26 @@ build_configure()
299 298
       CFLAGS="\
300 299
 -I${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
301 300
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
302
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
301
+-F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
303 302
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
304 303
 ${other_cflags} \
305 304
 ${sdk}" \
306 305
       CPPFLAGS="\
307 306
 -I${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
308 307
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
309
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
308
+-F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
310 309
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
311 310
 ${other_cppflags} \
312 311
 ${sdk}" \
313 312
       LDFLAGS="\
314 313
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
315
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mode} \
314
+-F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
316 315
 -F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
317 316
 -L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}${suffix} \
318
--L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mode} \
317
+-L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${configuration} \
319 318
 -L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH} \
320 319
 ${other_ldflags} \
321 320
 ${sdk}" \
322
-
323 321
       "${owd}/${srcdir}/configure" --prefix "${owd}/${DEPENDENCY_SUBDIR}/tmp" 1>&2  || exit 1
324 322
 
325 323
       make all install 1>&2 || exit 1
... ...
@@ -345,7 +343,7 @@ xcode_get_setting()
345 343
    configuration="$1"
346 344
    shift
347 345
 
348
-   xcodebuild -showBuildSettings -configuration "${configuration}" "$@" | \
346
+   xcodebuild -showBuildSettings -configuration "${configuration}" $* | \
349 347
    egrep "^[ ]*${key}" | \
350 348
    sed 's/^[^=]*=[ ]*\(.*\)/\1/' || \
351 349
    exit 1
... ...
@@ -354,68 +352,50 @@ xcode_get_setting()
354 352
 
355 353
 build_xcodebuild()
356 354
 {
357
-   local mode
355
+   local configuration
358 356
    local srcdir
359 357
    local builddir
360 358
    local relative
361 359
    local name
362 360
    local sdk
363 361
    local project
362
+   local schemename
363
+   local targetname
364 364
 
365
-   mode="$1"
365
+   configuration="$1"
366 366
    srcdir="$2"
367 367
    builddir="$3"
368 368
    relative="$4"
369 369
    name="$5"
370 370
    sdk="$6"
371 371
    project="$7"
372
+   schemename="$8"
373
+   targetname="$9"
372 374
 
373
-   if [ -d "${builddir}" -a "${CLEAN_BEFORE_BUILD}" != "" ]
374
-   then
375
-      rm -rf "${builddir}"
376
-   fi
375
+   [ -z "${configuration}" ] && internal_fail "configuration is empty"
376
+   [ -z "${srcdir}" ]      && internal_fail "srcdir is empty"
377
+   [ -z "${builddir}" ]    && internal_fail "builddir is empty"
378
+   [ -z "${relative}" ]    && internal_fail "relative is empty"
379
+   [ -z "${name}" ]        && internal_fail "name is empty"
380
+   [ -z "${sdk}" ]         && internal_fail "sdk is empty"
381
+   [ -z "${project}" ]     && internal_fail "project is empty"
377 382
 
378
-   local project
379 383
    local projectname
380 384
 
381
-   # always pass project directly
382
-   projectname=`read_repo_setting "${name}" "project"`
383
-   if [ "${projectname}" != "" ]
384
-   then
385
-      project="-project ${projectname}"
386
-   else
387
-      project="-project ${project}"
388
-   fi
389
-
390
-   local scheme
391
-   local schemename
392
-
393
-   scheme=
394
-   schemename=`read_repo_setting "${name}" "scheme"`
395
-   if [ "$schemename" != "" ]
396
-   then
397
-      scheme="-scheme ${schemename}"
398
-   fi
399
-
400
-   local target
401
-   local targetname
402
-
403
-   target=
404
-   targetname=`read_repo_setting "${name}" "target"`
405
-   if [ "$targetname" != "" ]
406
-   then
407
-      target="-target ${targetname}"
408
-   fi
385
+    # always pass project directly
386
+   projectname=`read_repo_setting "${name}" "project" "${project}"`
387
+   project="-project ${projectname}"
409 388
 
410 389
    local mapped
411 390
 
412
-   mapped=`read_build_setting "${name}" "${mode}.map" "${mode}"`
391
+   mapped=`read_build_setting "${name}" "${configuration}.map" "${configuration}"`
392
+   [ -z "${mapped}" ] && internal_fail "mapped configuration is empty"
413 393
 
414 394
    local hackish
415 395
    local targetname
416 396
    local suffix
417 397
 
418
-   suffix="/${mode}"
398
+   suffix="/${configuration}"
419 399
    if [ "${sdk}" != "Default" ]
420 400
    then
421 401
       hackish=`echo "${sdk}" | sed 's/^\([a-zA-Z]*\).*$/\1/g'`
... ...
@@ -429,29 +409,16 @@ build_xcodebuild()
429 409
    local skip_install
430 410
 
431 411
    skip_install=
432
-   proper_skip_install=`read_repo_setting "${name}" "proper_skip_install" "NO"`
412
+   proper_skip_install=`read_build_setting "${name}" "proper_skip_install" "NO"`
433 413
    if [ "$proper_skip_install" != "YES" ]
434 414
    then
435 415
       skip_install="SKIP_INSTALL=NO"
436 416
    fi
437 417
 
438
-   local public_headers
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
447
-
448
-   public_headers=`read_repo_setting "${name}" "public_headers" "${HEADER_PATH}/${header_name}"`
449
-   private_headers_subdir=`read_repo_setting "${name}" "private_headers_subdir" "private"`
450
-
451 418
    local xcodebuild
452 419
    local binary
453 420
 
454
-   xcodebuild=`read_local_setting "xcodebuild" "xcodebuild"`
421
+   xcodebuild=`read_config_setting "xcodebuild" "xcodebuild"`
455 422
    binary=`which "${xcodebuild}"`
456 423
    if [ "${binary}"  = "" ]
457 424
    then
... ...
@@ -471,11 +438,15 @@ build_xcodebuild()
471 438
    then
472 439
       xcconfig="-xcconfig ${xcconfigname}"
473 440
    fi
441
+
474 442
    #
475 443
    # xctool needs schemes, these are often autocreated, which xctool cant do
476 444
    # xcodebuild can just use a target
477 445
    # xctool is by and large useless fluff IMO
478 446
    #
447
+   local target
448
+   local scheme
449
+
479 450
    if [ "$xcodebuild" = "xctool"  -a "${schemename}" = ""  ]
480 451
    then
481 452
       if [ "$targetname" != "" ]
... ...
@@ -488,7 +459,16 @@ build_xcodebuild()
488 459
          echo "Or just delete ${HOME}/.mulle-bootstrap/xcodebuild and use xcodebuild (preferred)" >& 2
489 460
          exit 1
490 461
       fi
491
-   fi
462
+   else
463
+     if [ "${schemename}" != "" ]
464
+     then
465
+        scheme="-scheme ${schemename}"
466
+     fi
467
+     if [ "${targetname}" != "" ]
468
+     then
469
+        target="-target ${targetname}"
470
+     fi
471
+  fi
492 472
 
493 473
    local key
494 474
    local aux
... ...
@@ -517,6 +497,44 @@ build_xcodebuild()
517 497
    owd=`pwd`
518 498
    cd "${srcdir}" || exit 1
519 499
 
500
+      #
501
+      # headers are complicated, the preference is to get it uniform into
502
+      # dependencies/include/libraryname/..
503
+      #
504
+      local public_headers
505
+      local private_headers
506
+      local public_header_name
507
+      local private_header_name
508
+
509
+      public_headers=`xcode_get_setting PUBLIC_HEADERS_FOLDER_PATH "${mapped}" "${project}" "${scheme}" "${target}"`
510
+      private_headers=`xcode_get_setting PRIVATE_HEADERS_FOLDER_PATH "${mapped}" "${project}" "${scheme}" "${target}"`
511
+
512
+      read_yes_no_build_setting "${name}" "keep_xcode_header_settings"
513
+      if [ $? -ne 0 ]
514
+      then
515
+         public_header_name=`remove_absolute_path_prefix_up_to "${public_headers}" "include"`
516
+         private_header_name=`remove_absolute_path_prefix_up_to "${private_headers}" "include"`
517
+
518
+         if read_yes_no_build_setting "${name}" "mangle_header_dash"
519
+         then
520
+            public_header_name=`echo "${public_header_name}" | tr '-' '_'`"
521
+            private_header_name=`echo "${private_header_name}" | tr '-' '_'`"
522
+         fi
523
+
524
+         if [ "${public_header_name}" != "" ]
525
+         then
526
+            public_header_name="/${public_header_name}"
527
+         fi
528
+         if [ "${private_header_name}" != "" ]
529
+         then
530
+            private_header_name="/${private_header_name}"
531
+         fi
532
+
533
+         public_headers=`read_repo_setting "${name}" "public_headers" "${HEADER_PATH}${public_header_name}"`
534
+         private_headers=`read_repo_setting "${name}" "private_headers" "${HEADER_PATH}${private_header_name}"`
535
+      fi
536
+
537
+
520 538
       # manually point xcode to our headers and libs
521 539
       # this is like manually doing xcode-setup
522 540
       local dependencies_framework_search_path
... ...
@@ -550,9 +568,8 @@ ${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
550 568
 ${inherited}"
551 569
 
552 570
       set -f
553
-      set -x
571
+      set +x
554 572
 
555
-      echo "${BOOTSTRAP_SUBDIR}" >&2
556 573
       # if it doesn't install, probably SKIP_INSTALL is set
557 574
       $xcodebuild $command $project $sdk $scheme $target -configuration "${mapped}" \
558 575
       ${xcflags} \
... ...
@@ -563,7 +580,7 @@ ${inherited}"
563 580
       "DSTROOT=${owd}/${DEPENDENCY_SUBDIR}" \
564 581
       "INSTALL_PATH=${LIBRARY_PATH}${suffix}" \
565 582
       "PUBLIC_HEADERS_FOLDER_PATH=${public_headers}" \
566
-      "PRIVATE_HEADERS_FOLDER_PATH=${public_headers}/${private_headers_subdir}" \
583
+      "PRIVATE_HEADERS_FOLDER_PATH=${private_headers}" \
567 584
       SYMROOT="${owd}/${builddir}/" \
568 585
       OBJROOT="${owd}/${builddir}/obj" \
569 586
       ONLY_ACTIVE_ARCH=NO \
... ...
@@ -580,6 +597,44 @@ ${inherited}"
580 597
 }
581 598
 
582 599
 
600
+build_xcodebuild_schemes_or_target()
601
+{
602
+   local builddir
603
+   local name
604
+
605
+   builddir="$3"
606
+   name="$5"
607
+
608
+   if [ -d "${builddir}" -a "${CLEAN_BEFORE_BUILD}" != "" ]
609
+   then
610
+      rm -rf "${builddir}"
611
+   fi
612
+
613
+   local scheme
614
+   local schemes
615
+
616
+   schemes=`read_repo_setting "${name}" "schemes"`
617
+   for scheme in $schemes
618
+   do
619
+      build_xcodebuild "$@" "${scheme}" ""
620
+   done
621
+
622
+   local target
623
+   local targets
624
+
625
+   targets=`read_repo_setting "${name}" "targets"`
626
+   for target in $targets
627
+   do
628
+      build_xcodebuild "$@" "" "${target}"
629
+   done
630
+
631
+   if [ "${targets}" = "" -a "${schemes}" = "" ]
632
+   then
633
+      build_xcodebuild "$@"
634
+   fi
635
+}
636
+
637
+
583 638
 build()
584 639
 {
585 640
    local clone
... ...
@@ -601,27 +656,20 @@ build()
601 656
    local cmake
602 657
    local xcodebuild
603 658
 
604
-   preferences=`read_local_setting "preferences"`
605
-   if [ "$preferences" = "" ]
606
-   then
607
-      preferences=`read_build_root_setting "preferences" "script
659
+   preferences=`read_config_setting "build_preferences" "script
608 660
 xcodebuild
609 661
 cmake
610 662
 configure"`
611
-   fi
612 663
 
613
-   configurations=`read_local_setting "configurations"`
614
-   if [ "$configurations" = "" ]
615
-   then
616
-      configurations=`read_build_root_setting "configurations" "Debug
664
+   configurations=`read_build_root_setting "configurations" "Debug
617 665
 Release"`
618
-   fi
619 666
 
620 667
    xcodebuild=`which "xcodebuild"`
621 668
    cmake=`which "cmake"`
622 669
 
623 670
    # need uniform SDK for our builds
624 671
    sdks=`read_build_root_setting "sdks" "Default"`
672
+   [ -z "${sdks}" ] && fail "setting \"sdks\" must at least contain \"Default\" to build anything"
625 673
 
626 674
    for sdk in ${sdks}
627 675
    do
... ...
@@ -656,7 +704,7 @@ Release"`
656 704
 
657 705
                if [ "$project" != "" ]
658 706
                then
659
-                  build_xcodebuild "${configuration}" "${srcdir}" "${builddir}" "${relative}" "${name}" "${sdk}" "${project}"  || exit 1
707
+                  build_xcodebuild_schemes_or_target "${configuration}" "${srcdir}" "${builddir}" "${relative}" "${name}" "${sdk}" "${project}"  || exit 1
660 708
                   built=yes
661 709
                   break
662 710
                fi
... ...
@@ -1,4 +1,4 @@
1
- #! /bin/sh
1
+#! /bin/sh
2 2
 #
3 3
 #   Copyright (c) 2015 Nat! - Mulle kybernetiK
4 4
 #   All rights reserved.
... ...
@@ -105,7 +105,7 @@ ask_symlink_it()
105 105
       echo "You need to check out ${clone} yourself, as it's not there." >&2 || exit 1
106 106
    fi
107 107
 
108
-   SYMLINK_FORBIDDEN=`read_local_setting "symlink_forbidden"`
108
+   SYMLINK_FORBIDDEN=`read_config_setting "symlink_forbidden"`
109 109
 
110 110
    # check if checked out
111 111
    if [ -d "${clone}"/.git ]
... ...
@@ -165,7 +165,7 @@ checkout()
165 165
    local found
166 166
 
167 167
    srcname="${clone}"
168
-   script=`read_repo_setting "${name1}/bin" "${cmd}.sh"`
168
+   script=`read_repo_setting "${name1}" bin/"${cmd}.sh"`
169 169
    operation="git_command"
170 170
 
171 171
    # simplify this crap copy/paste code
... ...
@@ -233,7 +233,7 @@ Use it instead of cloning ${clone} ?"
233 233
        warn_scripts "${dstname}/.bootstrap" "${dstname}" || exit 1 # sic
234 234
    fi
235 235
 
236
-   script=`read_repo_setting "${name1}/bin" "post-${cmd}.sh"`
236
+   script=`read_repo_setting "${name1}" "bin/post-${cmd}.sh"`
237 237
    if [ -x "${script}" ]
238 238
    then
239 239
       "${script}" || exit 1
... ...
@@ -266,7 +266,7 @@ update()
266 266
          git_command "${clone}" "${dstname}" "${tag}" || exit 1
267 267
       fi
268 268
 
269
-      script=`read_repo_setting "${name}/bin" "post-${cmd}.sh"`
269
+      script=`read_repo_setting "${name}" "bin/post-${cmd}.sh"`
270 270
       if [ -x "${script}" ]
271 271
       then
272 272
          "${script}" || exit 1
... ...
@@ -299,7 +299,7 @@ git_command()
299 299
       then
300 300
          echo "Checkout failed, moving ${dst} to ${dst}.failed" >&2
301 301
          echo "You need to fix this manually and them move it back." >&2
302
-         echo "Hint: check ${BOOTSTRAP_SUBDIR}/`basename \"${dst}\"`/TAG" >&2
302
+         echo "Hint: check ${BOOTSTRAP_SUBDIR}/`basename "${dst}"`/TAG" >&2
303 303
 
304 304
          rm -rf "${dst}.failed" 2> /dev/null
305 305
          mv "${dst}" "${dst}.failed"
... ...
@@ -309,15 +309,18 @@ git_command()
309 309
 }
310 310
 
311 311
 
312
-COPYSETTINGS="taps brews gits pips gems buildorder buildignore"
312
+INHERIT_SETTINGS="taps brews gits pips gems buildorder buildignore"
313 313
 
314 314
 
315 315
 bootstrap_recurse()
316 316
 {
317 317
    local dst
318
+   local name
318 319
 
319 320
    dst="$1"
320
-   [ "${PWD}" = "${dst}" ] && echo "configuration error" >&2 && exit 1
321
+   [ "${PWD}" != "${dst}" ] || fail "configuration error"
322
+
323
+   name=`basename "${dst}"`
321 324
 
322 325
    # contains own bootstrap ? and not a symlink
323 326
    if [ ! -d "${dst}/.bootstrap" ] # -a ! -L "${dst}" ]
... ...
@@ -325,12 +328,13 @@ bootstrap_recurse()
325 328
       return 1
326 329
    fi
327 330
 
331
+   # prepare auto folder if it doesn't exist yet
328 332
    if [ ! -d "${BOOTSTRAP_SUBDIR}.auto" ]
329 333
    then
330
-      echo "Found a .bootstrap folder for `basename \"${dst}\"` will set up ${BOOTSTRAP_SUBDIR}.auto" >&2
334
+      echo "Found a .bootstrap folder for `basename "${dst}"` will set up ${BOOTSTRAP_SUBDIR}.auto" >&2
331 335
 
332 336
       mkdir -p "${BOOTSTRAP_SUBDIR}.auto/settings"
333
-      for i in $COPYSETTINGS
337
+      for i in $INHERIT_SETTINGS
334 338
       do
335 339
          if [ -f "${BOOTSTRAP_SUBDIR}.local/${i}" ]
336 340
          then
... ...
@@ -345,11 +349,10 @@ bootstrap_recurse()
345 349
    fi
346 350
 
347 351
    #
348
-   # we don't copy "other" settings, yet
349 352
    # prepend new contents to old contents
350 353
    # of a few select and known files
351 354
    #
352
-   for i in $COPYSETTINGS
355
+   for i in $INHERIT_SETTINGS
353 356
    do
354 357
       if [ -f "${dst}/.bootstrap/${i}" ]
355 358
       then
... ...
@@ -365,21 +368,23 @@ bootstrap_recurse()
365 368
    done
366 369
 
367 370
    #
368
-   # link up settings
371
+   # link up other non-inheriting settings
369 372
    #
370
-   if [ -f "${dst}/.bootstrap/gits" ]
373
+   if dir_has_files "${dst}/.bootstrap/settings"
371 374
    then
375
+      local relative
372 376
 
373
-      # symlink folders (settings)
374
-      if dir_has_files "${dst}/.bootstrap"
375
-      then
376
-         local relative
377
+      mkdir -p "${BOOTSTRAP_SUBDIR}.auto/settings/${name}" 2> /dev/null
378
+      relative=`compute_relative "${BOOTSTRAP_SUBDIR}"`
379
+      find "${dst}/.bootstrap/settings" -type f -depth 1 -print0 | \
380
+      xargs -0 -I % ln -s -f "${relative}/../../"% "${BOOTSTRAP_SUBDIR}.auto/settings/${name}"
377 381
 
378
-         relative=`compute_relative "${BOOTSTRAP_SUBDIR}"`
379
-         find "${dst}/.bootstrap"/* -depth 1 -type 'd' -print0 | xargs -0 -I % ln -s -f "${relative}/../"% "${BOOTSTRAP_SUBDIR}.auto/settings/"
380
-      fi
382
+      # flatten folders into our own settings
383
+      find "${dst}/.bootstrap/settings" -type d -depth 1 -print0 | \
384
+      xargs -0 -I % ln -s -f "${relative}/../"% "${BOOTSTRAP_SUBDIR}.auto/settings"
381 385
    fi
382 386
 
387
+
383 388
    return 0
384 389
 }
385 390
 
... ...
@@ -426,7 +431,7 @@ clone_repositories()
426 431
          do
427 432
             name1=`basename "${clone}" .git`
428 433
             name2=`basename "${clone}"`
429
-            tag=`read_repo_setting "${name1}" "tag"`
434
+            tag=`read_repo_setting "${name1}" "tag"` #repo (sic)
430 435
 
431 436
             dstname="${CLONES_FETCH_SUBDIR}/${name1}"
432 437
 
... ...
@@ -485,7 +490,7 @@ brew_update_if_needed()
485 490
    then
486 491
    	brew update
487 492
 
488
-	   mkdir -p "`dirname \"${last_update}\"`" 2> /dev/null
493
+	   mkdir -p "`dirname "${last_update}"`" 2> /dev/null
489 494
    	touch "${last_update}"
490 495
    fi
491 496
 }
... ...
@@ -526,7 +531,7 @@ install_brews()
526 531
       brew_update_if_needed
527 532
       for brew in ${brews}
528 533
       do
529
-         if [ "${cmd}" != "install" -o "`which \"${brew}\"`" = "" ]
534
+         if [ "${cmd}" != "install" -o "`which "${brew}"`" = "" ]
530 535
          then
531 536
             brew "$cmd" "${brew}" || exit 1
532 537
          fi
... ...
@@ -548,7 +553,7 @@ install_gems()
548 553
       for gem in ${gems}
549 554
       do
550 555
          echo "gem needs sudo to install ${gem}" >&2
551
-         sudo gem install ${gem} || exit 1
556
+         sudo gem install "${gem}" || exit 1
552 557
       done
553 558
    fi
554 559
 }
... ...
@@ -567,7 +572,7 @@ install_pips()
567 572
       for pip in ${pips}
568 573
       do
569 574
          echo "pip needs sudo to install ${pip}" >&2
570
-         sudo pip install ${pip} || exit 1
575
+         sudo pip install "${pip}" || exit 1
571 576
       done
572 577
    fi
573 578
 }
... ...
@@ -42,7 +42,7 @@ fail()
42 42
 internal_fail()
43 43
 {
44 44
    fail "**** mulle-bootstrap internal error ****
45
-" "$@"
45
+$*"
46 46
 }
47 47
 
48 48
 
... ...
@@ -50,7 +50,7 @@ is_yes()
50 50
 {
51 51
    local s
52 52
 
53
-   s="`echo \"${1}\" | tr '[:lower:]' '[:upper:]'`"
53
+   s=`echo "${1}" | tr '[:lower:]' '[:upper:]'`
54 54
    case "${s}" in
55 55
       YES|Y|1)
56 56
          return 0
... ...
@@ -104,7 +104,7 @@ path_depth()
104 104
          depth=`expr $depth + 1`
105 105
       done
106 106
    fi
107
-   echo $depth
107
+   echo "$depth"
108 108
 }
109 109
 
110 110
 
... ...
@@ -130,6 +130,23 @@ compute_relative()
130 130
 }
131 131
 
132 132
 
133
+remove_absolute_path_prefix_up_to()
134
+{
135
+   local s
136
+   local prefix
137
+
138
+   s="$1"
139
+   prefix="$2"
140
+
141
+   if [ "`basename "${s}"`" = "${prefix}" ]
142
+   then
143
+      return 0
144
+   fi
145
+
146
+   echo "${s}" | sed "s|^.*/${prefix}/\(.*\)*|\1|g"
147
+}
148
+
149
+
133 150
 user_say_yes()
134 151
 {
135 152
   local  x
... ...
@@ -171,7 +188,7 @@ fetch_brew_if_needed()
171 188
 
172 189
    last_update="${HOME}/.mulle-bootstrap/brew-update"
173 190
 
174
-   binary="`which brew`"
191
+   binary=`which brew`
175 192
    if [ "${binary}" = "" ]
176 193
    then
177 194
       user_say_yes "Brew isn't installed on this system.
... ...
@@ -187,7 +204,7 @@ Install brew now (Linux or OS X should work) ? "
187 204
          ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)" || exit 1
188 205
       fi
189 206
 
190
-      mkdir -p "`dirname \"${last_update}\"`" 2> /dev/null
207
+      mkdir -p "`dirname "${last_update}"`" 2> /dev/null
191 208
       touch "${last_update}"
192 209
       return 1
193 210
    fi
... ...
@@ -249,6 +266,17 @@ warn_user_setting()
249 266
 }
250 267
 
251 268
 
269
+warn_local_setting()
270
+{
271
+   local name
272
+
273
+   name="$1"
274
+   if [ "${DONT_WARN_RECURSION}" = "" -a "`DONT_WARN_RECURSION=YES read_local_setting \"dont_warn_local_setting\"`" = "" ]
275
+   then
276
+      echo "Using ${BOOTSTRAP_SUBDIR}.local/${name}" >& 2
277
+   fi
278
+}
279
+
252 280
 #
253 281
 # this knows intentionally no default, you cant have an empty
254 282
 # local setting
... ...
@@ -294,6 +322,8 @@ read_local_setting()
294 322
    local value
295 323
    local default
296 324
 
325
+   [ $# -lt 1 -o $# -gt 2 ] && internal_fail "parameterization error"
326
+
297 327
    name="$1"
298 328
    default="$2"
299 329
 
... ...
@@ -310,29 +340,61 @@ read_local_setting()
310 340
 }
311 341
 
312 342
 
313
-read_sane_local_path_setting()
343
+#
344
+# this has to be flexible, because fetch and build settings read differently
345
+#
346
+_read_bootstrap_setting()
314 347
 {
315 348
    local name
316 349
    local value
317 350
    local default
351
+   local suffix1
352
+   local suffix2
353
+   local suffix3
318 354
 
319 355
    name="$1"
320
-   default="$2"
356
+   suffix1="$2"
357
+   suffix2="$3"
358
+   suffix3="$4"
359
+   default="$5"
321 360
 
322
-   value=`_read_local_setting "${name}"`
323
-   if [ "$?" -ne 0 ]
361
+   [ $# -lt 4 -o $# -gt 5 ] && internal_fail "parameterization error"
362
+   [ "$name" = "" ] && internal_fail "missing parameters in _read_bootstrap_setting"
363
+
364
+   value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}${suffix1}/${name}" 2> /dev/null`
365
+   if [ $? -gt 1 ]
324 366
    then
325
-      case "${value}"  in
326
-         \$*|~/.|..|./|../|/*)
327
-            echo "refuse unsafe path ${value} for ${name}" >&2
328
-            exit 1
329
-         ;;
330
-      esac
331
-   else
332
-      if [ "$value" = "" ]
367
+      value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}${suffix2}/${name}" 2> /dev/null`
368
+      if [ $? -gt 1 ]
333 369
       then
334
-         value="${default}"
370
+         value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}${suffix3}/${name}" 2> /dev/null`
371
+         if [ $? -gt 1 ]
372
+         then
373
+            if [ $# -eq 4 ]
374
+            then
375
+               return 2
376
+            fi
377
+            value="${default}"
378
+         else
379
+            case "$1" in
380
+               .local*)
381
+                  warn_local_setting "${name}"
382
+               ;;
383
+            esac
384
+         fi
385
+      else
386
+         case "$1" in
387
+            .local*)
388
+               warn_local_setting "${name}"
389
+            ;;
390
+         esac
335 391
       fi
392
+   else
393
+      case "$1" in
394
+         .local*)
395
+            warn_local_setting "${name}"
396
+         ;;
397
+      esac
336 398
    fi
337 399
 
338 400
    echo "$value"
... ...
@@ -342,24 +404,14 @@ read_sane_local_path_setting()
342 404
 }
343 405
 
344 406
 
345
-warn_local_setting()
346
-{
347
-   local name
348
-
349
-   name="$1"
350
-   if [ "${DONT_WARN_RECURSION}" = "" -a "`DONT_WARN_RECURSION=YES read_local_setting \"dont_warn_local_setting\"`" = "" ]
351
-   then
352
-      echo "Using ${BOOTSTRAP_SUBDIR}.local/${name}" >& 2
353
-   fi
354
-}
355
-
356
-
357
-# "auto" after base
358 407
 read_repo_setting()
359 408
 {
360 409
    local name
361 410
    local value
362 411
    local default
412
+   local value
413
+
414
+   [ $# -lt 2 -o $# -gt 3 ] && internal_fail "parameterization error"
363 415
 
364 416
    package="$1"
365 417
    name="$2"
... ...
@@ -367,75 +419,34 @@ read_repo_setting()
367 419
 
368 420
    [ "$name" = "" -o "$package" = "" ] && internal_fail "missing parameters in read_repo_setting"
369 421
 
370
-   value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}.local/settings/${package}/${name}" 2> /dev/null`
371
-   if [ $? -gt 1 ]
422
+   # need to conserve return value 2 if empty
423
+   if [ $# -eq 2 ]
372 424
    then
373
-      value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}/settings/${package}/${name}" 2> /dev/null`
374
-      if [ $? -gt 1 ]
375
-      then
376
-         value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}.auto/settings/${package}/${name}" 2> /dev/null`
377
-         if [ $? -gt 1 ]
378
-         then
379
-            if [ $# -eq 2 ]
380
-            then
381
-               return 2
382
-            fi
383
-
384
-            value="${default}"
385
-         fi
386
-      fi
425
+      _read_bootstrap_setting  "settings/${package}/${name}" ".local" "" ".auto"
387 426
    else
388
-      warn_local_setting "${name}"
427
+      _read_bootstrap_setting  "settings/${package}/${name}" ".local" "" ".auto" "${default}"
389 428
    fi
390
-   echo "$value"
391
-
392
-   [ "${value}" = "${default}" ]
393
-   return $?
394 429
 }
395 430
 
396 431
 
397 432
 #
398
-# this has to be flexible, because fetch and build settings read differently
433
+# the default
399 434
 #
400
-_read_bootstrap_setting()
435
+read_config_setting()
401 436
 {
402 437
    local name
403 438
    local value
404 439
    local default
405
-   local suffix1
406
-   local suffix2
407
-   local suffix3
408 440
 
409
-   name="$1"
410
-   suffix1="$2"
411
-   suffix2="$3"
412
-   suffix3="$4"
413
-   default="$5"
441
+   [ $# -lt 1 -o $# -gt 2 ] && internal_fail "parameterization error"
414 442
 
415
-   [ "$name" = "" ] && internal_fail "missing parameters in _read_bootstrap_setting"
443
+   name="$1"
444
+   default="$2"
416 445
 
417
-   value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}${suffix1}/${name}" 2> /dev/null`
418
-   if [ $? -gt 1 ]
446
+   value=`_read_bootstrap_setting "${name}" ".local/config" "config" ".auto/config"`
447
+   if [ "${value}" = "" ]
419 448
    then
420
-      value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}${suffix2}/${name}" 2> /dev/null`
421
-      if [ $? -gt 1 ]
422
-      then
423
-         value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}${suffix3}/${name}" 2> /dev/null`
424
-         if [ $? -gt 1 ]
425
-         then
426
-            if [ $# -eq 1 ]
427
-            then
428
-               return 2
429
-            fi
430
-            value="${default}"
431
-         else
432
-            [ "$suffix1" = ".local" ] && warn_local_setting "${name}"
433
-         fi
434
-      else
435
-         [ "$suffix1" = ".local" ] && warn_local_setting "${name}"
436
-      fi
437
-   else
438
-      [ "$suffix1" = ".local" ] && warn_local_setting "${name}"
449
+      value=`read_local_setting "${name}" "${default}"`
439 450
    fi
440 451
 
441 452
    echo "$value"
... ...
@@ -444,15 +455,18 @@ _read_bootstrap_setting()
444 455
    return $?
445 456
 }
446 457
 
447
-#
448
-# the default
449
-#
450
-_read_build_setting()
458
+
459
+read_fetch_setting()
451 460
 {
452
-   _read_bootstrap_setting "$1" ".local" "" ".auto" "$2"
461
+   _read_bootstrap_setting "$1" ".auto" ".local" "" "$2"
453 462
 }
454 463
 
455 464
 
465
+_read_build_setting()
466
+{
467
+   _read_bootstrap_setting "$1" ".local/settings" "/settings" ".auto/settings" "$2"
468
+}
469
+
456 470
 
457 471
 read_build_setting()
458 472
 {
... ...
@@ -464,7 +478,8 @@ read_build_setting()
464 478
    name="$2"
465 479
    default="$3"
466 480
 
467
-   [ "$name" = "" -o "$package" = "" ] && internal_fail "missing parameters in read_build_setting"
481
+   [ $# -lt 2 -o $# -gt 3 ] && internal_fail "parameterization error"
482
+   [ "$name" = "" -o "$package" = "" ] && internal_fail "empty parameters in read_build_setting"
468 483
 
469 484
    value=`read_repo_setting "${package}" "${name}"`
470 485
    if [ $? -gt 1 ]
... ...
@@ -490,22 +505,48 @@ read_build_setting()
490 505
 
491 506
 read_build_root_setting()
492 507
 {
493
-   _read_bootstrap_setting "$1" ".local" "" ".auto" "$2"
508
+   _read_build_setting "$@"
494 509
 }
495 510
 
496 511
 
497
-read_fetch_setting()
512
+read_yes_no_build_setting()
498 513
 {
499
-   _read_bootstrap_setting "$1" ".auto" ".local" "" "$2"
514
+   local value
515
+
516
+   value=`read_build_setting "$1" "$2" "$3"`
517
+   is_yes "$value" "$1/$2"
500 518
 }
501 519
 
502 520
 
503
-read_yes_no_build_setting()
521
+read_sane_config_path_setting()
504 522
 {
523
+   local name
505 524
    local value
525
+   local default
506 526
 
507
-   value="`read_build_setting \"$1\" \"$2\" \"$3\"`"
508
-   is_yes "$value" "$1/$2"
527
+   name="$1"
528
+   default="$2"
529
+
530
+   value=`read_config_setting "${name}"`
531
+   if [ "$?" -ne 0 ]
532
+   then
533
+      case "${value}"  in
534
+         \$*|~/.|..|./|../|/*)
535
+            echo "refuse unsafe path ${value} for ${name}" >&2
536
+            exit 1
537
+         ;;
538
+      esac
539
+   else
540
+      if [ "$value" = "" ]
541
+      then
542
+         value="${default}"
543
+      fi
544
+   fi
545
+
546
+   echo "$value"
547
+
548
+   [ "${value}" = "${default}" ]
549
+   return $?
509 550
 }
510 551
 
511 552
 
... ...
@@ -31,19 +31,16 @@
31 31
 
32 32
 gcc_sdk_parameter()
33 33
 {
34
-   local mode
35 34
    local sdk
36 35
    local sdkpath
37 36
 
38
-
39
-   mode="$1"
40
-   sdk="$2"
37
+   sdk="$1"
41 38
 
42 39
    if [ "`uname`" = "Darwin" ]
43 40
    then
44 41
       if [ "${sdk}" != "Default" ]
45 42
       then
46
-         sdkpath="`xcrun --sdk macosx --show-sdk-path`"
43
+         sdkpath=`xcrun --sdk macosx --show-sdk-path`
47 44
          if [ "${sdkpath}" = "" ]
48 45
          then
49 46
             fail "SDK \"${sdk}\" is not installed"
... ...
@@ -64,15 +61,16 @@ gcc_cflags_value()
64 61
    local value
65 62
    local result
66 63
    local name
64
+   local i
67 65
 
68 66
    name="${1}"
69 67
 
70 68
    result=`get_build_setting "${name}" "OTHER_CFLAGS"`
71 69
    value=`get_build_setting "${name}"  "WARNING_CFLAGS"`
72
-   result="`concat  \"$result\" \"$value\"`"
73
-   for i  in `get_build_setting "${name}" "GCC_PREPROCESSOR_DEFINITIONS"`
70
+   result=`concat "$result" "$value"`
71
+   for i in `get_build_setting "${name}" "GCC_PREPROCESSOR_DEFINITIONS"`
74 72
    do
75
-      result="`concat \"$result\" \"-D${value}\"`"
73
+      result=`concat "$result" "-D${i}"`
76 74
    done
77 75
 
78 76
    echo "${result}"
... ...
@@ -89,7 +87,7 @@ gcc_cppflags_value()
89 87
 
90 88
    result=`get_build_setting "${name}" "OTHER_CPPFLAGS"`
91 89
    value=`gcc_cflags_value "${name}"`
92
-   result="`concat  \"$result\" \"$value\"`"
90
+   result=`concat "$result" "$value"`
93 91
 
94 92
    echo "${result}"
95 93
 }
... ...
@@ -54,23 +54,23 @@ fi
54 54
 #
55 55
 
56 56
 
57
-CLONES_SUBDIR_IS_CLEANABLE=`read_local_setting clean_repos_folder`
58
-CLONES_SUBDIR=`read_sane_local_path_setting "repos_foldername" ".repos"`
57
+CLONES_SUBDIR_IS_CLEANABLE=`read_config_setting clean_repos_folder`
58
+CLONES_SUBDIR=`read_sane_config_path_setting "repos_foldername" ".repos"`
59 59
 if [ $? -eq 0 -a "${CLONES_SUBDIR_IS_CLEANABLE}" = "" ]
60 60
 then
61 61
    CLONES_SUBDIR_IS_CLEANABLE="YES"
62 62
 fi
63 63
 
64 64
 
65
-CLONESBUILD_SUBDIR_IS_CLEANABLE=`read_local_setting clean_build_folder`
66
-CLONESBUILD_SUBDIR=`read_sane_local_path_setting "build_foldername" "build/.repos"`
65
+CLONESBUILD_SUBDIR_IS_CLEANABLE=`read_config_setting clean_build_folder`
66
+CLONESBUILD_SUBDIR=`read_sane_config_path_setting "build_foldername" "build/.repos"`
67 67
 if [ $? -eq 0 -a "${CLONESBUILD_SUBDIR_IS_CLEANABLE}" = "" ]
68 68
 then
69 69
    CLONESBUILD_SUBDIR_IS_CLEANABLE="YES"
70 70
 fi
71 71
 
72
-DEPENDENCY_SUBDIR_IS_DIST_CLEANABLE=`read_local_setting clean_output_folder`
73
-DEPENDENCY_SUBDIR=`read_sane_local_path_setting "output_foldername" "dependencies"`
72
+DEPENDENCY_SUBDIR_IS_DIST_CLEANABLE=`read_config_setting clean_output_folder`
73
+DEPENDENCY_SUBDIR=`read_sane_config_path_setting "output_foldername" "dependencies"`
74 74
 if [ $? -eq 0 -a "${DEPENDENCY_SUBDIR_IS_DIST_CLEANABLE}" = "" ]
75 75
 then
76 76
    DEPENDENCY_SUBDIR_IS_DIST_CLEANABLE="YES"
... ...
@@ -82,7 +82,6 @@ then
82 82
    CLONES_FETCH_SUBDIR="${CLONES_SUBDIR}"
83 83
 fi
84 84
 
85
-
86 85
 #
87 86
 #
88 87
 #
... ...
@@ -94,4 +93,15 @@ fi
94 93
 if [ "${CLONES_RELATIVE}" = "" ]
95 94
 then
96 95
    CLONES_RELATIVE=`compute_relative "${CLONES_SUBDIR}"`
97
-fi
98 96
\ No newline at end of file
97
+fi
98
+
99
+#
100
+# some checks
101
+#
102
+[ -z "${BOOTSTRAP_SUBDIR}" ]     && internal_fail "variable BOOTSTRAP_SUBDIR is empty"
103
+[ -z "${CLONES_SUBDIR}" ]        && internal_fail "variable CLONES_SUBDIR is empty"
104
+[ -z "${CLONESBUILD_SUBDIR}" ]   && internal_fail "variable CLONESBUILD_SUBDIR is empty"
105
+[ -z "${DEPENDENCY_SUBDIR}" ]    && internal_fail "variable DEPENDENCY_SUBDIR is empty"
106
+[ -z "${CLONES_RELATIVE}" ]      && internal_fail "variable CLONES_RELATIVE is empty"
107
+[ -z "${CLONESBUILD_RELATIVE}" ] && internal_fail "CLONESBUILD_RELATIVE is empty"
108
+
... ...
@@ -51,11 +51,12 @@ then
51 51
    fi
52 52
 fi
53 53
 
54
+
54 55
 TAG=${1:-${AGVTAG}}
55 56
 shift
56
-VENDOR_PREFIX=${1:-`basename "${PWD}"`}
57
+VENDOR_PREFIX="${1:-${name}}"
57 58
 shift
58
-REPO=${1:-.}
59
+REPO=${1:-"."}
59 60
 shift
60 61
 
61 62
 if [ "$TAG" = "" ]
... ...
@@ -92,6 +93,7 @@ git_must_be_clean()
92 93
    fi
93 94
 }
94 95
 
96
+
95 97
 ensure_repos_clean()
96 98
 {
97 99
    #
... ...
@@ -130,36 +132,28 @@ pretag_script()
130 132
 tag()
131 133
 {
132 134
    local i
135
+   local script
133 136
 
134
-   #
135
-   # Tag repos
136
-   #
137
-   script=`read_repo_setting "bin/pre-tag.sh"`
138
-   if [ -x "${script}" ]
139
-   then
140
-      "${script}" || exit 1
141
-   fi
142
-
143
-   ( cd "${REPO}" ; git tag "${TAG}" ) || exit 1
144
-
145
-   if  dir_has_files "${CLONES_SUBDIR}"
137
+   script=`read_fetch_setting "bin/tag.sh"`
138
+   if [ -x "$script" ]
146 139
    then
147
-      for i in "${CLONES_SUBDIR}"/*
148
-      do
149
-         if [ -d "$i" ]
150
-         then
151
-            if [ -d "${i}/.git" -o -d "${i}/refs" ]
140
+      "$script" "${TAG}" "${REPO}" || exit 1
141
+   else
142
+      ( cd "${REPO}" ; git tag "${TAG}" ) || exit 1
143
+
144
+      if  dir_has_files "${CLONES_SUBDIR}"
145
+      then
146
+         for i in "${CLONES_SUBDIR}"/*
147
+         do
148
+            if [ -d "$i" ]
152 149
             then
153
-               (cd "$i" ; git tag "${OUR_VENDOR_TAG}" ) || exit 1
150
+               if [ -d "${i}/.git" -o -d "${i}/refs" ]
151
+               then
152
+                  (cd "$i" ; git tag "${OUR_VENDOR_TAG}" ) || exit 1
153
+               fi
154 154
             fi
155
-         fi
156
-      done
157
-   fi
158
-
159
-   script=`read_repo_setting "bin/post-tag.sh"`
160
-   if [ -x "${script}" ]
161
-   then
162
-      "${script}" || exit 1
155
+         done
156
+      fi
163 157
    fi
164 158
 }
165 159
 
... ...
@@ -29,6 +29,7 @@
29 29
 #   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 30
 #   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 31
 #   POSSIBILITY OF SUCH DAMAGE.
32
+
32 33
 private_dir_has_files()
33 34
 {
34 35
    local empty
... ...
@@ -95,7 +96,7 @@ warn_scripts()
95 96
             echo "brew install ack ; ack -A1 \"shellPath|shellScript\"" >&2
96 97
             echo "$phases" >&2
97 98
          else
98
-            ack -A1 "shellPath|shellScript" `echo "$phases" | tr '\n' ' '` >&2
99
+            ack -A1 "shellPath|shellScript" `echo $phases | tr '\n' ' '` >&2
99 100
          fi
100 101
          echo "" >&2
101 102
       fi
... ...
@@ -10,9 +10,9 @@ shift
10 10
 
11 11
 . mulle-bootstrap-local-environment.sh
12 12
 
13
-HEADER_PATH=`read_local_setting "header_path" "/include"`
14
-LIBRARY_PATH=`read_local_setting "library_path" "/lib"`
15
-FRAMEWORK_PATH=`read_local_setting "framework_path" "/Frameworks"`
13
+HEADER_PATH=`read_config_setting "header_path" "/include"`
14
+LIBRARY_PATH=`read_config_setting "library_path" "/lib"`
15
+FRAMEWORK_PATH=`read_config_setting "framework_path" "/Frameworks"`
16 16
 
17 17
 case "$COMMAND" in
18 18
    add)
... ...
@@ -192,7 +192,7 @@ patch_xcode_project()
192 192
       fail "no xcodeproj found"
193 193
    fi
194 194
 
195
-   projectname="`basename \"${project}\"`"
195
+   projectname="`basename "${project}"`"
196 196
 
197 197
    #     012345678901234567890123456789012345678901234567890123456789
198 198
    echo "This operation will not destroy any existing settings." >&2