1#!/bin/sh 2 3CC=gcc 4CXX=g++ 5CFLAGS="-O3" 6CXXFLAGS="-O3" 7BUILTOBJS="" 8LIBCFILES="adler32.c compress.c crc32.c deflate.c infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c trees.c uncompr.c zutil.c" 9LIBCPPFILES="bstring.cpp cfcreate.cpp cfdblock.cpp cffdrmgr.cpp cffile.cpp cffolder.cpp cfheader.cpp cfreader.cpp cftypes.cpp object.cpp" 10CPPPROGRAMFILES="listcab.cpp" 11LIBINSTALLDIR=/usr/local/lib 12VERSION=0.30.0 13LIBRARY_NAME=cabinet 14PROGRAM_NAME=listcab 15 16# Compile C files 17 18for file in ${LIBCFILES} 19do 20 echo "${file}..." 21 libtool --mode=compile ${CC} ${CFLAGS} -c ${file} 22 23 if [ $? = 0 ]; then 24 echo "compiled" 25 BUILTOBJS="${BUILTOBJS} "`echo -n "${file}" | sed 's/.c$/.lo/'` 26 else 27 exit 1 28 fi 29done 30 31# Compile C++ files 32 33for file in ${LIBCPPFILES} 34do 35 echo "${file}..." 36 libtool --mode=compile ${CXX} ${CXXFLAGS} -c ${file} 37 38 if [ $? = 0 ]; then 39 echo "compiled" 40 BUILTOBJS="${BUILTOBJS} "`echo -n "${file}" | sed 's/.cpp$/.lo/'` 41 else 42 exit 1 43 fi 44done 45 46libtool --mode=link ${CXX} ${CXXFLAGS} -o lib${LIBRARY_NAME}.la ${BUILTOBJS} -rpath ${LIBINSTALLDIR} -release ${VERSION} 47libtool --mode=link ${CXX} ${CXXFLAGS} -o ${PROGRAM_NAME} ${CPPPROGRAMFILES} lib${LIBRARY_NAME}.la 48 49if [ "$?" != "0" ]; then 50 exit 1 51fi 52 53echo "done" 54echo "To test library please run ./testlib" 55 56exit 0 57