summaryrefslogtreecommitdiff
path: root/project/config/cfgdefs.sh
blob: 8400b6a9be0ba260e266fd88dc1f51efe069cc35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# in projects where [ $mb_use_custom_cfgdefs = yes ],
# cfgdefs.sh is invoked from within ./configure via
# . $mb_project_dir/project/cfgdefs.sh

# a successful return from cfgdefs.sh will be followed
# by a second invocation of the config_copy() function,
# reflecting any changes to common config variables
# made by cfgdefs.sh.

# finally, cfgdefs.sh may update the contents of the
# config-time generated cfgdefs.mk.

for arg ; do
	case "$arg" in
		*)
			error_msg ${arg#}: "unsupported config argument."
			exit 2
	esac
done


cfgdefs_bootstrap()
{
	cfgdefs_bootstrap_done=${cfgdefs_bootstrap_done:-}

	if [ _$cfgdefs_bootstrap_done = _yes ]; then
		return 0
	fi

	cfgdefs_objs=

	cfgdefs_utilsrc='make.c'

	cfgdefs_sources="arch.c buf.c compat.c cond.c dir.c enum.c for.c hash.c job.c"
	cfgdefs_sources="$cfgdefs_sources lst.c main.c make_malloc.c meta.c metachar.c parse.c"
	cfgdefs_sources="$cfgdefs_sources str.c suff.c targ.c trace.c util.c var.c"

	cfgdefs_cflags="-I${mb_source_dir}/src/internal"
	cfgdefs_cflags="$cfgdefs_cflags -D_PATH_DEFSYSPATH=\"${mb_source_dir}/mk\""
	cfgdefs_cflags="$cfgdefs_cflags -DHAVE_STRERROR -DHAVE_VSNPRINTF"
	cfgdefs_cflags="$cfgdefs_cflags -DHAVE_SETPGID -DHAVE_SETRLIMIT -DHAVE_SETENV"

	cfgdefs_make="$mb_pwd/bootstrap/make"

	mkdir -p "$mb_pwd/bootstrap"

	printf '\n\n'

	for src in $cfgdefs_utilsrc; do
		obj=${src%%.c}.o
		cfgdefs_objs="$cfgdefs_objs $mb_pwd/bootstrap/${obj}"

		set -x

		"$mb_native_cc" $mb_native_cflags $cfgdefs_cflags \
			-c "$mb_source_dir/src/${src}"             \
			-o "$mb_pwd/bootstrap/${obj}"

		set +x
	done

	for src in $cfgdefs_sources; do
		obj=${src%%.c}.o
		cfgdefs_objs="$cfgdefs_objs $mb_pwd/bootstrap/${obj}"

		set -x

		"$mb_native_cc" $mb_native_cflags $cfgdefs_cflags \
			-c "$mb_source_dir/src/logic/${src}"       \
			-o "$mb_pwd/bootstrap/${obj}"

		set +x
	done

	"$mb_native_cc" $mb_native_cflags $cfgdefs_cflags \
		$mb_native_ldflags $cfgdefs_objs           \
		-o "$cfgdefs_make"

	mb_make="$cfgdefs_make"

	cfgdefs_bootstrap_done='yes'
}

# bootstrap
cfgdefs_bootstrap

# all done
return 0