#!/bin/sh VERSION=0.01 # ---------------------------- # print Usage # ---------------------------- function printUsage() { cat <<EOF Usage: $0 [OPTION]... --cflags compile option --libs,--static-libs link option --libs-depends link option for depend libraries --prefix[=DIR] set prefix (or print prefix) --version print version EOF } # ---------------------------- # option analysis # ---------------------------- PREFIX=. PRINT_VERSION=0 PRINT_CFLAGS=0 PRINT_LIBS=0 PRINT_LIBS_DEPENDS=0 PRINT_PREFIX=0 if test $# -eq 0; then printUsage exit 1 fi while test $# -gt 0; do case "$1" in --version) PRINT_VERSION=1 ;; --cflags) PRINT_CFLAGS=1 ;; --libs) PRINT_LIBS=1 ;; --static-libs) PRINT_LIBS=1 ;; --libs-depends) PRINT_LIBS_DEPENDS=1 ;; --prefix) PRINT_PREFIX=1 ;; --prefix=*) PREFIX=`echo "$1" | LC_ALL="C" sed 's/[-_a-zA-Z0-9]*=//'` ;; *) printUsage exit 1 ;; esac shift done # ---------------------------- # VALUE SETTING # ---------------------------- which cmd > /dev/null if [ $? -eq 0 ]; then # for Windows CFLAGS="-I${PREFIX}/include" LIBS_DEPENDS="-lws2_32" LIBS="-L${PREFIX}/lib -lsc" else # for Linux CFLAGS="-I${PREFIX}/include" LIBS_DEPENDS="-lpthread -ldl" LIBS="-L${PREFIX}/lib -lsc" fi # ---------------------------- # print version # ---------------------------- if [ ${PRINT_VERSION} -eq 1 ]; then echo "${VERSION}" exit 0 fi # ---------------------------- # print cflags # ---------------------------- if [ ${PRINT_CFLAGS} -eq 1 ]; then echo "${CFLAGS}" fi # ---------------------------- # print libs # ---------------------------- if [ ${PRINT_LIBS} -eq 1 ]; then echo "${LIBS}" fi # ---------------------------- # print libs depends # ---------------------------- if [ ${PRINT_LIBS_DEPENDS} -eq 1 ]; then echo "${LIBS_DEPENDS}" fi # ---------------------------- # print prefix # ---------------------------- if [ ${PRINT_PREFIX} -eq 1 ]; then echo "${PREFIX}" fi