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

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

            1  +#! /usr/bin/env bash
            2  +
            3  +targetInstallEnvironment='kitcreator'
            4  +pkgdir="$(pwd)"
            5  +internalpkgname="${pkg}"
            6  +archivedir="${pkgdir}/src"
            7  +buildsrcdir="${pkgdir}/buildsrc"
            8  +installdir="${pkgdir}/inst"
            9  +runtimedir="${pkgdir}/out"
           10  +workdir="${pkgdir}/workdir-$$${RANDOM}${RANDOM}${RANDOM}${RANDOM}.work"
           11  +
           12  +_download="$(which download)"
           13  +
           14  +function clean() {
           15  +	rm -rf "${installdir}" "${runtimedir}"
           16  +}
           17  +
           18  +function distclean() {
           19  +	rm -rf "${archivedir}"
           20  +	rm -rf "${pkgdir}"/workdir-*
           21  +}
           22  +
           23  +function init() {
           24  +	clean || return 1
           25  +
           26  +	TCL_VERSION="unknown"
           27  +	if [ -f "${TCLCONFIGDIR}/tclConfig.sh" ]; then
           28  +		source "${TCLCONFIGDIR}/tclConfig.sh"
           29  +	fi
           30  +	export TCL_VERSION
           31  +}
           32  +
           33  +function predownload() {
           34  +	:
           35  +}
           36  +
           37  +function download() {
           38  +	if [ -d "${buildsrcdir}" ]; then
           39  +		return 0
           40  +	fi
           41  +
           42  +	if [ -n "${url}" ]; then
           43  +		# Determine type of file
           44  +		archivetype="$(echo "${url}" | sed 's@\?.*$@@')"
           45  +		case "${archivetype}" in
           46  +			*.tar.*)
           47  +				archivetype="$(echo "${archivetype}" | sed 's@^.*\.tar\.@tar.@')"
           48  +				;;
           49  +			*)
           50  +				archivetype="$(echo "${archivetype}" | sed 's@^.*\.@@')"
           51  +				;;
           52  +		esac
           53  +
           54  +		pkgarchive="${archivedir}/${pkg}-${version}.${archivetype}"
           55  +		mkdir "${archivedir}" >/dev/null 2>/dev/null
           56  +	fi
           57  +
           58  +	if [ -n "${url}" -a -n "${pkgarchive}" -a ! -e "${pkgarchive}" ]; then
           59  +		"${_download}" "${url}" "${pkgarchive}" "${sha256}" || return 1
           60  +	fi
           61  +
           62  +	return 0
           63  +}
           64  +
           65  +function postdownload() {
           66  +	:
           67  +}
           68  +
           69  +function extract() {
           70  +	if [ -d "${buildsrcdir}" ]; then
           71  +		mkdir "${workdir}" || return 1
           72  +
           73  +		cp -rp "${buildsrcdir}"/* "${workdir}" || return 1
           74  +
           75  +		return 0
           76  +	fi
           77  +
           78  +	if [ -n "${pkgarchive}" ]; then
           79  +		(
           80  +			mkdir "${workdir}" || exit 1
           81  +
           82  +			cd "${workdir}" || exit 1
           83  +
           84  +			case "${pkgarchive}" in
           85  +				*.tar.gz|*.tgz)
           86  +					gzip -dc "${pkgarchive}" | tar -xf - || exit 1
           87  +					;;
           88  +				*.tar.bz2|*.tbz|*.tbz2)
           89  +					bzip2 -dc "${pkgarchive}" | tar -xf - || exit 1
           90  +					;;
           91  +				*.tar.xz|*.txz)
           92  +					xz -dc "${pkgarchive}" | tar -xf - || exit 1
           93  +					;;
           94  +				*.zip)
           95  +					unzip "${pkgarchive}" || exit 1
           96  +					;;
           97  +			esac
           98  +
           99  +			shopt -s dotglob
          100  +			dir="$(echo ./*)"
          101  +			if [ -d "${dir}" ]; then
          102  +				mv "${dir}"/* . || exit 1
          103  +
          104  +				rmdir "${dir}" || exit 1
          105  +			fi
          106  +
          107  +			exit 0
          108  +		) || return 1
          109  +	fi
          110  +
          111  +	return 0
          112  +}
          113  +
          114  +function apply_patches() {
          115  +	:
          116  +}
          117  +
          118  +function preconfigure() {
          119  +	:
          120  +}
          121  +
          122  +function configure() {
          123  +	local tryopts tryopt
          124  +	local staticpkg staticpkgvar
          125  +	local isshared
          126  +	local save_cflags
          127  +	local base_var kc_var
          128  +
          129  +	staticpkgvar="$(echo "STATIC${internalpkgname}" | dd conv=ucase 2>/dev/null)"
          130  +	staticpkg="$(eval "echo \"\$${staticpkgvar}\"")"
          131  +
          132  +	# Set configure options for this sub-project
          133  +	for base_var in LDFLAGS CFLAGS CPPFLAGS LIBS; do
          134  +		kc_var="$(echo "KC_${internalpkgname}_${base_var}" | dd conv=ucase 2>/dev/null)"
          135  +		kc_var_val="$(eval "echo \"\$${kc_var}\"")"
          136  +
          137  +		if [ -n "${kc_var_val}" ]; then
          138  +			eval "${base_var}=\"\$${base_var} \$${kc_var}\"; export ${base_var}"
          139  +		fi
          140  +	done
          141  +
          142  +	# Determine if we should enable shared or not
          143  +	if [ "${staticpkg}" = "0" ]; then
          144  +		tryopts="--enable-shared --disable-shared"
          145  +	elif [ "${staticpkg}" = "-1" ]; then
          146  +		tryopts="--enable-shared"
          147  +	else
          148  +		tryopts="--disable-shared"
          149  +	fi
          150  +
          151  +	save_cflags="${CFLAGS}"
          152  +	for tryopt in $tryopts __fail__; do
          153  +		if [ "${tryopt}" = "__fail__" ]; then
          154  +			return 1
          155  +		fi
          156  +
          157  +		# Clean up, if needed
          158  +		make distclean >/dev/null 2>/dev/null
          159  +		if [ "${tryopt}" == "--enable-shared" ]; then
          160  +			isshared="1"
          161  +		else
          162  +			isshared="0"
          163  +		fi
          164  +
          165  +		# If build a static package for KitDLL, ensure that we use PIC
          166  +		# so that it can be linked into the shared object
          167  +		if [ "${isshared}" = "0" -a "${KITTARGET}" = "kitdll" ]; then
          168  +			CFLAGS="${save_cflags} -fPIC"
          169  +		else
          170  +			CFLAGS="${save_cflags}"
          171  +		fi
          172  +		export CFLAGS
          173  +
          174  +		if [ "${isshared}" = '0' ]; then
          175  +			sed 's@USE_TCL_STUBS@XXX_TCL_STUBS@g' configure > configure.new
          176  +
          177  +			pkg_configure_shared_build='0'
          178  +		else
          179  +			sed 's@XXX_TCL_STUBS@USE_TCL_STUBS@g' configure > configure.new
          180  +
          181  +			pkg_configure_shared_build='1'
          182  +		fi
          183  +
          184  +		cat configure.new > configure
          185  +		rm -f configure.new
          186  +
          187  +		./configure $tryopt --prefix="${installdir}" --exec-prefix="${installdir}" --libdir="${installdir}/lib" --with-tcl="${TCLCONFIGDIR}" "${configure_extra[@]}" ${CONFIGUREEXTRA} && break
          188  +	done
          189  +
          190  +	return 0
          191  +}
          192  +
          193  +function postconfigure() {
          194  +	:
          195  +}
          196  +
          197  +function prebuild() {
          198  +	:
          199  +}
          200  +
          201  +function build() {
          202  +	${MAKE:-make} tcllibdir="${installdir}/lib" "${make_extra[@]}"
          203  +}
          204  +
          205  +function postbuild() {
          206  +	:
          207  +}
          208  +
          209  +function preinstall() {
          210  +	:
          211  +}
          212  +
          213  +function install() {
          214  +	local installpkgdir
          215  +	local pkglibfile
          216  +
          217  +	mkdir -p "${installdir}/lib" || return 1
          218  +	${MAKE:-make} tcllibdir="${installdir}/lib" "${make_extra[@]}" install || return 1
          219  +
          220  +	# Create pkgIndex if needed
          221  +	installpkgdir="$(echo "${installdir}/lib"/*)"
          222  +
          223  +	if [ -d "${installpkgdir}" ]; then
          224  +		if [ ! -e "${installpkgdir}/pkgIndex.tcl" ]; then
          225  +			case "${pkg_configure_shared_build}" in
          226  +				0)
          227  +					cat << _EOF_ > "${installpkgdir}/pkgIndex.tcl"
          228  +package ifneeded ${pkg} ${version} [list load {} ${pkg}]
          229  +_EOF_
          230  +					;;
          231  +				1)
          232  +					pkglibfile="$(find "${installpkgdir}" -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.shlib' | head -n 1 | sed 's@^.*/@@')"
          233  +					cat << _EOF_ > "${installpkgdir}/pkgIndex.tcl"
          234  +package ifneeded ${pkg} ${version} [list load [file join \$dir ${pkglibfile}]]
          235  +_EOF_
          236  +					;;
          237  +			esac
          238  +		fi
          239  +	fi
          240  +}
          241  +
          242  +function postinstall() {
          243  +	:
          244  +}
          245  +
          246  +function createruntime() {
          247  +	local file
          248  +
          249  +	# Install files needed by installation
          250  +	mkdir -p "${runtimedir}" || return 1
          251  +	cp -r "${installdir}/lib" "${runtimedir}" || return 1
          252  +
          253  +	find "${runtimedir}" -name '*.a' -type f | while IFS='' read -r file; do
          254  +		rm -f "${file}"
          255  +	done
          256  +
          257  +	# Ensure that some files were installed
          258  +	if ! find "${runtimedir}" -type f 2>/dev/null | grep '^' >/dev/null; then
          259  +		return 1
          260  +	fi
          261  +
          262  +	return 0
          263  +}
          264  +
          265  +function die() {
          266  +	local msg
          267  +
          268  +	msg="$1"
          269  +
          270  +	echo "$msg" >&2
          271  +
          272  +	exit 1
          273  +}

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

    38     38   
    39     39   # Always rebuild kitsh
    40     40   rm -f "kitsh/.success"
    41     41   for pkg in ${KITCREATOR_ALLPKGS} ${KITCREATOR_PKGS}; do
    42     42   	if [ "${mode}" != "retry" -o ! -f "${pkg}/.success" ]; then
    43     43   		rm -f "${pkg}/build.log" "${pkg}/.success"
    44     44   		rm -rf "${pkg}/out" "${pkg}/inst" "${pkg}/build"
           45  +		rm -rf "${pkg}"/workdir-*
    45     46   
    46     47   		rm -rf "${pkg}/src"/tmp-*
    47     48   	fi
    48     49   
    49     50   	if [ "${mode}" = "distclean" ]; then
    50     51   		rm -rf "${pkg}/src"
    51     52   	fi
................................................................................
   157    158   	if echo 'exit 0' | "${testsh}" >/dev/null 2>/dev/null; then
   158    159   		TCLSH_NATIVE="${testsh}"
   159    160   
   160    161   		break
   161    162   	fi
   162    163   done
   163    164   export TCLSH_NATIVE
          165  +
          166  +# Function to determine what build mode is being used
          167  +function useCommonBuildSystem() {
          168  +	local script
          169  +
          170  +	script="$1"
          171  +
          172  +	if head "${script}" 2>/dev/null | grep -i '^# *BuildCompatible: *KitCreator *$' >/dev/null 2>/dev/null; then
          173  +		return 0
          174  +	fi
          175  +
          176  +	return 1
          177  +}
          178  +
          179  +# Cleanup build logs
          180  +for pkg in tcl tclvfs zlib ${KITCREATOR_PKGS} kitsh; do
          181  +	rm -f "${pkg}/build.log"
          182  +done
   164    183   
   165    184   # Verify that each component is happy with the environment
   166    185   validatefailed="0"
   167    186   for pkg in tcl tclvfs zlib ${KITCREATOR_PKGS} kitsh; do
   168    187   	failed='0'
   169    188   	if [ -f "${pkg}/.success" ]; then
   170    189   		continue
   171    190   	fi
   172    191   
   173    192   	if [ -x "${pkg}/validate.sh" ]; then
   174    193   		(
   175    194   			cd "${pkg}" >/dev/null 2>/dev/null || exit 1
   176    195   
   177         -			./validate.sh 3>&1 4>&2 > build.log 2>&1 || exit 1
          196  +			./validate.sh 3>&1 4>&2 >> build.log 2>&1 || exit 1
   178    197   		) || failed="1"
   179    198   
   180    199   		if [ "${failed}" = '1' ]; then
   181    200   			echo "Failed pre-requisite check for ${pkg}" >&2
   182    201   
   183    202   			validatefailed='1'
   184    203   		fi
................................................................................
   202    221   		(
   203    222   			cd "${pkg}" >/dev/null 2>/dev/null || exit 1
   204    223   
   205    224   			build_script='./build.sh'
   206    225   			if [ -x 'kitcreator-build.sh' ]; then
   207    226   				build_script='./kitcreator-build.sh'
   208    227   			fi
   209         -			"${build_script}" 3>&1 4>&2 > build.log 2>&1 || exit 1
          228  +
          229  +			if useCommonBuildSystem "${build_script}"; then
          230  +				(
          231  +					. ../common/common.sh
          232  +					. "${build_script}"
          233  +
          234  +					set -x
          235  +
          236  +					init || die 'init failed'
          237  +
          238  +					predownload || die 'predownload failed'
          239  +					download || die 'download failed'
          240  +					postdownload || die 'postdownload failed'
          241  +
          242  +					extract || die 'extract failed'
          243  +
          244  +					apply_patches || die 'apply patches failed'
          245  +
          246  +					cd "${workdir}" || exit 1
          247  +
          248  +					preconfigure || die 'preconfigure failed'
          249  +					configure || die 'configure failed'
          250  +					postconfigure || die 'postconfigure failed'
          251  +
          252  +					prebuild || die 'prebuild failed'
          253  +					build || die 'build failed'
          254  +					postbuild || die 'postbuild failed'
          255  +
          256  +					preinstall || die 'preinstall failed'
          257  +					install || die 'install failed'
          258  +					postinstall || die 'postinstall failed'
          259  +
          260  +					createruntime || die 'createruntime failed'
          261  +
          262  +					set +x
          263  +
          264  +					rm -rf "${workdir}"
          265  +				) 3>&1 4>&2 > build.log 2>&1 || exit 1
          266  +			else
          267  +				"${build_script}" 3>&1 4>&2 >> build.log 2>&1 || exit 1
          268  +			fi
   210    269   		) || failed="1"
   211    270   	fi
   212    271   
   213    272   	if [ "${failed}" = "1" ]; then
   214    273   		echo " failed."
   215    274   		failedpkgs="${failedpkgs} ${pkg}"
   216    275   	else

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

     1      1   #! /usr/bin/env bash
     2      2   
     3         -if [ ! -f 'build.sh' ]; then
     4         -	echo 'ERROR: This script must be run from the directory it is in' >&2
            3  +# BuildCompatible: KitCreator
     5      4   
     6         -	exit 1
     7         -fi
     8         -if [ -z "${TCLVERS}" ]; then
     9         -	echo 'ERROR: The TCLVERS environment variable is not set' >&2
    10         -
    11         -	exit 1
    12         -fi
    13         -
    14         -TCLUDPVERS="1.0.11"
    15         -SRC="src/tcludp-${TCLUDPVERS}.tar.gz"
    16         -SRCURL="http://sourceforge.net/projects/tcludp/files/tcludp/${TCLUDPVERS}/tcludp-${TCLUDPVERS}.tar.gz"
    17         -SRCHASH='a8a29d55a718eb90aada643841b3e0715216d27cea2e2df243e184edb780aa9d'
    18         -BUILDDIR="$(pwd)/build/tcludp"
    19         -OUTDIR="$(pwd)/out"
    20         -INSTDIR="$(pwd)/inst"
    21         -PATCHDIR="$(pwd)/patches"
    22         -export TCLUDPVERS SRC SRCURL BUILDDIR OUTDIR INSTDIR PATCHDIR
    23         -
    24         -# Set configure options for this sub-project
    25         -LDFLAGS="${LDFLAGS} ${KC_TCLUDP_LDFLAGS}"
    26         -CFLAGS="${CFLAGS} ${KC_TCLUDP_CFLAGS}"
    27         -CPPFLAGS="${CPPFLAGS} ${KC_TCLUDP_CPPFLAGS}"
    28         -LIBS="${LIBS} ${KC_TCLUDP_LIBS}"
    29         -export LDFLAGS CFLAGS CPPFLAGS LIBS
    30         -
    31         -rm -rf 'build' 'out' 'inst'
    32         -mkdir 'build' 'out' 'inst' || exit 1
    33         -
    34         -TCL_VERSION="unknown"
    35         -if [ -f "${TCLCONFIGDIR}/tclConfig.sh" ]; then
    36         -        source "${TCLCONFIGDIR}/tclConfig.sh"
    37         -fi
    38         -export TCL_VERSION
    39         -
    40         -if [ ! -f "${SRC}" ]; then
    41         -	mkdir 'src' >/dev/null 2>/dev/null
    42         -
    43         -	if [ ! -d 'buildsrc' ]; then
    44         -		download "${SRCURL}" "${SRC}" "${SRCHASH}" || exit 1
    45         -	fi
    46         -fi
    47         -
    48         -(
    49         -	cd 'build' || exit 1
    50         -
    51         -	if [ ! -d '../buildsrc' ]; then
    52         -		gzip -dc "../${SRC}" | tar -xf -
    53         -	else    
    54         -		cp -rp ../buildsrc/* './'
    55         -	fi
    56         -
    57         -	cd "${BUILDDIR}" || exit 1
    58         -
    59         -	# Try to build as a shared object if requested
    60         -	if [ "${STATICTCLUDP}" = "0" ]; then
    61         -		tryopts="--enable-shared --disable-shared"
    62         -	elif [ "${STATICTCLUDP}" = "-1" ]; then
    63         -		tryopts="--enable-shared"
    64         -	else
    65         -		tryopts="--disable-shared"
    66         -	fi
    67         -
    68         -	SAVE_CFLAGS="${CFLAGS}"
    69         -	for tryopt in $tryopts __fail__; do
    70         -		rm -rf "${INSTDIR}"
    71         -		mkdir "${INSTDIR}"
    72         -
    73         -		if [ "${tryopt}" = "__fail__" ]; then
    74         -			exit 1
    75         -		fi
    76         -
    77         -		# Clean up, if needed
    78         -		make distclean >/dev/null 2>/dev/null
    79         -		if [ "${tryopt}" == "--enable-shared" ]; then
    80         -			isshared="1"
    81         -		else
    82         -			isshared="0"
    83         -		fi
    84         -
    85         -		# If build a static TCLUDP for KitDLL, ensure that we use PIC
    86         -		# so that it can be linked into the shared object
    87         -		if [ "${isshared}" = "0" -a "${KITTARGET}" = "kitdll" ]; then
    88         -			CFLAGS="${SAVE_CFLAGS} -fPIC"
    89         -		else
    90         -			CFLAGS="${SAVE_CFLAGS}"
    91         -		fi
    92         -		export CFLAGS
    93         -
    94         -		if [ "${isshared}" = '0' ]; then
    95         -			sed 's@USE_TCL_STUBS@XXX_TCL_STUBS@g' configure > configure.new
    96         -		else
    97         -			sed 's@XXX_TCL_STUBS@USE_TCL_STUBS@g' configure > configure.new
    98         -		fi
    99         -		cat configure.new > configure
   100         -		rm -f configure.new
   101         -
   102         -		(
   103         -			echo "Running: ./configure $tryopt --prefix=\"${INSTDIR}\" --exec-prefix=\"${INSTDIR}\" --libdir=\"${INSTDIR}/lib\" --with-tcl=\"${TCLCONFIGDIR}\" ac_cv_path_DTPLITE=no ${CONFIGUREEXTRA}"
   104         -			./configure $tryopt --prefix="${INSTDIR}" --exec-prefix="${INSTDIR}" --libdir="${INSTDIR}/lib" --with-tcl="${TCLCONFIGDIR}" ac_cv_path_DTPLITE=no ${CONFIGUREEXTRA}
   105         -
   106         -			echo "Running: ${MAKE:-make} tcllibdir=\"${INSTDIR}/lib\""
   107         -			${MAKE:-make} tcllibdir="${INSTDIR}/lib" || exit 1
   108         -
   109         -			echo "Running: ${MAKE:-make} tcllibdir=\"${INSTDIR}/lib\" install"
   110         -			${MAKE:-make} tcllibdir="${INSTDIR}/lib" install || exit 1
   111         -		) || continue
   112         -
   113         -		break
   114         -	done
   115         -
   116         -	# Create pkgIndex if needed
   117         -	if [ ! -e "${INSTDIR}/lib/udp${TCLUDPVERS}/pkgIndex.tcl" ]; then
   118         -		cat << _EOF_ > "${INSTDIR}/lib/udp${TCLUDPVERS}/pkgIndex.tcl"
   119         -package ifneeded udp ${TCLUDPVERS} [list load {} udp]
   120         -_EOF_
   121         -	fi
   122         -
   123         -	# Install files needed by installation
   124         -	cp -r "${INSTDIR}/lib" "${OUTDIR}" || exit 1
   125         -	find "${OUTDIR}" -name '*.a' -type f | xargs -n 1 rm -f --
   126         -
   127         -	exit 0
   128         -) || exit 1
   129         -
   130         -exit 0
            5  +version="1.0.11"
            6  +url="http://sourceforge.net/projects/tcludp/files/tcludp/${version}/tcludp-${version}.tar.gz"
            7  +sha256='a8a29d55a718eb90aada643841b3e0715216d27cea2e2df243e184edb780aa9d'
            8  +configure_extra=(ac_cv_path_DTPLITE=no)
            9  +internalpkgname='tcludp'