ecb04a build system: posix make support: handle out-of-tree builds in posix make mode.

Authored and Committed by midipix 3 years ago
    build system: posix make support: handle out-of-tree builds in posix make mode.
    
        
file modified
+5 -0
Makefile.in CHANGED
@@ -244,6 +244,10 @@ app-objs: dirs $(APP_OBJS)
244
244
245
245
246
246
247
+ $(APP_SRCS): srcs.tag
248
+
249
+ $(COMMON_SRCS): srcs.tag
250
+
247
251
$(APP_OBJS): $(ALL_HEADERS) host.tag tree.tag
248
252
249
253
$(SHARED_OBJS): $(ALL_HEADERS) host.tag tree.tag
@@ -300,6 +304,7 @@ distclean: clean
300
304
301
305
clean: clean-implib
302
306
rm -f tree.tag
307
+ rm -f srcs.tag
303
308
rm -f dirs.tag
304
309
rm -f host.tag
305
310
rm -f host.tmp
sofort/core/_infer/infer_modern.mk CHANGED
@@ -17,3 +17,6 @@ lib/%$(OS_ARCHIVE_EXT):
17
17
mkdir -p lib
18
18
rm -f $@
19
19
$(AR) rcs $@ $^
20
+
21
+ srcs.tag:
22
+ touch $@
sofort/core/_infer/infer_posix.mk CHANGED
@@ -17,3 +17,11 @@ $(STATIC_LIB):
17
17
mkdir -p lib
18
18
rm -f $@
19
19
$(AR) rcs $@ $(STATIC_OBJS)
20
+
21
+ srcs.tag: tree.tag
22
+
23
+ srcs.tag:
24
+ $(PROJECT_DIR)/sofort/tools/srctree.sh \
25
+ --srctree=$(SOURCE_DIR) -- \
26
+ $(COMMON_SRCS) $(APP_SRCS)
27
+ touch $@
sofort/tools/srctree.sh ADDED
@@ -0,0 +1,83 @@
1
+ #!/bin/sh
2
+
3
+ # srctree.sh: support for out-of-tree builds in posix make mode.
4
+ # this file is covered by COPYING.SOFORT.
5
+
6
+ set -eu
7
+
8
+ usage()
9
+ {
10
+ cat << EOF >&2
11
+
12
+ Usage:
13
+ --help show this HELP message
14
+ --srctree=SRCTREE set source directory
15
+
16
+ EOF
17
+ exit 1
18
+ }
19
+
20
+
21
+ # one
22
+ workdir=$(pwd -P)
23
+ srctree=
24
+ argloop=
25
+
26
+
27
+ for arg ; do
28
+ case "$arg" in
29
+ --help)
30
+ usage
31
+ ;;
32
+
33
+ --srctree=*)
34
+ srctree=${arg#*=}
35
+ ;;
36
+
37
+ --)
38
+ argloop='done'
39
+ ;;
40
+
41
+ *)
42
+ if [ -z "$argloop" ]; then
43
+ printf 'Invalid option: %s\n' "$arg" >&2
44
+ usage
45
+ fi
46
+ ;;
47
+ esac
48
+ done
49
+
50
+
51
+ # two
52
+ if [ -z "$srctree" ] ; then
53
+ usage
54
+ fi
55
+
56
+ cd -- "$srctree"
57
+ srctree=$(pwd -P)
58
+ cd -- "$workdir"
59
+
60
+ if [ "$srctree" = "$workdir" ]; then
61
+ exit 0
62
+ fi
63
+
64
+
65
+ # three
66
+ for arg ; do
67
+ case "$arg" in
68
+ --srctree=*)
69
+ ;;
70
+
71
+ --)
72
+ ;;
73
+
74
+ *)
75
+ stat "$arg" > /dev/null 2>&1 \
76
+ || ln -s -- "$srctree/$arg" "$arg"
77
+ ;;
78
+ esac
79
+ done
80
+
81
+
82
+ # all done
83
+ exit 0