diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Make.config.in | 28 | ||||
-rw-r--r-- | src/Makefile | 82 | ||||
-rw-r--r-- | src/configure.ac | 292 | ||||
-rw-r--r-- | src/iem_bin_ambi_sources.c | 13 | ||||
-rw-r--r-- | src/iem_bin_ambi_sources.h | 11 | ||||
-rw-r--r-- | src/makefile_win | 39 | ||||
-rwxr-xr-x | src/makesource.sh | 65 |
7 files changed, 530 insertions, 0 deletions
diff --git a/src/Make.config.in b/src/Make.config.in new file mode 100644 index 0000000..8bba163 --- /dev/null +++ b/src/Make.config.in @@ -0,0 +1,28 @@ +LIBNAME =iem_bin_ambi + +PREFIX =@prefix@@PDLIBDIR@ + +INSTALL_BIN=$(PREFIX)/extra +INSTALL_DOC=$(PREFIX)/@REFERENCEPATH@$(LIBNAME) + +EXT = @EXT@ +DEFS = @DFLAGS@ +IFLAGS = -I. @INCLUDES@ + +CC = @CC@ +LD = @LD@ +STRIP = @STRIP@ +STRIPFLAGS= @STRIPFLAGS@ + +AFLAGS = +LFLAGS = @LFLAGS@ +WFLAGS = + +TARNAME = $(LIBNAME)-@IEMBINAMBI_VERSION@.tgz + +# ICCFLAGS=-march=pentiumiii -axK +Z_CFLAGS = $(IFLAGS) $(DEFS) -DPD $(WFLAGS) @CFLAGS@ $(CFLAGS) + +MAKEDEP_FLAGS = @MAKEDEP_FLAGS@ + +LIBS = @LIBS@ diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..7cb2ee7 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,82 @@ +default: all + +.PHONEY: default all everything dist \ + clean realclean distclean \ + install install-bin install-doc install-abs + +SOURCES=$(sort $(filter %.c, $(wildcard *.c))) + +Make.config: Make.config.in configure + ./configure + +configure: configure.ac + autoconf + +## uaehh, here comes some magic +## 1st we don't want depend and config-makefiles to be included on "clean"-targets + +ifeq (,$(findstring clean, $(MAKECMDGOALS))) +-include $(SOURCES:.c=.d) +-include Make.config +endif + +## 2nd only generate depend-files when we have Make.config included +## and thus MAKEDEP_FLAGS defined +ifdef MAKEDEP_FLAGS +## dependencies: as proposed by the GNU-make documentation +## see http://www.gnu.org/software/make/manual/html_node/make_47.html#SEC51 +%.d: %.c + @set -e; rm -f $@; \ + $(CPP) $(MAKEDEP_FLAGS) $(Z_CFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ +endif + +.SUFFIXES: .$(EXT) + +TARGETS = $(SOURCES:.c=.o) + + +all: $(LIBNAME) + cp $(LIBNAME).$(EXT) .. + +$(LIBNAME): $(TARGETS) + $(LD) $(LFLAGS) -o $(LIBNAME).$(EXT) *.o $(LIBS) + $(STRIP) $(STRIPFLAGS) $(LIBNAME).$(EXT) + +$(TARGETS): %.o : %.c + $(CC) $(Z_CFLAGS) -c -o $@ $*.c + + +clean: + -rm -f *.$(EXT) *.o + +realclean: clean + -rm -f *~ _* config.* + -rm -f *.d *.d.* + +distclean: realclean + -rm -f Make.config ../*.$(EXT) + -rm -f *.exp *.lib *.ncb \ + *.opt *.plg + -rm -rf autom4te.cache/ + +install: install-bin install-doc install-abs + +install-bin: + -install -d $(INSTALL_BIN) + -install -m 644 $(LIBNAME).$(EXT) $(INSTALL_BIN) + +install-doc: + -install -d $(INSTALL_DOC) + -install -m 644 ../examples/*.pd $(INSTALL_DOC) + +install-abs: + -install -d $(INSTALL_BIN) + -install -m 644 ../abs/*.pd $(INSTALL_BIN) + +dist: all realclean + (cd ../..;tar czvf $(TARNAME) $(LIBNAME)) + +everything: clean all install distclean + diff --git a/src/configure.ac b/src/configure.ac new file mode 100644 index 0000000..937ec7f --- /dev/null +++ b/src/configure.ac @@ -0,0 +1,292 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(iem_bin_ambi.c) + +dnl Checks for programs. +AC_PROG_CC + +AC_SUBST(STK) +AC_SUBST(DFLAGS) +AC_SUBST(LFLAGS) +AC_SUBST(EXT) +AC_SUBST(LD) +AC_SUBST(STRIP) +AC_SUBST(STRIPFLAGS) +AC_SUBST(IEMBINAMBI_VERSION) +AC_SUBST(REFERENCEPATH) +AC_SUBST(PDLIBDIR) +AC_SUBST(INCLUDES) + + +AC_ARG_WITH(pdversion, [ --with-pdversion=<ver> enforce a certain pd-version (e.g. 0.37)]) +AC_ARG_WITH(version, [ --with-version=<ver> enforce a certain iem_bin_ambi-version (e.g. 0.1)]) +AC_ARG_WITH(extension, [ --with-extension=<ext> enforce a certain extension for the dynamic library (e.g. dll)]) +AC_ARG_WITH(pdpath, [ --with-pd=</path/to/pd> where to look for pd-headers and and -libs]) +AC_ARG_ENABLE(PIC, [ --disable-PIC disable compilation with PIC-flag]) + +dnl Checks for libraries. +dnl Replace `main' with a function in -lc: +AC_CHECK_LIB(c, main) +AC_CHECK_LIB(crtdll, fclose) + +dnl Replace `main' with a function in -lm: +AC_CHECK_LIB(m, main) +dnl Replace `main' with a function in -lpthread: +dnl AC_CHECK_LIB(pthread, main) +dnl Replace `main' with a function in -lstk: +dnl AC_CHECK_LIB(stk, main, STK=yes) + + +if test "x$with_pd" != "x"; then + if test -d "${with_pd}/src"; then + INCLUDES="-I${with_pd}/src ${INCLUDES}" + fi + if test -d "${with_pd}/bin"; then + LIBS="-L${with_pd}/bin ${LIBS}" + fi +fi + +if test "x$includedir" != "x"; then + for id in $includedir + do + if test -d $id; then INCLUDES="-I$id $INCLUDES"; fi + done +fi +if test "x$libdir" != "x"; then + for id in $libdir + do + if test -d $id; then LIBS="-L$id $LIBS"; fi + done +fi + +AC_CHECK_LIB(pd, nullfn) + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(stdlib.h stdio.h string.h math.h time.h sys/time.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_TIME + +dnl Checks for library functions. +AC_FUNC_MMAP +AC_CHECK_FUNCS(select socket strerror) + + +### make-depend flags +if test "x$ac_cv_c_compiler_gnu" = "xyes"; then + AC_SUBST(MAKEDEP_FLAGS, "-MM") +else + AC_SUBST(MAKEDEP_FLAGS, "-M") +fi + +dnl check for "-mms-bitfields" cflag +dnl why is there no generic compiler-check for a given flag ? +dnl it would make things so easy: AC_CHECK_FLAG([-mms-bitfields],,) +AC_MSG_CHECKING("ms-bitfields") +cat > conftest.c << EOF +int main(){ + return 0; +} +EOF +if ${CC} ${INCLUDES} ${DFLAGS} -o conftest.o conftest.c ${CFLAGS} -mms-bitfields > /dev/null 2>&1 +then + echo "yes" + CFLAGS="${CFLAGS} -mms-bitfields" +else + echo "no" +fi + + + + +dnl isn't there a better way to check for good linker/stripper ? + +dnl if we don't have $LD set, we set it to $(CC) +dnl LD=${LD:=$CC} +if test "x$LD" = "x" +then + if test "x$host" != "x" + then + LD=${host}-ld + if $(which ${LD} > /dev/null) + then + : + else + LD="" + fi + fi +fi +LD=${LD:=$CC} + +dnl if we don't have $STRIP set, we set it to ${host}-strip or strip +AC_CHECK_TOOL([STRIP], [strip], [true]) +AC_MSG_CHECKING([if strip is GNU strip]) +if $STRIP -V 2>&1 | grep GNU > /dev/null +then + AC_SUBST(STRIPFLAGS, "--strip-unneeded") + AC_MSG_RESULT([yes]) +else + AC_SUBST(STRIPFLAGS,"-x") + AC_MSG_RESULT([no]) +fi + +DFLAGS="" + + +if test "x$enable_PIC" != "xno"; then +AC_MSG_CHECKING("PIC") +cat > conftest.c << EOF +int main(){ + return 0; +} +EOF +if ${CC} ${INCLUDES} ${DFLAGS} -o conftest.o conftest.c ${CFLAGS} -fPIC > /dev/null 2>&1 +then + echo "yes" + CFLAGS="${CFLAGS} -fPIC" +else + echo "no" +fi +fi + + +dnl +dnl OK, checks for machines are here now +dnl +if test `uname -s` = Linux; +then + LFLAGS="-export_dynamic -shared" + CFLAGS="$CFLAGS" + EXT=pd_linux +fi + +dnl This should use '-bundle_loader /path/to/pd/bin/pd' instead of'-undefined suppress' +dnl then strip might do something +if test `uname -s` = Darwin; +then + LD=cc + LFLAGS="-bundle -undefined suppress -flat_namespace" + EXT=pd_darwin +fi + +if test `uname | sed -e 's/^MINGW.*/NT/'` = NT; +then + LD=gcc + INCLUDES="-I@prefix@/src" + DFLAGS="-D__WIN32__" + LFLAGS="-shared @prefix@/bin/pd.dll" + EXT=dll +else + PDLIBDIR="/lib/pd" +fi + +if test `uname -s` = IRIX64; +then + LFLAGS="-n32 -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ + -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ + -shared -rdata_shared" + EXT=pd_irix6 + dnl DFLAGS="-DUNIX -DIRIX6" +fi + +if test `uname -s` = IRIX32; +then + LFLAGS="-o32 -DUNIX -DIRIX -O2 + -shared -rdata_shared" + EXT=pd_irix5 + dnl DFLAGS="-DUNIX -DIRIX5" +fi + + +if test "x$with_extension" != "x" +then + EXT=$with_extension +fi + + +dnl Checks for pd-version, to set the correct help-path +AC_MSG_CHECKING("pd\>=0.37") + +if test "$with_pdversion" != "" +then +echo -n "($with_pdversion)... " + PD_VERSION="$with_pdversion" +else +if test "x$cross_compiling" = "xno" +then + +cat > conftest.c << EOF +#include <stdio.h> +#include "m_pd.h" +int main(){ + printf("%d.%d\n", PD_MAJOR_VERSION, PD_MINOR_VERSION); + return 0; +} +EOF + + if $CC $INCLUDES -o conftest.o conftest.c > /dev/null 2>&1 + then + PD_VERSION=`./conftest.o` + else + PD_VERSION="" + fi + echo -n $PD_VERSION +else +dnl we are cross-compiling... + echo -n "(X)..." + PD_VERSION="0.38" +fi +fi + +let PD_MAJORVERSION=`echo $PD_VERSION | cut -d"." -f1`+0 +let PD_MINORVERSION=`echo $PD_VERSION | cut -d"." -f2`+0 + + + +if test "$PD_MAJORVERSION" -gt 0 || test "$PD_MINORVERSION" -ge 37 +then + REFERENCEPATH=extra/help- + echo " yes" +else + REFERENCEPATH=doc/5.reference/ + echo " no" +fi + + +dnl check for iem_bin_ambi-version (but why...) +AC_MSG_CHECKING("iem_bin_ambi-version") + +if test "$with_version" != "" +then + echo -n "($with_version)... " + IEMBINAMBI_VERSION="$with_version" +else + +if test "x$cross_compiling" = "xno" +then +cat > conftest.c << EOF +#include <stdio.h> +#include "iem_bin_ambi.h" +int main(){ + printf("%s\n", VERSION); + return 0; +} +EOF + +if $CC $INCLUDES -o conftest.o conftest.c > /dev/null 2>&1 +then + IEMBINAMBI_VERSION=`./conftest.o` + echo "$IEMBINAMBI_VERSION" +else + IEMBINAMBI_VERSION="" + echo "(unknown)" +fi +else + IEMBINAMBI_VERSION="X" + echo "(X)" +fi +fi + +AC_OUTPUT(Make.config) + +rm -f conftest.* diff --git a/src/iem_bin_ambi_sources.c b/src/iem_bin_ambi_sources.c new file mode 100644 index 0000000..6d45134 --- /dev/null +++ b/src/iem_bin_ambi_sources.c @@ -0,0 +1,13 @@ +/* iem_bin_ambi-setup autogenerated setup-file + * generated by "./makesource.sh" + * !! DO NOT MANUALLY EDIT !! + */ + +#include "iem_bin_ambi_sources.h" + +void iem_bin_ambi_sources_setup(void) +{ + bin_ambi_calc_HRTF_setup(); /* bin_ambi_calc_HRTF.c */ + bin_ambi_reduced_decode_setup(); /* bin_ambi_reduced_decode.c */ +} + diff --git a/src/iem_bin_ambi_sources.h b/src/iem_bin_ambi_sources.h new file mode 100644 index 0000000..53bddb2 --- /dev/null +++ b/src/iem_bin_ambi_sources.h @@ -0,0 +1,11 @@ +/* iem_bin_ambi-setup autogenerated header-file + * generated by "./makesource.sh" + * !! DO NOT MANUALLY EDIT !! + */ + +#ifndef IEMBINAMBI_SOURCES_H__ +#define IEMBINAMBI_SOURCES_H__ +void bin_ambi_calc_HRTF_setup(void); /* bin_ambi_calc_HRTF.c */ +void bin_ambi_reduced_decode_setup(void); /* bin_ambi_reduced_decode.c */ +#endif /* IEMBINAMBI_SOURCES_H__ */ + diff --git a/src/makefile_win b/src/makefile_win new file mode 100644 index 0000000..a7ba3db --- /dev/null +++ b/src/makefile_win @@ -0,0 +1,39 @@ +
+all: iem_bin_ambi.dll
+
+VIS_CPP_PATH = "C:\Programme\Microsoft Visual Studio\Vc98"
+
+PD_INST_PATH = "C:\Programme\pd"
+
+PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include
+
+PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -DPA_LITTLE_ENDIAN
+
+PD_WIN_L_FLAGS = /nologo
+
+PD_WIN_LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel /NODEFAULTLIB:uuid \
+ $(VIS_CPP_PATH)\lib\libc.lib \
+ $(VIS_CPP_PATH)\lib\oldnames.lib \
+ $(VIS_CPP_PATH)\lib\kernel32.lib \
+ $(VIS_CPP_PATH)\lib\wsock32.lib \
+ $(VIS_CPP_PATH)\lib\winmm.lib \
+ $(PD_INST_PATH)\bin\pthreadVC.lib \
+ $(PD_INST_PATH)\bin\pd.lib
+
+
+SRC = bin_ambi_calc_HRTF.c \
+ bin_ambi_reduced_decode.c \
+ iem_bin_ambi.c
+
+
+OBJ = $(SRC:.c=.obj)
+
+.c.obj:
+ cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c
+
+iem_bin_ambi.dll: $(OBJ)
+ link $(PD_WIN_L_FLAGS) /dll /export:iem_bin_ambi_setup \
+ /out:iem_bin_ambi.dll $(OBJ) $(PD_WIN_LIB)
+
+clean:
+ del *.obj
diff --git a/src/makesource.sh b/src/makesource.sh new file mode 100755 index 0000000..965491c --- /dev/null +++ b/src/makesource.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +IEMBINAMBI_H=iem_bin_ambi_sources.h +IEMBINAMBI_C=iem_bin_ambi_sources.c + +EGREP=egrep +SED=sed +LS=ls + +################################# +## functions + +function head_h() { + echo "/* iem_bin_ambi-setup autogenerated header-file" + echo " * generated by \"$0\"" + echo " * !! DO NOT MANUALLY EDIT !!" + echo " */" + echo + echo "#ifndef IEMBINAMBI_SOURCES_H__" + echo "#define IEMBINAMBI_SOURCES_H__" +} + +function foot_h() { + echo "#endif /* IEMBINAMBI_SOURCES_H__ */" + echo "" +} + +function head_c() { + echo "/* iem_bin_ambi-setup autogenerated setup-file" + echo " * generated by \"$0\"" + echo " * !! DO NOT MANUALLY EDIT !!" + echo " */" + echo + echo "#include \"$IEMBINAMBI_H\"" + echo + echo "void iem_bin_ambi_sources_setup(void)" + echo "{" +} + +function foot_c() { + echo "}" + echo +} + + +################################## +## body + +head_h > $IEMBINAMBI_H +head_c > $IEMBINAMBI_C + +for i in $(${LS} *.c | ${EGREP} -v "iem_bin_ambi.*\.c") +do +## each c-file in iem_bin_ambi needs to have an <file>_setup()-function +## that calls all needed setup-functions +## any non-alpha-numeric-character is replaced by "_" +## e.g. "bla~.c" -> "bla__setup()" + SETUPNAME=$(echo ${i%.c} | ${SED} -e 's/[^[:alnum:]]/_/g')_setup + echo "void ${SETUPNAME}(void); /* $i */" >> $IEMBINAMBI_H + echo " ${SETUPNAME}(); /* $i */" >> $IEMBINAMBI_C +done + +foot_h >> $IEMBINAMBI_H +foot_c >> $IEMBINAMBI_C + |