commit 015929c9650c381f0013884fb4a9a794b05a8298 Author: kevin Date: Tue Oct 30 00:28:18 2012 -0700 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..af37e38 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# directories to ignore +libcm + +.deps +autom4te.cache +build-aux +build/linux/debug/src/ +build/linux/debug/bin +build/linux/debug/lib +build/linux/debug/include +build/linux/release/src/ +build/linux/release/bin +build/linux/release/lib +build/linux/release/include + +#Files to ignore +*~ +*.[oa] + +Makefile +aclocal.m4 +config.h.in +config.h +configure +hold.makefile +Makefile.in +config.log +config.status +libtool +stamp-h1 + +m4/libtool.m4 +m4/ltoptions.m4 +m4/ltsugar.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..1d11e5b --- /dev/null +++ b/Makefile.am @@ -0,0 +1,61 @@ +ACLOCAL_AMFLAGS = -I m4 # use custom macro's in ./m4 + +lib_LTLIBRARIES= +bin_PROGRAMS= +include_HEADERS= + +# C compiler flags +# _GNU_SOURCE - turns on GNU specific extensions and gives correct prototype for double log2(double) +# -Wall turn on all warnings +# -Wno-multichar - turns off multi-character constant warnings from cmAudioFile.c + + + +AM_CPPFLAGS = -D _GNU_SOURCE -I.. -I$(srcdir)/src/libcm -I$(srcdir)/src/libcm/dsp -I$(srcdir)/src/libcm/vop -I$(srcdir)/src/libcm/app +AM_CFLAGS = -Wno-multichar +AM_CXXFLAGS = +AM_LDFLAGS = +MYLIBS = -lpthread -lfftw3f -lfftw3 +CMLIBS = src/libcm/libcm.la # autoconfig manual recommends storing direct referenes to non-3rd party libraries rather than using -L and -l + + +# debug/release switches +if DEBUG + AM_CFLAGS += -g + AM_CXXFLAGS += -g +else + AM_CFLAGS += -O3 + AM_CXXFLAGS += -O3 +endif + +# NOTE: 10/25/12 The use of -Wl, -Bstatic -Wl, -Bdynamic forces linking +# against the static version of 'libasound' and then turns dynamic linking +# back on for the other libraries. +# For some reason dynamically linking to asound causes runtime problems. +# The most notable of which is the inability for ALSA to successfully +# return hardware parameter values. +# See: http://stackoverflow.com/questions/809794/use-both-static-and-dynamically-linked-libraries-in-gcc?rq=1 + +# Linux specific +if OS_LINUX + MYLIBS += -llapack -lcblas -latlas -lgfortran +if OS_64 + AM_LDFLAGS += -L/usr/lib64/atlas -L/usr/lib64 -Wl,-Bstatic -lasound -Wl,-Bdynamic + MYLIBS += -lrt -lm + AM_CFLAGS += -m64 +endif +endif + +if OS_OSX + AM_LDFLAGS += -framework Cocoa -framework CoreAudio -framework CoreMIDI -framework Carbon -framework Accelerate -framework vecLib +endif + +include src/libcm/Makefile.am +src_libcm_libcm_la_SOURCES = $(cmSRC) $(cmHDR) +include_HEADERS += $(cmHDR) +lib_LTLIBRARIES += src/libcm/libcm.la + + +src_proj_proj_SOURCES = src/proj/main.c +src_proj_proj_LDADD = $(CMLIBS) $(MYLIBS) +bin_PROGRAMS += src/proj/proj diff --git a/build/clean.sh b/build/clean.sh new file mode 100755 index 0000000..a0c0ff0 --- /dev/null +++ b/build/clean.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Run 'make distclean' to clean many of the temporary make files. +# then use this script run from cm/build to clean the remaining files +# + + + +function clean_dir { + +rm -f $1/bin/kc.app/Contents/MacOS/kc +rm -rf $1/src +rm -rf $1/cm +rm -rf $1/include +rm -rf $1/lib +rm -rf $1/bin +rm -rf $1/.deps + +rm -f $1/config.h +rm -f $1/config.log +rm -f $1/config.status +rm -f $1/Makefile +rm -f $1/stamp-h1 +rm -f $1/libtool + +make -C $1 distclean + +} + + +rm -f ../aclocal.m4 +rm -f ../config.h.in +rm -f ../config.h.in~ +rm -f ../configure +rm -f ../Makefile.in +rm -f ../src/Makefile.in +rm -rf ../autom4te.cache +rm -rf ../build-aux +rm -rf ../m4/.svn +rm -f ../m4/libtool.m4 +rm -f ../m4/lt~obsolete.m4 +rm -f ../m4/ltoptions.m4 +rm -f ../m4/ltversion.m4 +rm -f ../m4/ltsugar.m4 + +clean_dir linux/debug +clean_dir linux/release +clean_dir osx/debug +clean_dir osx/release + +rm -rf osx/debug/a.out.dSYM + + +#rm -rf ../octave/results + +# remove all of emacs backup files (files ending width '~') +# find ../ -name "*~" -exec rm {} \; + + + diff --git a/build/linux/debug/build.sh b/build/linux/debug/build.sh new file mode 100755 index 0000000..d53c3ad --- /dev/null +++ b/build/linux/debug/build.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +curdir=`pwd` + +cd ../../.. +autoreconf --force --install + +cd ${curdir} + +../../../configure --prefix=${curdir} \ +--enable-debug \ +CFLAGS="-g -Wall" \ +CXXFLAGS="-g -Wall" \ +CPPFLAGS= \ +LDFLAGS= \ +LIBS= + + +#make +#make install \ No newline at end of file diff --git a/build/linux/release/build.sh b/build/linux/release/build.sh new file mode 100755 index 0000000..d1e4027 --- /dev/null +++ b/build/linux/release/build.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +curdir=`pwd` + +cd ../../.. +autoreconf --force --install + +cd ${curdir} + +../../../configure --prefix=${curdir} \ +CFLAGS="-Wall" \ +CXXFLAGS="-Wall" \ +CPPFLAGS= \ +LDFLAGS= \ +LIBS= + + +#make +#make install \ No newline at end of file diff --git a/build/osx/debug/build.sh b/build/osx/debug/build.sh new file mode 100755 index 0000000..d53c3ad --- /dev/null +++ b/build/osx/debug/build.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +curdir=`pwd` + +cd ../../.. +autoreconf --force --install + +cd ${curdir} + +../../../configure --prefix=${curdir} \ +--enable-debug \ +CFLAGS="-g -Wall" \ +CXXFLAGS="-g -Wall" \ +CPPFLAGS= \ +LDFLAGS= \ +LIBS= + + +#make +#make install \ No newline at end of file diff --git a/build/osx/release/build.sh b/build/osx/release/build.sh new file mode 100755 index 0000000..d1e4027 --- /dev/null +++ b/build/osx/release/build.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +curdir=`pwd` + +cd ../../.. +autoreconf --force --install + +cd ${curdir} + +../../../configure --prefix=${curdir} \ +CFLAGS="-Wall" \ +CXXFLAGS="-Wall" \ +CPPFLAGS= \ +LDFLAGS= \ +LIBS= + + +#make +#make install \ No newline at end of file diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..88c6d3f --- /dev/null +++ b/configure.ac @@ -0,0 +1,110 @@ +# +# Use "autoreconf --force --install" to update depedent files after changing +# this configure.ac or any of the Makefile.am files. +# + +AC_INIT([proj],[1.0],[proj@larke.org]) +AC_CONFIG_AUX_DIR([build-aux]) # put aux files in build-aux +AM_INIT_AUTOMAKE([1.9 -Wall foreign subdir-objects]) # subdir-objects needed for non-recursive make +AC_CONFIG_SRCDIR([src/proj/main.c]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_MACRO_DIR([m4]) + +LT_INIT + +# Check for programs +AC_PROG_CC +AC_PROG_CXX +# AC_PROG_RANLIB # required for static librarires + +# Checks for libraries. +AC_CHECK_LIB([cairo],[cairo_debug_reset_static_data],[AC_MSG_RESULT([The 'cairo' library was found.])],[AC_MSG_ERROR([The 'cairo' library was not found.])]) +#TODO: add more library checks + + +# Checks for header files. +AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h limits.h mach/mach.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h termios.h unistd.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_INLINE +AC_TYPE_OFF_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT64_T + +# Checks for library functions. +AC_FUNC_ERROR_AT_LINE +AC_FUNC_FORK +AC_FUNC_FSEEKO +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_FUNC_STRTOD +AC_CHECK_FUNCS([clock_gettime floor memmove memset mkdir pow rint select socket sqrt strcasecmp strchr strcspn strerror strspn strstr strtol]) + + +# The following is a custom macro in ./m4/os_type.m4 +# be sure to also set "ACLOCAL_AMFLAGS = -I m4" in ./Makefile.am +# Defines the config.h variable OS_LINUX or OS_OSX +AX_FUNC_OS_TYPE + +AX_FUNC_OS_64 + +# ac_cv_os_type is set by AX_FUNC_OS_TYPE +AM_CONDITIONAL([OS_LINUX],[test x"${ax_cv_os_type}" = xLinux]) +AM_CONDITIONAL([OS_OSX],[test x"${ax_cv_os_type}" = xDarwin]) +echo "OS='${ax_cv_os_type}'" + +AM_CONDITIONAL([OS_64],[test x"${ax_cv_os_64}" == xx86_64]) +echo "ptr width='${ax_cv_os_64}'" + + +AC_ARG_ENABLE([debug], + [ --enable-debug Turn on debugging], + [case "${enableval}" in + yes) debug=true ;; + no) debug=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;; + esac],[debug=false]) + +echo "debug=${debug}" + +AM_CONDITIONAL([DEBUG], [test x$debug = xtrue]) + +if test x$debug = xfalse; then +AC_DEFINE([NDEBUG], 1,[Debugging off.]) +fi + +AC_ARG_ENABLE([vectop], + [ --enable-vectop Turn on use of Lapack and Atlas vector/matrix operations. ], + [case "${enableval}" in + yes) vectop=true ;; + no) vectop=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-vectop]) ;; + esac],[vectop=true]) + +echo "vectop=${vectop}" + +# if --enable-vectop then #define CM_VECTOP = 1 in config.h otherwise CM_VECTOP is undefined. +if test x"$vectop" = xtrue; then +AC_DEFINE([CM_VECTOP], 1,[Use Lapack and Atlas.]) +fi + + +AC_ARG_ENABLE([memalign], + [ --enable-memalign Turn on memory alignment on dynamic memory allocations. ], + [case "${enableval}" in + yes) memalign=true ;; + no) memalign=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-memalign]) ;; + esac],[memalign=true]) + +echo "memalign=${memalign}" + +# if --enable-vectop then #define CM_MEMALIGN = 1 in config.h otherwise CM_MEMALIGN is undefined. +if test x"$memalign" = xtrue; then +AC_DEFINE([CM_MEMALIGN], 1,[Turn on dynamic memory alignment.]) +fi + + +AC_CONFIG_FILES([ Makefile ]) +AC_OUTPUT diff --git a/m4/os_64.m4 b/m4/os_64.m4 new file mode 100644 index 0000000..f84a4a1 --- /dev/null +++ b/m4/os_64.m4 @@ -0,0 +1,8 @@ +AC_DEFUN([AX_FUNC_OS_64], +[AC_CACHE_CHECK([operating system address width], +[ax_cv_os_64], +[ax_cv_os_64=`uname -m`]) +if test x"$ax_cv_os_64" = xx86_64; then +AC_DEFINE([OS_64], 1,[Operating system is 64 bits.]) +fi +]) # AX_FUNC_OS_TYPE diff --git a/m4/os_type.m4 b/m4/os_type.m4 new file mode 100644 index 0000000..9b2b86e --- /dev/null +++ b/m4/os_type.m4 @@ -0,0 +1,11 @@ +AC_DEFUN([AX_FUNC_OS_TYPE], +[AC_CACHE_CHECK([operating system type], +[ax_cv_os_type], +[ax_cv_os_type=`uname`]) +if test x"$ax_cv_os_type" = xLinux; then +AC_DEFINE([OS_LINUX], 1,[Operating system is Linux.]) +fi +if test x"$ax_cv_os_type" = xDarwin; then +AC_DEFINE([OS_OSX], 1,[Operating system is Darwin.]) +fi]) # AX_FUNC_OS_TYPE + diff --git a/src/proj/main.c b/src/proj/main.c new file mode 100644 index 0000000..19ff308 --- /dev/null +++ b/src/proj/main.c @@ -0,0 +1,39 @@ +#include "cmPrefix.h" +#include "cmGlobal.h" +#include "cmRpt.h" +#include "cmErr.h" +#include "cmCtx.h" +#include "cmMem.h" +#include "cmMallocDebug.h" +#include "cmLinkedHeap.h" +#include "cmFileSys.h" +#include "cmText.h" + +void print( void* arg, const char* text ) +{ + printf("%s\n",text); +} + +int main( int argc, char* argv[] ) +{ + // initialize the heap check library + bool memDebugFl = cmDEBUG_FL; + unsigned memGuardByteCnt = memDebugFl ? 8 : 0; + unsigned memAlignByteCnt = 16; + unsigned memFlags = memDebugFl ? kTrackMmFl | kDeferFreeMmFl | kFillUninitMmFl : 0; + + cmCtx_t ctx; + cmCtxSetup(&ctx,"cm test",print,print,NULL,memGuardByteCnt,memAlignByteCnt,memFlags); + + cmMdInitialize( memGuardByteCnt, memAlignByteCnt, memFlags, &ctx.rpt ); + + cmFsInitialize( &ctx, "cm_test" ); + + cmTsInitialize(&ctx ); + + cmTsFinalize(); + cmFsFinalize(); + cmMdReport( kIgnoreNormalMmFl ); + cmMdFinalize(); + return 0; +}