Check-in [cbce55da50]
Overview
SHA1:cbce55da50475ebdd6db500f910bea8ea8b96946
Date: 2016-09-06 03:32:47
User: rkeene
Comment:Added support for a simplified package build script
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2016-09-06
03:42
[69f695475e] Minor update to check for new build script system (user: rkeene, tags: trunk)
03:32
[cbce55da50] Added support for a simplified package build script (user: rkeene, tags: trunk)
2016-09-02
19:56
[82debae251] Fixed issue with 32-bit builds with a 64-bit cross-compiler (user: rkeene, tags: trunk)
Changes

Added common/common.sh version [9063052c4e].



































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#! /usr/bin/env bash

targetInstallEnvironment='kitcreator'
pkgdir="$(pwd)"
internalpkgname="${pkg}"
archivedir="${pkgdir}/src"
buildsrcdir="${pkgdir}/buildsrc"
installdir="${pkgdir}/inst"
runtimedir="${pkgdir}/out"
workdir="${pkgdir}/workdir-$$${RANDOM}${RANDOM}${RANDOM}${RANDOM}.work"

_download="$(which download)"

function clean() {
	rm -rf "${installdir}" "${runtimedir}"
}

function distclean() {
	rm -rf "${archivedir}"
	rm -rf "${pkgdir}"/workdir-*
}

function init() {
	clean || return 1

	TCL_VERSION="unknown"
	if [ -f "${TCLCONFIGDIR}/tclConfig.sh" ]; then
		source "${TCLCONFIGDIR}/tclConfig.sh"
	fi
	export TCL_VERSION
}

function predownload() {
	:
}

function download() {
	if [ -d "${buildsrcdir}" ]; then
		return 0
	fi

	if [ -n "${url}" ]; then
		# Determine type of file
		archivetype="$(echo "${url}" | sed 's@\?.*$@@')"
		case "${archivetype}" in
			*.tar.*)
				archivetype="$(echo "${archivetype}" | sed 's@^.*\.tar\.@tar.@')"
				;;
			*)
				archivetype="$(echo "${archivetype}" | sed 's@^.*\.@@')"
				;;
		esac

		pkgarchive="${archivedir}/${pkg}-${version}.${archivetype}"
		mkdir "${archivedir}" >/dev/null 2>/dev/null
	fi

	if [ -n "${url}" -a -n "${pkgarchive}" -a ! -e "${pkgarchive}" ]; then
		"${_download}" "${url}" "${pkgarchive}" "${sha256}" || return 1
	fi

	return 0
}

function postdownload() {
	:
}

function extract() {
	if [ -d "${buildsrcdir}" ]; then
		mkdir "${workdir}" || return 1

		cp -rp "${buildsrcdir}"/* "${workdir}" || return 1

		return 0
	fi

	if [ -n "${pkgarchive}" ]; then
		(
			mkdir "${workdir}" || exit 1

			cd "${workdir}" || exit 1

			case "${pkgarchive}" in
				*.tar.gz|*.tgz)
					gzip -dc "${pkgarchive}" | tar -xf - || exit 1
					;;
				*.tar.bz2|*.tbz|*.tbz2)
					bzip2 -dc "${pkgarchive}" | tar -xf - || exit 1
					;;
				*.tar.xz|*.txz)
					xz -dc "${pkgarchive}" | tar -xf - || exit 1
					;;
				*.zip)
					unzip "${pkgarchive}" || exit 1
					;;
			esac

			shopt -s dotglob
			dir="$(echo ./*)"
			if [ -d "${dir}" ]; then
				mv "${dir}"/* . || exit 1

				rmdir "${dir}" || exit 1
			fi

			exit 0
		) || return 1
	fi

	return 0
}

function apply_patches() {
	:
}

function preconfigure() {
	:
}

function configure() {
	local tryopts tryopt
	local staticpkg staticpkgvar
	local isshared
	local save_cflags
	local base_var kc_var

	staticpkgvar="$(echo "STATIC${internalpkgname}" | dd conv=ucase 2>/dev/null)"
	staticpkg="$(eval "echo \"\$${staticpkgvar}\"")"

	# Set configure options for this sub-project
	for base_var in LDFLAGS CFLAGS CPPFLAGS LIBS; do
		kc_var="$(echo "KC_${internalpkgname}_${base_var}" | dd conv=ucase 2>/dev/null)"
		kc_var_val="$(eval "echo \"\$${kc_var}\"")"

		if [ -n "${kc_var_val}" ]; then
			eval "${base_var}=\"\$${base_var} \$${kc_var}\"; export ${base_var}"
		fi
	done

	# Determine if we should enable shared or not
	if [ "${staticpkg}" = "0" ]; then
		tryopts="--enable-shared --disable-shared"
	elif [ "${staticpkg}" = "-1" ]; then
		tryopts="--enable-shared"
	else
		tryopts="--disable-shared"
	fi

	save_cflags="${CFLAGS}"
	for tryopt in $tryopts __fail__; do
		if [ "${tryopt}" = "__fail__" ]; then
			return 1
		fi

		# Clean up, if needed
		make distclean >/dev/null 2>/dev/null
		if [ "${tryopt}" == "--enable-shared" ]; then
			isshared="1"
		else
			isshared="0"
		fi

		# If build a static package for KitDLL, ensure that we use PIC
		# so that it can be linked into the shared object
		if [ "${isshared}" = "0" -a "${KITTARGET}" = "kitdll" ]; then
			CFLAGS="${save_cflags} -fPIC"
		else
			CFLAGS="${save_cflags}"
		fi
		export CFLAGS

		if [ "${isshared}" = '0' ]; then
			sed 's@USE_TCL_STUBS@XXX_TCL_STUBS@g' configure > configure.new

			pkg_configure_shared_build='0'
		else
			sed 's@XXX_TCL_STUBS@USE_TCL_STUBS@g' configure > configure.new

			pkg_configure_shared_build='1'
		fi

		cat configure.new > configure
		rm -f configure.new

		./configure $tryopt --prefix="${installdir}" --exec-prefix="${installdir}" --libdir="${installdir}/lib" --with-tcl="${TCLCONFIGDIR}" "${configure_extra[@]}" ${CONFIGUREEXTRA} && break
	done

	return 0
}

function postconfigure() {
	:
}

function prebuild() {
	:
}

function build() {
	${MAKE:-make} tcllibdir="${installdir}/lib" "${make_extra[@]}"
}

function postbuild() {
	:
}

function preinstall() {
	:
}

function install() {
	local installpkgdir
	local pkglibfile

	mkdir -p "${installdir}/lib" || return 1
	${MAKE:-make} tcllibdir="${installdir}/lib" "${make_extra[@]}" install || return 1

	# Create pkgIndex if needed
	installpkgdir="$(echo "${installdir}/lib"/*)"

	if [ -d "${installpkgdir}" ]; then
		if [ ! -e "${installpkgdir}/pkgIndex.tcl" ]; then
			case "${pkg_configure_shared_build}" in
				0)
					cat << _EOF_ > "${installpkgdir}/pkgIndex.tcl"
package ifneeded ${pkg} ${version} [list load {} ${pkg}]
_EOF_
					;;
				1)
					pkglibfile="$(find "${installpkgdir}" -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.shlib' | head -n 1 | sed 's@^.*/@@')"
					cat << _EOF_ > "${installpkgdir}/pkgIndex.tcl"
package ifneeded ${pkg} ${version} [list load [file join \$dir ${pkglibfile}]]
_EOF_
					;;
			esac
		fi
	fi
}

function postinstall() {
	:
}

function createruntime() {
	local file

	# Install files needed by installation
	mkdir -p "${runtimedir}" || return 1
	cp -r "${installdir}/lib" "${runtimedir}" || return 1

	find "${runtimedir}" -name '*.a' -type f | while IFS='' read -r file; do
		rm -f "${file}"
	done

	# Ensure that some files were installed
	if ! find "${runtimedir}" -type f 2>/dev/null | grep '^' >/dev/null; then
		return 1
	fi

	return 0
}

function die() {
	local msg

	msg="$1"

	echo "$msg" >&2

	exit 1
}

Modified kitcreator from [5a0fe6c78b] to [5a5604ad51].

38
39
40
41
42
43
44

45
46
47
48
49
50
51
...
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
184
...
202
203
204
205
206
207
208





































209



210
211
212
213
214
215
216

# Always rebuild kitsh
rm -f "kitsh/.success"
for pkg in ${KITCREATOR_ALLPKGS} ${KITCREATOR_PKGS}; do
	if [ "${mode}" != "retry" -o ! -f "${pkg}/.success" ]; then
		rm -f "${pkg}/build.log" "${pkg}/.success"
		rm -rf "${pkg}/out" "${pkg}/inst" "${pkg}/build"


		rm -rf "${pkg}/src"/tmp-*
	fi

	if [ "${mode}" = "distclean" ]; then
		rm -rf "${pkg}/src"
	fi
................................................................................
	if echo 'exit 0' | "${testsh}" >/dev/null 2>/dev/null; then
		TCLSH_NATIVE="${testsh}"

		break
	fi
done
export TCLSH_NATIVE



















# Verify that each component is happy with the environment
validatefailed="0"
for pkg in tcl tclvfs zlib ${KITCREATOR_PKGS} kitsh; do
	failed='0'
	if [ -f "${pkg}/.success" ]; then
		continue
	fi

	if [ -x "${pkg}/validate.sh" ]; then
		(
			cd "${pkg}" >/dev/null 2>/dev/null || exit 1

			./validate.sh 3>&1 4>&2 > build.log 2>&1 || exit 1
		) || failed="1"

		if [ "${failed}" = '1' ]; then
			echo "Failed pre-requisite check for ${pkg}" >&2

			validatefailed='1'
		fi
................................................................................
		(
			cd "${pkg}" >/dev/null 2>/dev/null || exit 1

			build_script='./build.sh'
			if [ -x 'kitcreator-build.sh' ]; then
				build_script='./kitcreator-build.sh'
			fi





































			"${build_script}" 3>&1 4>&2 > build.log 2>&1 || exit 1



		) || failed="1"
	fi

	if [ "${failed}" = "1" ]; then
		echo " failed."
		failedpkgs="${failedpkgs} ${pkg}"
	else







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>













|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275

# Always rebuild kitsh
rm -f "kitsh/.success"
for pkg in ${KITCREATOR_ALLPKGS} ${KITCREATOR_PKGS}; do
	if [ "${mode}" != "retry" -o ! -f "${pkg}/.success" ]; then
		rm -f "${pkg}/build.log" "${pkg}/.success"
		rm -rf "${pkg}/out" "${pkg}/inst" "${pkg}/build"
		rm -rf "${pkg}"/workdir-*

		rm -rf "${pkg}/src"/tmp-*
	fi

	if [ "${mode}" = "distclean" ]; then
		rm -rf "${pkg}/src"
	fi
................................................................................
	if echo 'exit 0' | "${testsh}" >/dev/null 2>/dev/null; then
		TCLSH_NATIVE="${testsh}"

		break
	fi
done
export TCLSH_NATIVE

# Function to determine what build mode is being used
function useCommonBuildSystem() {
	local script

	script="$1"

	if head "${script}" 2>/dev/null | grep -i '^# *BuildCompatible: *KitCreator *$' >/dev/null 2>/dev/null; then
		return 0
	fi

	return 1
}

# Cleanup build logs
for pkg in tcl tclvfs zlib ${KITCREATOR_PKGS} kitsh; do
	rm -f "${pkg}/build.log"
done

# Verify that each component is happy with the environment
validatefailed="0"
for pkg in tcl tclvfs zlib ${KITCREATOR_PKGS} kitsh; do
	failed='0'
	if [ -f "${pkg}/.success" ]; then
		continue
	fi

	if [ -x "${pkg}/validate.sh" ]; then
		(
			cd "${pkg}" >/dev/null 2>/dev/null || exit 1

			./validate.sh 3>&1 4>&2 >> build.log 2>&1 || exit 1
		) || failed="1"

		if [ "${failed}" = '1' ]; then
			echo "Failed pre-requisite check for ${pkg}" >&2

			validatefailed='1'
		fi
................................................................................
		(
			cd "${pkg}" >/dev/null 2>/dev/null || exit 1

			build_script='./build.sh'
			if [ -x 'kitcreator-build.sh' ]; then
				build_script='./kitcreator-build.sh'
			fi

			if useCommonBuildSystem "${build_script}"; then
				(
					. ../common/common.sh
					. "${build_script}"

					set -x

					init || die 'init failed'

					predownload || die 'predownload failed'
					download || die 'download failed'
					postdownload || die 'postdownload failed'

					extract || die 'extract failed'

					apply_patches || die 'apply patches failed'

					cd "${workdir}" || exit 1

					preconfigure || die 'preconfigure failed'
					configure || die 'configure failed'
					postconfigure || die 'postconfigure failed'

					prebuild || die 'prebuild failed'
					build || die 'build failed'
					postbuild || die 'postbuild failed'

					preinstall || die 'preinstall failed'
					install || die 'install failed'
					postinstall || die 'postinstall failed'

					createruntime || die 'createruntime failed'

					set +x

					rm -rf "${workdir}"
				) 3>&1 4>&2 > build.log 2>&1 || exit 1
			else
				"${build_script}" 3>&1 4>&2 >> build.log 2>&1 || exit 1
			fi
		) || failed="1"
	fi

	if [ "${failed}" = "1" ]; then
		echo " failed."
		failedpkgs="${failedpkgs} ${pkg}"
	else

Modified udp/build.sh from [9534382755] to [9c9d67bdc5].

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


#! /usr/bin/env bash

if [ ! -f 'build.sh' ]; then
	echo 'ERROR: This script must be run from the directory it is in' >&2

	exit 1
fi
if [ -z "${TCLVERS}" ]; then
	echo 'ERROR: The TCLVERS environment variable is not set' >&2

	exit 1
fi

TCLUDPVERS="1.0.11"
SRC="src/tcludp-${TCLUDPVERS}.tar.gz"
SRCURL="http://sourceforge.net/projects/tcludp/files/tcludp/${TCLUDPVERS}/tcludp-${TCLUDPVERS}.tar.gz"
SRCHASH='a8a29d55a718eb90aada643841b3e0715216d27cea2e2df243e184edb780aa9d'
BUILDDIR="$(pwd)/build/tcludp"
OUTDIR="$(pwd)/out"
INSTDIR="$(pwd)/inst"
PATCHDIR="$(pwd)/patches"
export TCLUDPVERS SRC SRCURL BUILDDIR OUTDIR INSTDIR PATCHDIR

# Set configure options for this sub-project
LDFLAGS="${LDFLAGS} ${KC_TCLUDP_LDFLAGS}"
CFLAGS="${CFLAGS} ${KC_TCLUDP_CFLAGS}"
CPPFLAGS="${CPPFLAGS} ${KC_TCLUDP_CPPFLAGS}"
LIBS="${LIBS} ${KC_TCLUDP_LIBS}"
export LDFLAGS CFLAGS CPPFLAGS LIBS

rm -rf 'build' 'out' 'inst'
mkdir 'build' 'out' 'inst' || exit 1

TCL_VERSION="unknown"
if [ -f "${TCLCONFIGDIR}/tclConfig.sh" ]; then
        source "${TCLCONFIGDIR}/tclConfig.sh"
fi
export TCL_VERSION

if [ ! -f "${SRC}" ]; then
	mkdir 'src' >/dev/null 2>/dev/null

	if [ ! -d 'buildsrc' ]; then
		download "${SRCURL}" "${SRC}" "${SRCHASH}" || exit 1
	fi
fi

(
	cd 'build' || exit 1

	if [ ! -d '../buildsrc' ]; then
		gzip -dc "../${SRC}" | tar -xf -
	else    
		cp -rp ../buildsrc/* './'
	fi

	cd "${BUILDDIR}" || exit 1

	# Try to build as a shared object if requested
	if [ "${STATICTCLUDP}" = "0" ]; then
		tryopts="--enable-shared --disable-shared"
	elif [ "${STATICTCLUDP}" = "-1" ]; then
		tryopts="--enable-shared"
	else
		tryopts="--disable-shared"
	fi

	SAVE_CFLAGS="${CFLAGS}"
	for tryopt in $tryopts __fail__; do
		rm -rf "${INSTDIR}"
		mkdir "${INSTDIR}"

		if [ "${tryopt}" = "__fail__" ]; then
			exit 1
		fi

		# Clean up, if needed
		make distclean >/dev/null 2>/dev/null
		if [ "${tryopt}" == "--enable-shared" ]; then
			isshared="1"
		else
			isshared="0"
		fi

		# If build a static TCLUDP for KitDLL, ensure that we use PIC
		# so that it can be linked into the shared object
		if [ "${isshared}" = "0" -a "${KITTARGET}" = "kitdll" ]; then
			CFLAGS="${SAVE_CFLAGS} -fPIC"
		else
			CFLAGS="${SAVE_CFLAGS}"
		fi
		export CFLAGS

		if [ "${isshared}" = '0' ]; then
			sed 's@USE_TCL_STUBS@XXX_TCL_STUBS@g' configure > configure.new
		else
			sed 's@XXX_TCL_STUBS@USE_TCL_STUBS@g' configure > configure.new
		fi
		cat configure.new > configure
		rm -f configure.new

		(
			echo "Running: ./configure $tryopt --prefix=\"${INSTDIR}\" --exec-prefix=\"${INSTDIR}\" --libdir=\"${INSTDIR}/lib\" --with-tcl=\"${TCLCONFIGDIR}\" ac_cv_path_DTPLITE=no ${CONFIGUREEXTRA}"
			./configure $tryopt --prefix="${INSTDIR}" --exec-prefix="${INSTDIR}" --libdir="${INSTDIR}/lib" --with-tcl="${TCLCONFIGDIR}" ac_cv_path_DTPLITE=no ${CONFIGUREEXTRA}

			echo "Running: ${MAKE:-make} tcllibdir=\"${INSTDIR}/lib\""
			${MAKE:-make} tcllibdir="${INSTDIR}/lib" || exit 1

			echo "Running: ${MAKE:-make} tcllibdir=\"${INSTDIR}/lib\" install"
			${MAKE:-make} tcllibdir="${INSTDIR}/lib" install || exit 1
		) || continue

		break
	done

	# Create pkgIndex if needed
	if [ ! -e "${INSTDIR}/lib/udp${TCLUDPVERS}/pkgIndex.tcl" ]; then
		cat << _EOF_ > "${INSTDIR}/lib/udp${TCLUDPVERS}/pkgIndex.tcl"
package ifneeded udp ${TCLUDPVERS} [list load {} udp]
_EOF_
	fi

	# Install files needed by installation
	cp -r "${INSTDIR}/lib" "${OUTDIR}" || exit 1
	find "${OUTDIR}" -name '*.a' -type f | xargs -n 1 rm -f --

	exit 0
) || exit 1

exit 0




|
<

<
<
<
<
<
<
<
<
|
<
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
>
1
2
3

4








5

6
7

















































































































8
9
#! /usr/bin/env bash

# BuildCompatible: KitCreator










version="1.0.11"

url="http://sourceforge.net/projects/tcludp/files/tcludp/${version}/tcludp-${version}.tar.gz"
sha256='a8a29d55a718eb90aada643841b3e0715216d27cea2e2df243e184edb780aa9d'

















































































































configure_extra=(ac_cv_path_DTPLITE=no)
internalpkgname='tcludp'