From 83362b2b9708005f8e183d5cf27a2940cabab8f6 Mon Sep 17 00:00:00 2001 From: kpl Date: Sun, 12 Jun 2022 17:59:20 -0400 Subject: [PATCH] Initial commit --- .gitignore | 36 ++++++++ Makefile.am | 109 ++++++++++++++++++++++++ README.md | 14 ++++ build/clean.sh | 39 +++++++++ build/linux/debug/build.sh | 25 ++++++ build/linux/release/build.sh | 24 ++++++ build/osx/debug/build.sh | 20 +++++ build/osx/release/build.sh | 19 +++++ configure.ac | 156 +++++++++++++++++++++++++++++++++++ m4/os_64.m4 | 8 ++ m4/os_type.m4 | 11 +++ src/proj/main.cpp | 14 ++++ 12 files changed, 475 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile.am create mode 100644 README.md create mode 100755 build/clean.sh create mode 100755 build/linux/debug/build.sh create mode 100755 build/linux/release/build.sh create mode 100755 build/osx/debug/build.sh create mode 100755 build/osx/release/build.sh create mode 100644 configure.ac create mode 100644 m4/os_64.m4 create mode 100644 m4/os_type.m4 create mode 100644 src/proj/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3159585 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# directories to ignore +libcw + +.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..b39bb6e --- /dev/null +++ b/Makefile.am @@ -0,0 +1,109 @@ +ACLOCAL_AMFLAGS = -I m4 # use custom macro's in ./m4 + +lib_LTLIBRARIES= +bin_PROGRAMS= +include_HEADERS= + +# To Profile w/ gprof: +# 1) Modify configure: ./configure --disable-shared CFLAGS="-pg" +# 2) Run the program. ./foo +# 3) Run gprof /libtool --mode=execute gprof ./foo + + +# 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 + + +WS_DIR = $(HOME)/sdk/libwebsockets/build/out + + +AM_CPPFLAGS = -I.. -I$(srcdir)/src/libcw +AM_CFLAGS = -Wno-multichar +AM_CXXFLAGS = -Wno-multichar +AM_LDFLAGS = + + +# debug/release switches +if DEBUG + AM_CFLAGS += -g + AM_CXXFLAGS += -g -Wall -fsanitize=undefined +else + AM_CFLAGS += -O3 + AM_CXXFLAGS += -O3 +endif + +# Linux specific +if OS_LINUX + +if OS_64 + AM_LDFLAGS += -L/usr/lib64 + AM_CFLAGS += -m64 +endif + +if cwALSA + AM_LDFLAGS += -lasound # -Wl,-Bstatic -lasound -Wl,-Bdynamic +endif + +endif + +if cwWEB + + AM_CXXFLAGS += --std=c++11 + + FFT_DIR = $(HOME)/src/fftw-3.3.8/build + FFT_DIR_D = $(FFT_DIR)/d + FFT_DIR_S = $(FFT_DIR)/s + + + AM_CPPFLAGS += -I$(FFT_DIR)/include -I$(FFT_DIR_D)/include -I$(FFT_DIR_S)/include + AM_LDFLAGS += -L$(FFT_DIR)/lib -L$(FFT_DIR_D)/lib -L$(FFT_DIR_S)/lib +else + AM_CXXFLAGS += --std=c++17 +endif + +include src/libcw/Makefile.am + +#libcw_la_SOURCES = $(libcwSRC) $(libcwHDR) +#lib_LTLIBRARIES += libcw.la +#include_HEADERS += $(libcwHDR) + +src_proj_proj_SOURCES = $(libcwHDR) $(libcwSRC) src/proj/main.cpp + +# 1) autoconfig manual recommends setting direct referenes to non-3rd party libraries rather than using -L and -l +# 2) -ldl is required for dlopen(),dlclose() ... +# src_proj_proj_LDADD = libcw.la -lpthread -ldl + +src_proj_proj_LDADD = -lpthread -ldl + +if cwFFTW + src_proj_proj_LDADD += -lfftw3 -lfftw3f +endif + +if cwWEB + src_proj_proj_LDADD += -lfftw3 -lfftw3f +endif + +if cwWEBSOCK + # AM_CPPFLAGS += -I$(WS_DIR)/include + # AM_LDFLAGS += -L$(WS_DIR)/lib + src_proj_proj_LDADD += -lwebsockets +endif + + +# src_proj_proj_CPPFLAGS = -I$(srcdir)/src/libcw $(AM_CPPFLAGS) +bin_PROGRAMS += src/proj/proj + +# ${exec_prefix} is the install prefix given to 'configure' by the user. +# ${srcdir} is the directory of this Makefile and is set by autoconf. + +# distclean-local sets the source tree back to it's minimal, pre-configure, state. +distclean-local: + rm -rf ${exec_prefix}/src + rm -rf ${srcdir}/autom4te.cache + rm -rf ${srcdir}/build-aux + rm -f ${srcdir}/m4/libtool.m4 ${srcdir}/m4/lt~obsolete.m4 ${srcdir}/m4/ltsugar.m4 + rm -f ${srcdir}/m4/ltversion.m4 ${srcdir}/m4/ltoptions.m4 + rm -f ${srcdir}/aclocal.m4 ${srcdir}/config.h.in ${srcdir}/config.h.in~ + rm -f ${srcdir}/Makefile.in ${srcdir}/configure diff --git a/README.md b/README.md new file mode 100644 index 0000000..64fadaa --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +Template App + + +# GDB Setup: + + set env LD_LIBRARY_PATH /home/kevin/sdk/libwebsockets/build/out/lib + r ~/src/cwtest/src/cwtest/cfg/main.cfg mtx + + +# Valgrind setup + + export LD_LIBRARY_PATH=~/sdk/libwebsockets/build/out/lib + valgrind --leak-check=yes --log-file=vg0.txt ./cwtest ~/src/cwtest/src/cwtest/cfg/main.cfg mtx + diff --git a/build/clean.sh b/build/clean.sh new file mode 100755 index 0000000..c2ac33c --- /dev/null +++ b/build/clean.sh @@ -0,0 +1,39 @@ +#!/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 { + + make -C $1 uninstall + make -C $1 distclean + + rm -f $1/bin/kc.app/Contents/MacOS/kc + + rm -rf $1/include + rm -rf $1/lib + rm -rf $1/bin + rm -rf $1/.deps + +} + + + +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..80c1641 --- /dev/null +++ b/build/linux/debug/build.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +curdir=`pwd` + +cd ../../.. +autoreconf --force --install + +cd ${curdir} + +# To Profile w/ gprof: +# 1) Modify configure: ./configure --disable-shared CFLAGS="-pg" +# 2) Run the program. ./foo +# 3) Run gprof /libtool --mode=execute gprof ./foo + +../../../configure --prefix=${curdir} --enable-debug --enable-websock \ +--enable-alsa \ +CFLAGS="-g -Wall" \ +CXXFLAGS="-g -Wall" \ +CPPFLAGS="-I${HOME}/sdk/libwebsockets/build/out/include" \ +LDFLAGS="-L${HOME}/sdk/libwebsockets/build/out/lib" \ +LIBS= + + +#make +#make install diff --git a/build/linux/release/build.sh b/build/linux/release/build.sh new file mode 100755 index 0000000..768adea --- /dev/null +++ b/build/linux/release/build.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +curdir=`pwd` + +cd ../../.. +autoreconf --force --install + +cd ${curdir} + +# To Profile w/ gprof: +# 1) Modify configure: ./configure --disable-shared CFLAGS="-pg" +# 2) Run the program. ./foo +# 3) Run gprof /libtool --mode=execute gprof ./foo + +../../../configure --prefix=${curdir} \ +CFLAGS="-Wall" \ +CXXFLAGS="-Wall" \ +CPPFLAGS= \ +LDFLAGS= \ +LIBS= + + +#make +#make install 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..b91d8e4 --- /dev/null +++ b/configure.ac @@ -0,0 +1,156 @@ +# +# Use "autoreconf --force --install" to update depedent files after changing +# this configure.ac or any of the Makefile.am files. +# + +AC_COPYRIGHT([Copyright (C) 2019-2022 Kevin Larke]) +AC_INIT([proj],[1.0],[proj@larke.org]) +AC_CONFIG_SRCDIR([src/proj/main.cpp]) +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_HEADERS([config.h]) +AC_CONFIG_MACRO_DIR([m4]) + +AM_PROG_AR + +LT_INIT + +# Check for programs +AC_PROG_CC +AC_PROG_CXX +# AC_PROG_RANLIB # required for static librarires + +AM_PROG_CC_C_O + +# 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]) + +# Checks for libraries. +fftw=false +AC_CHECK_LIB([fftw3],[fftw_malloc],[fftw=true],[]) +AM_CONDITIONAL([cwFFTW],[test x"${fftw}" = xtrue]) + +if test x"$fftw" = xtrue; then +AC_DEFINE([cwFFTW], 1,[Use libfftw3.]) +fi + +echo "fftw='${fftw}'" + +# 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}'" + +# +# Enable Debug +# + +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 + + +# +# Enable libwebsock +# +AC_ARG_ENABLE([websock], + [ --enable-websock Include websock dependencies], + [case "${enableval}" in + yes) websock=true ;; + no) websock=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-websock]) ;; + esac],[websock=false]) + +if test x"$websock" = xtrue; then + AC_CHECK_LIB([websockets],[lws_get_library_version],[AC_MSG_RESULT([The 'websockets' library was found.])],[AC_MSG_ERROR([The 'websockets' library was not found.])]) + AC_DEFINE([cwWEBSOCK], 1,[Use libwebsock.]) +fi +AM_CONDITIONAL([cwWEBSOCK], [test x$websock == xtrue]) +echo "websock=${websock}" + + +# +# Enable ALSA +# +AC_ARG_ENABLE([alsa], + [ --enable-alsa Include ALSA dependencies], + [case "${enableval}" in + yes) alsa=true ;; + no) alsa=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-alsa]) ;; + esac],[alsa=false]) + + +if test x"$alsa" = xtrue; then +AC_CHECK_LIB([asound],[snd_asoundlib_version],[AC_MSG_RESULT([The 'ALSA' library was found.])],[AC_MSG_ERROR([The 'ALSA' library was not found.])]) +AC_DEFINE([cwALSA], 1,[Use libalsa.]) +fi + +AM_CONDITIONAL([cwALSA], [test x$alsa == xtrue]) + +echo "alsa=${alsa}" + +# +# Enable Web +# + +AC_ARG_ENABLE([web], + [ --enable-web Include WEB dependencies], + [case "${enableval}" in + yes) web=true ;; + no) web=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-web]) ;; + esac],[web=false]) + + +if test x"$web" = xtrue; then +AC_DEFINE([cwWEB], 1,[Use libweb.]) +fi + +AM_CONDITIONAL([cwWEB], [test x$web == xtrue]) + +echo "web=${web}" + + + + +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.cpp b/src/proj/main.cpp new file mode 100644 index 0000000..6c34aeb --- /dev/null +++ b/src/proj/main.cpp @@ -0,0 +1,14 @@ +#include "cwCommon.h" +#include "cwLog.h" +#include "cwCommonImpl.h" + +void print( void* arg, const char* text ) +{ + printf("%s\n",text); +} + +int main( int argc, char* argv[] ) +{ + + return 0; +}