summaryrefslogtreecommitdiffhomepage
path: root/pkg.build
blob: 0ad5f4a1942ed16f61eee15b8581e5f84da2cb07 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#
# . ./build.vars and set -o errexit are assumed.
#

parse_with_pkg_name ${SCRIPT_FNAME%[0-9][0-9]*} ${2} ${PKG_BUILD_NAMES};
if ! is_build_script_done fetch; then
	if [ "${PKG_URL_TYPE:-wget}" = wget ]; then
		fetch ${PKG_URL} ${PKG_SHA256SUM};
	else
		fetch_git ${PKG_SUBDIR} ${PKG_URL} "${PKG_GIT_ARGS_EXTRA}";
	fi;
	set_build_script_done fetch -extract;
fi;
if test_cmd pkg_${PKG_NAME}_finish; then
	pkg_${PKG_NAME}_finish; exit 0;
elif [ "${PKG_URL_TYPE:-wget}" = wget ] &&\
! is_build_script_done extract; then
	rm_if_exists ${PKG_SUBDIR};
	tar -axf ${PKG_FNAME};
	set_build_script_done extract -build_dir;
fi;
if [ -z "${PKG_BUILD_DIR}" ]; then
	set_build_dir ${PKG_SUBDIR} ${PKG_BUILD_TYPE:-native};
fi;
if ! is_build_script_done build_dir; then
	[ ${PKG_SUBDIR} != ${PKG_BUILD_DIR} ] &&\
		rm_if_exists -m ${PKG_BUILD_DIR};
	set_build_script_done build_dir -patch;
fi;
if ! is_build_script_done patch; then
	for PATCH_FNAME in portage/${PKG_SUBDIR}.midipix.patch	\
			${_PWD}/${PKG_SUBDIR}.local.patch	\
			${_PWD}/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch; do
		[ -r ${PATCH_FNAME} ] &&\
			patch -b -d ${PKG_SUBDIR} -p1 < ${PATCH_FNAME};
	done; unset PATCH_FNAME;
	if [ -n "${PKG_PATCHES_EXTRA_URL}" ]; then
		apply_patches ${PKG_PATCHES_EXTRA_URL} ${PKG_SUBDIR};
		if [ -n "${PKG_PATCHES_EXTRA_MANIFEST}" ]; then
			compare_hash_manifest ${PKG_PATCHES_EXTRA_MANIFEST};
		fi;
	fi;
	[ -x ${PKG_SUBDIR}/configure ] &&			\
		cp portage/config.cache ${PKG_BUILD_DIR}/;
	if [ ${PKG_LIBTOOL_MIDIPIX:-0} -eq 1 ]; then
		cp portage/libtool.midipix ${PKG_SUBDIR}/;
		sed -i.orig -e "/^libdir=/s/libdir='/libdir='\$PKG_PREFIX\//"\
			${PKG_SUBDIR}/libtool.midipix;
		if [ ${PKG_LIBTOOL_MIDIPIX_FIX:-0} -eq 1 ]; then
			sed -i.orig.orig									\
				-e '/^\s\+test \"\$inst_prefix_dir\" = \"\$destdir\" && \\$/{s/^/#/;n;s/^/#/}'	\
				${PKG_SUBDIR}/libtool.midipix;
		fi;
	fi;
	set_build_script_done patch -configure;
fi;
cd ${PKG_BUILD_DIR};
if [ -x ../${PKG_SUBDIR}/configure ]\
&& ! is_build_script_done configure; then
	if test_cmd pkg_${PKG_NAME}_configure_pre; then
		pkg_${PKG_NAME}_configure_pre;
	fi;
	AR="${PKG_AR_CONFIGURE}" CC="${PKG_CC_CONFIGURE}"\
	CFLAGS="${PKG_CFLAGS_CONFIGURE}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}"\
	LDFLAGS="${PKG_LDFLAGS_CONFIGURE}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}"\
	../${PKG_SUBDIR}/configure				\
		${PKG_CONFIGURE_ARGS} ${PKG_CONFIGURE_ARGS_EXTRA};
	set_build_script_done configure clean -build;
else
	set_build_script_done clean;
fi;
if [ ${PKG_NO_CLEAN:-0} -eq 0 ]\
&& ! is_build_script_done clean; then
	make clean;
	set_build_script_done clean -build;
fi;
if ! is_build_script_done build; then
	run_cmd_unsplit make					\
		${PKG_MAKEFLAGS_BUILD}				\
		${PKG_MAKEFLAGS_BUILD_EXTRA}			\
		"${PKG_AR_BUILD:+AR=${PKG_AR_BUILD}}"		\
		"${PKG_CC_BUILD:+CC=${PKG_CC_BUILD}}"		\
		"${PKG_CFLAGS_BUILD:+CFLAGS=${PKG_CFLAGS_BUILD}}"\
		"${PKG_CFLAGS_BUILD_EXTRA:+CFLAGS+=${PKG_CFLAGS_BUILD_EXTRA}}"\
		"${PKG_LDFLAGS_BUILD:+LDFLAGS=${PKG_LDFLAGS_BUILD}}"\
		"${PKG_LDFLAGS_BUILD_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_BUILD_EXTRA}}";
	set_build_script_done build -install;
fi;
if ! is_build_script_done install; then
	if test_cmd pkg_${PKG_NAME}_install; then
		pkg_${PKG_NAME}_install;
	else
		run_cmd_unsplit make				\
			${PKG_MAKEFLAGS_INSTALL}		\
			${PKG_MAKEFLAGS_INSTALL_EXTRA}		\
			"${PKG_AR_INSTALL:+AR=${PKG_AR_INSTALL}}"\
			"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
			"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
			"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"\
			"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"\
			"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"\
			"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"\
			"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"\
			${PKG_INSTALL_TARGET:=install};
		if [ -n "${PKG_PREFIX_EXTRA}" ]; then
			run_cmd_unsplit make			\
				${PKG_MAKEFLAGS_INSTALL}	\
				${PKG_MAKEFLAGS_INSTALL_EXTRA}	\
				"${PKG_AR_INSTALL:+AR=${PKG_AR_INSTALL}}"\
				"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
				"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
				"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"\
				"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"\
				"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"\
				"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"\
				"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"\
				${PKG_PREFIX_EXTRA}		\
				${PKG_INSTALL_TARGET:=install};
		fi;
		if test_cmd pkg_${PKG_NAME}_install_post; then
			pkg_${PKG_NAME}_install_post;
		fi;
	fi;
	set_build_script_done install -finish;
fi;
set_build_script_done finish;

# vim:filetype=sh