Skip to content
Permalink
Browse files

preliminary auto-tools templates

Now is provided both a Makefile (Makefile.posix) and a preliminary
build using Autoconf/Automake templates.
  • Loading branch information...
faragon committed Jan 17, 2019
1 parent dcdce0a commit 0e0046851d977390db7f15036200750e266d5d7d
@@ -25,6 +25,8 @@ imgc
imgd
stest
table
counterpp
histogrampp
# Profiling
*.gcda
*.gcno
@@ -39,3 +41,22 @@ win/vs2013/stest_Release/
win/vs2013/x64/
private/
out_doc/
# Auto-tools
Makefile.in
Makefile
.deps
.libs
autom4te.cache
config.*
configure
install-sh
ltmain.sh
missing
depcomp
libtool
compile
aclocal.m4
utl/tmp
.dirstamp
*.log
*.trs

This file was deleted.

@@ -0,0 +1,15 @@
#
# Makefile.am
#
# libsrt root folder Automake template
#
# Copyright (c) 2015-2019 F. Aragon. All rights reserved.
# Released under the BSD 3-Clause License (see the doc/LICENSE)
#

MAINTAINERCLEANFILES = aclocal.m4 configure Makefile.in

SUBDIRS = src test

maintainer-clean-local:
rm -rf $(top_srcdir)/utl/tmp
@@ -1,15 +1,41 @@
#
# Makefile.inc
# Makefile for libsrt (POSIX systems: Linux, BSDs/Unix/Unix-like, etc.)
#
# Common definitions for libsrt Makefiles
# Examples:
# Build with defaults: make
# " gcc and profiling: make -f Makefile.posix CC=gcc PROFILING=1
# " gcc using C89/90 standard: make -f Makefile.posix CC=gcc C99=0
# " g++ default C++ settings: make -f Makefile.posix CC=g++
# " clang++ using C++11 standard: make -f Makefile.posix CC=clang++ CPP11=1
# " TinyCC with debug symbols: make -f Makefile.posix CC=tcc DEBUG=1
# " gcc cross compiler (PPC): make -f Makefile.posix CC=powerpc-linux-gnu-gcc
# " gcc cross compiler (ARM): make -f Makefile.posix CC=arm-linux-gnueabi-gcc
# Build without CRC32 hash tables, 1 bit/loop (100MB/s on i5@3GHz):
# make -f Makefile.posix ADD_CFLAGS="-DS_CRC32_SLC=0"
# or make -f Makefile.posix MINIMAL=1
# Build with CRC32 1024 byte hash table, 1 byte/loop (400MB/s on i5@3GHz):
# make -f Makefile.posix ADD_CFLAGS="-DS_CRC32_SLC=1"
# Build with CRC32 4096 byte hash table, 4 bytes/loop (1000MB/s on i5@3GHz):
# make -f Makefile.posix ADD_CFLAGS="-DS_CRC32_SLC=4"
# Build with CRC32 8192 byte hash table, 8 bytes/loop (2000MB/s on i5@3GHz):
# make -f Makefile.posix ADD_CFLAGS="-DS_CRC32_SLC=8"
# Build with CRC32 12288 byte hash table, 12 bytes/loop (2500MB/s on i5@3GHz):
# make -f Makefile.posix ADD_CFLAGS="-DS_CRC32_SLC=12"
# or make -f Makefile.posix # this is the default
# Build with CRC32 16384 byte hash table, 16 bytes/loop (2700MB/s on i5@3GHz):
# make -f Makefile.posix ADD_CFLAGS="-DS_CRC32_SLC=16"
# Build without VARGS support (default VARGS=1):
# make -f Makefile.posix VARGS=0
#
# Platforms: POSIX systems (Linux, BSDs/Unix/Unix-like, etc.)
# Observations:
# - On FreeBSD use gmake instead of make (as in that system "make" is "pmake",
# and not GNU make). If not installed, use: pkg install gmake
#
# Copyright (c) 2015-2019 F. Aragon. All rights reserved.
# Released under the BSD 3-Clause License (see the doc/LICENSE)
#

# Makefile parameters
# Makefile parameters and context detection handling

ifndef C99
C99 = 0
@@ -290,3 +316,51 @@ ifdef ADD_FLAGS
CXXFLAGS += $(ADD_FLAGS)
endif

# Build rules

VPATH = src:src/saux:test
SOURCES = sdata.c sdbg.c senc.c sstring.c sstringo.c schar.c ssearch.c ssort.c \
svector.c stree.c smap.c smset.c shmap.c shset.c shash.c scommon.c
ESOURCES= imgtools.c
HEADERS = scommon.h $(SOURCES:.c=.h) test/*.h
OBJECTS = $(SOURCES:.c=.o)
EOBJECTS= $(ESOURCES:.c=.o)
LIBSRT = libsrt.a
ELIBSRT = elibsrt.a
TEST = stest
EXAMPLES = counter enc histogram imgc imgd table
ifeq (,$(findstring tcc,$(CC)))
# Add CPP targets only if not using TCC
EN_BENCH = 1
endif
ifeq ($(UNAME_M), mips)
# Disable CPP targets on MIPS with unknown processor (e.g. PS2)
ifeq ($(UNAME_P), unknown)
EN_BENCH = 0
endif
endif
ifeq ($(EN_BENCH), 1)
EXAMPLES += bench counterpp histogrampp
endif

EXES = $(TEST) $(EXAMPLES)

# Rules for building: library, test

all: $(EXES) run_tests
$(OBJECTS): $(HEADERS)
$(LIBSRT): $(OBJECTS)
ar rcs $@ $^
$(ELIBSRT): $(EOBJECTS)
ar rcs $@ $^
$(EXES): $% $(ELIBSRT) $(LIBSRT)

run_tests: stest
@./$(TEST)
clean:
@rm -f $(OBJECTS) $(LIBSRT) $(ELIBSRT) *\.o *\.dSYM *\.gcno *\.gcda \
*\.gcov *\.out callgrind* out\.txt clang_analysis.txt \
*\.errors*
@for X in $(EXES) ; do rm -f $$X $$X.o ; done
@rm -rf out_doc
.PHONY: clean all run_tests
@@ -24,7 +24,7 @@ Key points:
How to build
===

* In most POSIX systems "make" will be enough, as the Makefile includes platform detection for corner cases. However, you can use multiple flags for tuning the build (you can also mix them):
* In most POSIX systems (e.g. Linux, Unix, and other Unix-like) "make -f Makefile.posix" will be enough, as the Makefile.posix includes platform detection for corner cases. However, you can use multiple flags for tuning the build (you can also mix them):
* make # Defaults (equivalent to make ADD\_CFLAGS="-DS\_CRC32\_SLC=12")
* make -j 8 # Make, spawning up to 8 concurrent jobs (faster on multiprocessor systems)
* make DEBUG=1 # Disable optimizations (-O0 -ggdb)
@@ -73,6 +73,14 @@ How to build
* ./make\_test.sh 16 # Check coding style
* ./make\_test.sh 24 # Like 8 plus 16 (3 would be like 1 plus 2, etc.)

* A preliminary Autoconf/Automake build is also provided:
* ./bootstrap.sh
* ./configure
* make
* make check

* A Visual Studio project is provided in win/vs2013/ for running the test through AppVeyor's CI.

Generic advantages
===

@@ -0,0 +1,13 @@
#!/bin/sh
#
# bootstrap.sh
#
# libsrt 'configure' bootstrap
#
# Copyright (c) 2015-2019 F. Aragon. All rights reserved.
# Released under the BSD 3-Clause License (see the doc/LICENSE)
#
ARC="autoreconf -f -i"
if ! $ARC >/dev/null 2>&1 ; then
echo "Bootstrap error: $ARC failed (code: $?)" >&2
fi
@@ -0,0 +1,56 @@
#
# configure.ac
#
# libsrt Autoconf template
#
# Copyright (c) 2015-2019 F. Aragon. All rights reserved.
# Released under the BSD 3-Clause License (see the doc/LICENSE)
#

AC_INIT([libsrt], [0.1-master], [https://github.com/faragon/libsrt/issues])

PACKAGE_URL="https://github.com/faragon/libsrt"
AC_SUBST([PACKAGE_URL])
PACKAGE_FULLNAME="libsrt"
AC_SUBST([PACKAGE_FULLNAME])

AC_CONFIG_AUX_DIR([utl/tmp/config-aux])
AC_CONFIG_MACRO_DIR([utl/tmp/config-m4])

CONFIG_ARGS="`echo $ac_configure_args | sed -e \"s% '[[A-Z]]*FLAGS=[[^']]\+'%%g\"`"
AC_SUBST([CONFIG_ARGS])

AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])

CFLAGS="${CFLAGS:-}"
CXXFLAGS="${CXXFLAGS:-}"
ori_cf="$CFLAGS"
ori_cxxf="$CXXFLAGS"
AC_LANG([C])
AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_CXX
AC_PROG_LD
AM_PROG_CC_C_O
CFLAGS="$ori_cf"
CXXFLAGS="$ori_cxxf"
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

PKG_PROG_PKG_CONFIG

AUTOCONF_ENV="SHELL=/bin/sh"

LT_INIT
AC_ENABLE_STATIC

m4_include([utl/m4/mode.m4])

AC_CONFIG_FILES([
Makefile
src/Makefile
test/Makefile
])

AC_OUTPUT

@@ -154,10 +154,12 @@ echo "make_test.sh running..."
# Locate GNU Make
if [ "$MAKE" == "" ] ; then
if type gmake >/dev/null 2>&1 ; then
MAKE=gmake
MAKE="gmake -f Makefile.posix"
else
MAKE=make
MAKE="make -f Makefile.posix"
fi
else
MAKE="$MAKE -f Makefile.posix"
fi

if (($TMUX & 1)) ; then
@@ -221,7 +223,7 @@ if (($TMUX & 4)) && type scan-build >/dev/null 2>&1 ; then
fi

if (($TMUX & 8)) ; then
make clean
$MAKE clean
OUT_DOC=out_doc
mkdir $OUT_DOC 2>/dev/null
if type python3 >/dev/null 2>&1 ; then
@@ -235,7 +237,7 @@ if (($TMUX & 8)) ; then
if type gcov >/dev/null 2>&1 ; then
echo "Coverage report generation..."
COVERAGE_OUT=$OUT_DOC/coverage.txt
make -j $MJOBS CC=gcc PROFILING=1 2>/dev/null >/dev/null
$MAKE -j $MJOBS CC=gcc PROFILING=1 2>/dev/null >/dev/null
for f in schar scommon sdata senc shash smap smset shmap \
shset ssearch ssort sstring sstringo stree svector \
stest ; do
@@ -256,16 +258,18 @@ fi

if (($TMUX & 16)) ; then
echo "Checking style..."
ls -1 src/*c src/saux/*c examples/*c examples/*h Makefile \
*\.sh utl/*\.sh | while read line ; do
ls -1 src/*c src/saux/*c examples/*c examples/*h Makefile.posix \
Makefile.inc Makefile.am *\.sh utl/*\.sh | while read line ; do
if ! utl/check_style.sh "$line" ; then
echo "$line... ERROR: style"
ERRORS=$((ERRORS + 1))
fi
done
if type egrep >/dev/null 2>&1 ; then
find doc examples src utl Makefile* LICENSE README.md \
make_test.sh -type f | while read line ; do
find doc examples/*c examples/*h src/*c src/*h src/saux/*c \
src/saux/*h Makefile.posix Makefile.inc Makefile.am \
LICENSE README.md make_test.sh -type f | \
while read line ; do
if (($(sed -n '/ \+$/p' <$line | wc -l) > 0)) ; then
echo "$line... ERROR, trailing spaces:"
sed -n '/ \+$/p' <$line | while read l2 ; do
@@ -277,7 +281,7 @@ if (($TMUX & 16)) ; then
fi
fi

make clean
$MAKE clean

exit $((ERRORS > 0 ? 1 : 0))

0 comments on commit 0e00468

Please sign in to comment.
You can’t perform that action at this time.