Browse code

Improve paths for mulle-brew and make things more consistent and simpler. Move mulle-brew into own project/formula.

Nat! authored on 22-04-2017 20:58:46
Showing 9 changed files
... ...
@@ -8,6 +8,9 @@ mulle-builds sake)
8 8
 * Because `mulle-bootstrap setting` now works, init by default does not
9 9
 create demo files any more. Inverted meaning of -d flag.
10 10
 * Various improvements to mulle-brew handling
11
+* The paths default is now to output an unquoted one-liner. This is less
12
+correct but simpler.
13
+
11 14
 
12 15
 ### 3.4.0
13 16
 
... ...
@@ -2,44 +2,154 @@
2 2
 
3 3
 ![Last version](https://img.shields.io/github/tag/mulle-nat/mulle-bootstrap.svg)
4 4
 
5
-[Homebrew](brew.sh) is the de facto standard package manager of OS X. Usually
6
-it is used to install packages system-wide into '/usr/local/'. But you can
7
-actually place homebrew anywhere. Then you can create your own playground
8
-development environment of tools and libraries.
5
+[Homebrew](//brew.sh) is the de facto standard package manager of OS X. It is also
6
+available on Linux as [Linuxbrew](linuxbrew.sh).
9 7
 
10
-**mulle-brew** helps you set-up and share such playgrounds.
8
+By default homebrew installs packages system-wide into '/usr/local/' (on OS X). But you can actually clone the [brew repository](https://github.com/Homebrew/brew/) to any place in the filesystem. `brew` will the install packages in that place. This way you can create your own playground development environment of tools and libraries.
9
+
10
+**mulle-brew** helps you set-up and share such playgrounds, which it keeps in a folder called `addictions`.
11 11
 
12 12
 ## Advantages
13 13
 
14 14
 * Keep the runtime and your system clear off temporary downloads.
15
-* Updating brew libraries for one project, doesn't neccessarily impact parallel projects
15
+* Updating brew libraries for one project, doesn't necessarily impact parallel projects
16 16
 * An easy way to share the required build environments
17
+* A uniform way to access those dependencies via a known name `addictions`
18
+
19
+
20
+## Installing **mulle-brew**
21
+
22
+Install mulle-brew with brew, it makes sense :) :
23
+
24
+```
25
+brew install mulle-kybernetik/software/mulle-brew
26
+```
27
+
28
+## Install and run hello world using **mulle-brew**
29
+
30
+Install hello:
31
+
32
+```
33
+mulle-brew init
34
+mulle-brew setting -g -r brews hello
35
+mulle-brew
36
+```
37
+
38
+Run hello:
39
+
40
+```
41
+mulle-brew run hello
42
+```
17 43
 
44
+What does `mulle-brew run` do ? It adds `${PWD}/addictions/bin` to your PATH shell variable. so that **hello** is found for the duration of this command. You could as well have used `./addictions/bin/hello`. The use of `mulle-brew run` becomes more important later on in more complex scenarios.
18 45
 
19
-## How does it work ?
20 46
 
21
-In the simplest form, `mulle-brew` is just a simple loop over a
22
-`.bootstrap/brews` file, that installs all the listed formulae. This list is
23
-the playground specification, that can be easily shared.
47
+## Install some libraries with **mulle-brew** and use them with cc, Xcode and clang
24 48
 
25
-Here is a sample `.bootstrap/brews` file that installs **autoconf** and
26
-**libpng**:
49
+Install **libpng** and **zlib**:
27 50
 
28 51
 ```
29
-mkdir .bootstrap 2> /dev/null
30
-cat << EOF > .bootstrap/brews
31
-autoconf
32
-libpng
52
+mulle-brew init
53
+mulle-brew setting -g -r brews libpng
54
+mulle-brew setting -g -r -a brews zlib
55
+mulle-brew
56
+```
57
+
58
+Create a small test program:
59
+
60
+```
61
+cat <<EOF > x.c
62
+#include <png.h>
63
+#include <zlib.h>
64
+
65
+main()
66
+{
67
+   printf( "png version: %u\n", png_access_version_number());
68
+   printf( "zlib version: %s\n", zlibVersion());
69
+   return( 0);
70
+}
71
+```
72
+
73
+#### Using cc
74
+
75
+Build it with **cc** and run it:
76
+
77
+```
78
+flags="`mulle-brew paths -l cflags`"
79
+cc ${flags} -o x x.c
80
+mulle-brew run ./x
81
+```
82
+
83
+If you are running `mulle-brew paths -l cflags` in `/tmp` it will produce this
84
+line:
85
+
86
+```
87
+-I/tmp/addictions/include -F/tmp/addictions/Frameworks -L/tmp/addictions/lib -lpng -lpng16 -lz
88
+```
89
+
90
+`mulle-brew paths cflags` on its own produces the -I, -F and -L flags. The `-l` option collects all the available libraries from `addictions/lib` and adds them as commandline options.
91
+
92
+
93
+#### Using cmake
94
+
95
+
96
+Create a `CMakeLists.txt`:
97
+
98
+```
99
+cat <<EOF > CMakeLists.txt
100
+cmake_minimum_required (VERSION 3.0)
101
+project (x)
102
+
103
+find_library( PNG_LIBRARY NAMES png)
104
+find_library( ZLIB_LIBRARY NAMES z)
105
+
106
+add_executable( x
107
+x.c)
108
+
109
+target_link_libraries( x
110
+\${PNG_LIBRARY}
111
+\${ZLIB_LIBRARY}
112
+)
33 113
 EOF
34 114
 ```
35 115
 
36
-When you call `mulle-brew` this will setup a local brew installation in a folder
37
-called `addictions`. The **autoconf** binaries will appear in `addictions/bin`
38
-and the **libpng** library in `addictions/lib` and `addictions/include`.
39
-`addictions` is your playground's '/usr/local' so to speak
116
+Build it with `cmake` and `make`:
117
+
118
+```
119
+mkdir build
120
+cd build
121
+cmake `mulle-brew paths cmake` ..
122
+make
123
+```
124
+
125
+> Check with `otool -L x` that indeed the libraries from `addictions/lib` have been picked up.
126
+
127
+
128
+
129
+
130
+#### Using Xcode
131
+
132
+Create a C tool project `x.xcodeproj` that resides in the same folder as `x.c`. Remove `main.c` and add `x.c`.
133
+
134
+Now enrich the xcode project with the **mulle-brew** dependencies header and library paths:
135
+
136
+```
137
+mulle-brew xcode add x.xcodeproj
138
+```
139
+
140
+You still need to manually add the libraries though.
40 141
 
41 142
 
42 143
 
144
+## Sharing addictions
145
+
146
+When you have multiple small projects, it would be nice to share a common `addictions` folder. You can do this with  `mulle-brew defer`. This commands links up the current project directory with its immediate parent. 
147
+
148
+The addictions folder will now reside in `../addictions` instead of `./addictions`. Now
149
+if you are already in the habit of using `mulle-brew paths` and `mulle-brew run`, you don't have to modify anything!
150
+
151
+You can remove from a master project with `mulle-brew emancipate`.
152
+
43 153
 
44 154
 ## Various Playground configurations
45 155
 
... ...
@@ -60,24 +170,24 @@ You use the Xcode supplied toolset, but you want the playground headers and
60 170
 libraries to override the system files.
61 171
 
62 172
 ```
63
-gcc `mulle-brew paths -m -q '' cflags`
173
+gcc `mulle-brew paths -m cflags`
64 174
 ```
65 175
 
66 176
 
67 177
 ### Sharing playgrounds with other projects
68 178
 
69
-You might find that you have multiple projects with overlapping depencies on
179
+You might find that you have multiple projects with overlapping dependencies on
70 180
 brew formula and the duplication becomes tedious. You can create a "master"
71 181
 playground in the common parent directory with:
72 182
 
73 183
 ```
74
-mulle-bootstrap defer
184
+mulle-brew defer
75 185
 ```
76 186
 
77 187
 And revert back to a private playground with
78 188
 
79 189
 ```
80
-mulle-bootstrap emancipate
190
+mulle-brew emancipate
81 191
 ```
82 192
 
83 193
 Here the use of `mulle-brew paths` comes in handy, as it adapts to the
... ...
@@ -87,12 +197,17 @@ new position of the `addictions` folder in the filesystem.
87 197
 
88 198
 ### Keep a cache of homebrew locally
89 199
 
90
-Cloning **brew** from GitHub can get tedious. You can use a local cache with:
200
+Cloning **brew** from GitHub for every project can get tedious. You can use a local cache with:
91 201
 
92 202
 ```
93
-mulle-brew config -h "clone_cache" "${HOME}/Library/Caches/mulle-brew"
203
+mulle-brew config -u "clone_cache" "${HOME}/Library/Caches/mulle-brew"
94 204
 ```
95 205
 
206
+### Hack the shared libraries to use a proper @rpath
207
+
208
+...
209
+
210
+
96 211
 
97 212
 ## GitHub and Mulle kybernetiK
98 213
 
99 214
deleted file mode 100755
... ...
@@ -1,423 +0,0 @@
1
-#! /usr/bin/env bash
2
-#
3
-#   Copyright (c) 2017 Nat! - Mulle kybernetiK
4
-#   All rights reserved.
5
-#
6
-#   Redistribution and use in source and binary forms, with or without
7
-#   modification, are permitted provided that the following conditions are met:
8
-#
9
-#   Redistributions of source code must retain the above copyright notice, this
10
-#   list of conditions and the following disclaimer.
11
-#
12
-#   Redistributions in binary form must reproduce the above copyright notice,
13
-#   this list of conditions and the following disclaimer in the documentation
14
-#   and/or other materials provided with the distribution.
15
-#
16
-#   Neither the name of Mulle kybernetiK nor the names of its contributors
17
-#   may be used to endorse or promote products derived from this software
18
-#   without specific prior written permission.
19
-#
20
-#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
-#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
-#   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
-#   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
-#   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
-#   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
-#   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
-#   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
-#   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
-#   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
-#   POSSIBILITY OF SUCH DAMAGE.
31
-#
32
-MULLE_EXECUTABLE_VERSION_MAJOR=3
33
-MULLE_EXECUTABLE_VERSION_MINOR=5
34
-MULLE_EXECUTABLE_VERSION_PATCH=0
35
-
36
-MULLE_EXECUTABLE_VERSION="${MULLE_EXECUTABLE_VERSION_MAJOR}.${MULLE_EXECUTABLE_VERSION_MINOR}.${MULLE_EXECUTABLE_VERSION_PATCH}"
37
-
38
-#
39
-# This is the main user interface to mulle-bootstrap
40
-# sorta like git
41
-#
42
-
43
-trap_fail()
44
-{
45
-   exit 1
46
-}
47
-
48
-
49
-mulle_brew_usage()
50
-{
51
-   cat <<EOF
52
-Usage:
53
-   ${MULLE_BOOTSTAP_EXECUTABLE} [flags] [command] [options]
54
-
55
-Flags:
56
-   -n   : do nothing creative or destructive
57
-   -v   : -v to be more verbose (-vv or -vvv for more verbosity)
58
-EOF
59
-
60
-   bootstrap_technical_option_usage
61
-
62
-   cat <<EOF
63
-
64
-Commands:
65
-   install   : fetches brews
66
-   update    : update brew
67
-   upgrade   : upgrade brew fomulae
68
-   init      : initializes a bootstrap project
69
-
70
-Options are command specific. Use mulle-brew <command> -h for help.
71
-EOF
72
-
73
-   if [ "${UNAME}" = 'darwin' ]
74
-   then
75
-      cat <<EOF
76
-   xcode     : setup xcodeproj settings
77
-EOF
78
-   fi
79
-
80
-   exit 1
81
-}
82
-
83
-
84
-_prepend_path_if_relative()
85
-{
86
-   case "$2" in
87
-      /*)
88
-         echo "$2"
89
-         ;;
90
-      *)
91
-         echo "$1/$2"
92
-         ;;
93
-   esac
94
-}
95
-
96
-
97
-resolve_symlinks()
98
-{
99
-   local dir_context
100
-   local linkpath
101
-
102
-   if linkpath="`readlink "$1"`"
103
-   then
104
-      dir_context=`dirname -- "$1"`
105
-      resolve_symlinks "`_prepend_path_if_relative "${dir_context}" "${linkpath}"`"
106
-   else
107
-      echo "$1"
108
-   fi
109
-}
110
-
111
-
112
-bootstrap_libexec_path()
113
-{
114
-   local path="$1"
115
-
116
-   local exedir
117
-   local exedirpath
118
-   local prefix
119
-   local libexecpath
120
-
121
-   path="`resolve_symlinks "${path}"`"
122
-   exedirpath="`dirname "${path}"`"
123
-   prefix="`dirname "${exedirpath}"`"
124
-   libexecpath="${prefix}/libexec/mulle-bootstrap"
125
-
126
-   if [ ! -x "${libexecpath}/mulle-bootstrap-functions.sh" ]
127
-   then
128
-      libexecpath="${exedirpath}/src"
129
-   fi
130
-
131
-   if [ -x "${libexecpath}/mulle-bootstrap-functions.sh" ]
132
-   then
133
-      echo "${libexecpath}"
134
-   fi
135
-}
136
-
137
-
138
-bootstrap_init()
139
-{
140
-   local libexecpath
141
-
142
-   libexecpath="`bootstrap_libexec_path "$0"`"
143
-   if [ -z "${libexecpath}" ]
144
-   then
145
-      echo "could not find libexec for ${MULLE_EXECUTABLE}" >&2
146
-      exit 1
147
-   fi
148
-
149
-   #
150
-   # shell export commands with minimal
151
-   # trap setup
152
-   #
153
-   case "${1}" in
154
-      library-path)
155
-         echo "${libexecpath}"
156
-         exit 0
157
-      ;;
158
-
159
-      version)
160
-         echo "${MULLE_EXECUTABLE_VERSION}"
161
-         exit 0
162
-      ;;
163
-   esac
164
-
165
-
166
-   PATH="${libexecpath}:$PATH"
167
-   export PATH
168
-
169
-   if [ ! -z "${MULLE_BOOTSTRAP_LIBEXEC_TRACE}" ]
170
-   then
171
-      echo "PATH=$PATH" >&2
172
-   fi
173
-
174
-   #  set -e # more pain then gain in the end
175
-   #  set -u # doesn't work with my style
176
-
177
-   # now include this first to get
178
-   # logging and UNAME
179
-
180
-   . mulle-bootstrap-logging.sh
181
-   . mulle-bootstrap-local-environment.sh || fail "not loaded"
182
-
183
-   trap trap_fail INT
184
-
185
-   # source_environment
186
-}
187
-
188
-
189
-brew_main()
190
-{
191
-   local command
192
-   local ps4string
193
-
194
-   # technical flags
195
-   local MULLE_FLAG_EXEKUTOR_DRY_RUN="NO"
196
-   local MULLE_FLAG_LOG_CACHE="NO"
197
-   local MULLE_FLAG_LOG_DEBUG="NO"
198
-   local MULLE_FLAG_LOG_EXEKUTOR="NO"
199
-   local MULLE_FLAG_LOG_EXEKUTOR="NO"
200
-   local MULLE_FLAG_LOG_FLUFF="NO"
201
-   local MULLE_FLAG_LOG_SCRIPTS="NO"
202
-   local MULLE_FLAG_LOG_SETTINGS="NO"
203
-   local MULLE_FLAG_LOG_VERBOSE="NO"
204
-   local MULLE_FLAG_MERGE_LOG="NO"
205
-   local MULLE_TRACE_PATHS_FLIP_X="NO"
206
-   local MULLE_TRACE_POSTPONE="NO"
207
-   local MULLE_TRACE_RESOLVER_FLIP_X="NO"
208
-   local MULLE_TRACE_SETTINGS_FLIP_X="NO"
209
-
210
-   #
211
-   # simple option handling
212
-   #
213
-   while [ $# -ne 0 ]
214
-   do
215
-      if bootstrap_technical_flags "$1"
216
-      then
217
-         shift
218
-         continue
219
-      fi
220
-
221
-      case "$1" in
222
-         -h|--help)
223
-            mulle_brew_usage
224
-         ;;
225
-
226
-         -*)
227
-            log_error "${MULLE_EXECUTABLE_FAIL_PREFIX}: Unknown option \"$1\""
228
-            mulle_brew_usage
229
-         ;;
230
-
231
-         *)
232
-            break
233
-         ;;
234
-      esac
235
-
236
-      shift
237
-   done
238
-
239
-   bootstrap_setup_trace "${MULLE_TRACE}"
240
-
241
-   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" = "YES" ]
242
-   then
243
-      log_trace "Dry run is active."
244
-   fi
245
-
246
-   # source in environment now
247
-
248
-   local_environment_main
249
-
250
-   #
251
-   # some commands only run when we have a .bootstrap folder
252
-   #
253
-   command="${1:-install}"
254
-   [ $# -eq 0 ] || shift
255
-
256
-
257
-   local previous
258
-
259
-   case "${command}" in
260
-      help|init|uname)
261
-      ;;
262
-
263
-      *)
264
-         local  orgpwd
265
-
266
-         orgpwd="$PWD"
267
-
268
-         while ! is_bootstrap_project
269
-         do
270
-            local old
271
-
272
-            old="$PWD"
273
-            cd ..
274
-
275
-            if [ "$PWD" = "${old}" ]
276
-            then
277
-               fail "There is no ${BOOTSTRAP_DIR} or ${BOOTSTRAP_DIR}.local folder here ($orgpwd), can't continue"
278
-            fi
279
-         done
280
-      ;;
281
-   esac
282
-
283
-   if bootstrap_should_defer_to_master "$@"
284
-   then
285
-      return 1
286
-   fi
287
-
288
-
289
-   MULLE_EXECUTABLE_FAIL_PREFIX="${MULLE_EXECUTABLE} ${command}"
290
-   MULLE_EXECUTABLE_OPTIONS="$@"
291
-
292
-   case "${command}" in
293
-      clean)
294
-         . mulle-bootstrap-clean.sh
295
-
296
-         clean_main "$@" || exit 1
297
-      ;;
298
-
299
-      config)
300
-         . mulle-bootstrap-settings.sh
301
-
302
-         config_main "$@" || exit 1
303
-      ;;
304
-
305
-      dist)
306
-         . mulle-bootstrap-clean.sh
307
-
308
-         clean_main "dist" || exit 1
309
-      ;;
310
-
311
-      defer)
312
-         . mulle-bootstrap-defer.sh
313
-
314
-         defer_main "$@" || exit 1
315
-      ;;
316
-
317
-      emancipate)
318
-         . mulle-bootstrap-defer.sh
319
-
320
-         emancipate_main "$@" || exit 1
321
-      ;;
322
-
323
-      help)
324
-         mulle_brew_usage "$@" || exit 1
325
-      ;;
326
-
327
-      init)
328
-         . mulle-bootstrap-init.sh
329
-
330
-         init_main "$@" || exit 1
331
-      ;;
332
-
333
-      install|fetch)
334
-         . mulle-bootstrap-brew.sh
335
-
336
-         brew_install_main "$@" || exit 1
337
-      ;;
338
-
339
-      library-path)
340
-         echo "$PATH" | tr ':' '\012' | head -1
341
-         return 0
342
-      ;;
343
-
344
-      paths)
345
-         . mulle-bootstrap-paths.sh
346
-
347
-         paths_main "$@" || exit 1
348
-      ;;
349
-
350
-      setting)
351
-         . mulle-bootstrap-settings.sh
352
-
353
-         setting_main "$@" || exit 1
354
-      ;;
355
-
356
-
357
-      show)
358
-         . mulle-bootstrap-show.sh
359
-
360
-         show_main "$@" || exit 1
361
-      ;;
362
-
363
-      uname)
364
-         echo "${UNAME}"
365
-         exit 0
366
-      ;;
367
-
368
-      update)
369
-         . mulle-bootstrap-brew.sh
370
-
371
-         brew_update_main "$@" || exit 1
372
-      ;;
373
-
374
-      upgrade)
375
-         . mulle-bootstrap-brew.sh
376
-
377
-         brew_upgrade_main "$@" || exit 1
378
-      ;;
379
-
380
-      version)
381
-         echo "${MULLE_EXECUTABLE_VERSION}"
382
-         return 0
383
-      ;;
384
-
385
-      xcode|setup-xcode)
386
-         . mulle-bootstrap-xcode.sh
387
-
388
-         MULLE_EXECUTABLE_FAIL_PREFIX="mulle-bootstrap xcode"
389
-         xcode_main "$@" || exit 1
390
-      ;;
391
-
392
-      *)
393
-         log_error "${MULLE_EXECUTABLE_FAIL_PREFIX}: Unknown command \"${command}\""
394
-         mulle_brew_usage
395
-      ;;
396
-   esac
397
-}
398
-
399
-#
400
-# service both names
401
-#
402
-MULLE_EXECUTABLE="`basename -- "$0"`"
403
-MULLE_ARGUMENTS="$@"
404
-MULLE_EXECUTABLE_FAIL_PREFIX="${MULLE_EXECUTABLE}"
405
-MULLE_EXECUTABLE_PID="$$"
406
-export MULLE_EXECUTABLE_PID
407
-
408
-
409
-bootstrap_init "$@" # needs params
410
-
411
-main()
412
-{
413
-   if ! brew_main "$@"
414
-   then
415
-      # just do it again, but cd has been set differently
416
-      main "$@" # is array
417
-      exit $?
418
-   fi
419
-}
420
-
421
-main "$@"
422
-
423
-trap - TERM EXIT
... ...
@@ -153,6 +153,8 @@ print_stashdir_embedded_repositories()
153 153
 
154 154
 setup_clean_environment()
155 155
 {
156
+   build_complete_environment
157
+
156 158
    [ -z "${DEPENDENCIES_DIR}"  ]   && internal_fail "DEPENDENCIES_DIR is empty"
157 159
    [ -z "${CLONESBUILD_DIR}" ]     && internal_fail "CLONESBUILD_DIR is empty"
158 160
    [ -z "${ADDICTIONS_DIR}" ]      && internal_fail "ADDICTIONS_DIR is empty"
... ...
@@ -306,11 +308,6 @@ clean_execute()
306 308
 {
307 309
    local style="$1"
308 310
 
309
-   [ -z "${DEPENDENCIES_DIR}"  ]   && internal_fail "DEPENDENCIES_DIR is empty"
310
-   [ -z "${CLONESBUILD_DIR}" ]  && internal_fail "CLONESBUILD_DIR is empty"
311
-   [ -z "${ADDICTIONS_DIR}"   ]    && internal_fail "ADDICTIONS_DIR is empty"
312
-   [ -z "${STASHES_DEFAULT_DIR}" ] && internal_fail "STASHES_DEFAULT_DIR is empty"
313
-
314 311
    setup_clean_environment
315 312
 
316 313
    case "${style}" in
... ...
@@ -36,6 +36,8 @@ MULLE_BOOTSTRAP_COMMON_SETTINGS_SH="included"
36 36
 #
37 37
 build_complete_environment()
38 38
 {
39
+   log_debug ":build_complete_environment:"
40
+
39 41
    #
40 42
    # Global Settings
41 43
    # used to be configurable, but just slows me down
... ...
@@ -55,6 +57,13 @@ build_complete_environment()
55 57
    fi
56 58
    N_CONFIGURATIONS="`echo "${OPTION_CONFIGURATIONS}" | wc -l | awk '{ print $1 }'`"
57 59
 
60
+   # experimentally, these could reside outside the project folder but never tested
61
+   CLONESBUILD_DIR="`read_sane_config_path_setting "build_dir" "build/.repos"`"
62
+   BUILDLOGS_DIR="`read_sane_config_path_setting "build_log_dir" "${CLONESBUILD_DIR}/.logs"`"
63
+
64
+   [ -z "${CLONESBUILD_DIR}" ]  && internal_fail "variable CLONESBUILD_DIR is empty"
65
+   [ -z "${BUILDLOGS_DIR}" ]    && internal_fail "variable BUILDLOGS_DIR is empty"
66
+
58 67
    #
59 68
    # expand PATH for build, but it's kinda slow
60 69
    # so don't do it all the time
... ...
@@ -99,17 +108,8 @@ build_complete_environment()
99 108
 
100 109
 common_settings_initialize()
101 110
 {
102
-   [ -z "${MULLE_BOOTSTRAP_LOGGING_SH}" ] && . mulle-bootstrap-logging.sh
103
-
104 111
    log_debug ":common_settings_initialize:"
105 112
 
106
-   [ -z "${MULLE_BOOTSTRAP_LOCAL_ENVIRONMENT_SH}" ] && . mulle-bootstrap-local-environment.sh
107
-   [ -z "${MULLE_BOOTSTRAP_SETTINGS_SH}" ]          && . mulle-bootstrap-settings.sh
108
-
109
-   # experimentally, these could reside outside the project folder but never tested
110
-   CLONESBUILD_DIR="`read_sane_config_path_setting "build_dir" "build/.repos"`"
111
-   BUILDLOGS_DIR="`read_sane_config_path_setting "build_log_dir" "${CLONESBUILD_DIR}/.logs"`"
112
-
113 113
    # all of these must reside in the project folder
114 114
    # used to be configurable, but what's the point really ? just slows us down
115 115
 
... ...
@@ -121,8 +121,6 @@ common_settings_initialize()
121 121
    # ADDICTIONS_DIR="`read_sane_config_path_setting "addictions_dir" "addictions"`"
122 122
    # STASHES_DEFAULT_DIR="`read_sane_config_path_setting "stashes_dir" "stashes"`"
123 123
 
124
-   [ -z "${CLONESBUILD_DIR}" ]  && internal_fail "variable CLONESBUILD_DIR is empty"
125
-   [ -z "${BUILDLOGS_DIR}" ]    && internal_fail "variable BUILDLOGS_DIR is empty"
126 124
 #   [ -z "${DEPENDENCIES_DIR}" ]    && internal_fail "variable DEPENDENCIES_DIR is empty"
127 125
 #   [ -z "${ADDICTIONS_DIR}" ]      && internal_fail "variable ADDICTIONS_DIR is empty"
128 126
 #   [ -z "${STASHES_DEFAULT_DIR}" ] && internal_fail "variable STASHES_DEFAULT_DIR is empty"
... ...
@@ -40,19 +40,21 @@ Usage:
40 40
 Output paths for various tool types. You can specify multiple types.
41 41
 
42 42
 Options:
43
-   -1             : output is a one-liner
44 43
    -f             : emit link directives for Frameworks
45 44
    -l             : emit link directives for libraries
46 45
    -m             : emit regardless of directory existence
47
-   -q <char>      : specify quote character
46
+   -n             : output is a multi-liner
47
+   -q <char>      : specify quote character, default empty
48 48
    -s <char>      : specify PATH seperator character
49 49
 
50 50
 Types:
51 51
    addictions     : output "addictions" path
52 52
    binpath        : output paths for binaries
53
+   cflags         : output CFLAGS for standalone build
53 54
    cppflags       : output CPPFLAGS
54 55
    cmakeflags     : output cmake flag definitions
55 56
    cmakepaths     : output cmake paths definitions
57
+   make           : output PATH, CPPFLAGS, LDFLAGS
56 58
 EOF
57 59
 
58 60
    if [ "${MULLE_EXECUTABLE}" = "mulle-bootstrap" ]
... ...
@@ -63,12 +65,12 @@ EOF
63 65
    fi
64 66
 
65 67
    cat <<EOF >&2
66
-   environment*   : output CPPFLAGS, LDFLAGS (default)
67 68
    frameworkpath  : output framework search paths PATH style
68 69
    headerpath     : output framework search paths PATH style
69 70
    ldflags        : output LDFLAGS
70 71
    librarypath    : output library search paths PATH style
71 72
    path           : output PATH
73
+   run            : output PATH, LD_LIBRARY_PATH (default)
72 74
 
73 75
 EOF
74 76
   exit 1
... ...
@@ -283,7 +285,12 @@ _flags_ldflags_value()
283 285
 _flags_cflags_value()
284 286
 {
285 287
    _flags_cppflags_value "$@"
286
-   _flags_ldflags_value "$@"
288
+   (
289
+      # avoid duplicate -F
290
+      OPTION_SUPPRESS_FRAMEWORK_LDFLAGS="YES"
291
+
292
+      _flags_ldflags_value "$@"
293
+   )
287 294
 }
288 295
 
289 296
 
... ...
@@ -391,10 +398,10 @@ _flags_do_cmake_flags()
391 398
    if [ ! -z "${values}" ]
392 399
    then
393 400
       values="`echo "${values}" | tr '\012' ' ' | sed 's/ *$//'`"
394
-      line="-DCMAKE_C_FLAGS=\"${values}\""
401
+      line="-DCMAKE_C_FLAGS=${OPTION_QUOTE}${values}${OPTION_QUOTE}"
395 402
       result="`add_line "${result}" "${line}"`"
396 403
 
397
-      line="-DCMAKE_CXX_FLAGS=\"${values}\""
404
+      line="-DCMAKE_CXX_FLAGS=${OPTION_QUOTE}${values}${OPTION_QUOTE}"
398 405
       result="`add_line "${result}" "${line}"`"
399 406
    fi
400 407
 
... ...
@@ -402,10 +409,10 @@ _flags_do_cmake_flags()
402 409
    if [ ! -z "${values}" ]
403 410
    then
404 411
       values="`echo "${values}" | tr '\012' ' ' | sed 's/ *$//'`"
405
-      line="-DCMAKE_EXE_LINKER_FLAGS=\"${values}\""
412
+      line="-DCMAKE_EXE_LINKER_FLAGS=${OPTION_QUOTE}${values}${OPTION_QUOTE}"
406 413
       result="`add_line "${result}" "${line}"`"
407 414
 
408
-      line="-DCMAKE_SHARED_LINKER_FLAGS=\"${values}\""
415
+      line="-DCMAKE_SHARED_LINKER_FLAGS=${OPTION_QUOTE}${values}${OPTION_QUOTE}"
409 416
       result="`add_line "${result}" "${line}"`"
410 417
    fi
411 418
 
... ...
@@ -423,22 +430,21 @@ _flags_do_cmake_paths()
423 430
    values="`_flags_headerpath_value`"
424 431
    if [ ! -z "${values}" ]
425 432
    then
426
-      line="-DCMAKE_INCLUDE_PATH =\"${values}\""
433
+      line="-DCMAKE_INCLUDE_PATH=${OPTION_QUOTE}${values}${OPTION_QUOTE}"
427 434
       result="`add_line "${result}" "${line}"`"
428 435
    fi
429 436
 
430 437
    values="`_flags_librarypath_value`"
431 438
    if [ ! -z "${values}" ]
432 439
    then
433
-      line="-DCMAKE_LIBRARY_PATH=\"${values}\""
440
+      line="-DCMAKE_LIBRARY_PATH=${OPTION_QUOTE}${values}${OPTION_QUOTE}"
434 441
       result="`add_line "${result}" "${line}"`"
435 442
    fi
436 443
 
437
-   # does CMAKE_FRAMEWORK_PATH even exist ?
438 444
    values="`_flags_frameworkpath_value`"
439 445
    if [ ! -z "${values}" ]
440 446
    then
441
-      line="-DCMAKE_FRAMEWORK_PATH=\"${values}\""
447
+      line="-DCMAKE_FRAMEWORK_PATH=${OPTION_QUOTE}${values}${OPTION_QUOTE}"
442 448
       result="`add_line "${result}" "${line}"`"
443 449
    fi
444 450
 
... ...
@@ -457,7 +463,7 @@ _flags_do_path()
457 463
    values="`_flags_binpath_value`"
458 464
    if [ ! -z "${values}" ]
459 465
    then
460
-      line="PATH='${values}:${PATH}'"
466
+      line="PATH=${OPTION_QUOTE}${values}:${PATH}${OPTION_QUOTE}"
461 467
       result="`add_line "${result}" "${line}"`"
462 468
    fi
463 469
 
... ...
@@ -465,7 +471,7 @@ _flags_do_path()
465 471
 }
466 472
 
467 473
 
468
-_flags_do_environment()
474
+_flags_do_make_environment()
469 475
 {
470 476
    local result="$1"
471 477
 
... ...
@@ -476,7 +482,7 @@ _flags_do_environment()
476 482
    if [ ! -z "${values}" ]
477 483
    then
478 484
       values="`echo "${values}" | tr '\012' ' ' | sed 's/ *$//'`"
479
-      line="CPPFLAGS=\"${values}\""
485
+      line="CPPFLAGS=${OPTION_QUOTE}${values}${OPTION_QUOTE}"
480 486
       result="`add_line "${result}" "${line}"`"
481 487
    fi
482 488
 
... ...
@@ -484,7 +490,14 @@ _flags_do_environment()
484 490
    if [ ! -z "${values}" ]
485 491
    then
486 492
       values="`echo "${values}" | tr '\012' ' ' | sed 's/ *$//'`"
487
-      line="LDFLAGS=\"${values}\""
493
+      line="LDFLAGS=${OPTION_QUOTE}${values}${OPTION_QUOTE}"
494
+      result="`add_line "${result}" "${line}"`"
495
+   fi
496
+
497
+   values="`_flags_binpath_value`"
498
+   if [ ! -z "${values}" ]
499
+   then
500
+      line="PATH=${OPTION_QUOTE}${values}:${PATH}${OPTION_QUOTE}"
488 501
       result="`add_line "${result}" "${line}"`"
489 502
    fi
490 503
 
... ...
@@ -492,6 +505,79 @@ _flags_do_environment()
492 505
 }
493 506
 
494 507
 
508
+_flags_do_run_environment()
509
+{
510
+   local result="$1"
511
+
512
+   local values
513
+   local line
514
+
515
+   values="`_flags_librarypath_value`"
516
+   if [ ! -z "${values}" ]
517
+   then
518
+      case "${UNAME}" in
519
+         darwin)
520
+            line="DYLD_FALLBACK_LIBRARY_PATH=${OPTION_QUOTE}${values}:${HOME}/lib:/usr/local/lib:/lib:/usr/lib${OPTION_QUOTE}"
521
+         ;;
522
+
523
+         *)
524
+            line="LD_LIBRARY_PATH=${OPTION_QUOTE}${values}:${LD_LIBRARY_PATH}${OPTION_QUOTE}"
525
+         ;;
526
+      esac
527
+      result="`add_line "${result}" "${line}"`"
528
+   fi
529
+
530
+   values="`_flags_frameworkpath_value`"
531
+   if [ ! -z "${values}" ]
532
+   then
533
+      case "${UNAME}" in
534
+         darwin)
535
+            line="DYLD_FALLBACK_FRAMEWORK_PATH=${OPTION_QUOTE}${values}:/Library/Frameworks:/Network/Library/Frameworks:/System/Library/Frameworks${OPTION_QUOTE}"
536
+            result="`add_line "${result}" "${line}"`"
537
+         ;;
538
+      esac
539
+   fi
540
+
541
+   values="`_flags_binpath_value`"
542
+   if [ ! -z "${values}" ]
543
+   then
544
+      line="PATH=${OPTION_QUOTE}${values}:${PATH}${OPTION_QUOTE}"
545
+      result="`add_line "${result}" "${line}"`"
546
+   fi
547
+
548
+   printf "%s" "$result"
549
+}
550
+
551
+
552
+run_main()
553
+{
554
+   local commandline
555
+   local value
556
+
557
+   [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ] && . mulle-bootstrap-functions.sh
558
+
559
+   #
560
+   # use mulle-bootstrap this way to get properly deferred
561
+   # paths
562
+   #
563
+   commandline="`${MULLE_EXECUTABLE} -s paths -1 -q "'"`"
564
+   while [ $# -ne 0 ]
565
+   do
566
+      value="$1"
567
+#      case "${value}" in
568
+#         \`*)
569
+#            value="`eval_exekutor echo "${value}"`"
570
+#         ;;
571
+#      esac
572
+
573
+      commandline="`concat "${commandline}" "'${value}'"`"
574
+      shift
575
+   done
576
+
577
+   eval_exekutor "${commandline}"
578
+}
579
+
580
+
495 581
 paths_main()
496 582
 {
497 583
    local types
... ...
@@ -509,8 +595,8 @@ paths_main()
509 595
    local OPTION_WITH_LIBRARYPATHS="YES"
510 596
    local OPTION_WITH_MISSING_PATHS="NO"
511 597
    local OPTION_PATH_SEPARATOR=":"
512
-   local OPTION_QUOTE="'"
513
-   local OPTION_LINE_SEPERATOR="\n"
598
+   local OPTION_QUOTE=""
599
+   local OPTION_LINE_SEPERATOR=" "
514 600
 
515 601
    log_debug ":paths_main:"
516 602
 
... ...
@@ -540,7 +626,7 @@ paths_main()
540 626
             paths_usage
541 627
          ;;
542 628
 
543
-         -1|--one-line)
629
+         -1|--one-line) # old code
544 630
             OPTION_LINE_SEPERATOR=" "
545 631
          ;;
546 632
 
... ...
@@ -562,6 +648,10 @@ paths_main()
562 648
             OPTION_WITH_MISSING_PATHS="YES"
563 649
          ;;
564 650
 
651
+         -n|--multiple-lines)
652
+            OPTION_LINE_SEPERATOR="\n"
653
+         ;;
654
+
565 655
          -na|--no-addictions)
566 656
             OPTION_WITH_ADDICTIONS="NO"
567 657
          ;;
... ...
@@ -622,7 +712,7 @@ paths_main()
622 712
    local result
623 713
 
624 714
    result=""
625
-   type="${1:-environment}"
715
+   type="${1:-run}"
626 716
 
627 717
 
628 718
    local memo
... ...
@@ -635,12 +725,12 @@ paths_main()
635 725
       [ $# -ne 0 ] && shift
636 726
 
637 727
       case "${type}" in
638
-         addictions)
728
+         "addictions")
639 729
             values="`_flags_emit_path "${ADDICTIONS_DIR}"`"
640 730
             result="`add_line "${result}" "${values}"`"
641 731
          ;;
642 732
 
643
-         dependencies)
733
+         "dependencies")
644 734
             values="`_flags_emit_path "${DEPENDENCIES_DIR}"`"
645 735
             result="`add_line "${result}" "${values}"`"
646 736
          ;;
... ...
@@ -650,11 +740,11 @@ paths_main()
650 740
             result="`add_line "${result}" "${values}"`"
651 741
          ;;
652 742
 
653
-         "cmakeflags")
743
+         "cmakeflags") # obsolete
654 744
             result="`_flags_do_cmake_flags "${result}"`"
655 745
          ;;
656 746
 
657
-         "cmakepaths")
747
+         "cmake"|"cmakepaths")
658 748
             result="`_flags_do_cmake_paths "${result}"`"
659 749
          ;;
660 750
 
... ...
@@ -662,8 +752,12 @@ paths_main()
662 752
             result="`_flags_do_path "${result}"`"
663 753
          ;;
664 754
 
665
-         "environment")
666
-            result="`_flags_do_environment "${result}"`"
755
+         "make")
756
+            result="`_flags_do_make_environment "${result}"`"
757
+         ;;
758
+
759
+         "run")
760
+            result="`_flags_do_run_environment "${result}"`"
667 761
          ;;
668 762
 
669 763
          *)
... ...
@@ -869,6 +869,7 @@ zip_unpack()
869 869
 scm_initialize()
870 870
 {
871 871
    log_debug ":scm_initialize:"
872
+
872 873
    [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ] && . mulle-bootstrap-functions.sh
873 874
    [ -z "${MULLE_BOOTSTRAP_REPOSITORIES_SH}" ] && . mulle-bootstrap-repositories.sh
874 875
 
... ...
@@ -303,7 +303,7 @@ _read_setting()
303 303
            "${key}" != "MULLE_NAT_REPOSITORIES" \
304 304
          ]
305 305
       then
306
-         log_printf "${C_SETTING}%b${C_RESET}\n" "Setting ${C_MAGENTA}${key}${C_SETTING} found in \"${apath}\" as ${C_MAGENTA}${C_BOLD}${value}${C_SETTING}"
306
+         log_printf "${C_SETTING}%b${C_RESET}\n" "Setting ${C_MAGENTA}${key}${C_SETTING} found in \"${apath}\" as ${C_MAGENTA}${value}${C_SETTING}"
307 307
       fi
308 308
    fi
309 309
 
... ...
@@ -348,8 +348,10 @@ Release"
348 348
    user_say_yes "$query"
349 349
    [ $? -eq 0 ] || exit 1
350 350
 
351
-
352
-   patch_library_configurations "${xcode_configurations}" "${configurations}" "${project}" "${default}" "${flag}"
351
+   if [ "${MULLE_EXECUTABLE}" = "mulle-bootstrap" ]
352
+   then
353
+      patch_library_configurations "${xcode_configurations}" "${configurations}" "${project}" "${default}" "${flag}"
354
+   fi
353 355
 
354 356
    exekutor mulle-xcode-settings "${flag}" "ADDICTIONS_DIR" "${addictions_dir}" "${project}"  || exit 1
355 357
    exekutor mulle-xcode-settings "${flag}" "DEPENDENCIES_DIR" "${dependencies_dir}" "${project}"  || exit 1
... ...
@@ -380,12 +382,9 @@ xcode_main()
380 382
 {
381 383
    log_debug "::: xcode :::"
382 384
 
383
-   [ -z "${MULLE_BOOTSTRAP_SETTINGS_SH}" ] && . mulle-bootstrap-settings.sh
384
-   [ -z "${MULLE_BOOTSTRAP_BREW_SH}" ]     && . mulle-bootstrap-brew.sh
385
+   [ -z "${MULLE_BOOTSTRAP_SETTINGS_SH}" ]        && . mulle-bootstrap-settings.sh
385 386
    [ -z "${MULLE_BOOTSTRAP_COMMON_SETTINGS_SH}" ] && . mulle-bootstrap-common-settings.sh
386 387
 
387
-   build_complete_environment
388
-
389 388
    if [ "${UNAME}" != 'darwin' ]
390 389
    then
391 390
       fail "for now xcode only works on OS X"