aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-04-29 09:54:15 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-04-29 09:54:15 +0000
commit4a320e1a78d7d5971a9768b0e349bddbd2e3a831 (patch)
tree4a8940f28588e830db4a8371c865c940cf327428
parent039d8816d4f4f292e93c7608582a5660cdc7b635 (diff)
another build-system based on autoconf
svn path=/trunk/externals/iem16/; revision=7614
-rw-r--r--src/Make.config.in34
-rw-r--r--src/Makefile103
-rw-r--r--src/acinclude.m495
-rw-r--r--src/configure.ac280
-rw-r--r--src/makefile79
5 files changed, 512 insertions, 79 deletions
diff --git a/src/Make.config.in b/src/Make.config.in
new file mode 100644
index 0000000..7c685e0
--- /dev/null
+++ b/src/Make.config.in
@@ -0,0 +1,34 @@
+LIBRARY_NAME=@LIBRARY_NAME@
+
+# when build as a library this holds a pre-processor define
+# (e.g. "-DZEXY_LIBRARY")
+# when build as single externals this is empty
+BUILDLIBRARY =@BUILDLIBRARY@
+
+PREFIX =@prefix@@PDLIBDIR@
+
+INSTALL_BIN=$(DESTDIR)$(PREFIX)/lib/pd/extra
+INSTALL_DOC=$(DESTDIR)$(PREFIX)/lib/pd/@REFERENCEPATH@$(LIBRARY_NAME)
+
+EXT = @EXT@
+DEFS = @DFLAGS@
+IFLAGS = -I. @INCLUDES@
+
+CC = @CC@
+LD = @LD@
+STRIP = @STRIP@
+STRIPFLAGS= @STRIPFLAGS@
+
+AFLAGS =
+LFLAGS = @LFLAGS@
+WFLAGS =
+
+TARNAME = $(LIBRARY_NAME)-@LIBRARY_VERSION@.tgz
+
+# ICCFLAGS=-march=pentiumiii -axK
+LIBRARY_CFLAGS = $(IFLAGS) $(DEFS) $(BUILDLIBRARY) -DPD $(WFLAGS) @CFLAGS@ $(CFLAGS)
+
+MAKEDEP_FLAGS = @MAKEDEP_FLAGS@
+CONFIGUREFLAGS = @CONFIGUREFLAGS@
+
+LIBS = @LIBS@
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..25e5bbe
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,103 @@
+default: all
+
+.PHONEY: default all everything dist \
+ clean realclean distclean \
+ install install-bin install-doc install-abs \
+ tests
+
+-include Make.config
+
+TESTDIR=../tests
+
+HELPERSOURCES=$(LIBRARY_NAME).c
+
+OBJECTSOURCES=$(sort $(filter-out $(HELPERSOURCES), $(filter %.c, $(wildcard *.c))))
+
+SOURCES=$(OBJECTSOURCES) $(HELPERSOURCES)
+
+configure: configure.ac aclocal.m4
+ autoconf
+
+aclocal.m4: acinclude.m4
+ aclocal
+
+Make.config: Make.config.in configure
+ ./configure $(CONFIGUREFLAGS)
+
+-include $(SOURCES:.c=.d)
+
+## 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) $(LIBRARY_CFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+endif
+
+.SUFFIXES: .$(EXT)
+
+TARGETS = $(SOURCES:.c=.o)
+
+OBJECTS = $(OBJECTSOURCES:.c=.$(EXT))
+
+## if $(BUILDLIBRARY) is defined, we build everything as a single library
+## else we build separate externals
+ifneq "$(BUILDLIBRARY)" ""
+all: $(LIBRARY_NAME)
+ cp $(LIBRARY_NAME).$(EXT) ..
+else
+all: $(OBJECTS)
+endif
+
+$(OBJECTS): %.$(EXT) : %.o
+ $(LD) $(LFLAGS) -o $@ $*.o $(LIBS)
+ $(STRIP) $(STRIPFLAGS) $@
+
+$(LIBRARY_NAME): $(TARGETS)
+ $(LD) $(LFLAGS) -o $@.$(EXT) *.o $(LIBS)
+ $(STRIP) $(STRIPFLAGS) $@.$(EXT)
+
+$(TARGETS): %.o : %.c
+ $(CC) $(LIBRARY_CFLAGS) -c -o $@ $*.c
+
+externals: $(OBJECTS)
+
+clean:
+ -rm -f *.$(EXT) *.o
+
+realclean: clean
+ -rm -f *~ _* config.*
+ -rm -f *.d *.d.*
+
+distclean: realclean
+ -rm -f Make.config ../*.$(EXT)
+ -rm -f $(LIBRARY_NAME).exp $(LIBRARY_NAME).lib $(LIBRARY_NAME).ncb \
+ $(LIBRARY_NAME).opt $(LIBRARY_NAME).plg
+ -rm -rf autom4te.cache/
+
+tests: all
+ make -C $(TESTDIR)
+
+install: install-bin install-doc install-abs
+
+install-bin:
+ -install -d $(INSTALL_BIN)
+ -install -m 644 $(LIBRARY_NAME).$(EXT) $(INSTALL_BIN)
+
+install-doc:
+ -install -d $(INSTALL_DOC)
+ -install -m 644 ../doc/*.pd $(INSTALL_DOC)
+
+install-abs:
+ -install -d $(INSTALL_BIN)
+ -install -m 644 ../abs/*.pd $(INSTALL_BIN)
+
+dist: all realclean
+ (cd ../..;tar czvf $(TARNAME) $(LIBRARY_NAME))
+
+everything: clean all install distclean
+
diff --git a/src/acinclude.m4 b/src/acinclude.m4
new file mode 100644
index 0000000..772fecf
--- /dev/null
+++ b/src/acinclude.m4
@@ -0,0 +1,95 @@
+dnl Copyright (C) 2005-2006 IOhannes m zmölnig
+dnl This file is free software; IOhannes m zmölnig
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# AC_CHECK_CXXFLAGS(ADDITIONAL-CXXFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
+#
+# checks whether the $(CXX) compiler accepts the ADDITIONAL-CXXFLAGS
+# if so, they are added to the CXXFLAGS
+AC_DEFUN([AC_CHECK_CXXFLAGS],
+[
+ AC_MSG_CHECKING([whether $CXX accepts "$1"])
+cat > conftest.c++ << EOF
+int main(){
+ return 0;
+}
+EOF
+if $CXX $CPPFLAGS $CXXFLAGS -o conftest.o conftest.c++ [$1] > /dev/null 2>&1
+then
+ AC_MSG_RESULT([yes])
+ CXXFLAGS="${CXXFLAGS} [$1]"
+ [$2]
+else
+ AC_MSG_RESULT([no])
+ [$3]
+fi
+])# AC_CHECK_CXXFLAGS
+
+# AC_CHECK_CFLAGS(ADDITIONAL-CFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
+#
+# checks whether the $(C) compiler accepts the ADDITIONAL-CFLAGS
+# if so, they are added to the CFLAGS
+AC_DEFUN([AC_CHECK_CFLAGS],
+[
+ AC_MSG_CHECKING([whether $CC accepts "$1"])
+cat > conftest.c << EOF
+int main(){
+ return 0;
+}
+EOF
+if $CC $CFLAGS [$1] -o conftest.o conftest.c > /dev/null 2>&1
+then
+ AC_MSG_RESULT([yes])
+ CFLAGS="${CFLAGS} [$1]"
+ [$2]
+else
+ AC_MSG_RESULT([no])
+ [$3]
+fi
+])# AC_CHECK_CFLAGS
+
+# AC_CHECK_FRAMEWORK(FRAMEWORK, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
+#
+#
+AC_DEFUN([AC_CHECK_FRAMEWORK],
+[
+ AC_MSG_CHECKING([for "$1"-framework])
+
+ temp_check_ldflags_org="${LDFLAGS}"
+ LDFLAGS="-framework [$1] ${LDFLAGS}"
+
+ AC_LINK_IFELSE(AC_LANG_PROGRAM(,), [temp_check_ldflags_success="yes"],[temp_check_ldflags_success="no"])
+
+ if test "x$temp_check_ldflags_success" = "xyes"; then
+ AC_MSG_RESULT([yes])
+ [$2]
+ else
+ AC_MSG_RESULT([no])
+ LDFLAGS="$temp_check_ldflags_org"
+ [$3]
+ fi
+])# AC_CHECK_FRAMEWORK
+
+# AC_CHECK_LDFLAGS(ADDITIONAL-LDFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
+#
+# checks whether the $(LD) linker accepts the ADDITIONAL-LDFLAGS
+# if so, they are added to the LDFLAGS
+AC_DEFUN([AC_CHECK_LDFLAGS],
+[
+ AC_MSG_CHECKING([whether linker accepts "$1"])
+ temp_check_ldflags_org="${LDFLAGS}"
+ LDFLAGS="$1 ${LDFLAGS}"
+
+ AC_LINK_IFELSE(AC_LANG_PROGRAM(,), [temp_check_ldflags_success="yes"],[temp_check_ldflags_success="no"])
+
+ if test "x$temp_check_ldflags_success" = "xyes"; then
+ AC_MSG_RESULT([yes])
+ [$2]
+ else
+ AC_MSG_RESULT([no])
+ LDFLAGS="$temp_check_ldflags_org"
+ [$3]
+ fi
+])# AC_CHECK_LDFLAGS
+
diff --git a/src/configure.ac b/src/configure.ac
new file mode 100644
index 0000000..980f56f
--- /dev/null
+++ b/src/configure.ac
@@ -0,0 +1,280 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(iem16.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(LIBRARY_NAME)
+AC_SUBST(LIBRARY_VERSION)
+AC_SUBST(BUILDLIBRARY)
+AC_SUBST(REFERENCEPATH)
+AC_SUBST(PDLIBDIR)
+AC_SUBST(INCLUDES)
+AC_SUBST(CONFIGUREFLAGS)
+
+LIBRARY_NAME=${ac_unique_file%.*}
+
+## store the flags passed to us
+## is there no way to get the flags without quotes?
+#CONFIGUREFLAGS=${ac_configure_args}
+## and is this solution portable? time will show....
+CONFIGUREFLAGS=$(echo ${ac_configure_args} | sed "s/'//g")
+
+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])
+if test "x" = "x${enable_PIC}" ; then
+ enable_PIC="${with_PIC}"
+fi
+
+if test "x$enable_PIC" != "xno"; then
+ AC_CHECK_CFLAGS([-fPIC])
+fi
+
+
+AC_ARG_ENABLE(library,[ --disable-library split the library into single externals])
+if test "xno" != "x${enable_library}" ; then
+dnl LATER: find a more generic way to generate the .._LIBRARY define
+ BUILDLIBRARY="-DLIBRARY"
+fi
+
+
+dnl check for "-mms-bitfields" cflag
+dnl it would make things so easy: AC_CHECK_FLAG([-mms-bitfields],,)
+AC_CHECK_CFLAGS([-mms-bitfields])
+
+
+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 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
+if test "x$STRIP" = "x"
+then
+ if test "x$host" != "x"
+ then
+ STRIP=${host}-strip
+ if $(which ${host}-strip > /dev/null)
+ then
+ :
+ else
+ STRIP="echo fake strip"
+ fi
+ else
+ STRIP=strip
+ fi
+fi
+dnl STRIP=${STRIP:=strip}
+
+
+dnl
+dnl OK, checks which machines are here now
+dnl this needs some rethinking when cross-compiling (?)
+dnl
+AC_CHECK_LDFLAGS([-export_dynamic -shared])
+
+if test `uname -s` = Linux;
+then
+ EXT=pd_linux
+ STRIPFLAGS="--strip-unneeded"
+ if test "$enable_icc" = "yes"; then
+ CC=icc
+ fi
+
+ if test $CC = "icc"
+ then
+ LD=$CC
+ AC_CHECK_LDFLAGS([-ip -ipo_obj])
+ AC_CHECK_CFLAGS([-ip -ipo_obj])
+ fi
+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}
+ EXT=pd_darwin
+ STRIP="echo faking strip"
+ STRIPFLAGS=
+
+ if test "$enable_lpt" = "yes"; then
+ AC_MSG_ERROR("lpt not supported on this platform");
+ fi
+ if test "$enable_lpt" = ""; then
+ AC_MSG_WARN("lpt not supported on this platform - disabling");
+ enable_lpt="no";
+ fi
+fi
+
+#AC_CHECK_LDFLAGS([-dynamiclib -mmacosx-version-min=10.3 -undefined dynamic_lookup],
+# ,
+ AC_CHECK_LDFLAGS([-bundle -undefined suppress -flat_namespace])
+# )
+
+if test `uname | sed -e 's/^MINGW.*/NT/'` = NT ;
+then
+ LD=${CC}
+# LDFLAGS="-shared pd.dll"
+ EXT=dll
+fi
+
+AC_CHECK_LDFLAGS([-shared pd.dll])
+
+if test `uname -s` = IRIX64;
+then
+ LDFLAGS="-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"
+ STRIPFLAGS="--strip-unneeded"
+ if test "$enable_lpt" = "yes"; then
+ AC_MSG_ERROR("lpt not supported on this platform");
+ fi
+ if test "$enable_lpt" = ""; then
+ AC_MSG_WARN("lpt not supported on this platform - disabling");
+ enable_lpt="no";
+ fi
+fi
+
+if test `uname -s` = IRIX32;
+then
+ LDFLAGS="-o32 -DUNIX -DIRIX -O2
+ -shared -rdata_shared"
+ EXT=pd_irix5
+ dnl DFLAGS="-DUNIX -DIRIX5"
+ STRIPFLAGS="--strip-unneeded"
+ if test "$enable_lpt" = "yes"; then
+ AC_MSG_ERROR("lpt not supported on this platform");
+ fi
+ if test "$enable_lpt" = ""; then
+ AC_MSG_WARN("lpt not supported on this platform - disabling");
+ enable_lpt="no";
+ fi
+fi
+
+if test "x$with_extension" != "x"
+then
+ EXT=$with_extension
+fi
+
+dnl check for ${LIBRARY_NAME}-version (but why...)
+AC_MSG_CHECKING("library version")
+
+if test "$with_version" != ""
+then
+ echo -n "($with_version)... "
+ LIBRARY_VERSION="$with_version"
+else
+
+if test "x$cross_compiling" = "xno"
+then
+cat > conftest.c << EOF
+#include <stdio.h>
+#include "${LIBRARY_NAME}.h"
+int main(){
+ printf("%s\n", VERSION);
+ return 0;
+}
+EOF
+
+if ${CC} ${INCLUDES} -o conftest.o conftest.c > /dev/null 2>&1
+then
+ LIBRARY_VERSION=`./conftest.o`
+ echo "$LIBRARY_VERSION"
+else
+ LIBRARY_VERSION=""
+ echo "(unknown)"
+fi
+else
+ LIBRARY_VERSION="X"
+ echo "(X)"
+fi
+fi
+
+LFLAGS=${LDFLAGS}
+AC_OUTPUT(Make.config)
+
+dnl rm -f conftest.*
diff --git a/src/makefile b/src/makefile
deleted file mode 100644
index 458372d..0000000
--- a/src/makefile
+++ /dev/null
@@ -1,79 +0,0 @@
-current: all
-
-# the IEM16-EXTERNAL-makefile
-# everything is GnuGPL that should come with the iem16.tgz
-# NO WARRANTIES FOR ANYTHING
-# et cetera
-# forum::für::umläute@IEM:2003
-
-# make sure that the "m_pd.h" is somehow available either by putting it into this
-# directory, by adding it's path to the INCLUDE-path or by putting it into an
-# already included path, e.g. "/usr/local/include/"
-
-#these are the user adjustables : adjust them to fit into your system
-# PD will install to $(DESTDIR)$(INSTALLL_PREFIX)$(PDLIBDIR), which is /usr/local/lib/pd
-# by default
-DESTDIR =
-INSTALL_PREFIX = /usr/local
-PDLIBDIR = /lib/pd
-#these were the user adjustables
-
-
-TARGETS = iem16 \
- iem16_table \
- iem16_array iem16_array_tilde \
- iem16_delay
-
-# ----------------------- LINUX ----------------------------
-.SUFFIXES: .pd_linux
-
-
-LINUXOBJECTS = $(TARGETS:%=%.o)
-ARCH = $(shell uname --machine)
-
-PD_DIR = $(DESTDIR)$(INSTALL_PREFIX)$(PDLIBDIR)
-
-ifeq (${ARCH},alpha)
-AFLAGS = -mieee -mcpu=ev56
-endif
-
-LINCLUDE =
-
-$(LINUXOBJECTS): *.h
-
-#CFLAGS = -O2 -g -Wall $(LINCLUDE) $(UCFLAGS) $(AFLAGS)
-CFLAGS = -fPIC -O3 -g -Wall $(LINCLUDE) $(UCFLAGS) $(AFLAGS)
-
-
-everything: clean all install distclean
-
-distclean:
- touch dummy.o
- touch dummy.pd_linux
- touch dummy~
- touch _dummy
- rm *.o *.pd_linux *~ _*
-
-clean:
- touch dummy.o
- touch dummy.pd_linux
- rm *.o *.pd_linux
-
-all: $(LINUXOBJECTS)
-
- @echo :: $(LINUXOBJECTS)
-
- $(LD) -export_dynamic -shared -o iem16.pd_linux *.o -lc -lm
- strip --strip-unneeded iem16.pd_linux
-
-.c.pd_linux:
- $(CC) $(CFLAGS) -O2 -DPD -fPIC $(INCLUDE) -c -o $*.o $*.c
-
-
-install: installdocs
- install -d $(PD_DIR)/extra
- install -m 644 iem16.pd_linux $(PD_DIR)/extra
-
-installdocs:
- install -d $(PD_DIR)/doc/5.reference/iem16
- install -m644 ../examples/*.pd $(PD_DIR)/doc/5.reference/iem16