#!/bin/sh # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. host="@HOST_GUESS@" prefix="@prefix@" exec_prefix="@exec_prefix@" INSTALLDIR=`eval echo "@libexecdir@"` INCLUDEDIR=`eval echo "@includedir@"` CPPFLAGS="$CPPFLAGS -I$INCLUDEDIR" CFLAGS="@CFLAGS@" CXXFLAGS="@CXXFLAGS@" BUILD= DEBUGECHO= if [ -z "$CC" ]; then CC="@CC@" fi if [ -z "$CXX" ]; then CXX="@CXX@" fi debug() { if [ -n "$DEBUGECHO" ]; then echo $* fi } bail() { echo $* exit 1 } case $host in *-*-darwin*) PICFLAGS="-fPIC" MODULELD="$CC -bundle -flat_namespace -undefined suppress" MODULELDXX="$CXX -bundle -flat_namespace -undefined suppress" MODULEEXT=bundle RLDFLAG="-Wl,--rpath=" ;; *-*-solaris*) PICFLAGS="-fpic" if test "x$CC" != "xgcc" ; then CFLAGS="$CFLAGS -mt" PICFLAGS="-Kpic" fi MODULELD="$CC -G" MODULELDXX="$CXX -G" MODULEEXT=so RLDFLAG="-R" WHOLE_ARCHIVE="-Wl,-z -Wl,allextract" NOWHOLE_ARCHIVE="-Wl,-z -Wl,defaultextract" ;; *-*-linux*) LDFLAGS="$LDFLAGS -Wl,-E" CPPFLAGS="$CPPFLAGS" PICFLAGS="-fpic" MODULELD="$CC -shared" MODULELDXX="$CXX -shared" MODULEEXT=so RLDFLAG="-Wl,--rpath=" WHOLE_ARCHIVE="-Wl,--whole-archive" NOWHOLE_ARCHIVE="-Wl,--no-whole-archive" ;; *-*-freebsd*) PICFLAGS="-fpic" MODULELD="$CC -shared" MODULELDXX="$CXX -shared" MODULEEXT=so RLDFLAG="-Wl,--rpath=" ;; *) PICFLAGS="-fpic" MODULELD="$CC -shared" MODULEEXT=so RLDFLAG="-Wl,--rpath=" ;; esac LD=$MODULELD for v in $* do case $v in -v) shift DEBUGECHO=1 ;; -h) cat < $obj" debug "$CC $CPPFLAGS $CFLAGS $PICFLAGS -c $SRC -o $obj" $CC $CPPFLAGS $CFLAGS $PICFLAGS -c $SRC -o $obj || bail "Compile failed: $CC $CPPFLAGS $CFLAGS $PICFLAGS -c $SRC -o $obj" OBJS="$OBJS $obj" BUILD=1 shift done ;; -C) shift while [ -r "$1" ]; do SRC=$1 obj=`echo $SRC | sed -e 's/\.[a-z]*$/\.lo/g;'` echo " compiling $SRC -> $obj" debug "$CXX $CPPFLAGS $CXXFLAGS $PICFLAGS -c $SRC -o $obj" $CXX $CPPFLAGS $CXXFLAGS $PICFLAGS -c $SRC -o $obj || bail "Compile failed: $CXX $CPPFLAGS $CXXFLAGS $PICFLAGS -c $SRC -o $obj" OBJS="$OBJS $obj" LD=$MODULELDXX BUILD=1 shift done ;; -o) OBJ=$2 shift 2 ;; -i) INSTALL=1 shift ;; esac done if [ "$BUILD" = "1" -a -n "$OBJ" ]; then echo " linking -> $OBJ" debug "$LD $LDFLAGS -o $OBJ $OBJS $LIBS" $LD $LDFLAGS -o $OBJ $OBJS $LIBS || bail "Link failed: $LD $LDFLAGS -o $OBJ $OBJS $LIBS" fi if [ -n "$OBJ" ]; then if [ -r "$OBJ" ]; then if [ "$INSTALL" = "1" ]; then echo " installing $OBJ -> $INSTALLDIR/$OBJ" cp $OBJ $INSTALLDIR/$OBJ chmod 0755 $INSTALLDIR/$OBJ fi else echo "No $OBJ" fi fi