Browse code

Add possibility to install tarballs (e.g. Crashlytics.framework). First steps towards helpful usage output.

Nat! authored on 01-10-2015 12:54:38
Showing 11 changed files
... ...
@@ -38,7 +38,8 @@ dependencies. Optimally this folder is empty or non-existant.
38 38
 * Folders in `.bootstrap.auto/repos` are the settings inherited from
39 39
 .bootstrap.
40 40
 
41
-### How are multiple values separated ?
41
+
42
+### How are multiple value settings separated ?
42 43
 
43 44
 Separation is done by newline, not by space.
44 45
 
... ...
@@ -50,7 +51,11 @@ Release" > .bootstrap/settings/configurations # RIGHT
50 51
 ```
51 52
 
52 53
 
53
-### The default target/scheme is not the one I want ?
54
+### mulle-bootstrap does not do what  I want  ?
55
+
56
+Check out the SETTINGS.md file for help  about tweaking  mulle-bootstrap.
57
+
58
+As an example, here is how to specify what target to build.
54 59
 
55 60
 Put the target name into `.bootstrap/settings/{reponame}/targets`
56 61
 
... ...
@@ -59,48 +64,6 @@ mkdir -p  ".bootstrap/settings/Finch" 2> /dev/null
59 64
 echo "Finch Demo" > .bootstrap/Finch/targets
60 65
 ```
61 66
 
62
-Use "schemes" instead of "targets" to specify a scheme.
63
-
64
-### Can it build to various specific SDKs ?
65
-
66
-Put the SDK names into ".bootstrap/settings/sdks".
67
-
68
-```console
69
-mkdir -p  ".bootstrap/settings/sdks" 2> /dev/null
70
-cat <<EOF > .bootstrap/settings/sdks
71
-iphoneos
72
-iphonesimulator
73
-EOF
74
-```
75
-
76
-Or if you don't want to change .bootstrap for temporary edits:
77
-
78
-```console
79
-cat <<EOF > .bootstrap.local/sdks
80
-iphoneos
81
-iphonesimulator
82
-EOF
83
-```
84
-
85
-
86
-### I don't like the name "dependencies" for the output folder ?
87
-
88
-You could rename it to "output" persistently with
89
-
90
-```console
91
-echo "output" > ~/.mulle-bootstrap/output_foldername
92
-```
93
-
94
-If want to rename for just this project ?
95
-
96
-```console
97
-mkdir -p .bootstrap.local 2> /dev/null
98
-echo "output" > .bootstrap.local/output_foldername
99
-```
100
-
101
-If you do this after running **mulle-bootstrap setup-xcode**, you will run into
102
-problems.
103
-
104 67
 ### Can I change the build folder from build/.repos to something else  ?
105 68
 
106 69
 Better not. You can set it with "build_foldername".
... ...
@@ -113,13 +76,7 @@ so choosing `~` or `/tmp` as a build folder is not a great idea.</font>
113 76
 echo "you_have/been_warned" > ~/.bootstrap.local/build_foldername
114 77
 ```
115 78
 
116
-### Can I change the repository folder name from .repos to something else ?
117
-
118
-Somewhat, but it must remain toplevel for now, otherwise the
119
-detection of local clone copies gets wonky. So with that in mind: as above, but
120
-use "repos_foldername" instead.
121
-
122
-### What happens when I symlink something ?
79
+### What happens when I symlink a folder instead of cloning it ?
123 80
 
124 81
 It is assumed, that the repository link is "usable" as is. Specifically it won't
125 82
 be recursively bootstrapped. It also won't get any kind of .bootstrap
... ...
@@ -146,7 +103,6 @@ mkdir -p .bootstrap/Foo 2> /dev/null
146 103
 echo "BrandedFoo" > .bootstrap/settings/Foo/PRODUCT_NAME
147 104
 ```
148 105
 
149
-
150 106
 If you have lots of stuff, you may want to use your own **.xcconfig** file. This
151 107
 is likely to be more useful if placed into the .bootstrap folder directly.
152 108
 
... ...
@@ -155,14 +111,6 @@ mkdir -p  ".bootstrap/settings" 2> /dev/null
155 111
 cp myconfig.xcconfig > .bootstrap/settings/xcconfig
156 112
 ```
157 113
 
158
-
159
-Need to add some other magic Xcode build flags ?
160
-
161
-```console
162
-mkdir -p  ".bootstrap/settings" 2> /dev/null
163
-echo "-verbose" > .bootstrap/settings/xcodebuild-flags
164
-```
165
-
166 114
 ### Should I put build settings into .bootstrap/{reponame} or into .bootstrap ?
167 115
 
168 116
 It's better to specify build settings on a per repository basis. Repository
... ...
@@ -49,6 +49,27 @@ then
49 49
    shift
50 50
 fi
51 51
 
52
+if [ "$1" = "-v" ]
53
+then
54
+   MULLE_BOOTSTRAP_TRACE=VERBOSE
55
+   export MULLE_BOOTSTRAP_TRACE
56
+   GITFLAGS="-v"
57
+   export GITFLAGS
58
+   shift
59
+fi
60
+
61
+if [ "$1" = "-s" ] # silent
62
+then
63
+   MULLE_BOOTSTRAP_TRACE=
64
+   MULLE_BOOTSTRAP_TERSE=YES
65
+   export MULLE_BOOTSTRAP_TERSE
66
+   GITFLAGS="-q"
67
+   export GITFLAGS
68
+   shift
69
+fi
70
+
71
+
72
+
52 73
 command=${1:-"bootstrap"}
53 74
 shift
54 75
 
... ...
@@ -117,24 +138,30 @@ case "${command}" in
117 138
    tag)
118 139
       mulle-bootstrap-tag.sh "$@" || exit 1
119 140
       ;;
141
+
120 142
    *)
121
-      echo "usage: mulle-bootstrap [-n] [command]" >&2
122
-      echo "version 0.1" >&2
123
-      echo    " Common user commands:" >&2
124
-      echo    "   bootstrap : does fetch and build recursively [default]" >&2
125
-      echo    "   nomagic   : does fetch and build, but not recursively" >&2
126
-      echo    "" >& 2
127
-      echo    " Common maintainer commands:" >&2
128
-      echo    "   init      : initializes a bootstrap project" >&2
129
-      echo    "   xcode [o] : sets up the xcodeproj settings" >&2
130
-      echo    "               with [o=remove] removes settings again." >&2
131
-      echo    "   tag       : tag this project and fetched repositories" >&2
132
-      echo    "" >& 2
133
-      echo    " Specialized commands:" >&2
134
-      echo    "   build     : builds fetched repositories" >&2
135
-      echo    "   fetch [o] : fetches required repositories recursively." >&2
136
-      echo    "               whith [o=nonrecursive] fetches non recursively." >&2
137
-      echo    "   clean [o] : cleans intermediate build files." >&2
138
-      echo    "               with [o=dist] cleans clones and dependencies too." >&2
143
+      echo "usage: mulle-bootstrap [-n][-v][-s] [command]" >&2
144
+      echo "version 0.2" >&2
145
+      echo " Flags (must be in this order)" >&2
146
+      echo "   -n        : do nothing creative or destructive" >&2
147
+      echo "   -v        : be more verbose" >&2
148
+      echo "   -s        : be more terse" >&2
149
+      echo ""
150
+      echo " Common user commands:" >&2
151
+      echo "   bootstrap : does fetch and build recursively [default]" >&2
152
+      echo "   nomagic   : does fetch and build, but not recursively" >&2
153
+      echo "" >& 2
154
+      echo " Common maintainer commands:" >&2
155
+      echo "   init      : initializes a bootstrap project" >&2
156
+      echo "   xcode [o] : sets up the xcodeproj settings" >&2
157
+      echo "               with [o=remove] removes settings again." >&2
158
+      echo "   tag       : tag this project and fetched repositories" >&2
159
+      echo "" >& 2
160
+      echo " Specialized commands:" >&2
161
+      echo "   build     : builds fetched repositories" >&2
162
+      echo "   fetch [o] : fetches required repositories recursively." >&2
163
+      echo "               whith [o=nonrecursive] fetches non recursively." >&2
164
+      echo "   clean [o] : cleans intermediate build files." >&2
165
+      echo "               with [o=dist] cleans clones and dependencies too." >&2
139 166
       exit 1
140 167
 esac
... ...
@@ -33,6 +33,19 @@
33 33
 .  mulle-bootstrap-gcc.sh
34 34
 
35 35
 
36
+check_and_usage_and_help()
37
+{
38
+   echo "usage: mulle-bootstrap-build.sh [repos]*" 2>&1
39
+   exit 1
40
+}
41
+
42
+
43
+if [ "$1" = "-h" -o "$1" = "--help" ]
44
+then
45
+   check_and_usage_and_help
46
+fi
47
+
48
+
36 49
 CLEAN_BEFORE_BUILD=`read_config_setting "clean_before_build"`
37 50
 HEADER_PATH=`read_config_setting "header_path" "/include"`
38 51
 LIBRARY_PATH=`read_config_setting "library_path" "/lib"`
... ...
@@ -43,74 +56,190 @@ FRAMEWORK_PATH=`read_config_setting "framework_path" "/Frameworks"`
43 56
 # where we expect them. Expect  others to build to
44 57
 # <prefix>/include  and <prefix>/lib or <prefix>/Frameworks
45 58
 #
46
-collect_and_dispense_product()
59
+dispense_headers()
47 60
 {
48
-   local  subdir
49
-   local  dst
50 61
    local  src
51 62
 
52
-   output="$1"
53
-   subdir="$2"
63
+   src="$1"
64
+
65
+   local dst
66
+   local usrlocal
67
+
68
+   log_fluff "Considering copying ${src}"
54 69
 
55
-   src="${output}/include"
56 70
    if [ -d "${src}" ]
57 71
    then
58 72
       if dir_has_files "${src}"
59 73
       then
60
-         dst="${DEPENDENCY_SUBDIR}${HEADER_PATH}"
61
-         exekutor mkdir -p "${dst}" 2> /dev/null
62
-         exekutor find -x "${src}" ! -path "${src}" -depth 1 -type d -exec mv -v -n '{}' "${dst}" \;  2> /dev/null
63
-         exekutor find -x  "${src}" ! -path "${src}" -depth 1 -type f -exec mv -v -n '{}' "${dst}" \;  2> /dev/null
74
+         usrlocal="`read_build_setting "headers_c_and_d_prefix" "/usr/local"`"
75
+
76
+         dst="${REFERENCE_DEPENDENCY_SUBDIR}${usrlocal}${HEADER_PATH}"
77
+         mkdir_if_missing "${REFERENCE_DEPENDENCY_SUBDIR}${usrlocal}${HEADER_PATH}"
78
+
79
+         log_fluff "Copying ${src} to ${dst}"
80
+         exekutor find -x "${src}" ! -path "${src}" -depth 1 -type d -print0 | \
81
+            exekutor xargs -0 -J % mv -v -n % "${dst}"
82
+         [ $? -eq 0 ]  || exit 1
83
+         exekutor find -x "${src}" ! -path "${src}" -depth 1 -type f -print0 | \
84
+            exekutor xargs -0 -J % mv -v -n % "${dst}"
85
+         [ $? -eq 0 ]  || exit 1
86
+         rmdir_safer "${src}"
64 87
       fi
65
-      exekutor rm -rf "${src}"
66 88
    fi
89
+}
90
+
91
+
92
+dispense_binaries()
93
+{
94
+   local src
95
+
96
+   src="$1"
97
+   findtype="$2"
98
+   subpath="$3"
99
+
100
+   local dst
101
+   local usrlocal
67 102
 
68
-   src="${output}/lib"
69
-   if [ -d  "${src}" ]
103
+   log_fluff "Considering copying ${src}"
104
+
105
+   if [ -d "${src}" ]
70 106
    then
71 107
       if dir_has_files "${src}"
72 108
       then
73
-         dst="${DEPENDENCY_SUBDIR}${LIBRARY_PATH}${subdir}"
74
-         exekutor mkdir -p "${dst}" 2> /dev/null
75
-         exekutor find -x  "${src}" ! -path "${src}" -depth 1 -exec mv -v '{}' "${dst}" \;  2> /dev/null
109
+         dst="${REFERENCE_DEPENDENCY_SUBDIR}${subpath}${subdir}"
110
+
111
+         log_fluff "Copying ${src} to ${dst}"
112
+         mkdir_if_missing "${dst}"
113
+         exekutor find -x "${src}" ! -path "${src}" -type "${findtype}" -depth 1 -print0 | \
114
+            exekutor xargs -0 -J % mv -v -n % "${dst}"
115
+         [ $? -eq 0 ]  || exit 1
76 116
       fi
77
-      exekutor rm -rf "${src}"
117
+      rmdir_safer "${src}"
78 118
    fi
119
+}
79 120
 
80
-   src="${output}/Frameworks"
81
-   if [ -d "${src}" ]
121
+
122
+collect_and_dispense_product()
123
+{
124
+   local  subdir
125
+   local  dst
126
+   local  src
127
+
128
+   subdir="$1"
129
+   wasxcode="$2"
130
+
131
+   log_fluff "Start collecting and dispensing product"
132
+   #
133
+   # probably should use install_name_tool to hack all dylib paths that contain .ref
134
+   # (will this work with signing stuff ?)
135
+   #
136
+   if [ "${wasxcode}" = "YES" ]
82 137
    then
83
-      if dir_has_files "${src}"
84
-      then
85
-         dst="${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${subdir}"
86
-         exekutor mkdir -p "${dst}" 2> /dev/null
87
-         exekutor find -x "${src}" ! -path "${src}" -depth 1 -exec mv -v '{}' "${dst}" \; 2> /dev/null
88
-      fi
89
-      exekutor rm -rf "${src}"
138
+      log_fluff "Choosing xcode dispense path"
139
+
140
+      src="${BUILD_DEPENDENCY_SUBDIR}/usr/local/include"
141
+      dispense_headers "${src}"
142
+
143
+      src="${BUILD_DEPENDENCY_SUBDIR}/usr/include"
144
+      dispense_headers "${src}"
145
+
146
+      src="${BUILD_DEPENDENCY_SUBDIR}/include"
147
+      dispense_headers "${src}"
148
+
149
+      src="${BUILD_DEPENDENCY_SUBDIR}/lib${subdir}"
150
+      dispense_binaries "${src}" "f" "${LIBRARY_PATH}"
151
+
152
+      src="${BUILD_DEPENDENCY_SUBDIR}/Frameworks${subdir}"
153
+      dispense_binaries "${src}" "d" "${FRAMEWORK_PATH}"
154
+   else
155
+      log_fluff "Choosing cmake/configure dispense path"
156
+
157
+      src="${BUILD_DEPENDENCY_SUBDIR}/usr/local/include"
158
+      dispense_headers "${src}"
159
+
160
+      src="${BUILD_DEPENDENCY_SUBDIR}/usr/local/lib"
161
+      dispense_binaries "${src}" "f" "${LIBRARY_PATH}"
162
+
163
+      # coming from Cmake and configure
164
+      src="${BUILD_DEPENDENCY_SUBDIR}/usr/local/Frameworks"
165
+      dispense_binaries "${src}" "d" "${FRAMEWORK_PATH}"
166
+   fi
167
+
168
+   #
169
+   # Delete empty dirs if so
170
+   #
171
+   src="${BUILD_DEPENDENCY_SUBDIR}/usr/local"
172
+   dir_has_files "${src}"
173
+   if [ $? -ne 0 ]
174
+   then
175
+      rmdir_safer "${src}"
176
+   fi
177
+
178
+   src="${BUILD_DEPENDENCY_SUBDIR}/usr"
179
+   dir_has_files "${src}"
180
+   if [ $? -ne 0 ]
181
+   then
182
+      rmdir_safer "${src}"
90 183
    fi
91 184
 
185
+   #
186
+   # probably should hack all executables with install_name_tool that contain .ref
187
+   #
92 188
    # now copy over the rest of the output
189
+   usrlocal="`read_build_setting "others_c_and_d_prefix" "/usr/local"`"
190
+
191
+   log_fluff "Considering copying ${BUILD_DEPENDENCY_SUBDIR}/*"
192
+
193
+   src="${BUILD_DEPENDENCY_SUBDIR}"
194
+   if [ "${wasxcode}" = "YES" ]
195
+   then
196
+      src="${src}${subdir}"
197
+   fi
198
+
199
+   if dir_has_files "${src}"
200
+   then
201
+      dst="${REFERENCE_DEPENDENCY_SUBDIR}${usrlocal}"
202
+
203
+      log_fluff "Copying ${src}/* to ${dst}"
204
+      exekutor find -x "${src}" ! -path "${src}" -depth 1 -exec mv -v -n '{}' "${dst}" | \
205
+            exekutor xargs -0 -J % mv -v -n % "${dst}"
206
+      [ $? -eq 0 ]  || exit 1
207
+   fi
208
+
209
+   if [ "$MULLE_BOOTSTRAP_VERBOSE" = "YES"  ]
210
+   then
211
+      if dir_has_files "${BUILD_DEPENDENCY_SUBDIR}"
212
+      then
213
+         log_fluff "${BUILD_DEPENDENCY_SUBDIR} contained files after collect and dispense"
214
+         log_fluff "--------------------"
215
+         ( cd "${BUILD_DEPENDENCY_SUBDIR}" ; ls -R >&2 )
216
+         log_fluff "--------------------"
217
+      fi
218
+   fi
93 219
 
94
-   dst="${DEPENDENCY_SUBDIR}"
95
-   exekutor find -x "${output}" ! -path "${output}" -depth 1 -exec mv -v -n '{}' "${dst}" \;  2> /dev/null
220
+   rmdir_safer "${BUILD_DEPENDENCY_SUBDIR}"
96 221
 
97
-   return 0
222
+   log_fluff "Done collecting and dispensing product"
223
+   log_fluff
98 224
 }
99 225
 
100 226
 
101 227
 enforce_build_sanity()
102 228
 {
229
+   local builddir
230
+
231
+   builddir="$1"
232
+
103 233
    # these must not exist
104
-   if [ -d "${DEPENDENCY_SUBDIR}/tmp" ]
234
+   if [ -d "${BUILD_DEPENDENCY_SUBDIR}" ]
105 235
    then
106
-      fail "A previous build left ${DEPENDENCY_SUBDIR}/tmp can't continue"
236
+      fail "A previous build left ${BUILD_DEPENDENCY_SUBDIR} can't continue"
107 237
    fi
108 238
 
109 239
    if [ -d "${builddir}" -a "${CLEAN_BEFORE_BUILD}" != "" ]
110 240
    then
111
-      exekutor rm -rf "${builddir}"
241
+      rmdir_safer "${builddir}"
112 242
    fi
113
-
114 243
 }
115 244
 
116 245
 
... ...
@@ -171,7 +300,7 @@ build_cmake()
171 300
    name="$5"
172 301
    sdk="$6"
173 302
 
174
-   enforce_build_sanity
303
+   enforce_build_sanity "${builddir}"
175 304
 
176 305
    log_info "Do a cmake ${C_MAGENTA}${configuration}${C_INFO} build of \
177 306
 ${C_MAGENTA}${name}${C_INFO} for SDK ${C_MAGENTA}${sdk}${C_INFO} ..."
... ...
@@ -190,17 +319,21 @@ ${C_MAGENTA}${name}${C_INFO} for SDK ${C_MAGENTA}${sdk}${C_INFO} ..."
190 319
 
191 320
    owd="${PWD}"
192 321
    # to avoid warning make sure directories are all there
193
-   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" 2> /dev/null
194
-   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" 2> /dev/null
195
-   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" 2> /dev/null
196
-
197
-   exekutor mkdir -p "${builddir}" 2> /dev/null
322
+   # TODO: I DONT LIKE THIS
323
+   [ ! -e "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}" ]  &&  \
324
+      mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}"
325
+   [ ! -e "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}" ]  &&  \
326
+      mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}"
327
+   [ ! -e "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}" ]  &&  \
328
+      mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}"
329
+
330
+   mkdir_if_missing "${builddir}"
198 331
    exekutor cd "${builddir}" || exit 1
199 332
 
200 333
       # check that relative ise right
201
-      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" ] || exit 1
202
-      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" ] || exit 1
203
-      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
334
+      exekutor [ -d "${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}" ] || exit 1
335
+      exekutor [ -d "${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" ] || exit 1
336
+      exekutor [ -d "${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
204 337
 
205 338
       #
206 339
       # cmake doesn't seem to "get" CMAKE_CXX_FLAGS or -INCLUDE
... ...
@@ -208,28 +341,28 @@ ${C_MAGENTA}${name}${C_INFO} for SDK ${C_MAGENTA}${sdk}${C_INFO} ..."
208 341
       set -f
209 342
 
210 343
       exekutor cmake "-DCMAKE_BUILD_TYPE=${mapped}" \
211
-"-DCMAKE_INSTALL_PREFIX:PATH=${owd}/${DEPENDENCY_SUBDIR}/tmp"  \
344
+"-DCMAKE_INSTALL_PREFIX:PATH=${owd}/${BUILD_DEPENDENCY_SUBDIR}/usr/local"  \
212 345
 "-DCMAKE_C_FLAGS=\
213
--I${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
214
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
215
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
216
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
346
+-I${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH} \
347
+-F${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
348
+-F${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
349
+-F${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
217 350
 ${other_cflags} \
218 351
 ${sdk}" \
219 352
 "-DCMAKE_CXX_FLAGS=\
220
--I${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
221
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
222
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
223
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
353
+-I${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH} \
354
+-F${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
355
+-F${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
356
+-F${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
224 357
 ${other_cppflags} \
225 358
 ${sdk}" \
226 359
 "-DCMAKE_LD_FLAGS=\
227
--L${relative}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}${suffix} \
228
--L${relative}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${configuration} \
229
--L${relative}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH} \
230
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
231
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
232
--F${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
360
+-L${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${LIBRARY_PATH}${suffix} \
361
+-L${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${configuration} \
362
+-L${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${LIBRARY_PATH} \
363
+-F${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
364
+-F${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
365
+-F${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
233 366
 ${other_ldflags} \
234 367
 ${sdk}" \
235 368
 "${relative}/${srcdir}" 1>&2  || exit 1
... ...
@@ -240,9 +373,7 @@ ${sdk}" \
240 373
 
241 374
    exekutor cd "${owd}"
242 375
 
243
-   collect_and_dispense_product "${owd}/${DEPENDENCY_SUBDIR}/tmp" "${suffix}" || exit 1
244
-
245
-   exekutor rm -rf "${owd}/${DEPENDENCY_SUBDIR}/tmp"
376
+   collect_and_dispense_product "${suffix}" || exit 1
246 377
 }
247 378
 
248 379
 
... ...
@@ -269,7 +400,7 @@ build_configure()
269 400
    name="$5"
270 401
    sdk="$6"
271 402
 
272
-   enforce_build_sanity
403
+   enforce_build_sanity "${builddir}"
273 404
 
274 405
    log_info "Do a configure ${C_MAGENTA}${configuration}${C_INFO} build of \
275 406
 ${C_MAGENTA}${name}${C_INFO} for SDK ${C_MAGENTA}${sdk}${C_INFO} ..."
... ...
@@ -288,46 +419,49 @@ ${C_MAGENTA}${name}${C_INFO} for SDK ${C_MAGENTA}${sdk}${C_INFO} ..."
288 419
    other_ldflags=`gcc_ldflags_value "${name}"`
289 420
 
290 421
    owd="${PWD}"
291
-   # to avoid warning make sure directories are all there
292
-   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" 2> /dev/null
293
-   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" 2> /dev/null
294
-   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" 2> /dev/null
295
-
296
-   exekutor mkdir -p "${builddir}" 2> /dev/null
422
+   # to avoid warnings make sure directories are all there
423
+   [ ! -e "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}" ]  &&  \
424
+      mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}"
425
+   [ ! -e "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}" ]  &&  \
426
+      mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}"
427
+   [ ! -e "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}" ]  &&  \
428
+      mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}"
429
+
430
+   mkdir_if_missing "${builddir}" 2> /dev/null
297 431
    exekutor cd "${builddir}" || exit 1
298 432
 
299
-      # check that relative ise right
300
-      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" ] || exit 1
301
-      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" ] || exit 1
302
-      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
433
+      # check that relative is right
434
+      exekutor [ -d "${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}" ] || exit 1
435
+      exekutor [ -d "${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" ] || exit 1
436
+      exekutor [ -d "${relative}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
303 437
 
304 438
       set -f
305 439
 
306 440
       # use absolute paths for configure, safer (and easier to read IMO)
307 441
       CFLAGS="\
308
--I${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
309
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
310
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
311
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
442
+-I${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH} \
443
+-F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
444
+-F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
445
+-F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
312 446
 ${other_cflags} \
313 447
 ${sdk}" \
314 448
       CPPFLAGS="\
315
--I${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
316
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
317
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
318
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
449
+-I${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH} \
450
+-F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
451
+-F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
452
+-F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
319 453
 ${other_cppflags} \
320 454
 ${sdk}" \
321 455
       LDFLAGS="\
322
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
323
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
324
--F${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
325
--L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}${suffix} \
326
--L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${configuration} \
327
--L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH} \
456
+-F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix} \
457
+-F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration} \
458
+-F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH} \
459
+-L${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${LIBRARY_PATH}${suffix} \
460
+-L${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${configuration} \
461
+-L${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${LIBRARY_PATH} \
328 462
 ${other_ldflags} \
329 463
 ${sdk}" \
330
-      exekutor "${owd}/${srcdir}/configure" --prefix "${owd}/${DEPENDENCY_SUBDIR}/tmp" 1>&2  || exit 1
464
+      exekutor "${owd}/${srcdir}/configure" --prefix "${owd}/${BUILD_DEPENDENCY_SUBDIR}/usr/local" 1>&2  || exit 1
331 465
 
332 466
       exekutor make all install 1>&2 || exit 1
333 467
 
... ...
@@ -335,9 +469,7 @@ ${sdk}" \
335 469
 
336 470
    exekutor cd "${owd}"
337 471
 
338
-   collect_and_dispense_product "${owd}/${DEPENDENCY_SUBDIR}/tmp" "${suffix}" || exit 1
339
-
340
-   rm -rf "${owd}/${DEPENDENCY_SUBDIR}/tmp"
472
+   collect_and_dispense_product "${suffix}" || exit 1
341 473
 }
342 474
 
343 475
 
... ...
@@ -356,34 +488,22 @@ xcode_get_setting()
356 488
 
357 489
 
358 490
 #
359
-# What we can not fix up is
360
-# /usr/local/include/${PROJECT_NAME}
361
-# since we can't read the unresolved value (yet)
491
+# Code I didn't want to throw away really
492
+# In general just uss "public_headers" or
493
+# "private_headers" and set them to a /usr/local/include/whatever
362 494
 #
363
-fixup_header_path()
495
+create_mangled_header_path()
364 496
 {
497
+   local name
365 498
    local key
366
-   local setting_key
367 499
    local default
368
-   local name
369
-   local prefix
370 500
 
371 501
    key="$1"
372
-   shift
373
-   setting_key="$1"
374
-   shift
375
-   name="$1"
376
-   shift
377
-   default="$1"
378
-   shift
379
-
380
-   read_yes_no_build_setting "${name}" "xcode_mangle_header_settings"
381
-   if [ $? -ne 0 ]
382
-   then
383
-      return 1
384
-   fi
502
+   name="$2"
503
+   default="$3"
385 504
 
386 505
    local headers
506
+   local prefix
387 507
 
388 508
    headers=`xcode_get_setting "${key}" $*`
389 509
    log_fluff "${key} read as \"${headers}\""
... ...
@@ -413,13 +533,43 @@ fixup_header_path()
413 533
       prefix="${HEADER_PATH}"
414 534
    fi
415 535
 
416
-
417 536
    if read_yes_no_build_setting "${name}" "xcode_mangle_header_dash"
418 537
    then
419 538
       headers="`echo "${headers}" | tr '-' '_'`"
420 539
    fi
421 540
 
422
-   headers="`read_repo_setting "${name}" "${setting_key}" "${prefix}${headers}"`"
541
+   echo "${headers}"
542
+}
543
+
544
+
545
+fixup_header_path()
546
+{
547
+   local key
548
+   local setting_key
549
+   local default
550
+   local name
551
+   local prefix
552
+
553
+   key="$1"
554
+   shift
555
+   setting_key="$1"
556
+   shift
557
+   name="$1"
558
+   shift
559
+   default="$1"
560
+   shift
561
+
562
+   headers="`read_repo_setting "${name}" "${setting_key}"`"
563
+   if [ "$headers" = "" ]
564
+   then
565
+      read_yes_no_build_setting "${name}" "xcode_mangle_header_settings"
566
+      if [ $? -ne 0 ]
567
+      then
568
+         return 1
569
+      fi
570
+
571
+      headers="`"$create_mangled_header_path "${key}" "${name}" ${default}"`"
572
+   fi
423 573
 
424 574
    log_fluff "${key} set to \"${headers}\""
425 575
 
... ...
@@ -483,6 +633,8 @@ build_xcodebuild()
483 633
    [ -z "${sdk}" ]         && internal_fail "sdk is empty"
484 634
    [ -z "${project}" ]     && internal_fail "project is empty"
485 635
 
636
+   enforce_build_sanity "${builddir}"
637
+
486 638
    local info
487 639
 
488 640
    info=""
... ...
@@ -588,6 +740,20 @@ ${info} ..."
588 740
       command=install
589 741
    fi
590 742
 
743
+      #
744
+      # headers are complicated, the preference is to get it uniform into
745
+      # dependencies/include/libraryname/..
746
+      #
747
+
748
+   local public_headers
749
+   local private_headers
750
+   local default
751
+
752
+   default="/include/${name}"
753
+   public_headers="`fixup_header_path "PUBLIC_HEADERS_FOLDER_PATH" "public_headers" "${name}" "${default}" ${arguments}`"
754
+   default="/include/${name}/private"
755
+   private_headers="`fixup_header_path "PRIVATE_HEADERS_FOLDER_PATH" "private_headers" "${name}" "${default}" ${arguments}`"
756
+
591 757
    owd=`pwd`
592 758
    cd "${srcdir}" || exit 1
593 759
 
... ...
@@ -616,21 +782,6 @@ ${info} ..."
616 782
       fi
617 783
 
618 784
 
619
-      #
620
-      # headers are complicated, the preference is to get it uniform into
621
-      # dependencies/include/libraryname/..
622
-      #
623
-
624
-      local public_headers
625
-      local private_headers
626
-      local default
627
-
628
-      default="/include/${name}"
629
-      public_headers="`fixup_header_path "PUBLIC_HEADERS_FOLDER_PATH" "public_headers" "${name}" "${default}" ${arguments}`"
630
-      default="/include/${name}/private"
631
-      private_headers="`fixup_header_path "PRIVATE_HEADERS_FOLDER_PATH" "private_headers" "${name}" "${default}" ${arguments}`"
632
-
633
-
634 785
       # manually point xcode to our headers and libs
635 786
       # this is like manually doing xcode-setup
636 787
       local dependencies_framework_search_path
... ...
@@ -645,7 +796,7 @@ ${info} ..."
645 796
       #
646 797
       inherited="`xcode_get_setting HEADER_SEARCH_PATHS ${arguments}`"
647 798
       path=`combined_escaped_search_path \
648
-"${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" \
799
+"${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${HEADER_PATH}" \
649 800
 "/usr/local/include"`
650 801
       if [ -z "${inherited}" ]
651 802
       then
... ...
@@ -656,12 +807,12 @@ ${info} ..."
656 807
 
657 808
       inherited="`xcode_get_setting LIBRARY_SEARCH_PATHS ${arguments}`"
658 809
       path=`combined_escaped_search_path \
659
-"${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mapped}" \
660
-"${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}" \
810
+"${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mapped}" \
811
+"${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${LIBRARY_PATH}" \
661 812
 "/usr/local/lib"`
662 813
       if [ ! -z "$sdk" ]
663 814
       then
664
-         escaped="`escaped_spaces "${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mapped}"'-$(EFFECTIVE_PLATFORM_NAME)'`"
815
+         escaped="`escaped_spaces "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mapped}"'-$(EFFECTIVE_PLATFORM_NAME)'`"
665 816
          path="${escaped} ${path}" # prepend
666 817
       fi
667 818
       if [ -z "${inherited}" ]
... ...
@@ -674,11 +825,11 @@ ${info} ..."
674 825
 
675 826
       inherited="`xcode_get_setting FRAMEWORK_SEARCH_PATHS ${arguments}`"
676 827
       path=`combined_escaped_search_path \
677
-"${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mapped}" \
678
-"${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}"`
828
+"${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mapped}" \
829
+"${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}"`
679 830
       if [ ! -z "$sdk" ]
680 831
       then
681
-         escaped="`escaped_spaces "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mapped}"'-$(EFFECTIVE_PLATFORM_NAME)'`"
832
+         escaped="`escaped_spaces "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mapped}"'-$(EFFECTIVE_PLATFORM_NAME)'`"
682 833
          path="${escaped} ${path}" # prepend
683 834
       fi
684 835
       if [ -z "${inherited}" ]
... ...
@@ -702,7 +853,7 @@ ${info} ..."
702 853
       cmdline="\"${xcodebuild}\" \"${command}\" ${arguments} \
703 854
 ARCHS='\${ARCHS_STANDARD_32_64_BIT}' \
704 855
 DEPLOYMENT_LOCATION=YES \
705
-DSTROOT='${owd}/${DEPENDENCY_SUBDIR}' \
856
+DSTROOT='${owd}/${BUILD_DEPENDENCY_SUBDIR}' \
706 857
 INSTALL_PATH='${LIBRARY_PATH}${suffix}' \
707 858
 SYMROOT='${owd}/${builddir}/' \
708 859
 OBJROOT='${owd}/${builddir}/obj' \
... ...
@@ -717,6 +868,8 @@ FRAMEWORK_SEARCH_PATHS='${dependencies_framework_search_path}'"
717 868
       set +f
718 869
 
719 870
    cd "${owd}"
871
+
872
+   collect_and_dispense_product "${suffix}" "YES" || exit 1
720 873
 }
721 874
 
722 875
 
... ...
@@ -724,13 +877,15 @@ build_xcodebuild_schemes_or_target()
724 877
 {
725 878
    local builddir
726 879
    local name
880
+   local project
727 881
 
728 882
    builddir="$3"
729 883
    name="$5"
884
+   project="$7"
730 885
 
731 886
    if [ -d "${builddir}" -a "${CLEAN_BEFORE_BUILD}" != "" ]
732 887
    then
733
-      exekutor rm -rf "${builddir}"
888
+      rmdir_safer "${builddir}"
734 889
    fi
735 890
 
736 891
    local scheme
... ...
@@ -746,6 +901,7 @@ build_xcodebuild_schemes_or_target()
746 901
    for scheme in $schemes
747 902
    do
748 903
       IFS="$old"
904
+      log_fluff "Building scheme \"${scheme}\" of \"${project}\" ..."
749 905
       build_xcodebuild "$@" "${scheme}" ""
750 906
    done
751 907
    IFS="${old}"
... ...
@@ -761,17 +917,20 @@ build_xcodebuild_schemes_or_target()
761 917
    for target in $targets
762 918
    do
763 919
       IFS="${old}"
920
+      log_fluff "Building target \"${target}\" of \"${project}\" ..."
764 921
       build_xcodebuild "$@" "" "${target}"
765 922
    done
766 923
    IFS="${old}"
767 924
 
768 925
    if [ "${targets}" = "" -a "${schemes}" = "" ]
769 926
    then
927
+      log_fluff "Building project \"${project}\"..."
770 928
       build_xcodebuild "$@"
771 929
    fi
772 930
 }
773 931
 
774 932
 
933
+
775 934
 build()
776 935
 {
777 936
    local srcdir
... ...
@@ -861,7 +1020,7 @@ Release"`
861 1020
                fi
862 1021
                if [ -x "${srcdir}/configure" ]
863 1022
                then
864
-                  build_configure "${configuration}" "${srcdir}" "${builddir}" "${relative}" "${name}" "${sdk}" || exit 1
1023
+                  build_configure "${configuration}" "${srcdir}" "${builddir}" "${relative}" "${name}" "${sdk}"  || exit 1
865 1024
                   built=yes
866 1025
                   break
867 1026
                fi
... ...
@@ -871,7 +1030,7 @@ Release"`
871 1030
             then
872 1031
                if [ -f "${srcdir}/CMakeLists.txt" ]
873 1032
                then
874
-                  build_cmake "${configuration}" "${srcdir}" "${builddir}" "${relative}" "${name}" "${sdk}" || exit 1
1033
+                  build_cmake "${configuration}" "${srcdir}" "${builddir}" "${relative}" "${name}" "${sdk}"  || exit 1
875 1034
                   built=yes
876 1035
                   break
877 1036
                fi
... ...
@@ -887,6 +1046,50 @@ Release"`
887 1046
 }
888 1047
 
889 1048
 
1049
+#
1050
+# ${DEPENDENCY_SUBDIR} is split into
1051
+#
1052
+#  REFERENCE_DEPENDENCY_SUBDIR and
1053
+#  BUILD_DEPENDENCY_SUBDIR
1054
+#
1055
+# above this function, noone should access ${DEPENDENCY_SUBDIR}
1056
+#
1057
+build_wrapper()
1058
+{
1059
+   local clone
1060
+
1061
+   clone="$1"
1062
+
1063
+   REFERENCE_DEPENDENCY_SUBDIR="${DEPENDENCY_SUBDIR}"
1064
+   BUILD_DEPENDENCY_SUBDIR="${DEPENDENCY_SUBDIR}/tmp"
1065
+
1066
+   DEPENDENCY_SUBDIR="WRONG_DONT_USE_DEPENDENCY_SUBDIR_DURING_BUILD"
1067
+
1068
+   if [ -d "${BUILD_DEPENDENCY_SUBDIR}" ]
1069
+   then
1070
+      log_info "Cleaning up orphaned ${BUILD_DEPENDENCY_SUBDIR}"
1071
+      rmdir_safer "${BUILD_DEPENDENCY_SUBDIR}"
1072
+   fi
1073
+
1074
+   #
1075
+   # move dependencies we have so far away into safety,
1076
+   # need that path for includes though
1077
+   #
1078
+   log_fluff "Setting up ${BUILD_DEPENDENCY_SUBDIR}"
1079
+
1080
+   build "${clone}"
1081
+
1082
+   log_fluff "Remove ${BUILD_DEPENDENCY_SUBDIR}"
1083
+
1084
+   rmdir_safer "${BUILD_DEPENDENCY_SUBDIR}"
1085
+
1086
+   DEPENDENCY_SUBDIR="${REFERENCE_DEPENDENCY_SUBDIR}"
1087
+
1088
+   REFERENCE_DEPENDENCY_SUBDIR="WRONG_DONT_USE_REFERENCE_DEPENDENCY_SUBDIR_AFTER_BUILD"
1089
+   BUILD_DEPENDENCY_SUBDIR="WRONG_DONT_USE_BUILD_DEPENDENCY_SUBDIR_AFTER_BUILD"
1090
+}
1091
+
1092
+
890 1093
 build_if_readable()
891 1094
 {
892 1095
    local clone
... ...
@@ -904,7 +1107,7 @@ build_if_readable()
904 1107
       xdone=`/bin/echo "${built}" | grep "${name}"`
905 1108
       if [ "$xdone" = "" ]
906 1109
       then
907
-         build "${clone}"
1110
+         build_wrapper "${clone}"
908 1111
          echo "${name}
909 1112
 ${built}"
910 1113
       fi
... ...
@@ -951,6 +1154,7 @@ build_clones()
951 1154
          if [ -d "${clone}" ]
952 1155
          then
953 1156
             built=`build_if_readable "${clone}" "${name}" "${built}"`
1157
+            [ $? -eq 0 ] || exit 1
954 1158
          else
955 1159
             fail "buildorder contains unknown repo ${name}"
956 1160
          fi
... ...
@@ -963,6 +1167,7 @@ build_clones()
963 1167
          if [ -d "${clone}" ]
964 1168
          then
965 1169
             built=`build_if_readable "${clone}" "${name}" "${built}"`
1170
+            [ $? -eq 0 ] || exit 1
966 1171
          fi
967 1172
       done
968 1173
    else
... ...
@@ -973,6 +1178,7 @@ build_clones()
973 1178
          if [ -d "${clone}" ]
974 1179
          then
975 1180
             built=`build_if_readable "${clone}" "${name}" "${built}"`
1181
+            [ $? -eq 0 ] || exit 1
976 1182
          else
977 1183
             fail "unknown repo ${name}"
978 1184
          fi
... ...
@@ -981,8 +1187,55 @@ build_clones()
981 1187
 }
982 1188
 
983 1189
 
1190
+install_tars()
1191
+{
1192
+   local tarballs
1193
+   local tar
1194
+   local cmd
1195
+   cmd="$1"
1196
+
1197
+   tarballs=`read_fetch_setting "tarballs" | sort | sort -u`
1198
+   if [ "${tarballs}" != "" ]
1199
+   then
1200
+      local old
1201
+
1202
+      old="${IFS:-" "}"
1203
+      IFS="
1204
+"
1205
+      for tar in ${tarballs}
1206
+      do
1207
+         if [ ! -f "$tar" ]
1208
+         then
1209
+            fail "tarball \"$tar\" not found"
1210
+         else
1211
+            log_info "Installing tarball \"${tar}\""
1212
+            exekutor tar -xz -C "${DEPENDENCY_SUBDIR}" -f "${tar}" || fail "failed to extract ${tar}"
1213
+         fi
1214
+      done
1215
+      IFS="${old}"
1216
+   fi
1217
+}
1218
+
1219
+
984 1220
 main()
985 1221
 {
1222
+   local  no_clean
1223
+
1224
+   log_fluff "Setting up ${DEPENDENCY_SUBDIR}"
1225
+   no_clean="`read_config_setting "dont_clean_dependencies_before_build"`"
1226
+   if [ "${no_clean}" != "YES" ]
1227
+   then
1228
+      rmdir_safer "${DEPENDENCY_SUBDIR}"
1229
+   fi
1230
+
1231
+   # if present then we didnt't want to clean and we do nothing special
1232
+   if [ ! -d "${DEPENDENCY_SUBDIR}" ]
1233
+   then
1234
+      mkdir_if_missing "${DEPENDENCY_SUBDIR}/usr/local/include"
1235
+      exekutor ln -s "usr/local/include" "${DEPENDENCY_SUBDIR}/include" || fail "failed to symlink future usr/local/include"
1236
+      install_tars "$@"
1237
+   fi
1238
+
986 1239
    build_clones "$@"
987 1240
 }
988 1241
 
... ...
@@ -2,31 +2,60 @@
2 2
 #
3 3
 # (c) 2015, coded by Nat!, Mulle KybernetiK
4 4
 #
5
-COMMAND=${1:-"objs"}
6
-
7 5
 . mulle-bootstrap-local-environment.sh
8 6
 
9
-case "$COMMAND" in
10
-   output)
11
-   ;;
12
-   dist)
13
-   ;;
14
-   intermediate|objs|build)
15
-   COMMAND="objs"
16
-   ;;
17
-   *)
18
-   echo "usage: mulle-bootstrap-clean.sh [output|dist]" 2>&1
19
-   exit 1
20
-   ;;
21
-esac
22 7
 
8
+BUILD_CLEANABLE_SUBDIRS=`read_sane_config_path_setting "clean_folders" "${CLONESBUILD_SUBDIR}
9
+${DEPENDENCY_SUBDIR}/tmp"`
10
+OUTPUT_CLEANABLE_SUBDIRS=`read_sane_config_path_setting "output_clean_folders" "${DEPENDENCY_SUBDIR}"`
11
+DIST_CLEANABLE_SUBDIRS=`read_sane_config_path_setting "dist_clean_folders" "${CLONES_SUBDIR}
12
+.bootstrap.auto"`
23 13
 
24
-clean_asserted_folder()
14
+
15
+check_and_usage_and_help()
25 16
 {
17
+   case "$COMMAND" in
18
+      output)
19
+      ;;
20
+      dist)
21
+      ;;
22
+      build)
23
+      COMMAND="build"
24
+      ;;
25
+      *)
26
+      echo "usage: mulle-bootstrap-clean.sh [build|output|dist]" >&2
27
+      echo "" >&2
28
+      echo "   build   : is the default, it cleans
29
+${BUILD_CLEANABLE_SUBDIRS}" >&2
30
+      echo "" >&2
31
+      echo "   output  : cleans additionaly
32
+${OUTPUT_CLEANABLE_SUBDIRS}" >&2
33
+      echo "" >&2
34
+      echo "   dist    : cleans additionaly
35
+${DIST_CLEANABLE_SUBDIRS}" >&2
36
+      exit 1
37
+      ;;
38
+   esac
39
+}
40
+
41
+
42
+if [ "$1" = "-h" -o "$1" = "--help" ]
43
+then
44
+   check_and_usage_and_help
45
+fi
46
+
47
+
48
+COMMAND=${1:-"build"}
49
+shift
26 50
 
51
+check_and_usage_and_help
52
+
53
+
54
+clean_asserted_folder()
55
+{
27 56
    if [ -d "$1" ]
28 57
    then
29
-      assert_sane_path "$1"
58
+      assert_sane_subdir_path "$1"
30 59
       log_info "Deleting \"$1\""
31 60
       exekutor rm -rf "$1"
32 61
    else
... ...
@@ -43,13 +72,18 @@ clean_asserted_folder()
43 72
 clean()
44 73
 {
45 74
    local flag
75
+   local old
76
+
77
+   old="${IFS:-" "}"
78
+   IFS="
79
+"
46 80
 
47 81
    flag="NO"
48
-   if [ ! -z "$OBJS_CLEANABLE_SUBDIRS" ]
82
+   if [ ! -z "$BUILD_CLEANABLE_SUBDIRS" ]
49 83
    then
50
-      if [ "${COMMAND}" = "objs" -o "${COMMAND}" = "dist" -o "${COMMAND}" = "output"  ]
84
+      if [ "${COMMAND}" = "build" -o "${COMMAND}" = "dist" -o "${COMMAND}" = "output"  ]
51 85
       then
52
-         for dir in ${OBJS_CLEANABLE_SUBDIRS}
86
+         for dir in ${BUILD_CLEANABLE_SUBDIRS}
53 87
          do
54 88
             clean_asserted_folder "${dir}"
55 89
             flag="YES"
... ...
@@ -87,6 +121,8 @@ clean()
87 121
    then
88 122
       log_info "Nothing configured to clean"
89 123
    fi
124
+
125
+   IFS="${old}"
90 126
 }
91 127
 
92 128
 
... ...
@@ -97,13 +133,8 @@ main()
97 133
    # for users of previous versions.
98 134
    # Also don't change the search paths for read_sane_config_path_setting
99 135
    #
100
-   OBJS_CLEANABLE_SUBDIRS=`read_sane_config_path_setting "clean_folders" "${CLONESBUILD_SUBDIR}"`
101
-   OUTPUT_CLEANABLE_SUBDIRS=`read_sane_config_path_setting "output_clean_folders" "${DEPENDENCY_SUBDIR}"`
102
-   DIST_CLEANABLE_SUBDIRS=`read_sane_config_path_setting "dist_clean_folders" "${CLONES_SUBDIR}
103
-.bootstrap.auto"`
104 136
 
105 137
    clean
106 138
 }
107 139
 
108
-
109 140
 main
... ...
@@ -35,31 +35,40 @@
35 35
 # You can also specify a list of "brew" dependencies. That
36 36
 # will be third party libraries, you don't tag or debug
37 37
 #
38
-COMMAND=${1:-"install"}
39
-
40 38
 . mulle-bootstrap-warn-scripts.sh
41 39
 . mulle-bootstrap-local-environment.sh
42 40
 
43 41
 
42
+check_and_usage_and_help()
43
+{
44
+   case "$COMMAND" in
45
+      install)
46
+      ;;
47
+      nonrecursive)
48
+        COMMAND=install
49
+        DONT_RECURSE="YES"
50
+      ;;
51
+      update)
52
+      ;;
53
+      *)
54
+      echo "usage: mulle-bootstrap-fetch.sh <install|nonrecursive|update>" 2>&1
55
+      exit 1
56
+      ;;
57
+   esac
58
+}
59
+
60
+if [ "$1" = "-h" -o "$1" = "--help" ]
61
+then
62
+   check_and_usage_and_help
63
+fi
64
+
65
+COMMAND=${1:-"install"}
44 66
 if [ "${MULLE_BOOTSTRAP}" = "mulle-bootstrap" ]
45 67
 then
46 68
    COMMAND="install"
47 69
 fi
48 70
 
49
-case "$COMMAND" in
50
-   install)
51
-   ;;
52
-   nonrecursive)
53
-     COMMAND=install
54
-     DONT_RECURSE="YES"
55
-   ;;
56
-   update)
57
-   ;;
58
-   *)
59
-   echo "usage: mulle-bootstrap-fetch.sh <install|nonrecursive|update>" 2>&1
60
-   exit 1
61
-   ;;
62
-esac
71
+check_and_usage_and_help
63 72
 
64 73
 
65 74
 link_command()
... ...
@@ -87,7 +96,7 @@ link_command()
87 96
          name="`basename "${dst}"`"
88 97
          echo "tag ${tag} will be ignored, due to symlink" >&2
89 98
          echo "if you want to checkout this tag do:" >&2
90
-         echo "(cd .repos/${name}; git checkout \"${tag}\" )" >&2
99
+         echo "(cd .repos/${name}; git ${GITFLAGS} checkout \"${tag}\" )" >&2
91 100
       fi
92 101
    fi
93 102
 
... ...
@@ -164,6 +173,19 @@ checkout()
164 173
    local flag
165 174
    local found
166 175
 
176
+   #
177
+   # this implicitly ensures, that these folders are
178
+   # movable and cleanable by mulle-bootstrap
179
+   # so ppl can't really use  src mistakenly
180
+
181
+   if [ -e "${DEPENDENCY_SUBDIR}" -o -e "${CLONESBUILD_SUBDIR}" ]
182
+   then
183
+      log_error "Stale folders ${DEPENDENCY_SUBDIR} and/or ${CLONESBUILD_SUBDIR} found."
184
+      log_error "Please remove them before continuing."
185
+      log_info  "Suggested command: ${C_WHITE}mulle-bootstrap clean output"
186
+      exit 1
187
+   fi
188
+
167 189
    srcname="${clone}"
168 190
    script=`read_repo_setting "${name1}" bin/"${cmd}.sh"`
169 191
    operation="git_command"
... ...
@@ -236,7 +258,7 @@ Use it instead of cloning ${clone} ?"
236 258
    script=`read_repo_setting "${name1}" "bin/post-${cmd}.sh"`
237 259
    if [ -x "${script}" ]
238 260
    then
239
-      "${script}" || exit 1
261
+      exekutor "${script}" || exit 1
240 262
    fi
241 263
 }
242 264
 
... ...
@@ -261,15 +283,15 @@ update()
261 283
    then
262 284
       if [ -x "${script}" ]
263 285
       then
264
-         "${script}" || exit 1
286
+         exekutor "${script}" || exit 1
265 287
       else
266
-         git_command "${clone}" "${dstname}" "${tag}" || exit 1
288
+         exekutor git_command ${GITFLAGS} "${clone}" "${dstname}" "${tag}" || exit 1
267 289
       fi
268 290
 
269 291
       script=`read_repo_setting "${name}" "bin/post-${cmd}.sh"`
270 292
       if [ -x "${script}" ]
271 293
       then
272
-         "${script}" || exit 1
294
+         exekutor "${script}" || exit 1
273 295
       fi
274 296
    fi
275 297
 }
... ...
@@ -288,15 +310,15 @@ git_command()
288 310
    if [ "${COMMAND}" = "install" ]
289 311
    then
290 312
       log_info "Cloning ${C_WHITE}${src}${C_INFO} ..."
291
-      git clone "${src}" "${dst}" || exit 1
313
+      exekutor git clone ${GITFLAGS} "${src}" "${dst}" || exit 1
292 314
    else
293
-      ( cd "${dst}" ; git pull ) || exit 1
315
+      ( exekutor cd "${dst}" ; exekutor git pull ) || exit 1
294 316
    fi
295 317
 
296 318
    if [ "${tag}" != "" ]
297 319
    then
298 320
       log_info "Checking out ${C_MAGENTA}${tag}${C_INFO} ..."
299
-      (cd "${dst}" ; git checkout "${tag}" )
321
+      ( exekutor cd "${dst}" ; exekutor git checkout ${GITFLAGS} "${tag}" )
300 322
 
301 323
       if [ $? -ne 0 ]
302 324
       then
... ...
@@ -304,8 +326,8 @@ git_command()
304 326
          log_error "You need to fix this manually and then move it back."
305 327
          log_info "Hint: check ${BOOTSTRAP_SUBDIR}/`basename "${dst}"`/TAG" >&2
306 328
 
307
-         rm -rf "${dst}.failed" 2> /dev/null
308
-         mv "${dst}" "${dst}.failed"
329
+         rmdir_safer "${dst}.failed"
330
+         exekutor mv "${dst}" "${dst}.failed"
309 331
          exit 1
310 332
       fi
311 333
    fi
... ...
@@ -339,16 +361,16 @@ bootstrap_recurse()
339 361
    then
340 362
       echo "Found a .bootstrap folder for `basename "${dst}"` will set up ${BOOTSTRAP_SUBDIR}.auto" >&2
341 363
 
342
-      mkdir -p "${BOOTSTRAP_SUBDIR}.auto/settings"
364
+      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/settings"
343 365
       for i in $INHERIT_SETTINGS
344 366
       do
345 367
          if [ -f "${BOOTSTRAP_SUBDIR}.local/${i}" ]
346 368
          then
347
-            cp "${BOOTSTRAP_SUBDIR}}.local/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}" || exit 1
369
+            exekutor cp "${BOOTSTRAP_SUBDIR}}.local/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}" || exit 1
348 370
          else
349 371
             if [ -f "${BOOTSTRAP_SUBDIR}/${i}" ]
350 372
             then
351
-               cp "${BOOTSTRAP_SUBDIR}/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}" || exit 1
373
+               exekutor cp "${BOOTSTRAP_SUBDIR}/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}" || exit 1
352 374
             fi
353 375
          fi
354 376
       done
... ...
@@ -364,11 +386,11 @@ bootstrap_recurse()
364 386
       then
365 387
          if [ -f "${BOOTSTRAP_SUBDIR}.auto/${i}" ]
366 388
          then
367
-            mv "${BOOTSTRAP_SUBDIR}.auto/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}.tmp" || exit 1
368
-            cat "${dst}/.bootstrap/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}.tmp" > "${BOOTSTRAP_SUBDIR}.auto/${i}"  || exit 1
369
-            rm "${BOOTSTRAP_SUBDIR}.auto/${i}.tmp" || exit 1
389
+            exekutor mv "${BOOTSTRAP_SUBDIR}.auto/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}.tmp" || exit 1
390
+            exekutor cat "${dst}/.bootstrap/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}.tmp" > "${BOOTSTRAP_SUBDIR}.auto/${i}"  || exit 1
391
+            exekutor rm "${BOOTSTRAP_SUBDIR}.auto/${i}.tmp" || exit 1
370 392
          else
371
-            cp "${dst}/.bootstrap/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}" || exit 1
393
+            exekutor cp "${dst}/.bootstrap/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}" || exit 1
372 394
          fi
373 395
       fi
374 396
    done
... ...
@@ -380,14 +402,14 @@ bootstrap_recurse()
380 402
    then
381 403
       local relative
382 404
 
383
-      mkdir -p "${BOOTSTRAP_SUBDIR}.auto/settings/${name}" 2> /dev/null
405
+      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/settings/${name}"
384 406
       relative=`compute_relative "${BOOTSTRAP_SUBDIR}"`
385
-      find "${dst}/.bootstrap/settings" -type f -depth 1 -print0 | \
386
-      xargs -0 -I % ln -s -f "${relative}/../../"% "${BOOTSTRAP_SUBDIR}.auto/settings/${name}"
407
+      exekutor find "${dst}/.bootstrap/settings" -type f -depth 1 -print0 | \
408
+         exekutor xargs -0 -I % ln -s -f "${relative}/../../"% "${BOOTSTRAP_SUBDIR}.auto/settings/${name}"
387 409
 
388 410
       # flatten folders into our own settings
389
-      find "${dst}/.bootstrap/settings" -type d -depth 1 -print0 | \
390
-      xargs -0 -I % ln -s -f "${relative}/../"% "${BOOTSTRAP_SUBDIR}.auto/settings"
411
+      exekutor find "${dst}/.bootstrap/settings" -type d -depth 1 -print0 | \
412
+         exekutor xargs -0 -I % ln -s -f "${relative}/../"% "${BOOTSTRAP_SUBDIR}.auto/settings"
391 413
    fi
392 414
 
393 415
 
... ...
@@ -400,8 +422,8 @@ bootstrap_recurse()
400 422
 # if you specify ../ it will assume you have
401 423
 # checked it out yourself, If there is something
402 424
 # checked out already it will use it, or ask
403
-# convetion: .git suffix == repo to clone
404
-#         no .git suffix, try to symlink
425
+# convention: .git suffix == repo to clone
426
+#          no .git suffix, try to symlink
405 427
 #
406 428
 clone_repositories()
407 429
 {
... ...
@@ -423,7 +445,7 @@ clone_repositories()
423 445
       do
424 446
          if [ -d "${i}" -o -L "${i}" ]
425 447
          then
426
-            chmod -h 000 "${i}"
448
+            exekutor chmod -h 000 "${i}"
427 449
          fi
428 450
       done
429 451
    fi
... ...
@@ -442,7 +464,7 @@ clone_repositories()
442 464
             then
443 465
                fail "install first before upgrading"
444 466
             fi
445
-            mkdir -p "${CLONES_FETCH_SUBDIR}" || exit 1
467
+            mkdir_if_missing "${CLONES_FETCH_SUBDIR}"
446 468
          fi
447 469
 
448 470
          for clone in ${clones}
... ...
@@ -460,7 +482,7 @@ clone_repositories()
460 482
             then
461 483
                permission=`lso "${CLONES_FETCH_SUBDIR}"`
462 484
                [ ! -z "$permission" ] || fail "failed to get permission of ${CLONES_FETCH_SUBDIR}"
463
-               chmod -h "${permission}" "${dstname}"
485
+               exekutor chmod -h "${permission}" "${dstname}"
464 486
             fi
465 487
 
466 488
             local info
... ...
@@ -529,8 +551,8 @@ brew_update_if_needed()
529 551
    then
530 552
    	brew update
531 553
 
532
-	   mkdir -p "`dirname "${last_update}"`" 2> /dev/null
533
-   	touch "${last_update}"
554
+	   mkdir_if_missing "`dirname "${last_update}"`"
555
+   	exekutor touch "${last_update}"
534 556
    fi
535 557
 }
536 558
 
... ...
@@ -542,14 +564,21 @@ install_taps()
542 564
 {
543 565
    local tap
544 566
    local taps
567
+   local old
545 568
 
546 569
    taps=`read_fetch_setting "taps" | sort | sort -u`
547 570
    if [ "${taps}" != "" ]
548 571
    then
572
+      local old
573
+
549 574
       brew_update_if_needed
575
+
576
+      old="${IFS:-" "}"
577
+      IFS="
578
+"
550 579
       for tap in ${taps}
551 580
       do
552
-         brew tap "${tap}" > /dev/null || exit 1
581
+         exekutor brew tap "${tap}" > /dev/null || exit 1
553 582
       done
554 583
    fi
555 584
 }
... ...
@@ -567,17 +596,56 @@ install_brews()
567 596
    brews=`read_fetch_setting "brews" | sort | sort -u`
568 597
    if [ "${brews}" != "" ]
569 598
    then
599
+      local old
600
+
570 601
       brew_update_if_needed