Test commit - dynamic lib links

This commit is contained in:
Václav Valíček 2020-06-14 22:23:20 +02:00
parent 732abb2e64
commit bbce30caa0
7 changed files with 32 additions and 75 deletions

1
.gitignore vendored
View File

@ -34,3 +34,4 @@ full-package-name-VERSION/
*-coverage/
*.gcda
*.gcno
libtool

View File

@ -1,24 +1,22 @@
AM_CFLAGS = # CFLAGS applicable to all executables (products)
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
# between my_executable and the tests
noinst_LIBRARIES = libcommon.a
libcommon_a_SOURCES = src/common.h src/common.c
# src/common.h appear in SOURCES to that it gets copied to
# distribution tgz.
# libtool library definition
lib_LTLIBRARIES = libtest.la
libtest_la_SOURCES = src/test.h src/test.c
libtest_la_LDFLAGS = -version-info 0:0:0
# The main product
bin_PROGRAMS = myexecutable # make all will generate ./my_executable
bin_PROGRAMS = main_executable
#include .c and .h in SOURCES so that both appear in dist
myexecutable_SOURCES = \
main_executable_SOURCES = \
src/add.c \
src/add.h \
src/main.c
myexecutable_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS) #--std=c11 # CFLAGS applicable to myexecutable_SOURCES
myexecutable_LDADD = libcommon.a
myexecutable_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
main_executable_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS) #--std=c11 # CFLAGS applicable to myexecutable_SOURCES
main_executable_LDADD = libtest.la
main_executable_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
# myexecutable_CFLAGS = $(CODE_COVERAGE_CFLAGS)

View File

@ -6,5 +6,5 @@
# autoreconf runs all the autotool configuration tools in the right order
# and will avoid regenerating files.
#
autoreconf --install --make # install missing files
autoreconf --install
# automake --add-missing --copy >/dev/null 2>&1 # add install-sh

View File

@ -1,81 +1,39 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_INIT([test_automake_shared], [0.9.1], [https://github.com/valicek1])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign subdir-objects]) # Does not require NEWS, COPYING, AUTHORS, ChangeLog or README
# silent make https://autotools.io/automake/silent.html
# 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
AM_SILENT_RULES([yes]) # silent rules, for make -s use just [] as arg
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_MACRO_DIR([m4])
AC_LANG([C]) # Use C not C++
AC_LANG([C]) # use C
# Checks for programs.
AC_PROG_CC
# 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_CC # Checks for programs
AC_PROG_CC_C99 # C99 standard
AC_PROG_INSTALL
AC_PROG_CC_C_O # Need to have per product flags myexecutable_CFLAG
AC_PROG_RANLIB # Need for to create libraries: .a
# Checks for libraries.
# 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.])
# ])
AC_PROG_LIBTOOL # libtool init
# Checks for header files.
AC_HEADER_ASSERT # ./configure --disable-assert to define NDEBUG
AC_CHECK_HEADER([stdlib.h])
# Check for C11's optional Atomic operations library
# AC_CHECK_HEADER([stdatomic.h], [], [
# AC_MSG_ERROR([C11 with atomic support needed.])
# ])
AC_ARG_ENABLE([myerror],
AS_HELP_STRING([--enable-myerror],[enable error]),
[enable_myerror=yes],[enable_myerror=${enableval}])
# Checks for typedefs, structures, and compiler characteristics.
# 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
if test "x${enable_myerror}" == "xyes"; then
AC_DEFINE([MYERROR], 1, [myerroris enabled])
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
AC_CONFIG_FILES([Makefile])

View File

@ -3,7 +3,7 @@
#endif
#include <stdio.h>
#include "common.h"
#include "test.h"
#include <assert.h>
int main(int argc, char *argv[])

View File

@ -1,5 +1,5 @@
#include <stdio.h>
#include "common.h"
#include "test.h"
void myfunc()
{
printf("myfunc() called\n");

View File

@ -1,9 +1,9 @@
#ifndef COMMON_H
#define COMMON_H
#ifndef TEST_H
#define TEST_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
void myfunc();
#endif /* COMMON_H */
#endif /* TEST_H */