summaryrefslogtreecommitdiffhomepage
path: root/pkg.build
blob: 15e1eeb61626c972417ab3889fbdc1df3d80e7ac (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#
# . ./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 test_cmd pkg_${PKG_NAME}_fetch; then
		pkg_${PKG_NAME}_fetch;
	else
		if [ "${PKG_URL_TYPE:-wget}" = wget ]; then
			fetch "${PKG_URL}" ${PKG_SHA256SUM};
		else
			fetch_git ${PKG_SUBDIR} ${PKG_URL} "${PKG_GIT_ARGS_EXTRA}";
		fi;
	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};
	if [ ${PKG_SUBDIR_CREATE:-0} -eq 1 ]; then
		mkdir ${PKG_SUBDIR};
	fi;
	if [ "${PKG_FNAME##*.tar.}" = "bz2" ]; then
		bunzip2 -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
	elif [ "${PKG_FNAME##*.tar.}" = "gz" ]; then
		gunzip -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
	elif [ "${PKG_FNAME##*.tar.}" = "xz" ]; then
		xz -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
	elif [ "${PKG_FNAME##*.t}" = "bz2" ]; then
		bunzip2 -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
	elif [ "${PKG_FNAME##*.t}" = "gz" ]; then
		gunzip -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
	elif [ "${PKG_FNAME##*.t}" = "xz" ]; then
		xz -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
	else
		tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf ${PKG_FNAME};
	fi;
	if test_cmd pkg_${PKG_NAME}_extract_post; then
		pkg_${PKG_NAME}_extract_post;
	fi;
	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
	if [ ${PKG_AUTOGEN:-0} -eq 1 ]; then
		cd ${PKG_SUBDIR} &&				\
		install -m 0700 ${MIDIPIX_BUILD_PWD}/config.sub build-aux/ &&\
				./autogen.sh && cd ${OLDPWD};
	fi;
	for PATCH_FNAME in portage/${PKG_SUBDIR}.midipix.patch	\
			${MIDIPIX_BUILD_PWD}/${PKG_SUBDIR}.local.patch	\
			${MIDIPIX_BUILD_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
	if test_cmd pkg_${PKG_NAME}_build; then
		pkg_${PKG_NAME}_build;
	else
		if [ "${PKG_SLIBTOOL}" != "none" ]; then
			export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}";
		fi;
		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}}";
	fi;
	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;
	find ${PKG_PREFIX}/lib -type f -name \*.la -exec rm -f {} \;
	if [ ${PKG_LIBFILES_FIX:-0} -eq 1 ]; then
		env TARGET="${TARGET}"				\
		find . \( -name '*.so' -or -name '*.so.[0-9]'	\
			-or -name '*.so.[0-9].[0-9]' -or	\
			-name '*.so.[0-9].[0-9].[0-9]' \)	\
			-exec sh -c '				\
		SO_PNAME={}; SO_PNAME=${SO_PNAME#./};		\
		if [ "${SO_PNAME##*.}" = "so" ]; then		\
			SO_NAME=${SO_PNAME%%.*};		\
		else	SO_NAME=${SO_PNAME}; fi;		\
		echo perk -epdlltool ${SO_PNAME} \> ${SO_NAME}.def;					\
		perk -epdlltool ${SO_PNAME} > ${SO_NAME}.def;						\
		echo ${TARGET}-dlltool -l ${SO_NAME}.lib.a -D ${SO_PNAME} -d ${SO_NAME}.def;		\
		${TARGET}-dlltool -l ${SO_NAME}.lib.a -D ${SO_PNAME} -d ${SO_NAME}.def;			\
		echo cp ${SO_NAME}.lib.a '"${PKG_PREFIX}/lib"';						\
		cp ${SO_NAME}.lib.a '"${PKG_PREFIX}/lib" \;;

	fi;
	set_build_script_done install -finish;
fi;
set_build_script_done finish;

# vim:filetype=sh