Static?
This commit is contained in:
parent
732abb2e64
commit
4576db4396
23
.gitignore
vendored
23
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
# original
|
||||||
.deps
|
.deps
|
||||||
.dirstamp
|
.dirstamp
|
||||||
Makefile
|
Makefile
|
||||||
|
@ -16,10 +17,8 @@ missing
|
||||||
src/Makefile
|
src/Makefile
|
||||||
src/Makefile.in
|
src/Makefile.in
|
||||||
src/*.o
|
src/*.o
|
||||||
src/myexecutable
|
|
||||||
stamp-h1
|
stamp-h1
|
||||||
*~
|
*~
|
||||||
myexecutable
|
|
||||||
test-driver
|
test-driver
|
||||||
test-suite.log
|
test-suite.log
|
||||||
tests/*.o
|
tests/*.o
|
||||||
|
@ -34,3 +33,23 @@ full-package-name-VERSION/
|
||||||
*-coverage/
|
*-coverage/
|
||||||
*.gcda
|
*.gcda
|
||||||
*.gcno
|
*.gcno
|
||||||
|
# Added
|
||||||
|
libtool
|
||||||
|
.libs
|
||||||
|
*.lo
|
||||||
|
*.la
|
||||||
|
main_executable
|
||||||
|
|
||||||
|
|
||||||
|
# M4???
|
||||||
|
m4/libtool.m4
|
||||||
|
m4/ltoptions.m4
|
||||||
|
m4/ltsugar.m4
|
||||||
|
m4/ltversion.m4
|
||||||
|
m4/lt~obsolete.m4
|
||||||
|
|
||||||
|
# build-aux
|
||||||
|
build-aux/config.guess
|
||||||
|
build-aux/config.sub
|
||||||
|
build-aux/ltmain.sh
|
||||||
|
|
||||||
|
|
6
AUTHORS
6
AUTHORS
|
@ -1,6 +0,0 @@
|
||||||
Example: http://git.savannah.gnu.org/cgit/make.git/tree/AUTHORS
|
|
||||||
|
|
||||||
GNU Coding Standards 6.3: Recording Contributors
|
|
||||||
http://www.gnu.org/prep/maintain/html_node/Recording-Contributors.html
|
|
||||||
|
|
||||||
First version of all files by Ruben Laguna <ruben.laguna at gmail.com>
|
|
40
Makefile.am
40
Makefile.am
|
@ -1,28 +1,26 @@
|
||||||
AM_CFLAGS = # CFLAGS applicable to all executables (products)
|
AM_CFLAGS = # CFLAGS applicable to all executables (products)
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/src # so that tests also find header files
|
AM_CPPFLAGS = -I$(top_srcdir)/src # so that tests also find header files
|
||||||
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
# Convenience library so that it can be resued
|
# libtool library definition
|
||||||
# between my_executable and the tests
|
lib_LTLIBRARIES = libtest.la
|
||||||
noinst_LIBRARIES = libcommon.a
|
libtest_la_SOURCES = src/test.h src/test.c
|
||||||
libcommon_a_SOURCES = src/common.h src/common.c
|
|
||||||
# src/common.h appear in SOURCES to that it gets copied to
|
|
||||||
# distribution tgz.
|
|
||||||
|
|
||||||
# The main product
|
bin_PROGRAMS = main_executable
|
||||||
bin_PROGRAMS = myexecutable # make all will generate ./my_executable
|
|
||||||
|
|
||||||
#include .c and .h in SOURCES so that both appear in dist
|
#include .c and .h in SOURCES so that both appear in dist
|
||||||
myexecutable_SOURCES = \
|
main_executable_SOURCES = src/main.c
|
||||||
src/add.c \
|
main_executable_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS) #--std=c11 # CFLAGS applicable to myexecutable_SOURCES
|
||||||
src/add.h \
|
main_executable_LDADD = libtest.la
|
||||||
src/main.c
|
main_executable_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
|
||||||
myexecutable_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS) #--std=c11 # CFLAGS applicable to myexecutable_SOURCES
|
|
||||||
myexecutable_LDADD = libcommon.a
|
|
||||||
myexecutable_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
|
|
||||||
# myexecutable_CFLAGS = $(CODE_COVERAGE_CFLAGS)
|
# myexecutable_CFLAGS = $(CODE_COVERAGE_CFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pkgconfig_DATA = libtest.pc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
# 'check' comes from 'make check'
|
# 'check' comes from 'make check'
|
||||||
|
|
||||||
|
@ -33,13 +31,13 @@ myexecutable_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
|
||||||
CODE_COVERAGE_IGNORE_PATTERN = tests/*
|
CODE_COVERAGE_IGNORE_PATTERN = tests/*
|
||||||
CODE_COVERAGE_IGNORE_PATTERN += stdio2.h
|
CODE_COVERAGE_IGNORE_PATTERN += stdio2.h
|
||||||
|
|
||||||
TESTS = add.ctaptest
|
#TESTS = add.ctaptest
|
||||||
check_PROGRAMS = add.ctaptest
|
#check_PROGRAMS = add.ctaptest
|
||||||
|
|
||||||
add_ctaptest_SOURCES = tests/add.c src/add.c src/add.h
|
#add_ctaptest_SOURCES = tests/add.c src/add.c src/add.h
|
||||||
add_ctaptest_CPPFLAGS = $(AM_CPPFLAGS) # so that tests find the header files
|
#add_ctaptest_CPPFLAGS = $(AM_CPPFLAGS) # so that tests find the header files
|
||||||
add_ctaptest_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
|
#add_ctaptest_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
|
||||||
add_ctaptest_CFLAGS = $(CODE_COVERAGE_CFLAGS)
|
#add_ctaptest_CFLAGS = $(CODE_COVERAGE_CFLAGS)
|
||||||
|
|
||||||
|
|
||||||
# See http://www.gnu.org/software/automake/manual/html_node/Use-TAP-with-the-Automake-test-harness.html
|
# See http://www.gnu.org/software/automake/manual/html_node/Use-TAP-with-the-Automake-test-harness.html
|
||||||
|
|
19
NEWS
19
NEWS
|
@ -1,19 +0,0 @@
|
||||||
Read GNU Coding Standards 6.7
|
|
||||||
http://www.gnu.org/prep/standards/html_node/NEWS-File.html#NEWS-File
|
|
||||||
|
|
||||||
Example: http://git.savannah.gnu.org/cgit/make.git/tree/NEWS
|
|
||||||
|
|
||||||
YourProject NEWS
|
|
||||||
History of user-visible changes
|
|
||||||
25 Jan 2015
|
|
||||||
|
|
||||||
See the end of this file for copyrights and conditions.
|
|
||||||
|
|
||||||
|
|
||||||
Version 1.0.0
|
|
||||||
|
|
||||||
* New features: XXXX
|
|
||||||
Description of the feature
|
|
||||||
|
|
||||||
|
|
||||||
|
|
76
README
76
README
|
@ -1,76 +0,0 @@
|
||||||
# autotools-template
|
|
||||||
Template for an autotools (autoconf, automake) project
|
|
||||||
|
|
||||||
Introduction
|
|
||||||
============
|
|
||||||
|
|
||||||
Setting up an `Autotools` build system can be daunting. So I decided to
|
|
||||||
create a template with the basics to use as the basis for my projects.
|
|
||||||
|
|
||||||
It may be surprising to the novice that there is no `./configure` but
|
|
||||||
`./configure` is a generated file that it's shipped with the
|
|
||||||
distribution of your software (the tarball that you get `make dist`).
|
|
||||||
As such the `./configure` doesn't belong in the source control
|
|
||||||
repository. Running `autoreconf -f` will generate `./configure` and a
|
|
||||||
bunch of other files.
|
|
||||||
|
|
||||||
To build from scrath you need to perform:
|
|
||||||
|
|
||||||
autoreconf -i # Only needed if configure.ac or Makefile.am changes
|
|
||||||
./configure # generates Makefiles and config.h
|
|
||||||
make # build
|
|
||||||
make check # run the tests
|
|
||||||
|
|
||||||
|
|
||||||
I'm not an autotools expert by any means. So take my advice with a grain
|
|
||||||
of salt.
|
|
||||||
|
|
||||||
There are two input files:
|
|
||||||
|
|
||||||
* `configure.ac`: The `./configure` script will be generated from
|
|
||||||
from it. Here is were you check for libraries,
|
|
||||||
headers, etc.
|
|
||||||
* `Makefile.am`: This file will be transformed into `Makefile.in` that
|
|
||||||
`./configure` will use to generate the `Makefile`.
|
|
||||||
|
|
||||||
Regarding tests, the basic aproach is to have multiple is to run some
|
|
||||||
programs with the test and just check the exit code for those. This is
|
|
||||||
simple and functional but you only get a PASS / FAIL per executable. To
|
|
||||||
be able to get the individual tests results (asusming that there are
|
|
||||||
several , potentially hundreds, of test on a single executable) you need
|
|
||||||
to use the TAP.
|
|
||||||
|
|
||||||
The TAP aproach is that the executables that you use for test will
|
|
||||||
output the test result on standard out so that `make check` will parse
|
|
||||||
it, collect the results, and present them in a nice way.
|
|
||||||
|
|
||||||
I opted to go for the TAP approach although it requires a more complex
|
|
||||||
setup.
|
|
||||||
|
|
||||||
What to do after cloning the repository
|
|
||||||
=======================================
|
|
||||||
|
|
||||||
configure.ac
|
|
||||||
------------
|
|
||||||
|
|
||||||
Edit configure.ac to change the FULL-PACKAGE-NAME, VERSION and
|
|
||||||
BUG-REPORT-ADDRESS fields to match your project.
|
|
||||||
|
|
||||||
Makefile.am
|
|
||||||
-----------
|
|
||||||
|
|
||||||
Edit src/Makefile.am to say which "products" (executables, binaries)
|
|
||||||
will be generated and what are the source files for each one.
|
|
||||||
|
|
||||||
bin_PROGRAMS = executable1 executable2
|
|
||||||
executable1_SOURCES = sourcefile1.c sourcefile2.c
|
|
||||||
executable1_CFLAGS =
|
|
||||||
executable2_SOURCES = sourcefile3.c sourcefile4.c
|
|
||||||
executable2_CFLAGS =
|
|
||||||
|
|
||||||
|
|
||||||
Reference material
|
|
||||||
==================
|
|
||||||
|
|
||||||
Autotools: A Practitioner's Guide to GNU Autoconf, Automake, and Libtool by John Calcote
|
|
||||||
Autotools Mythbuster https://autotools.io/index.html
|
|
|
@ -6,5 +6,5 @@
|
||||||
# autoreconf runs all the autotool configuration tools in the right order
|
# autoreconf runs all the autotool configuration tools in the right order
|
||||||
# and will avoid regenerating files.
|
# and will avoid regenerating files.
|
||||||
#
|
#
|
||||||
autoreconf --install --make # install missing files
|
autoreconf --install
|
||||||
# automake --add-missing --copy >/dev/null 2>&1 # add install-sh
|
# automake --add-missing --copy >/dev/null 2>&1 # add install-sh
|
||||||
|
|
74
configure.ac
74
configure.ac
|
@ -1,84 +1,44 @@
|
||||||
# -*- Autoconf -*-
|
|
||||||
# Process this file with autoconf to produce a configure script.
|
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
|
AC_INIT([test_automake_static], [0.9.1], [https://github.com/valicek1])
|
||||||
AC_CONFIG_AUX_DIR([build-aux])
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AM_INIT_AUTOMAKE([foreign subdir-objects]) # Does not require NEWS, COPYING, AUTHORS, ChangeLog or README
|
AM_INIT_AUTOMAKE([foreign subdir-objects]) # Does not require NEWS, COPYING, AUTHORS, ChangeLog or README
|
||||||
|
|
||||||
# silent make https://autotools.io/automake/silent.html
|
AM_SILENT_RULES([yes]) # silent rules, for make -s use just [] as arg
|
||||||
# silent rules enabled by default with 'yes'
|
|
||||||
# disable silent runles with ./configure --disable-silent-rules
|
|
||||||
AM_SILENT_RULES([yes]) # less verbose make output
|
|
||||||
# AM_SILENT_RULES() # use make -s to get silent output
|
|
||||||
|
|
||||||
AC_CONFIG_SRCDIR([src/main.c])
|
AC_CONFIG_SRCDIR([src/main.c]) # main src dir
|
||||||
AC_CONFIG_HEADERS([config.h]) # use config.h instead of passing -D in the command line
|
AC_CONFIG_HEADERS([config.h]) # use config.h instead of passing -D in the command line
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
AC_LANG([C]) # Use C not C++
|
AC_LANG([C]) # use C
|
||||||
|
|
||||||
# Checks for programs.
|
AC_PROG_CC # Checks for programs
|
||||||
AC_PROG_CC
|
AC_PROG_CC_C99 # C99 standard
|
||||||
|
|
||||||
# In case that you want to check for specific versions of gcc
|
|
||||||
# For example in case that you need C11 support you want to
|
|
||||||
# check for gcc-4.9
|
|
||||||
#AC_PROG_CC([gcc-4.9 gcc cc])
|
|
||||||
|
|
||||||
AC_PROG_CC_C99 # or AC_PROG_CC_89 to force C89 mode or AC_PROG_CC_STDC to go to latest supported standard (currently C99)
|
|
||||||
|
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
AC_PROG_CC_C_O # Need to have per product flags myexecutable_CFLAG
|
AC_PROG_CC_C_O # Need to have per product flags myexecutable_CFLAG
|
||||||
AC_PROG_RANLIB # Need for to create libraries: .a
|
LT_INIT([disable-shared])
|
||||||
|
AC_SUBST(LIBTOOL_DEPS)
|
||||||
|
AC_LTDL_DLLIB
|
||||||
# Checks for libraries.
|
PKG_INSTALLDIR
|
||||||
|
|
||||||
# Found libraries are automatically addded to LIBS
|
|
||||||
# AC_SEARCH_LIBS([pthread_cond_wait], [pthread],[],[
|
|
||||||
# AC_MSG_ERROR([You need to install pthreads library.])
|
|
||||||
# ])
|
|
||||||
|
|
||||||
# AC_SEARCH_LIBS([g_test_init], [glib-2.0],[],[
|
|
||||||
# AC_MSG_ERROR([You need to install glib-2.0 library.])
|
|
||||||
# ])
|
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_HEADER_ASSERT # ./configure --disable-assert to define NDEBUG
|
AC_HEADER_ASSERT # ./configure --disable-assert to define NDEBUG
|
||||||
AC_CHECK_HEADER([stdlib.h])
|
AC_CHECK_HEADER([stdlib.h])
|
||||||
|
|
||||||
# Check for C11's optional Atomic operations library
|
AC_ARG_ENABLE([myerror],
|
||||||
# AC_CHECK_HEADER([stdatomic.h], [], [
|
AS_HELP_STRING([--enable-myerror],[enable error]),
|
||||||
# AC_MSG_ERROR([C11 with atomic support needed.])
|
[enable_myerror=yes],[enable_myerror=${enableval}])
|
||||||
# ])
|
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
if test "x${enable_myerror}" == "xyes"; then
|
||||||
|
AC_DEFINE([MYERROR], 1, [myerroris enabled])
|
||||||
# Checks for library functions.
|
|
||||||
|
|
||||||
# The following statement will use pkg-config --cflags --libs
|
|
||||||
# to find out CFLAGS and -l options required to build a target that
|
|
||||||
# it's going to link against glib2.0.
|
|
||||||
# The required CFLAGS and -l options are available as DEPS_CFLAGS
|
|
||||||
# and DEPS_LIBS in Makefile.am
|
|
||||||
# PKG_CHECK_MODULES([DEPS], [glib-2.0 >= 2.24.1])
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([myfeature],
|
|
||||||
AS_HELP_STRING([--disable-myfeature],[disable myfeature to get remove support for this and that]),
|
|
||||||
[enable_myfeature=${enableval}],[enable_myfeature=yes])
|
|
||||||
|
|
||||||
if test "x${enable_myfeature}" == "xyes"; then
|
|
||||||
AC_DEFINE([MYFEATURE], 1, [myfeature is enabled])
|
|
||||||
else
|
|
||||||
AC_MSG_WARN([
|
AC_MSG_WARN([
|
||||||
-----------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------
|
||||||
Are you sure that you want to have myfeature disabled? You will lose this and that.
|
Results won't be real!
|
||||||
-----------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------
|
||||||
])
|
])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile])
|
AC_CONFIG_FILES([Makefile libtest.pc])
|
||||||
AC_REQUIRE_AUX_FILE([tap-driver.sh])
|
AC_REQUIRE_AUX_FILE([tap-driver.sh])
|
||||||
AX_VALGRIND_CHECK # http://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html - make check-valgrind
|
AX_VALGRIND_CHECK # http://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html - make check-valgrind
|
||||||
AX_CODE_COVERAGE # http://www.gnu.org/software/autoconf-archive/ax_code_coverage.html#ax_code_coverage - make check-code-coverage generates coverage report
|
AX_CODE_COVERAGE # http://www.gnu.org/software/autoconf-archive/ax_code_coverage.html#ax_code_coverage - make check-code-coverage generates coverage report
|
||||||
|
|
13
libtest.pc
Normal file
13
libtest.pc
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
prefix=/home/vasek/ll
|
||||||
|
exec_prefix=${prefix}
|
||||||
|
libdir=${exec_prefix}/lib
|
||||||
|
includedir=${prefix}/include
|
||||||
|
|
||||||
|
Name: test_automake_static
|
||||||
|
Description: test_automake_static 0.9.1
|
||||||
|
Version: 0.9.1
|
||||||
|
|
||||||
|
Requires:
|
||||||
|
Cflags: -I${includedir}
|
||||||
|
Libs: -L${libdir} -llibtest
|
||||||
|
|
13
libtest.pc.in
Normal file
13
libtest.pc.in
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
|
||||||
|
Name: @PACKAGE_NAME@
|
||||||
|
Description: @PACKAGE_STRING@
|
||||||
|
Version: @PACKAGE_VERSION@
|
||||||
|
|
||||||
|
Requires:
|
||||||
|
Cflags: -I${includedir}
|
||||||
|
Libs: -L${libdir} -llibtest
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#ifndef ADD_H
|
|
||||||
#define ADD_H
|
|
||||||
|
|
||||||
int add(int a,int b);
|
|
||||||
|
|
||||||
#endif /* ADD_H */
|
|
|
@ -1,6 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include "common.h"
|
|
||||||
void myfunc()
|
|
||||||
{
|
|
||||||
printf("myfunc() called\n");
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
#ifndef COMMON_H
|
|
||||||
#define COMMON_H
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
void myfunc();
|
|
||||||
|
|
||||||
#endif /* COMMON_H */
|
|
12
src/main.c
12
src/main.c
|
@ -1,19 +1,13 @@
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "common.h"
|
#include "test.h"
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
printf ("Hello world\n");
|
printf ("Hello world\n");
|
||||||
printf ("PACKAGE " PACKAGE "\n");
|
printf("14 + 5 = %d\n", mysum(14, 5));
|
||||||
printf ("PACKAGE_BUGREPORT " PACKAGE_BUGREPORT "\n");
|
|
||||||
printf ("PACKAGE_NAME "PACKAGE_NAME "\n");
|
|
||||||
printf ("PACKAGE_STRING " PACKAGE_STRING "\n");
|
|
||||||
printf ("PACKAGE_TARNAME " PACKAGE_TARNAME "\n");
|
|
||||||
assert( 1 > 0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
12
src/test.c
Normal file
12
src/test.c
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
int mysum(int a, int b){
|
||||||
|
#ifdef MYERROR
|
||||||
|
return 42;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return a + b;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
9
src/test.h
Normal file
9
src/test.h
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef TEST_H
|
||||||
|
#define TEST_H
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
int mysum(int a, int b);
|
||||||
|
|
||||||
|
#endif /* TEST_H */
|
Loading…
Reference in New Issue
Block a user