mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-13 04:57:05 +00:00
New mod_portaudio (sponspred by eWorldCom http://www.eworldcom.hu/)
This updates mod_portaudio to use the new v19 api and also contains
major behavioural changes. This initial check-in should be tested to find
any obscure use cases that lead to crashes etc...
All of the old api interface commands are now depricated and any attempt to
use them should cause a polite warning asking you to try the new single "pa" command.
New Features:
*) Mulitiple calls with hold/call switching.
*) Inbound calls can play a ring file on specified device. (global and per call)
*) Optional hold music for backgrounded calls. (global and per call)
Example dialplan usage:
<extension name="2000">
<condition field="destination_number" expression="^2000$">
<!--if the next 3 lines are omitted the defaults will be used from portaudio.conf-->
<action application="set" data="pa_ring_file=/sounds/myring.wav"/>
<action application="set" data="pa_hold_file=/sounds/myhold.wav"/>
<action application="set" data="export_vars=pa_ring_file,pa_hold_file"/>
<action application="bridge" data="portaudio"/>
</condition>
</extension>
Example API interface usage:
call extension 1000
> pa call 1000
call extension 1001 putting the other call on hold
> pa call 1001
swap the calls between hold and active
> pa switch
view the current calls
> pa list
forground the call with id 1
> pa switch 1
background all calls
> pa switch none
send a dtmf string (1234) to the current call
> pa dtmf 1234
answer the oldest unanswered inbound call
> pa answer
answer the call with id 1
> pa answer 1
hangup the active call
> pa hangup
hangup the call with id 1
> pa hangup 1
get device info
> pa dump
print usage summary
> pa help
USAGE:
--------------------------------------------------------------------------------
pa help
pa dump
pa call <dest> [<dialplan> <cid_name> <cid_num> <rate>]
pa answer [<call_id>]
pa hangup [<call_id>]
pa list
pa switch [<call_id>|none]
pa_dtmf <digit string>
--------------------------------------------------------------------------------
The source of the portaudio v19 library will also be checked in for the
sake of the build system.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3981 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
0ac4fbc159
commit
39a9e94305
262 files changed
+149417
-1085
No files matched your search
@@ -0,0 +1,106 @@
|
||||
#
|
||||
# Makefile template for PortAudioCpp
|
||||
# Ludwig Schwardt
|
||||
# 01/10/2003
|
||||
#
|
||||
# Not much to edit here - rather check configure.ac
|
||||
#
|
||||
|
||||
PREFIX = @prefix@
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
CFLAGS = @CFLAGS@ @DEFS@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
SHARED_FLAGS = @SHARED_FLAGS@
|
||||
LIBS = @LIBS@
|
||||
DLL_LIBS = @DLL_LIBS@
|
||||
AR = @AR@
|
||||
RANLIB = @RANLIB@
|
||||
INSTALL = @INSTALL@
|
||||
|
||||
PACPP_ROOT = @PACPP_ROOT@
|
||||
PORTAUDIO = @PORTAUDIO@
|
||||
PADLL = @PADLL@
|
||||
PACPP_DLL = @PACPP_DLL@
|
||||
PALIB = libportaudio.a
|
||||
PACPP_LIB = libportaudiocpp.a
|
||||
PACPP_DLLV = $(PACPP_DLL).0.0.12
|
||||
|
||||
SRCDIR = $(PACPP_ROOT)/source/portaudiocpp
|
||||
BINDIR = $(PACPP_ROOT)/example
|
||||
LIBDIR = $(PACPP_ROOT)/lib
|
||||
DOCDIR = $(PACPP_ROOT)/doc
|
||||
|
||||
OBJS = \
|
||||
$(SRCDIR)/BlockingStream.o \
|
||||
$(SRCDIR)/CallbackInterface.o \
|
||||
$(SRCDIR)/CallbackStream.o \
|
||||
$(SRCDIR)/CFunCallbackStream.o \
|
||||
$(SRCDIR)/CppFunCallbackStream.o \
|
||||
$(SRCDIR)/Device.o \
|
||||
$(SRCDIR)/DirectionSpecificStreamParameters.o \
|
||||
$(SRCDIR)/Exception.o \
|
||||
$(SRCDIR)/HostApi.o \
|
||||
$(SRCDIR)/InterfaceCallbackStream.o \
|
||||
$(SRCDIR)/MemFunCallbackStream.o \
|
||||
$(SRCDIR)/Stream.o \
|
||||
$(SRCDIR)/StreamParameters.o \
|
||||
$(SRCDIR)/System.o \
|
||||
$(SRCDIR)/SystemDeviceIterator.o \
|
||||
$(SRCDIR)/SystemHostApiIterator.o
|
||||
|
||||
# Not supported yet
|
||||
# $(SRCDIR)/AsioDeviceAdapter.o
|
||||
|
||||
EXAMPLES = \
|
||||
$(BINDIR)/devs \
|
||||
$(BINDIR)/sine
|
||||
|
||||
.PHONY: all clean docs
|
||||
|
||||
all: $(EXAMPLES) $(LIBDIR)/$(PACPP_LIB) $(LIBDIR)/$(PACPP_DLL)
|
||||
|
||||
clean:
|
||||
rm -rf $(SRCDIR)/*.o $(BINDIR)/*.o $(EXAMPLES) $(LIBDIR) $(DOCDIR)/api_reference
|
||||
rm -rf autom4te.cache config.status config.log
|
||||
|
||||
docs:
|
||||
cd $(DOCDIR); doxygen config.doxy.linux
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
%.o: %.cxx
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
|
||||
$(EXAMPLES): $(BINDIR)/%: $(BINDIR)/%.o $(OBJS)
|
||||
$(CXX) $^ -o $@ $(LIBS)
|
||||
|
||||
$(LIBDIR)/$(PACPP_LIB): $(LIBDIR) $(OBJS)
|
||||
$(AR) ruv $(LIBDIR)/$(PACPP_LIB) $(OBJS)
|
||||
$(RANLIB) $(LIBDIR)/$(PACPP_LIB)
|
||||
|
||||
$(LIBDIR)/$(PACPP_DLLV): $(LIBDIR) $(OBJS)
|
||||
$(CXX) $(SHARED_FLAGS) -o $(LIBDIR)/$(PACPP_DLLV) $(OBJS) $(DLL_LIBS)
|
||||
|
||||
$(LIBDIR)/$(PACPP_DLL): $(LIBDIR) $(OBJS)
|
||||
$(CXX) $(SHARED_FLAGS) -o $(LIBDIR)/$(PACPP_DLL) $(OBJS) $(DLL_LIBS)
|
||||
|
||||
#install: $(LIBDIR)/$(PACPP_LIB) $(LIBDIR)/$(PACPP_DLLV)
|
||||
# $(INSTALL) -m 644 $(LIBDIR)/$(PACPP_DLLV) $(PREFIX)/lib/$(PACPP_DLLV)
|
||||
# $(INSTALL) -m 644 $(LIBDIR)/$(PACPP_LIB) $(PREFIX)/lib/$(PACPP_LIB)
|
||||
# cd $(PREFIX)/lib && rm -f $(PACPP_DLL) && ln -s $(PACPP_DLLV) $(PACPP_DLL)
|
||||
# @echo ""
|
||||
# @echo "------------------------------------------------------------"
|
||||
# @echo "PortAudioCpp was successfully installed."
|
||||
# @echo ""
|
||||
# @echo "On some systems (e.g. Linux) you should run 'ldconfig' now"
|
||||
# @echo "to make the shared object available. You may also need to"
|
||||
# @echo "modify your LD_LIBRARY_PATH environment variable to include"
|
||||
# @echo "the directory $(PREFIX)/lib"
|
||||
# @echo "------------------------------------------------------------"
|
||||
# @echo ""
|
||||
|
||||
$(LIBDIR):
|
||||
mkdir $(LIBDIR)
|
||||
Whitespace-only changes.
@@ -0,0 +1,57 @@
|
||||
|
||||
dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
|
||||
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
|
||||
dnl also defines GSTUFF_PKG_ERRORS on error
|
||||
AC_DEFUN(PKG_CHECK_MODULES, [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$PKG_CONFIG"; then
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
fi
|
||||
|
||||
if test "$PKG_CONFIG" = "no" ; then
|
||||
echo "*** The pkg-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, or set the PKG_CONFIG environment variable"
|
||||
echo "*** to the full path to pkg-config."
|
||||
echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
|
||||
else
|
||||
PKG_CONFIG_MIN_VERSION=0.9.0
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
|
||||
AC_MSG_CHECKING(for $2)
|
||||
|
||||
if $PKG_CONFIG --exists "$2" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING($1_CFLAGS)
|
||||
$1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
|
||||
AC_MSG_RESULT($$1_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING($1_LIBS)
|
||||
$1_LIBS=`$PKG_CONFIG --libs "$2"`
|
||||
AC_MSG_RESULT($$1_LIBS)
|
||||
else
|
||||
$1_CFLAGS=""
|
||||
$1_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
$1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
|
||||
ifelse([$4], ,echo $$1_PKG_ERRORS,)
|
||||
fi
|
||||
|
||||
AC_SUBST($1_CFLAGS)
|
||||
AC_SUBST($1_LIBS)
|
||||
else
|
||||
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
|
||||
echo "*** See http://www.freedesktop.org/software/pkgconfig"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$3], , :, [$3])
|
||||
else
|
||||
ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
+1308
File diff suppressed because it is too large.
Load diff
+1505
File diff suppressed because it is too large.
Load diff
+4297
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,214 @@
|
||||
#
|
||||
# PortAudioCpp V19 autoconf input file
|
||||
# Shamelessly ripped from the PortAudio one by Dominic Mazzoni
|
||||
# Ludwig Schwardt
|
||||
#
|
||||
|
||||
# Require autoconf >= 2.13
|
||||
AC_PREREQ(2.13)
|
||||
|
||||
AC_INIT([PortAudioCpp], [12])
|
||||
AC_CONFIG_SRCDIR([../../include/portaudiocpp/PortAudioCpp.hxx])
|
||||
|
||||
###### Top-level directory of pacpp
|
||||
###### This makes it easy to shuffle the build directories
|
||||
###### Also edit AC_CONFIG_SRCDIR above (wouldn't accept this variable)!
|
||||
PACPP_ROOT="../.."
|
||||
|
||||
######
|
||||
###### SET THIS TO PORTAUDIO DIRECTORY
|
||||
######
|
||||
PORTAUDIO="$PACPP_ROOT/../portaudio"
|
||||
|
||||
# Various other variables and flags
|
||||
|
||||
PACPP_INC="$PACPP_ROOT/include"
|
||||
INCLUDES="-I$PACPP_INC -I$PORTAUDIO -I$PORTAUDIO/pa_common"
|
||||
CFLAGS="-g -O2 -Wall -ansi -pedantic $INCLUDES"
|
||||
CXXFLAGS="$CFLAGS"
|
||||
PALIBDIR="$PORTAUDIO/lib"
|
||||
|
||||
# Checks for programs
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_INSTALL
|
||||
AC_PATH_PROG(AR, ar, no)
|
||||
if [[ $AR = "no" ]] ; then
|
||||
AC_MSG_ERROR("Could not find ar - needed to create a library");
|
||||
fi
|
||||
|
||||
# This must be one of the first tests we do or it will fail...
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
# Transfer these variables to the Makefile
|
||||
AC_SUBST(PACPP_ROOT)
|
||||
AC_SUBST(PORTAUDIO)
|
||||
AC_SUBST(PADLL)
|
||||
AC_SUBST(PACPP_DLL)
|
||||
AC_SUBST(PACPP_INC)
|
||||
AC_SUBST(SHARED_FLAGS)
|
||||
AC_SUBST(DLL_LIBS)
|
||||
AC_SUBST(CXXFLAGS)
|
||||
|
||||
##################### CHECK FOR INSTALLED PACKAGES ############################
|
||||
|
||||
# checks for various host APIs and arguments to configure that
|
||||
# turn them on or off
|
||||
|
||||
AC_CHECK_LIB(asound, snd_pcm_open, have_alsa=yes, have_alsa=no)
|
||||
|
||||
# Determine the host description for the subsequent test.
|
||||
# PKG_CHECK_MODULES seems to check and set the host variable also, but
|
||||
# that then requires pkg-config availability which is not standard on
|
||||
# MinGW systems and can be a pain to install.
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
PKG_CHECK_MODULES(JACK, jack, have_jack=yes, have_jack=no)
|
||||
|
||||
AC_ARG_WITH(alsa,
|
||||
[ --with-alsa (default=auto)],
|
||||
with_alsa=$withval, with_alsa="yes")
|
||||
|
||||
AC_ARG_WITH(jack,
|
||||
[ --with-jack (default=auto)],
|
||||
with_jack=$withval, with_jack="yes")
|
||||
|
||||
AC_ARG_WITH(oss,
|
||||
[ --with-oss (default=yes)],
|
||||
with_oss=$withval, with_oss="yes")
|
||||
|
||||
AC_ARG_WITH(host_os,
|
||||
[ --with-host_os (no default)],
|
||||
host_os=$withval)
|
||||
|
||||
AC_ARG_WITH(winapi,
|
||||
[ --with-winapi ((wmme/directx/asio) default=wmme)],
|
||||
with_winapi=$withval, with_winapi="wmme")
|
||||
|
||||
# Mac API added for ASIO, can have other api's listed
|
||||
AC_ARG_WITH(macapi,
|
||||
[ --with-macapi (asio) default=asio)],
|
||||
with_macapi=$withval, with_macapi="asio")
|
||||
|
||||
AC_ARG_WITH(asiodir,
|
||||
[ --with-asiodir (default=/usr/local/asiosdk2)],
|
||||
with_asiodir=$withval, with_asiodir="/usr/local/asiosdk2")
|
||||
|
||||
AC_ARG_WITH(dxdir,
|
||||
[ --with-dxdir (default=/usr/local/dx7sdk)],
|
||||
with_dxdir=$withval, with_dxdir="/usr/local/dx7sdk")
|
||||
|
||||
|
||||
##################### HOST-SPECIFIC LIBRARY SETTINGS ##########################
|
||||
|
||||
case "${host_os}" in
|
||||
darwin* )
|
||||
# Mac OS X configuration
|
||||
|
||||
LIBS="-framework AudioUnit -framework AudioToolbox -framework CoreAudio";
|
||||
PADLL="libportaudio.dylib";
|
||||
PACPP_DLL="libportaudiocpp.dylib";
|
||||
SHARED_FLAGS="-framework AudioUnit -framework AudioToolbox";
|
||||
SHARED_FLAGS="$SHARED_FLAGS -framework CoreAudio -dynamiclib";
|
||||
if [[ $with_macapi = "asio" ]] ; then
|
||||
if [[ $with_asiodir ]] ; then
|
||||
ASIODIR="$with_asiodir";
|
||||
else
|
||||
ASIODIR="/usr/local/asiosdk2";
|
||||
fi
|
||||
echo "ASIODIR: $ASIODIR";
|
||||
fi
|
||||
;;
|
||||
|
||||
mingw* )
|
||||
# MingW configuration
|
||||
|
||||
echo "WINAPI: $with_winapi"
|
||||
if [[ $with_winapi = "directx" ]] ; then
|
||||
if [[ $with_dxdir ]] ; then
|
||||
DXDIR="$with_dxdir";
|
||||
else
|
||||
DXDIR="/usr/local/dx7sdk";
|
||||
fi
|
||||
echo "DXDIR: $DXDIR"
|
||||
LIBS="-L$PALIBDIR -lportaudio"
|
||||
LIBS="$LIBS -lwinmm -lm -ldsound -lole32";
|
||||
PADLL="portaudio.dll";
|
||||
PACPP_DLL="portaudiocpp.dll";
|
||||
SHARED_FLAGS="-shared -mthreads";
|
||||
DLL_LIBS="-lwinmm -lm -L./dx7sdk/lib -ldsound -lole32";
|
||||
CFLAGS="$CFLAGS -DPA_NO_WMME -DPA_NO_ASIO";
|
||||
CXXFLAGS="$CFLAGS"
|
||||
elif [[ $with_winapi = "asio" ]] ; then
|
||||
if [[ $with_asiodir ]] ; then
|
||||
ASIODIR="$with_asiodir";
|
||||
else
|
||||
ASIODIR="/usr/local/asiosdk2";
|
||||
fi
|
||||
echo "ASIODIR: $ASIODIR"
|
||||
|
||||
LIBS="-L$PALIBDIR -lportaudio"
|
||||
LIBS="$LIBS -lwinmm -lm -lstdc++ -lole32 -luuid";
|
||||
PADLL="portaudio.dll";
|
||||
PACPP_DLL="portaudiocpp.dll";
|
||||
SHARED_FLAGS="-shared -mthreads";
|
||||
DLL_LIBS="-lwinmm -lm -lstdc++ -lole32 -luuid";
|
||||
CFLAGS="$CFLAGS -ffast-math -fomit-frame-pointer -DPA_NO_WMME -DPA_NO_DS -DWINDOWS";
|
||||
CXXFLAGS="$CFLAGS";
|
||||
else # WMME default
|
||||
LIBS="-L$PALIBDIR -lportaudio"
|
||||
LIBS="$LIBS -lwinmm -lm -lstdc++ -lole32 -luuid";
|
||||
PADLL="portaudio.dll";
|
||||
PACPP_DLL="portaudiocpp.dll";
|
||||
SHARED_FLAGS="-shared -mthreads";
|
||||
DLL_LIBS="-lwinmm";
|
||||
CFLAGS="$CFLAGS -DPA_NO_DS -DPA_NO_ASIO";
|
||||
CXXFLAGS="$CFLAGS";
|
||||
fi
|
||||
;;
|
||||
|
||||
cygwin* )
|
||||
# Cygwin configuration
|
||||
|
||||
LIBS="-L$PALIBDIR -lportaudio"
|
||||
LIBS="$LIBS -lwinmm -lm";
|
||||
PADLL="portaudio.dll";
|
||||
PACPP_DLL="portaudiocpp.dll";
|
||||
SHARED_FLAGS="-shared -mthreads";
|
||||
DLL_LIBS="-lwinmm";
|
||||
;;
|
||||
|
||||
*)
|
||||
# Unix OSS configuration
|
||||
|
||||
AC_CHECK_LIB(pthread, pthread_create,
|
||||
,
|
||||
AC_MSG_ERROR([libpthread not found!]))
|
||||
|
||||
LIBS="$LIBS -L$PALIBDIR -lportaudio"
|
||||
|
||||
if [[ $have_jack = "yes" ] && [ $with_jack != "no" ]] ; then
|
||||
LIBS="$LIBS $JACK_LIBS"
|
||||
CFLAGS="$CFLAGS $JACK_CFLAGS"
|
||||
AC_DEFINE(PA_USE_JACK)
|
||||
fi
|
||||
|
||||
if [[ $have_alsa = "yes" ] && [ $with_alsa != "no" ]] ; then
|
||||
LIBS="$LIBS -lasound"
|
||||
AC_DEFINE(PA_USE_ALSA)
|
||||
fi
|
||||
|
||||
if [[ $with_oss != "no" ]] ; then
|
||||
AC_DEFINE(PA_USE_OSS)
|
||||
fi
|
||||
LIBS="$LIBS -lm -lpthread";
|
||||
PADLL="libportaudio.so";
|
||||
PACPP_DLL="libportaudiocpp.so";
|
||||
SHARED_FLAGS="-shared";
|
||||
esac
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
@@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
chmodcmd=""
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
||||
Reference in new issue
Block a user