Skip to content

Commit 20bd0ce

Browse files
committed
[sb2] Also take lib64 into account when loading wrappers. JB#61868
Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
1 parent 933efd8 commit 20bd0ce

File tree

7 files changed

+164
-144
lines changed

7 files changed

+164
-144
lines changed

llbuild/Makefile.include

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ __kicker_target: all
2929

3030

3131
TOPDIR := $(CURDIR)
32+
edit := sed \
33+
-e 's|@prefix[@]|$(prefix)|g' \
34+
-e 's|@bindir[@]|$(bindir)|g' \
35+
-e 's|@libdir[@]|$(libdir)|g' \
36+
-e 's|@datadir[@]|$(datadir)|g' \
37+
-e 's|@configure_input[@]|Generated from $@.sh.in; do not edit by hand.|g'
3238

3339
# a useful function to expand paths
3440
define O
@@ -110,6 +116,11 @@ built-in.o:: %.o
110116

111117
%:: %.o
112118

119+
%:: %.sh.in
120+
$(Q)rm -f $(@) $(@).tmp
121+
$(Q)$(edit) $(<) > $(OBJDIR)/$(@).tmp
122+
$(Q)chmod +x,a-w $(@).tmp
123+
$(Q)mv $(@).tmp $(@)
113124

114125
define ll_clean
115126
$(Q)rm -rf $(CLEAN_FILES)

utils/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,13 @@ $(D)/sb2-interp-wrapper: $(D)/sb2-interp-wrapper.o preload/libsb2.$(SHLIBEXT)
5959
$(P)LD
6060
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -ldl
6161

62+
scripts = \
63+
sb2 \
64+
sb2-config \
65+
sb2-config-gcc-toolchain \
66+
sb2-init \
67+
sb2-upgrade-config
6268

63-
targets := $(targets) $(D)/sb2-show $(D)/sb2-monitor $(D)/sb2-ruletree
69+
70+
71+
targets := $(targets) $(D)/sb2-show $(D)/sb2-monitor $(D)/sb2-ruletree $(call O,$(scripts))

utils/sb2-config-gcc-toolchain renamed to utils/sb2-config-gcc-toolchain.sh.in

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
# Copyright (C) 2007 Lauri Leukkunen <lle@rahina.org>
66
# Licensed under GPL version 2
77

8-
my_path=$_
9-
if [ $(basename $my_path) != $(basename $0) ]; then
10-
my_path=$0
11-
if [ $(basename $my_path) = $my_path ]; then
12-
my_path=$(which $my_path)
13-
fi
14-
fi
15-
168
log_config_action()
179
{
1810
tstamp=$(/bin/date '+%Y-%m-%d %H:%M:%S')
@@ -39,7 +31,7 @@ Options:
3931
-A arch manually override target architecture
4032
-h print this help
4133
-m mapping_mode target uses mapping_mode as default mode
42-
-S SBOX_DIR define value for SBOX_DIR
34+
-S SBOX_DATADIR define value for SBOX_DIR
4335
-R TARGET_ROOT define value for SBOX_TARGET_ROOT
4436
-V this toolchain is a secondary toolchain,
4537
tools require version numbers in pathnames
@@ -148,7 +140,7 @@ do
148140
(m) MAPPING_MODE=$OPTARG ;;
149141
(C) SBOX_EXTRA_CROSS_COMPILER_ARGS="$SBOX_EXTRA_CROSS_COMPILER_ARGS $OPTARG " ;;
150142
(L) SBOX_EXTRA_CROSS_LD_ARGS="$SBOX_EXTRA_CROSS_LD_ARGS $OPTARG " ;;
151-
(S) SBOX_DIR=$OPTARG ;;
143+
(S) SBOX_DATADIR=$OPTARG ;;
152144
(R) SBOX_TARGET_ROOT=$OPTARG ;;
153145
(V) SECONDARY_COMPILER=yes ;;
154146
(v) verbose=yes ;;
@@ -169,8 +161,8 @@ esac
169161

170162
# ---------- Check parameters
171163

172-
if [ -z "$SBOX_DIR" ]; then
173-
SBOX_DIR=$(readlink -f $(dirname $(readlink -f $my_path))/..)
164+
if [ -z "$SBOX_DATADIR" ]; then
165+
SBOX_DATADIR=@datadir@
174166
fi
175167

176168
if [ -z "$TARGET" ]; then
@@ -195,7 +187,7 @@ if [ -z "$MAPPING_MODE" ]; then
195187
exit 1
196188
fi
197189

198-
if [ ! -d $SBOX_DIR/share/scratchbox2/modes/$MAPPING_MODE ]; then
190+
if [ ! -d $SBOX_DATADIR/scratchbox2/modes/$MAPPING_MODE ]; then
199191
echo "Invalid mapping mode: $MAPPING_MODE"
200192
exit 1
201193
fi
@@ -285,21 +277,21 @@ fi
285277
SBOX_CROSS_GCC_SPECS_FILE=""
286278
SBOX_EXTRA_CROSS_COMPILER_STDINC=""
287279

288-
# FIXME: SBOX_CROSS_GCC_SPECS_FILE may point to $SBOX_DIR/share/scratchbox2/modes
280+
# FIXME: SBOX_CROSS_GCC_SPECS_FILE may point to $SBOX_DATADIR/scratchbox2/modes
289281
# after this. It should point to a session-specific location, but we don't have any
290282
# mechanism for that currently.
291283
if [ -n "$GCC_SPECS" ]; then
292284
# the file was specified on the command line
293285
SBOX_CROSS_GCC_SPECS_FILE="$GCC_SPECS"
294286
# else try to locate a specs file which was provided with gcc
295-
elif [ -f $SBOX_DIR/share/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_VERSION-specs-$ARCH ]; then
296-
SBOX_CROSS_GCC_SPECS_FILE="$SBOX_DIR/share/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_VERSION-specs-$ARCH"
297-
elif [ -f $SBOX_DIR/share/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_VERSION-specs ]; then
298-
SBOX_CROSS_GCC_SPECS_FILE="$SBOX_DIR/share/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_VERSION-specs"
299-
elif [ -f $SBOX_DIR/share/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_SHORTVERSION-specs ]; then
300-
SBOX_CROSS_GCC_SPECS_FILE="$SBOX_DIR/share/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_SHORTVERSION-specs"
301-
elif [ -f $SBOX_DIR/share/scratchbox2/modes/$MAPPING_MODE/gcc-specs ]; then
302-
SBOX_CROSS_GCC_SPECS_FILE="$SBOX_DIR/share/scratchbox2/modes/$MAPPING_MODE/gcc-specs"
287+
elif [ -f $SBOX_DATADIR/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_VERSION-specs-$ARCH ]; then
288+
SBOX_CROSS_GCC_SPECS_FILE="$SBOX_DATADIR/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_VERSION-specs-$ARCH"
289+
elif [ -f $SBOX_DATADIR/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_VERSION-specs ]; then
290+
SBOX_CROSS_GCC_SPECS_FILE="$SBOX_DATADIR/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_VERSION-specs"
291+
elif [ -f $SBOX_DATADIR/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_SHORTVERSION-specs ]; then
292+
SBOX_CROSS_GCC_SPECS_FILE="$SBOX_DATADIR/scratchbox2/modes/$MAPPING_MODE/gcc-$SBOX_CROSS_GCC_SHORTVERSION-specs"
293+
elif [ -f $SBOX_DATADIR/scratchbox2/modes/$MAPPING_MODE/gcc-specs ]; then
294+
SBOX_CROSS_GCC_SPECS_FILE="$SBOX_DATADIR/scratchbox2/modes/$MAPPING_MODE/gcc-specs"
303295
else
304296
SBOX_EXTRA_CROSS_COMPILER_STDINC="-I/usr/include"
305297
fi

utils/sb2-config renamed to utils/sb2-config.sh.in

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22
# Copyright (C) 2006,2007 Lauri Leukkunen <lle@rahina.org>
33
# Licensed under GPL version 2
44

5-
my_path=$_
6-
if [ $(basename $my_path) != $(basename $0) ]; then
7-
my_path=$0
8-
if [ $(basename $my_path) = $my_path ]; then
9-
my_path=$(which $my_path)
10-
fi
11-
fi
12-
5+
136
log_config_action()
147
{
158
mkdir -p $SBOX_CONFIG_DIR
@@ -49,7 +42,7 @@ EOF
4942

5043
version()
5144
{
52-
cat $SBOX_DIR/share/scratchbox2/version
45+
cat $SBOX_DATADIR/version
5346
exit 0
5447
}
5548

@@ -183,7 +176,7 @@ showenv_vars()
183176
# else there are none.
184177
}
185178

186-
SBOX_DIR=$(readlink -f $(dirname $(readlink -f $my_path))/..)
179+
SBOX_DATADIR=@datadir@
187180
WRITE_CONFIG=0
188181

189182
if [ $# = 0 ]; then

utils/sb2-init renamed to utils/sb2-init.sh.in

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
# sb2-init - Copyright (C) 2007 Lauri Leukkunen <lle@rahina.org>
33
# Licensed under GPL version 2
44

5-
my_path=$_
6-
if [ $(basename $my_path) != $(basename $0) ]; then
7-
my_path=$0
8-
if [ $(basename $my_path) = $my_path ]; then
9-
my_path=$(which $my_path)
10-
fi
11-
fi
12-
135
log_config_action()
146
{
157
tstamp=$(/bin/date '+%Y-%m-%d %H:%M:%S')
@@ -44,7 +36,7 @@ show_existing_config_info()
4436
echo
4537
fi
4638
done
47-
if [ has_targets = "no" ]; then
39+
if [ $has_targets = "no" ]; then
4840
echo "none."
4941
fi
5042
}
@@ -102,7 +94,7 @@ EOF
10294

10395
version()
10496
{
105-
cat $SBOX_DIR/share/scratchbox2/version
97+
cat $SBOX_DATADIR/scratchbox2/version
10698
exit 0
10799
}
108100

@@ -208,15 +200,15 @@ configure_toolchains()
208200
else
209201
gccconfig_arch_option2=""
210202
fi
211-
for compiler_path in $*; do
203+
for compiler_path in "${@}"; do
212204
log_config_action "sb2-init: configuring toolchain, compiler $compiler_path"
213-
if ! $SBOX_SHARE_DIR/scripts/sb2-config-gcc-toolchain \
205+
if ! $SBOX_DATADIR/scratchbox2/scripts/sb2-config-gcc-toolchain \
214206
-v \
215207
$secondary_compiler \
216208
$gccconfig_arch_option \
217209
$gccconfig_arch_option2 \
218210
-R "$SBOX_TARGET_ROOT" \
219-
-S "$SBOX_DIR" \
211+
-S "$SBOX_DATADIR" \
220212
-t "$TARGET" \
221213
-m "$MAPPING_MODE" \
222214
-C "$SB2INIT_SBOX_EXTRA_CROSS_COMPILER_ARGS" \
@@ -231,10 +223,9 @@ configure_toolchains()
231223
done
232224
}
233225

234-
if [ -z "$SBOX_DIR" ]; then
235-
SBOX_DIR=$(readlink -f $(dirname $(readlink -f $my_path))/..)
226+
if [ -z "$SBOXDATA_DIR" ]; then
227+
SBOX_DATADIR=@datadir@
236228
fi
237-
SBOX_SHARE_DIR=$SBOX_DIR/share/scratchbox2
238229

239230
# Use an array to preserve spaces in original arguments:
240231
declare -a init_orig_args_array
@@ -264,7 +255,7 @@ fi
264255
# because a) name of the target is currently unknown, b) there might be
265256
# errors in the parameters, or c) if the user is just requesting help or
266257
# version and we are not actually going to configure anything.
267-
eval $($SBOX_SHARE_DIR/scripts/sb2-parse-sb2-init-args "${init_orig_args_array[@]}")
258+
eval $($SBOX_DATADIR/scratchbox2/scripts/sb2-parse-sb2-init-args "${init_orig_args_array[@]}")
268259

269260
TARGET=$SB2INIT_TARGET
270261
SBOX_TARGET_ROOT=$SB2INIT_TARGET_ROOT
@@ -301,7 +292,7 @@ if [ -z "$MAPPING_MODE" ]; then
301292
echo "Info: Mapping mode not specified, using default ($MAPPING_MODE)"
302293
fi
303294

304-
if [ ! -d $SBOX_DIR/share/scratchbox2/modes/$MAPPING_MODE ]; then
295+
if [ ! -d $SBOX_DATADIR/scratchbox2/modes/$MAPPING_MODE ]; then
305296
echo "Invalid mapping mode: $MAPPING_MODE"
306297
exit 1
307298
fi
@@ -319,7 +310,7 @@ log_config_action "sb2-init $SBOX_INIT_ORIG_ARGS"
319310
# Parse parameters (round 2); store parameters to the config directory.
320311
# "$SBOX_CONFIG_DIR/sb2-init-args" can be overwritten by sb2-init or
321312
# sb2-upgrade-config; the config log should identify who did what..
322-
$SBOX_SHARE_DIR/scripts/sb2-parse-sb2-init-args "${init_orig_args_array[@]}" \
313+
$SBOX_DATADIR/scratchbox2/scripts/sb2-parse-sb2-init-args "${init_orig_args_array[@]}" \
323314
>$SBOX_CONFIG_DIR/sb2-init-args
324315

325316
if [ -z "$SB2INIT_COMPILERS" ]; then
@@ -503,7 +494,7 @@ fi
503494
# if the target system is (based on) debian,
504495
# DEB_* environment variables are needed. We'll set them in any case:
505496
echo "sb2-init: Creating Debian build system settings for this target:"
506-
if ! $SBOX_DIR/share/scratchbox2/scripts/sb2-config-debian -t $TARGET ;then
497+
if ! $SBOX_DATADIR/scratchbox2/scripts/sb2-config-debian -t $TARGET ;then
507498
log_config_action "sb2-init: failed run sb2-config-debian"
508499
echo "sb2-init: sb2-config-debian failed."
509500
exit 1
@@ -520,12 +511,12 @@ fi
520511
if [ $SB2INIT_WITH_LOCALES = 1 ]; then
521512
if [ -n "$SB2INIT_TOOLS_ROOT" ]; then
522513
$SBOX_DIR/bin/sb2 -t $TARGET \
523-
$SBOX_DIR/share/scratchbox2/scripts/sb2-generate-locales -T
514+
$SBOX_DATADIR/scratchbox2/scripts/sb2-generate-locales -T
524515
fi
525516

526517
if [ -z "$SB2INIT_CPUTRANSP" ]; then
527518
$SBOX_DIR/bin/sb2 -t $TARGET \
528-
$SBOX_DIR/share/scratchbox2/scripts/sb2-generate-locales
519+
$SBOX_DATADIR/scratchbox2/scripts/sb2-generate-locales
529520
fi
530521
fi
531522

utils/sb2-upgrade-config renamed to utils/sb2-upgrade-config.sh.in

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,8 @@
88
# Copyright (C) 2009 Nokia Corporation.
99
# Licensed under GPL version 2
1010

11-
my_path=$_
12-
if [ $(basename $my_path) != $(basename $0) ]; then
13-
my_path=$0
14-
if [ $(basename $my_path) = $my_path ]; then
15-
my_path=$(which $my_path)
16-
fi
17-
fi
18-
19-
SBOX_SHARE_DIR=$(readlink -f $(dirname $(readlink -f $my_path))/..)
20-
SBOX_DIR=$(readlink -f $SBOX_SHARE_DIR/../..)
11+
SBOX_DATADIR=@datadir@
12+
SBOX_DIR=@prefix@
2113
SBOX_TARGET=$1
2214
SBOX_CONFIG_DIR=~/.scratchbox2/$SBOX_TARGET/sb2.config.d
2315

@@ -66,7 +58,7 @@ get_sb2_init_arguments_from_old_config_file()
6658
-n '/^SBOX_TARGET_ROOT/ s/^SBOX_TARGET_ROOT=(.*)/\1/ p' $OLD_CONFIG_FILE)
6759
export SB2INIT_TARGET_ROOT=$SBOX_TARGET_ROOT
6860

69-
$SBOX_SHARE_DIR/scripts/sb2-parse-sb2-init-args $SBOX_INIT_ORIG_ARGS \
61+
$SBOX_DATADIR/scratchbox2/scripts/sb2-parse-sb2-init-args $SBOX_INIT_ORIG_ARGS \
7062
> $SBOX_CONFIG_DIR/sb2-init-args
7163
log_config_action "Config upgrade: arguments of original sb2-init restored from old config file"
7264
}
@@ -88,12 +80,12 @@ update_toolchain_configs()
8880
for compiler_path in "$@"; do
8981
# echo "Updating compiler $compiler_path"
9082
log_config_action "Config upgrade: settings for compiler $compiler_path"
91-
if ! $SBOX_SHARE_DIR/scripts/sb2-config-gcc-toolchain \
83+
if ! $SBOX_DATADIR/scratchbox2/scripts/sb2-config-gcc-toolchain \
9284
$secondary_compiler \
9385
$gccconfig_arch_option \
9486
$gccconfig_arch_option2 \
9587
-R "$SB2INIT_TARGET_ROOT" \
96-
-S "$SBOX_SHARE_DIR/../.." \
88+
-S "$SBOX_DATADIR" \
9789
-t "$SB2INIT_TARGET" \
9890
-m "$SB2INIT_MAPPING_MODE" \
9991
-C "$SB2INIT_SBOX_EXTRA_CROSS_COMPILER_ARGS" \
@@ -159,7 +151,7 @@ update_host_ld_library_path()
159151

160152
update_debian_config()
161153
{
162-
$SBOX_DIR/share/scratchbox2/scripts/sb2-config-debian -t $SBOX_TARGET
154+
$SBOX_DATADIR/scratchbox2/scripts/sb2-config-debian -t $SBOX_TARGET
163155
}
164156

165157
if [ ! -d $SBOX_CONFIG_DIR ]; then

0 commit comments

Comments
 (0)