Files
harbour-core/harbour/bin/hb-mkslib.sh
Przemyslaw Czerpak 503c1ddf13 2007-09-02 17:27 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/hbgtmk.sh
  * harbour/tests/codebl.prg
  * harbour/tests/testprof.prg
  * harbour/tests/keywords.prg
  * harbour/tests/testpp.prg
  * harbour/make_rpm.sh
  * harbour/makefile.gc
  * harbour/bin/hb-mkslib.sh
  * harbour/include/hbexpra.c
  * harbour/include/hbmath.ch
  * harbour/include/hbrddntx.h
  * harbour/include/hbexprb.c
  * harbour/harbour.spec
  * harbour/contrib/dot/pp.prg
  * harbour/contrib/libct/ctwin.c
  * harbour/contrib/ole2/w32ole.c
  * harbour/contrib/hgf/win32/win32.c
  * harbour/contrib/mysql/mysql.ch
  * harbour/contrib/odbc/todbc.prg
  * harbour/contrib/odbc/sql.ch
  * harbour/contrib/hb_struc/hbstruc.ch
  * harbour/contrib/bmdbfcdx/bmdbfcdx1.c
  * harbour/contrib/msql/msql.ch
  * harbour/contrib/msql/readme.txt
  * harbour/source/pp/ppcore.c
  * harbour/source/rtl/gtdos/gtdos.c
  * harbour/source/rtl/gtxwc/gtxwc.h
  * harbour/source/rtl/hbgtcore.c
  * harbour/source/rtl/gtcrs/gtcrs.h
  * harbour/source/rtl/gtalleg/gtalleg.c
  * harbour/source/rtl/gtalleg/ssf.h
  * harbour/source/rtl/gtalleg/fixedth.sfc
  * harbour/source/rtl/gtchrmap.c
  * harbour/source/rtl/itemseri.c
  * harbour/source/rtl/gtstd/gtstd.c
  * harbour/source/rtl/gtsln/gtsln.h
  * harbour/source/rtl/gttrm/gttrm.c
  * harbour/source/rtl/gtpca/gtpca.c
  * harbour/source/rtl/hbhex.c
  * harbour/source/rtl/tget.prg
  * harbour/source/rtl/gtcgi/gtcgi.c
  * harbour/source/rtl/hbinet.c
  * harbour/source/vm/hvm.c
  * harbour/source/debug/dbgtobj.prg
  * harbour/source/debug/dbgwa.prg
  * harbour/source/common/expropt2.c
  * harbour/source/rdd/dbfcdx/dbfcdx1.c
  * harbour/source/rdd/dbffpt/dbffpt1.c
  * harbour/utils/hbpp/hbppcore.c
  * harbour/utils/hbpptest/pp_test.prg
  * harbour/utils/hbpptest/pretest.prg
  * harbour/make_tgz.sh
    * converted TABs to SPACEs
2007-09-02 15:28:05 +00:00

141 lines
3.8 KiB
Bash
Executable File

#!/bin/sh
[ "$BASH" ] || exec bash `which $0` ${1+"$@"}
#
# $Id$
#
# ---------------------------------------------------------------
# Copyright 2003 Przemyslaw Czerpak <druzus@polbox.com>
# simple script to build shared libraries from static ones and
# object files
#
# See doc/license.txt for licensing terms.
# ---------------------------------------------------------------
if [ -n "${HB_ARCHITECTURE}" ]
then
hb_arch="${HB_ARCHITECTURE}"
else
hb_arch=`uname -s | tr -d "[-]" | tr '[A-Z]' '[a-z]' 2>/dev/null`
fi
case "$hb_arch" in
*windows*|*mingw32*) hb_arch="w32" ;;
*dos) hb_arch="dos" ;;
*bsd) hb_arch="bsd" ;;
esac
case "$hb_arch" in
darwin) SLIB_EXT=".dylib" ;;
w32) SLIB_EXT=".dll" ;;
*) SLIB_EXT=".so" ;;
esac
NAME="${1%${SLIB_EXT}}"
LIB_NAME="${NAME##*/}"
DSTDIR="${NAME%${LIB_NAME}}"
[ -n "${DSTDIR}" ] || DSTDIR="./"
if [ $# -lt 2 ] || [ -z "${LIB_NAME}" ]
then
echo "usage: `basename $0` <target[${SLIB_EXT}]> [link options] src1.a .. srcN.a [obj1.o .. objN.o]"
exit 1
fi
shift
BASE=`echo ${LIB_NAME} | sed "s/\([^.-]*\)[.-][0-9.]*/\1/g"`
VERSION="${LIB_NAME#${BASE}}"
VERSION="${VERSION#[.-]}"
REVIS="${VERSION}"
MAJOR="${REVIS%%.*}"
REVIS="${REVIS#${MAJOR}}"
REVIS="${REVIS#.}"
MINOR="${REVIS%%.*}"
REVIS="${REVIS#${MINOR}}"
REVIS="${REVIS#.}"
REVIS="${REVIS%%.*}"
[ -n "${MAJOR}" ] || MAJOR=0
[ -n "${MINOR}" ] || MINOR=1
[ -n "${REVIS}" ] || REVIS=0
VERSION="${MAJOR}.${MINOR}.${REVIS}"
OTMPDIR="/tmp/hb-mkslib-$$"
dir=`pwd`
cleanup()
{
rm -fR "${OTMPDIR}"
}
trap cleanup EXIT &>/dev/null
rm -fR "${OTMPDIR}"
mkdir -p "${OTMPDIR}"
cd "${OTMPDIR}"
for f in $*
do
case "${f}" in
*.o)
if [ ! -r "${dir}/${f}" ]
then
echo "cannot read file: ${f}"
exit 1
fi
cp "${dir}/${f}" "${OTMPDIR}" || exit 1
;;
*.a)
if [ ! -r "${dir}/${f}" ]
then
echo "cannot read file: ${f}"
exit 1
fi
d="${f%.a}"
d="${f##*/}"
mkdir $d
cd $d
${CCPREFIX}ar -x "${dir}/${f}" || exit 1
cd ..
;;
*)
linker_options="${linker_options} ${f}"
;;
esac
done
OBJLST=`find . -name \*.o`
cd "${OTMPDIR}"
if [ "${SLIB_EXT}" = ".dylib" ]; then
FULLNAME="${BASE}.${VERSION}${SLIB_EXT}"
ld -r -o "${FULLNAME}.o" $OBJLST && \
${CCPREFIX}gcc -dynamiclib -install_name "${BASE}.${MAJOR}${SLIB_EXT}" \
-compatibility_version ${MAJOR}.${MINOR} -current_version ${VERSION} \
-flat_namespace -undefined warning -multiply_defined suppress -single_module \
-o "${FULLNAME}" "${FULLNAME}.o" ${linker_options} && \
cd "${dir}" && \
mv -f "${OTMPDIR}/${FULLNAME}" "${DSTDIR}${FULLNAME}" && \
ln -sf "${FULLNAME}" "${DSTDIR}${BASE}.${MAJOR}${SLIB_EXT}" && \
ln -sf "${FULLNAME}" "${DSTDIR}${BASE}${SLIB_EXT}"
elif [ "${SLIB_EXT}" = ".dll" ]; then
FULLNAME="${LIB_NAME}${SLIB_EXT}"
SYSLIBS="-luser32 -lwinspool -lgdi32 -lcomctl32 -lcomdlg32 -lole32"
SYSLIBS="${SYSLIBS} -loleaut32 -luuid -lmpr -lwsock32 -lws2_32 -lmapi32"
${CCPREFIX}gcc -shared -o "${FULLNAME}" $OBJLST ${linker_options} ${SYSLIBS} ${HB_DLLIBS} && \
cd "${dir}" && \
rm -f "${DSTDIR}${FULLNAME}" && \
mv -f "${OTMPDIR}/${FULLNAME}" "${DSTDIR}${FULLNAME}"
else
#FULLNAME="${BASE}-${VERSION}${SLIB_EXT}"
#FULLNAME="${BASE}{SLIB_EXT}.${VERSION}"
FULLNAME="${LIB_NAME}${SLIB_EXT}"
${CCPREFIX}gcc -shared -o "${FULLNAME}" $OBJLST ${linker_options} ${L_USR} && \
cd "${dir}" && \
mv -f "${OTMPDIR}/${FULLNAME}" "${DSTDIR}${FULLNAME}"
fi
stat="$?"
[ $stat != 0 ] && cd "${dir}" && rm -f "${DSTDIR}${FULLNAME}"
cleanup
exit "${stat}"