⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c

📁 短小精悍的C语言标准函数库。提供450个以上的可移植的算法和工具代码。
💻
📖 第 1 页 / 共 2 页
字号:
fi

# Set compiler to default (cc) if not set already
# And patch together the CC options and defines into one variable
#
CCNAME="${CCNAME:-cc}"
CCOPTS="$CCOPTS $CCDEFINES"

#   Parse command line arguments, figure out what we are doing
#   (Parsing is currently fairly simplistic, and depends on ordering
#   of flags.  Could be improved later if required.)
#
#   Set default values for compile & link options
LINKUP=no
COMPILE=yes
VERBOSE=no                        
QUIET=no                            #   Default is non-verbose messages 

#   -v means verbose reports
if [ /$1/ = /-v/ ]; then
    VERBOSE=yes
    shift
fi

#   -q means quiet
if [ /$1/ = /-q/ ]; then
    QUIET=yes
    shift
fi

#   -S means report detected system type
if [ /$1/ = /-S/ ]; then
    echo "$UTYPE"
    exit
fi

#   -C means report compiler syntax type
if [ /$1/ = /-C/ ]; then
    echo "$CCNAME -c $CCOPTS"
    exit
fi

#   -c means compile the object -- we were going to do that anyway,
#   but this ensures backwards compatibility
#
if  [ /$1/ = /-c/ ]; then
    shift
fi

#   -r means replace object file into library
#   The RANLIB symbol should be set to 1 if 'ar rs' does not work.
#   If the library is specified as 'any', uses value of CCLIBNAME, or
#   first lib*.a file in directory.  Creates library if necessary.
#   If 'any' library is specified but no library exists and CCLIBNAME
#   is not defined, uses libany.a.
#
if [ /$1/ = /-r/ ]; then
    if [ /$2/ = /any/ ]; then
        if [ -n "$CCLIBNAME" ]; then
            LIBRARY=$CCLIBNAME
        else
            LIBRARY=libany.a
            for LIBFILE in lib*.a; do
                if [ -f $LIBFILE ]; then
                    LIBRARY=$LIBFILE
                    break
                fi
            done
        fi
    else
        LIBRARY=$2
    fi
    LIBNAME=`echo $LIBRARY | cut -d"." -f1`
    shift; shift
    
    for i in $*; do
        shift
        OBJECT=`echo $i | cut -d"." -f1`.o

        TRACE="Replacing object $OBJECT in library $LIBRARY"
        if [ "$RANLIB" = "1" ]; then
            COMMAND="ar r $LIBNAME.a $OBJECT; ranlib $LIBNAME.a"
        else
            COMMAND="ar rs $LIBNAME.a $OBJECT"
        fi
        if [ "$QUIET" = "no" ]; then
            if [ "$VERBOSE" = "no" ]; then
                echo "$TRACE..."
            else
                echo "$TRACE ($COMMAND)..."
            fi
        fi
        if [ ! -z "$CCTRACE" ]; then
            echo "$TRACE (COMMAND)">>$CCTRACE
        fi

        $COMMAND
    done
    exit 
fi

#   Compile/link main if -l is first argument
if [ /$1/ = /-l/ ]; then
    LINKUP=yes
    shift
fi

#   Link main if -L is first argument (assumed to already be compiled)
if [ /$1/ = /-L/ ]; then
    LINKUP=yes
    COMPILE=no
    shift
fi

#   If we will be linking, and don't already have a list of libraries to
#   link against, then build list of libraries to link with.
#
#   Modified for OS/2, EDM, 96/12/30 (OS/2 uses name.a, rather than libname.a)

if [ "$LINKUP" = "yes" -o /$1/ = // ]; then
    LIBSFL=0
    LIBLIST=""
    for LIBRARY in lib*.a; do
        if [ "$LIBRARY" = "lib*.a" ]; then
            break
        fi
        #   Pull out the xxx from libxxx.a (or similiar)
        LIBNAME=`echo $LIBRARY | sed -e 's/^...\([^\.]*\)\..*$/\1/'`

        #  libsfl.a must come last, so we will just flag it
        if [ "$LIBNAME" = "sfl" ]; then
            LIBSFL=1
        else
            #  In OS/2 we must link with the whole name, including 
            #  lib prefix, if any
            if [ "$UTYPE" = "OS/2" ]; then
                 LIBNAME=`echo $LIBRARY | cut -d"." -f1`
            fi
            LIBLIST="$LIBLIST -l$LIBNAME"
        fi
    done

    #   XXX -- Possible we should put this list in both orders, ie
    #   forward and backwards?  (sort; sort -r)

    #   Build list of libraries to include in the link command, including 
    #   those referred to by libsfl.a:
    #
    #      - /usr/lib/libsfl.a, if not found locally
    #      - /emx/lib/libsfl.a, or /local/emx/lib/libsfl.a, under OS/2, 
    #        (if present)
    #
    #   Modified for OS/2, by EDM, 96/12/30 (searching for libsfl.a)

    if [ -n "$CCLIBS" ]; then
        LIBLIST="$LIBLIST $CCLIBS"
    elif [ "$UTYPE" = "OS/2" ]; then
        if [ $LIBSFL -eq 1 \
        -o -f /usr/lib/libsfl.a \
        -o -f /emx/lib/libsfl.a \
        -o -f /local/emx/lib/libsfl.a ]; then
            LIBLIST="$LIBLIST -llibsfl"
        fi
    else
        if [ $LIBSFL -eq 1 \
        -o -f /usr/lib/libsfl.a ]; then
            LIBLIST="$LIBLIST -lsfl"
        fi
    fi
fi

#   Show help if no arguments
if [ /$1/ = // ]; then
    echo "Detected system=$UTYPE, compiles with:"
    echo "     $CCNAME -c $CCOPTS"
    echo "Syntax: c filename...    Compile ANSI C program(s)"
    echo "        c -c filename... Compile ANSI C programs(s)"
    echo "        c -l main...     Compile and link main program(s)"
    echo "        c -L main...     Link main(s) with" ${LIBLIST-"no libraries"}
    echo "        c -S             Report detected system name"
    echo "        c -C             Report C compiler command syntax"
    echo "        c -r lib file    Replace file into specified library"
    echo "          -v             (First arg prefix to above): be verbose"
    echo "          -q             (First arg prefix to above): be quiet"
    exit
fi

#   Compile and maybe link each filename on the command line
for i in $*; do
    shift
    FILENAME=`echo $i | cut -d"." -f1`

    #   Precompilation is required if program contains 'EXEC SQL'
    egrep -- "EXEC SQL" $FILENAME.c >/dev/null
    if [ $? -eq 0 ]; then
        PRECOMPILE=yes
    else
        PRECOMPILE=no
    fi

    #   Compile, if required
    PRECOMPILED=0
    if [ "$COMPILE" = "yes" -o ! -f $FILENAME.o ]; then
        if [ "$PRECOMPILE" = "yes" ]; then
            #   Precompile using Oracle SQL pre-compiler
            if [ "$ORACLE_HOME" != "" ]; then
                mv $FILENAME.c $FILENAME.pc
                $NICE proc16 $PCCFLAGS code=ansi_c ireclen=255 \
                            iname=$FILENAME.pc oname=$FILENAME.c
                $PRECOMPILED=1
            fi
        fi
        if [ -f $FILENAME.o ]; then
            rm $FILENAME.o
        fi

        TRACE="Compiling $FILENAME"
        COMMAND="$CCNAME -c $CCOPTS $FILENAME.c"
        if [ "$QUIET" = "no" ]; then
            if [ "$VERBOSE" = "no" ]; then
                echo "$TRACE..."
            else
                echo "$TRACE ($COMMAND)..."
            fi
        fi
        if [ ! -z "$CCTRACE" ]; then
            echo "$TRACE (COMMAND)">>$CCTRACE
        fi
       
        $NICE $COMMAND 2> $FILENAME.lst

        #   Show listing and abort if there was a compile error
        if [ $? -eq 0 ]; then
            cat $FILENAME.lst
            rm  $FILENAME.lst
        else
            cat $FILENAME.lst
            if [ ! -z "$CCTRACE" ]; then
                cat $FILENAME.lst >>$CCTRACE
            fi
            exit 1
        fi

        #   If we precompiled the program, restore original source code
        if [ $PRECOMPILED -eq 1 ]; then
            mv $FILENAME.pc $FILENAME.c
        fi
    fi

    #   If okay, link if required
    if [ "$LINKUP" = "yes" ]; then
        TRACE="Linking $FILENAME"
        COMMAND="$CCNAME $CCOPTS $FILENAME.o -o $FILENAME"

        if   [ "$UTYPE" = "OS/2" ]; then
            COMMAND="$COMMAND.exe $LIBLIST -L."

        elif [ "$LINKPATH" = "1" ]; then
            COMMAND="$COMMAND $STDLIBS -L. $LIBLIST $LIBLIST"

        else
            COMMAND="$COMMAND $LIBLIST $LIBLIST -L. $STDLIBS"
        fi
        if [ "$QUIET" = "no" ]; then
            if [ "$VERBOSE" = "no" ]; then
                echo "$TRACE..."
            else
                echo "$TRACE ($COMMAND)..."
            fi
        fi
        if [ ! -z "$CCTRACE" ]; then
            echo "$TRACE (COMMAND)">>$CCTRACE
        fi

        $NICE $COMMAND 2> $FILENAME.lst

        #   Show listing and abort if there was a link error
        if [ $? -eq 0 ]; then
            cat $FILENAME.lst
            rm  $FILENAME.lst
        else
            cat $FILENAME.lst
            if [ ! -z "$CCTRACE" ]; then
                cat $FILENAME.lst >>$CCTRACE
            fi
            exit 1
        fi
    fi
done

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -