Rev 227 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/sh# -*- mode: sh; tabs: 8; show-tabs: yes; hard-tabs: yes; -*-################################################################################# Module name : Build system# Module type : makefile util# Environment(s): WIN32, Unix(Solaris/Linux)## Merge multiple archives## Version Who Date Description# 1.0 APY 09/06/99 Created# 2.0 APY 31/07/01 WIN32 support# 3.0 DDP 04/02/04 Microtec support# Added a "-m libraian_path" switch to interwork# with the MRI68K and MRICF toolsets# Use -m \$(mri_librarian) to access the librarian# to be used.# APY 20/05/04 -t and -a options# 1.2.0# DDP 23-Nov-04 1.3.0:# Remove use of basename.# Under Win32 $0 contains \\ and basename# does not work.# Added -n switch# Prevent redirection to /dev/null for systems# in which this doesn't work.# DDP 10-Jan-05 There is no windows/solaris way to determine the# srcipt name - just name it.### $Source: /cvsroot/etm/devl/TOOLS/armerge,v $# $Revision: 1.3 $ $Date: 2004/05/25 10:49:32 $ $State: Exp $# $Author: adamy $ $Locker: $##################################################################################SCRIPT=armergeVERSION="1.3.0"#.. Parse command line#FLAG_MACHTYPE=""FLAG_DIR=""FLAG_LIB=""FLAG_AR=""FLAG_V=0FLAG_MICROTEC=""FLAG_NULL="/dev/null"while [ "$#" -gt "0" -a "${FLAG_LIB}" = "" ]; docase $1 in-h | -\? )cat << EOFArchive Merge Utility (${VERSION})Copyright (c) VIX TECHNOLOGY (AUST) LTDusage:${SCRIPT} [-?h] [-d tmpdir] [-v] [-t machtype] [-a librarian][-m librarian] {dest-library} source [source ...]Where:-h, -? Help-v Verbose-d <dir> Destination directory-t Override GBE_MACHTYPE host selection.-a Alternative librarian.-m Microtec (exclusive to -t and -a)-n file Replace null deviceEOFexit 0;;-v) FLAG_V=1;;-d) if [ "${FLAG_DIR}" != "" ]; thenecho ${SCRIPT} "You must specify only one -d. Aborting."exit 1fiif [ "$2" = "" ]; thenecho "${SCRIPT}: The $1 switch requires a command to be executed. Aborting."exit 1fiFLAG_DIR=$2shift;;-m) if [ "$2" = "" ]; thenecho "${SCRIPT}: The $1 switch requires a command to be executed. Aborting."exit 1fiFLAG_MICROTEC=$2shift;;-t) if [ "$2" = "" ]; thenecho "${SCRIPT}: The $1 switch requires a command to be executed. Aborting."exit 1fiFLAG_MACHTYPE=$2shift;;-a) if [ "$2" = "" ]; thenecho "${SCRIPT}: The $1 switch requires a command to be executed. Aborting."exit 1fiFLAG_AR=$2shift;;-n) if [ "$2" = "" ]; thenecho "${SCRIPT}: The $1 switch requires a command to be executed. Aborting."exit 1fiFLAG_NULL=$2shift;;* ) FLAG_LIB=$1;;esacshiftdoneif [ "${FLAG_MACHTYPE}" = "" ]; thenif [ "${GBE_MACHTYPE}" = "" ]; thenecho ${SCRIPT} "GBE_MACHTYPE unknown. Aborting."exit 1fiFLAG_MACHTYPE=${GBE_MACHTYPE}fiif [ "${FLAG_LIB}" = "" ]; thenecho ${SCRIPT} "You must specify a destination library. Aborting."exit 1fiif [ $# -eq 0 ]; thenecho ${SCRIPT} "You must specify one or source libraries. Aborting."exit 1fiSOURCE_LIBS=""while [ "$1" != "" ]; doSOURCE_LIBS="${SOURCE_LIBS} ${1}"shiftdone[ ${FLAG_V} -ne 0 ] && echo "${SCRIPT}: MACHTYPE = ${FLAG_MACHTYPE}"## Mictotec linker#..if [ $FLAG_MICROTEC ] ; then#.. Merge Libraries#if [ -f ${FLAG_LIB} ]; thenrm ${FLAG_LIB}fi#.. Check/create work directory#if [ "${FLAG_DIR}" = "" ]; thenFLAG_DIR="."elif [ ! -d ${FLAG_DIR} ]; thenmkdir -p ${FLAG_DIR}if [ ! -d ${FLAG_DIR} ]; thenecho ${SCRIPT} "Unable to create target directory. Aborting."exit 1fifi#.. Create a command file#CMDFILE="${FLAG_DIR}/armerge.cmd"rm -f $CMDFILEecho >>$CMDFILE "create ${FLAG_LIB}"for LIB in ${SOURCE_LIBS}; doecho >>$CMDFILE "ADDL ${LIB}"doneecho >>$CMDFILE "save"echo >>$CMDFILE "exit"$FLAG_MICROTEC < $CMDFILEif [ $? -ne 0 ]; thenexit 1firm -f $CMDFILE## WIN32#...elif [ "${FLAG_MACHTYPE}" = "win32" -o "${FLAG_MACHTYPE}" = "MSVC" ]; then#.. Merge Libraries#if [ "${FLAG_AR}" = "" ]; then # default librarianFLAG_AR=libfi;if [ -f ${FLAG_LIB} ]; thenrm ${FLAG_LIB}fi[ ${FLAG_V} -ne 0 ] && echo "${SCRIPT}: ${FLAG_AR} -nologo -out:${FLAG_LIB} ${SOURCE_LIBS}"${FLAG_AR} -nologo -out:${FLAG_LIB} ${SOURCE_LIBS}if [ $? -ne 0 ]; thenexit 1fi## UNIX (default)#...else[ ${FLAG_V} -ne 0 ] && echo "${SCRIPT}: .. Unix AR Merge"#.. Check/create work directory#if [ "${FLAG_DIR}" = "" ]; thenFLAG_DIR="."elif [ ! -d ${FLAG_DIR} ]; thenmkdir -p ${FLAG_DIR}if [ ! -d ${FLAG_DIR} ]; thenecho ${SCRIPT} "Unable to create target directory. Aborting."exit 1fifi#.. Extract objects#if [ "${FLAG_AR}" = "" ]; then # default librarianFLAG_AR=arfi;SOURCE_OBJS=""for LIB in ${SOURCE_LIBS}; doecho "${SCRIPT}: scanning ${LIB}"OBJS=`${FLAG_AR} -t ${LIB}`for OBJ in ${OBJS}; doif [ ${FLAG_V} -ne 0 ]; thenecho "${SCRIPT}: .. extracting ${OBJ}"fi`${FLAG_AR} -p ${LIB} ${OBJ} > ${FLAG_DIR}/${OBJ}`doneSOURCE_OBJS="${SOURCE_OBJS} ${OBJS}"done#.. Merge#if [ -f ${FLAG_LIB} ]; thenrm ${FLAG_LIB}fifor OBJ in ${SOURCE_OBJS}; do${FLAG_AR} -q ${FLAG_LIB} ${FLAG_DIR}/${OBJ}if [ $? -ne 0 ]; thenexit 1fidone${FLAG_AR} -ts ${FLAG_LIB} > ${FLAG_NULL}if [ $? -ne 0 ]; thenexit 1fifor OBJ in ${SOURCE_OBJS}; dorm ${FLAG_DIR}/${OBJ}donefiexit 0