Check-in [2ae580efcd]
Overview
Comment:Added NSF build script
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2ae580efcd7d99ff7427235e9f5b8869cbca859b
User & Date: rkeene on 2015-10-15 14:21:18
Other Links: manifest | tags
Context
2015-10-23
20:09
Use TCLSH_NATIVE only when cross-compiling (as indicated by KC_CROSSCOMPILE) check-in: 40706ce9b4 user: ssoberni tags: trunk
2015-10-15
14:21
Added NSF build script check-in: 2ae580efcd user: rkeene tags: trunk
2015-10-08
18:32
Simplify change in the previous check-in. check-in: 78bb12c14d user: mistachkin tags: trunk
Changes

Added nsf/build.sh version [15ddc9112c].

            1  +#! /usr/bin/env bash
            2  +
            3  +if [ ! -f 'build.sh' ]; then
            4  +    echo 'ERROR: This script must be run from the directory it is in' >&2
            5  +    
            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  +NSFVERS="2.0.0"
           15  +NSFVERSEXTRA=""
           16  +SRC="src/nsf${NSFVERS}.tar.gz"
           17  +SRCURL="http://sourceforge.net/projects/next-scripting/files/${NSFVERS}/nsf${NSFVERS}.tar.gz/download"
           18  +BUILDDIR="$(pwd)/build/nsf${NSFVERS}"
           19  +OUTDIR="$(pwd)/out"
           20  +INSTDIR="$(pwd)/inst"
           21  +export NSFVERS SRC SRCURL BUILDDIR OUTDIR INSTDIR
           22  +
           23  +# Set configure options for this sub-project
           24  +LDFLAGS="${LDFLAGS} ${KC_NSF_LDFLAGS}"
           25  +CFLAGS="${CFLAGS} ${KC_NSF_CFLAGS}"
           26  +CPPFLAGS="${CPPFLAGS} ${KC_NSF_CPPFLAGS}"
           27  +LIBS="${LIBS} ${KC_NSF_LIBS}"
           28  +export LDFLAGS CFLAGS CPPFLAGS LIBS
           29  +
           30  +rm -rf 'build' 'out' 'inst'
           31  +mkdir 'build' 'out' 'inst' || exit 1
           32  +
           33  +if [ ! -f "${SRC}" ]; then
           34  +    mkdir 'src' >/dev/null 2>/dev/null
           35  +    
           36  +    if [ ! -d 'buildsrc' ]; then
           37  +	rm -f "${SRC}.tmp"
           38  +	wget -O "${SRC}.tmp" "${SRCURL}" || exit 1
           39  +	mv "${SRC}.tmp" "${SRC}"
           40  +    fi
           41  +fi
           42  +
           43  +(
           44  +    cd 'build' || exit 1
           45  +    
           46  +    if [ ! -d '../buildsrc' ]; then
           47  +	gzip -dc "../${SRC}" | tar -xf -
           48  +    else    
           49  +	cp -rp ../buildsrc/* './'
           50  +    fi
           51  +    
           52  +    cd "${BUILDDIR}" || exit 1
           53  +
           54  +    # There's a STATIC<packageInAllUpperCase>=-1,0,1
           55  +    # ... where -1 means no (i.e., shared),
           56  +    # ... 0 means try not to (try shared first, if that
           57  +    # 	  doesn't work do static),
           58  +    # ... and 1 means try to (try only static)
           59  +    
           60  +    if [ "${STATICNSF}" = "0" ]; then
           61  +	tryopts="--enable-shared --disable-shared"
           62  +    elif [ "${STATICNSF}" = "1" ]; then
           63  +	tryopts="--disable-shared"
           64  +    else
           65  +	# -1
           66  +	tryopts="--enable-shared"
           67  +    fi
           68  +    
           69  +    SAVE_CFLAGS="${CFLAGS}"
           70  +    for tryopt in $tryopts __fail__; do
           71  +	# Clean up, if needed
           72  +	make distclean >/dev/null 2>/dev/null
           73  +	rm -rf "${INSTDIR}"
           74  +	mkdir "${INSTDIR}"
           75  +	
           76  +	if [ "${tryopt}" = "__fail__" ]; then
           77  +	    exit 1
           78  +	fi
           79  +	
           80  +	if [ "${tryopt}" == "--enable-shared" ]; then
           81  +	    isshared="1"
           82  +	else
           83  +	    isshared="0"
           84  +	fi
           85  +	
           86  +	# If build a static NSF for KitDLL, ensure that we use PIC
           87  +	# so that it can be linked into the shared object
           88  +	if [ "${isshared}" = "0" -a "${KITTARGET}" = "kitdll" ]; then
           89  +	    CFLAGS="${SAVE_CFLAGS} -fPIC"
           90  +	else
           91  +	    CFLAGS="${SAVE_CFLAGS}"
           92  +	fi
           93  +	export CFLAGS
           94  +	
           95  +	if [ "${isshared}" = '0' ]; then
           96  +	    sed 's@USE_TCL_STUBS@XXX_TCL_STUBS@g' configure > configure.new
           97  +	else
           98  +	    sed 's@XXX_TCL_STUBS@USE_TCL_STUBS@g' configure > configure.new
           99  +	fi
          100  +	cat configure.new > configure
          101  +	rm -f configure.new
          102  +	
          103  +	(
          104  +	    # Build
          105  +	    echo "Running: ./configure $tryopt --disable-symbols --prefix=\"${INSTDIR}\" --exec-prefix=\"${INSTDIR}\" --libdir=\"${INSTDIR}/lib\" --with-tcl=\"${TCLCONFIGDIR}\" ${CONFIGUREEXTRA}"
          106  +	    ./configure $tryopt --disable-symbols --prefix="${INSTDIR}" --exec-prefix="${INSTDIR}" --libdir="${INSTDIR}/lib" --with-tcl="${TCLCONFIGDIR}" ${CONFIGUREEXTRA}
          107  +	    
          108  +	    echo "Running: ${MAKE:-make} TCLSH=${TCLSH_NATIVE}"
          109  +	    ${MAKE:-make} TCLSH=${TCLSH_NATIVE} || exit 1
          110  +	    
          111  +	    echo "Running: ${MAKE:-make} install TCLSH=${TCLSH_NATIVE}"
          112  +	    ${MAKE:-make} install TCLSH=${TCLSH_NATIVE}
          113  +	    
          114  +	) || continue
          115  +	
          116  +	break
          117  +    done
          118  +    
          119  +    mkdir "${OUTDIR}/lib" || exit 1
          120  +    cp -r "${INSTDIR}/lib"/nsf*/serialize "${OUTDIR}/lib/nsf${NSFVERS}-serialize"
          121  +    cp -r "${INSTDIR}/lib"/nsf*/lib "${OUTDIR}/lib/nsf${NSFVERS}-lib"
          122  +    cp -r "${INSTDIR}/lib"/nsf*/nx "${OUTDIR}/lib/nsf${NSFVERS}-nx"
          123  +    cp -r "${INSTDIR}/lib"/nsf*/xotcl "${OUTDIR}/lib/nsf${NSFVERS}-xotcl"
          124  +    
          125  +    mkdir "${OUTDIR}/lib/nsf${NSFVERS}" || exit 1
          126  +    
          127  +    if [ "${isshared}" = '0' ]; then
          128  +	cat << _EOF_ > "${OUTDIR}/lib/nsf${NSFVERS}/pkgIndex.tcl"
          129  +package ifneeded nsf ${NSFVERS} "[list load "" nsf]; package provide nsf ${NSFVERS}"
          130  +_EOF_
          131  +    else
          132  +	cp -r "${INSTDIR}/lib"/nsf*/*nsf*.* "${OUTDIR}/lib/nsf${NSFVERS}/"
          133  +	cp -r "${INSTDIR}/lib"/nsf*/pkgIndex.tcl "${OUTDIR}/lib/nsf${NSFVERS}/"
          134  +    fi
          135  +    
          136  +    rm -f "${OUTDIR}"/lib/nsf*/*.a
          137  +    
          138  +    "${STRIP:-strip}" -g "${OUTDIR}"/lib/nsf*/*.so >/dev/null 2>/dev/null
          139  +    
          140  +    exit 0
          141  +) || exit 1
          142  +exit 0