From: Juergen Beisert <jbe@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [RFC] src-autoconf-lib package template, this is a try to make it more 'feature' complete
Date: Wed, 13 Jun 2012 20:04:50 +0200 [thread overview]
Message-ID: <201206132004.51279.jbe@pengutronix.de> (raw)
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
diff --git a/rules/templates/src-autoconf-lib/@name@.c b/rules/templates/src-autoconf-lib/@name@.c
index f89e37e..c7944a5 100644
--- a/rules/templates/src-autoconf-lib/@name@.c
+++ b/rules/templates/src-autoconf-lib/@name@.c
@@ -1,8 +1,47 @@
+/*
+ * (C) Copyright <year> <your name> <your mail address>
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
#include <stdio.h>
-int main(void)
+#include "internal.h"
+#include "lib@name@.h"
+
+DSO_VISIBLE int @name@_open(void)
+{
+ printf("lib@name@ opened\n");
+ return EXIT_SUCCESS;
+}
+
+DSO_VISIBLE int @name@_close(void)
{
- printf("hello fish!\n");
- return 0;
+ printf("lib@name@ closed\n");
+ return EXIT_SUCCESS;
}
+/* library's paper work */
+
+/* this function will be called, when the library gets loaded */
+void INIT_LIB init_function(void)
+{
+}
+
+/* this function will be called, when the library gets unloaded */
+void EXIT_LIB fini_function(void)
+{
+}
diff --git a/rules/templates/src-autoconf-lib/COPYING b/rules/templates/src-autoconf-lib/COPYING
new file mode 100644
index 0000000..65c5ca8
--- /dev/null
+++ b/rules/templates/src-autoconf-lib/COPYING
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/rules/templates/src-autoconf-lib/Makefile.am b/rules/templates/src-autoconf-lib/Makefile.am
index 3f80257..100052b 100644
--- a/rules/templates/src-autoconf-lib/Makefile.am
+++ b/rules/templates/src-autoconf-lib/Makefile.am
@@ -1,25 +1,76 @@
+if BUILD_SILENTLY
+AM_MAKEFLAGS = --no-print-directory
+endif
+
+ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+
+# pkg's stuff
+pkgconfigdir = \
+ $(libdir)/pkgconfig
+
+pkgconfig_DATA = \
+ lib@name@.pc
+
+# this one gets not installed, only internally used
+noinst_HEADERS = \
+ internal.h
+
+# this one gets installed to enable others to link against your library
+include_HEADERS = \
+ lib@name@.h
+
+#
+# What is to build here
+#
lib_LTLIBRARIES = \
lib@name@.la
-AM_CPPFLAGS = \
- -I$(top_srcdir)/include \
- -I$(top_builddir)/include
-# $(some_CFLAGS)
-
EXTRA_DIST = \
- autogen.sh
+ autogen.sh \
+ m4/attributes.m4 \
+ lib@name@.pc.in \
+ COPYING
MAINTAINERCLEANFILES = \
- configure \
- aclocal.m4 \
- Makefile.in
+ configure \
+ config.guess \
+ config.sub \
+ install-sh \
+ ltmain.sh \
+ autoscan.log \
+ config.h.in~ \
+ configure.scan \
+ missing \
+ depcomp \
+ aclocal.m4 \
+ config.h.in \
+ Makefile.in \
+ aclocal.m4 \
+ m4/libtool.m4 \
+ m4/ltoptions.m4 \
+ m4/ltsugar.m4 \
+ m4/ltversion.m4 \
+ m4/lt~obsolete.m4 \
+ $(DIST_ARCHIVES)
#
-# binary
+# library
#
-lib@namenodash@_la_SOURCES = \
- @name@.c
+# lib@namenodash@_la_CPPFLAGS = \
+# $(some_pre_processor_flags)
+
+# lib@namenodash@_la_CFLAGS = \
+# $(some_compiler_flags)
-#@namenodash@_LDADD = \
-# $(some_LIBS)
+# lib@namenodash@_la_LIBADD = \
+# $(some_libs)
+# Note: It overrides the AM_LDFLAGS variable
+lib@namenodash@_la_LDFLAGS = \
+ $(AM_LDFLAGS) \
+ @LDFLAGS_NOUNDEFINED@ \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ -release $(API_RELEASE)
+
+lib@namenodash@_la_SOURCES = \
+ @name@.c
diff --git a/rules/templates/src-autoconf-lib/README b/rules/templates/src-autoconf-lib/README
new file mode 100644
index 0000000..3a095b9
--- /dev/null
+++ b/rules/templates/src-autoconf-lib/README
@@ -0,0 +1,43 @@
+ lib@name@ - The @NAME@ library
+ ------------------------------------
+
+ Overview
+ --------
+
+ <tell something about this library>
+
+ License
+ -------
+
+ Most of this library is distributed under the terms of the GNU
+ Lesser General Public License (LGPL); see the file COPYING for
+ the actual terms.
+
+ Configure options
+ -----------------
+
+ Here is a list of configure options which are sometimes useful
+ for installation.
+
+ --enable-debug
+ Make the library more noise and do more runtime checks.
+ This will slow down the library at runtime.
+
+ --enable-profiling
+ Build the library with profiling support.
+
+ --enable-coverage
+ Build the library with coverage support.
+
+ --disable-hide
+ Built the library with all internal symbols visible. The
+ default is to only provide the exported functions to a
+ user. When --enable-debug is given all internal symbols
+ are visible.
+
+ Environment Variables
+ ---------------------
+
+ You can overwrite CPPFLAGS, CFLAGS and LDFLAGS from the environment. But
+ keep in mind to not forget to add the "-O2 -g", if you use your own CFLAGS
+ settings. Only in the case CFLAGS is unset, configure defaults to "-O2 -g"
diff --git a/rules/templates/src-autoconf-lib/configure.ac b/rules/templates/src-autoconf-lib/configure.ac
index 091ce7a..d25d961 100644
--- a/rules/templates/src-autoconf-lib/configure.ac
+++ b/rules/templates/src-autoconf-lib/configure.ac
@@ -1,70 +1,345 @@
-AC_PREREQ(2.59)
+AC_PREREQ(2.60)
esyscmd([echo "define(myversion, $(dir=$(basename $(pwd)); if test \"${dir%%-trunk}\" != \"$dir\"; then echo 99999999-9;
else prefix=${dir%%-[0-9]*-[0-9]}; echo ${dir##$prefix-}; fi))"])
-AC_INIT([@name@], myversion, [bugs@pengutronix.de])
-AC_CONFIG_SRCDIR([@name@.c])
+AC_INIT([@name@], myversion, [bugs@yourdomain.to], [@name@], [http://www.yourdomain.to/])
+AC_REVISION(1.0)
+AC_CONFIG_SRCDIR([config.h.in])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
-AM_MAINTAINER_MODE
+# default is less output while building the package
+AM_SILENT_RULES([yes])
+
+# If you don't want the default installation path to be '/usr/local' change it here
+# AC_PREFIX_DEFAULT(<new prefix>)
-CFLAGS="${CFLAGS} -W -Wall"
+# If possible, enable extensions to Posix
+AC_USE_SYSTEM_EXTENSIONS
#
# libtool library versioning stuff
#
-# Library code modified: REVISION++
-# Interfaces changed/added/removed: CURRENT++ REVISION=0
-# Interfaces added: AGE++
-# Interfaces removed: AGE=0
+# Using this variables results into
+#
+# lib<something>-<API_RELEASE>.so.<LT_CURRENT.LT_REVISION.LT_AGE>
+#
+# API_RELEASE: API compatibility. Its up to you to define a specific version here
+#
+# LT_CURRENT.LT_REVISION.LT_AGE: binary compatibility.
+# Here the rule is:
+# - library code was modified: LT_REVISION++
+# - interfaces changed/added/removed: LT_CURRENT++ and REVISION = 0
+# - interfaces added: LT_AGE++
+# - interfaces removed: LT_AGE = 0
+#
+API_RELEASE=0.0
+AC_SUBST(API_RELEASE)
+
+# Library release
LT_CURRENT=0
LT_REVISION=0
LT_AGE=0
+
AC_SUBST(LT_CURRENT)
+AC_DEFINE_UNQUOTED(@NAME@_MAJOR, ${LT_CURRENT}, [libs major number])
AC_SUBST(LT_REVISION)
+AC_DEFINE_UNQUOTED(@NAME@_MINOR, ${LT_REVISION}, [libs minor number])
AC_SUBST(LT_AGE)
+AC_DEFINE_UNQUOTED(@NAME@_MICRO, ${LT_AGE}, [libs micro number])
+AM_MAINTAINER_MODE
+AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
+
+#
+# TODO Enable the following block, if you need something to run at compiletime.
+# This means it will not be compiled by a cross compiler, the host compiler is
+# used instead. For the non cross compile case nothing change
+#
+
+# AC_MSG_CHECKING([if cross compiling])
+# if test "x${cross_compiling}" = "xno"; then
+# CC_FOR_BUILD=${CC_FOR_BUILD-${CC-gcc}}
+# else
+# CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
+# fi
+# AC_MSG_RESULT([${cross_compiling}])
#
# Checks for programs.
#
AC_PROG_CC
-AC_PROG_LIBTOOL
-AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
+#
+# to only build the static library uncomment the following line
+# AC_DISABLE_SHARED([])
+# to only build the shared library uncomment the following line
+# AC_DISABLE_STATIC([])
+
+LT_INIT
+
+#
+# Using additional preprocessor, compiler or linker flags:
+# - add them to AM_CPPFLAGS, AM_CFLAGS or AM_LDFLAGS if they should be used
+# by all source files
+# - give the user a chance to setup her/his own flags with the CPPFLAGS, CFLAGS
+# and LDFLAGS
+# - if some flags are specific to a file add the flags via the substitute macro
+# into the Makefile
+#
+# Don't add the "-g" to the CFLAGS variable. It will be done automatically if
+# autoconf detects a GNU compiler.
+#
+#
+# Please note: 'configure' defaults the CFLAGS to "-O2 -g" if it detects a
+# GCC. If the user overwrites the CFLAGS externallly, there will be no default!
+# Keep the user informed about this behaviour.
-##
-# libsomething
-##
-#REQUIRES_LIBSOMETHING="libsomething >= 20090402-1"
-#AC_SUBST(REQUIRES_LIBSOMETHING)
-#PKG_CHECK_MODULES(libsomething, $REQUIRES_LIBSOMETHING)
+#
+# Check here for mandadory external libraries
+#
+# Rule of thumb: when your library needs an external library, add it
+# to the 'LIBS' variable. Do _not_ add it manually into the Makefile.am files.
+# These libraries _must_ be listed in the *.pc file.
+#
+# Don't add libraries without a check. Even if you know the 'sqrt()' requires
+# 'libm' on most systems, check for its real need with 'AC_SEARCH_LIBS(sqrt, m)'.
+# Doing it in this way will ensure an embedded developer knows exactly what
+# dependencies your library has (because it get listed in the *.pc file).
+#
+# Another way for checking libraries is the PKG_CHECK_MODULES macro. But please
+# honor if a user switches off a feature you also switch of the test for a
+# external component via PKG_CHECK_MODULES when it is no longer required!
+# PKG_CHECK_MODULES returns *_CFLAGS and *_LIBS. Again, add the *_LIBS to the
+# global 'LIBS', but for the CFLAGS you can decide if you add them to the
+# CFLAGS, AM_CFLAGS or as substitution variables in the Makefile.am.
+#
+
+#
+# Check for functions and header files. First write your code and then run
+# the 'autoscan' tool to get an idea what is still missing in your 'configure.ac'
+#
+# ----------------------------------------------------------------------------
+
+#
+# Ensure this file is easy to read. First list all switches and after that
+# make your descisions on the results of the switches
+#
+
#
# Debugging
#
-AC_MSG_CHECKING([whether to enable debugging])
-AC_ARG_ENABLE(debug,
- AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=yes@:>@]),
- [case "$enableval" in
- y | yes) CONFIG_DEBUG=yes ;;
- *) CONFIG_DEBUG=no ;;
- esac],
- [CONFIG_DEBUG=yes])
-AC_MSG_RESULT([${CONFIG_DEBUG}])
-if test "${CONFIG_DEBUG}" = "yes"; then
- CFLAGS="${CFLAGS} -Werror -Wsign-compare -Wfloat-equal -Wformat-security -g -O1"
- AC_DEFINE(DEBUG, 1, [debugging])
+AC_MSG_CHECKING([whether to enable debug])
+AC_ARG_ENABLE([debug],
+ [AS_HELP_STRING([--enable-debug],
+ [use debug compiler flags and macros @<:@default=disabled@:>@])],
+ [],
+ [enable_debug=no])
+AC_MSG_RESULT([${enable_debug}])
+
+#
+# Enable profiling support
+#
+AC_MSG_CHECKING([whether to enable profiling support])
+AC_ARG_ENABLE([profile],
+ [AS_HELP_STRING([--enable-profile],
+ [allow profiling @<:@default=disabled@:>@])],
+ [],
+ [enable_profile=no])
+AC_MSG_RESULT([${enable_profile}])
+
+#
+# Enable test coverage support
+#
+AC_MSG_CHECKING([whether to enable code coverage support])
+AC_ARG_ENABLE([coverage],
+ [AS_HELP_STRING([--enable-coverage],
+ [allow code coverage @<:@default=disabled@:>@])],
+ [],
+ [enable_coverage=no])
+AC_MSG_RESULT([${enable_coverage}])
+
+#
+# should the library export all symbols?
+#
+AC_MSG_CHECKING([whether to hide internal symbols])
+AC_ARG_ENABLE([hide],
+ [AS_HELP_STRING([--disable-hide],
+ [hide all internal library symbols @<:@default=enabled@:>@])],
+ [],
+ [enable_hide=yes])
+AC_MSG_RESULT([${enable_hide}])
+
+# ----------------------------------------------------------------------------
+
+#
+# add as much warnings as possible, but check what the compiler
+# is able to understand and use it only if possible
+#
+CC_CHECK_CFLAGS_SILENT([-pipe],[AM_CFLAGS="${AM_CFLAGS} -pipe"])
+CC_CHECK_CFLAGS_SILENT([-W],[AM_CFLAGS="${AM_CFLAGS} -W"])
+CC_CHECK_CFLAGS_SILENT([-Wall],[AM_CFLAGS="${AM_CFLAGS} -Wall"])
+CC_CHECK_CFLAGS_SILENT([-Wsign-compare],[AM_CFLAGS="${AM_CFLAGS} -Wsign-compare"])
+CC_CHECK_CFLAGS_SILENT([-Wfloat-equal],[AM_CFLAGS="${AM_CFLAGS} -Wfloat-equal"])
+CC_CHECK_CFLAGS_SILENT([-Wformat-security],[AM_CFLAGS="${AM_CFLAGS} -Wformat-security"])
+CC_CHECK_CFLAGS_SILENT([-Wno-unused-parameter],[AM_CFLAGS="${AM_CFLAGS} -Wno-unused-parameter"])
+
+#
+# Does the linker supports "--no-undefined"?
+#
+CC_NOUNDEFINED
+
+#
+# Can we register functions running at library's load time?
+#
+CC_ATTRIBUTE_CONSTRUCTOR([AC_DEFINE(PRERUN, 1, [run at link time])], [])
+
+#
+# Add only those libraries that are *really* used
+#
+CC_CHECK_LDFLAGS([-Wl,--as-needed], [AM_LDFLAGS="${AM_LDFLAGS} -Wl,--as-needed"],[])
+
+# -------------------------- use all the settings ----------------------------
+
+#
+# we must add the optimization downgrade at the end of CFLAGS, as the compiler
+# will get the flags in this order later on: $(AM_CFLAGS) $(CFLAGS)
+# So, the "-O1" would always overwritten, when we would add it to the AM_CFLAGS
+#
+if test "${enable_debug}" = "yes"; then
+ CFLAGS="${CFLAGS} -O1"
+ if test "${enable_hide}" = "yes"; then
+ AC_MSG_NOTICE([Hiding library symbols disabled due to debugging enabled])
+ fi
+ enable_hide=no
+ AC_DEFINE(DEBUG, 1, [debugging])
else
- CFLAGS="${CFLAGS} -O2"
+ AC_DEFINE(NDEBUG, 1, [no debugging])
+fi
+
+if test "${enable_profile}" = "yes"; then
+ CC_CHECK_CFLAGS_SILENT([-pg], [], [enable_profile=no])
+ CC_CHECK_LDFLAGS([-pg], [], [enable_profile=no])
+# still enabled?
+ if test "${enable_profile}" = "yes"; then
+ AC_DEFINE(PROFILING, 1, [profiling])
+ AM_CFLAGS="${AM_CFLAGS} -pg"
+ AM_LDFLAGS="${AM_LDFLAGS} -pg"
+ else
+ AC_MSG_NOTICE([Toolchain does not support profiling])
+ fi
+fi
+
+if test "${enable_coverage}" = "yes"; then
+ CC_CHECK_CFLAGS_SILENT([-fprofile-arcs -ftest-coverage], [], [enable_coverage=no])
+ CC_CHECK_LDFLAGS([-lgcov], [], [enable_coverage=no])
+# still enabled?
+ if test "${enable_coverage}" = "yes"; then
+ AC_DEFINE(COVERAGE, 1, [coverage])
+ AM_CFLAGS="${AM_CFLAGS} -fprofile-arcs -ftest-coverage"
+ AM_LDFLAGS="${AM_LDFLAGS} -lgcov"
+ else
+ AC_MSG_NOTICE([Toolchain does not support coverage])
+ fi
+fi
+
+#
+# Enable "-fvisibility=hidden" only if the used compiler supports it
+#
+if test "${enable_hide}" = "yes"; then
+
+ AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden])
+ CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden], [], [enable_hide=no])
+# still enabled?
+ if test "${enable_hide}" = "yes"; then
+ AC_DEFINE(DSO_HIDDEN, 1, [hide internal library symbols])
+ AM_CFLAGS="${AM_CFLAGS} -fvisibility=hidden"
+ fi
+ AC_MSG_RESULT([${enable_hide}]);
fi
+# ------------------------------- homework ------------------------------
+
+#
+# this library provides a pkg config file
+#
+pkgconfigdir=${libdir}/pkgconfig
+AC_SUBST(pkgconfigdir)
+
+# substitute the settings valid for all source files
+AC_SUBST(AM_CFLAGS)
+AC_SUBST(AM_CPPFLAGS)
+AC_SUBST(AM_LDFLAGS)
+
+# add private libs to the pkg-config file
+# 'private libs' are those required to link this library
+# its used later on if someone wants to link this library statically
+AC_SUBST(LIBS)
+
+# add required lib information to the pkg-config file (on demand)
+AC_SUBST(REQUIRES)
+
+# add lib information which may conflicts with this libarry
+AC_SUBST(CONFLICTS)
+
+# add special compile flags on demand
+AC_SUBST(PRIVATE_CFLAGS)
+
+# be very silent on request
+AM_CONDITIONAL(BUILD_SILENTLY, test "x$AM_DEFAULT_VERBOSITY" = x0)
AC_CONFIG_FILES([
Makefile
+ lib@name@.pc
])
AC_OUTPUT
+AC_MSG_RESULT([
+ ------------------------------------------------------
+ Configure results for: ${PACKAGE}
+ ------------------------------------------------------
+
+ Release State:
+ ------------------------------------------------------
+ Library API release: ${API_RELEASE}
+ Library release: ${LT_CURRENT}.${LT_REVISION}.${LT_AGE}
+ Package release: ${VERSION}
+
+ General:
+ ------------------------------------------------------
+ Cross compiling: ${cross_compiling}
+ Compiler: ${CC}
+ Target CPU: ${host_cpu}
+ Target OS: ${host_os}
+
+ Detected options:
+ ------------------------------------------------------
+ CPPFLAGS: ${AM_CPPFLAGS}
+ CFLAGS: ${AM_CFLAGS}
+ LDFLAGS: ${AM_LDFLAGS}
+ Hidden symbols ${enable_hide}
+ Coverage: ${enable_coverage}
+ Profiling: ${enable_profile}
+ Debug: ${enable_debug}
+ Private libs: ${LIBS}
+
+ User options:
+ ------------------------------------------------------
+ CFLAGS: ${CFLAGS}
+ CPPFLAGS: ${CPPFLAGS}
+ LDFLAGS: ${LDFLAGS}
+
+ Install options:
+ ------------------------------------------------------
+ prefix: ${prefix}
+ sysconfdir: ${sysconfdir}
+ libdir: ${libdir}
+ includedir: ${includedir}
+ bindir: ${bindir}
+ fast install: ${enable_fast_install}
+])
diff --git a/rules/templates/src-autoconf-lib/internal.h b/rules/templates/src-autoconf-lib/internal.h
new file mode 100644
index 0000000..3e15064
--- /dev/null
+++ b/rules/templates/src-autoconf-lib/internal.h
@@ -0,0 +1,29 @@
+/*
+ * (C) Copyright <year> <your name> <your mail address>
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+#include <assert.h>
+
+#ifdef DSO_HIDDEN
+# define DSO_VISIBLE __attribute__ ((visibility("default")))
+#else
+# define DSO_VISIBLE
+#endif
+
+#ifdef PRERUN
+# define INIT_LIB __attribute__((constructor))
+# define EXIT_LIB __attribute__((destructor))
+#else
+# define INIT_LIB
+# define EXIT_LIB
+#endif
diff --git a/rules/templates/src-autoconf-lib/lib@name@.h b/rules/templates/src-autoconf-lib/lib@name@.h
new file mode 100644
index 0000000..1f9f2f0
--- /dev/null
+++ b/rules/templates/src-autoconf-lib/lib@name@.h
@@ -0,0 +1,16 @@
+/*
+ * (C) Copyright <year> <your name> <your mail address>
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+extern int @name@_open(void);
+extern int @name@_close(void);
diff --git a/rules/templates/src-autoconf-lib/lib@name@.pc.in b/rules/templates/src-autoconf-lib/lib@name@.pc.in
new file mode 100644
index 0000000..5bbd850
--- /dev/null
+++ b/rules/templates/src-autoconf-lib/lib@name@.pc.in
@@ -0,0 +1,14 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: lib@name@
+Description: Add here the purpose of the library
+Version: @VERSION@
+URL: http://www.yourdomain.to/
+Requires: @REQUIRES@
+Conflicts: @CONFLICTS@
+Libs: -l@name@
+Libs.private: @LIBS@
+Cflags: -I${includedir} @PRIVATE_CFLAGS@
diff --git a/rules/templates/src-autoconf-lib/m4/attributes.m4 b/rules/templates/src-autoconf-lib/m4/attributes.m4
new file mode 100644
index 0000000..9d561c2
--- /dev/null
+++ b/rules/templates/src-autoconf-lib/m4/attributes.m4
@@ -0,0 +1,311 @@
+dnl Macros to check the presence of generic (non-typed) symbols.
+dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes@gmail.com>
+dnl Copyright (c) 2006-2008 xine project
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2, or (at your option)
+dnl any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+dnl
+dnl As a special exception, the copyright owners of the
+dnl macro gives unlimited permission to copy, distribute and modify the
+dnl configure scripts that are the output of Autoconf when processing the
+dnl Macro. You need not follow the terms of the GNU General Public
+dnl License when using or distributing such scripts, even though portions
+dnl of the text of the Macro appear in them. The GNU General Public
+dnl License (GPL) does govern all other use of the material that
+dnl constitutes the Autoconf Macro.
+dnl
+dnl This special exception to the GPL applies to versions of the
+dnl Autoconf Macro released by this project. When you make and
+dnl distribute a modified version of the Autoconf Macro, you may extend
+dnl this special exception to the GPL to apply to your modified version as
+dnl well.
+
+dnl Check if the flag is supported by compiler
+dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [
+ AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]),
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])],
+ [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"],
+ [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"])
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+ [$2], [$3])
+])
+
+dnl Check if the flag is supported by compiler (cacheable)
+dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_CFLAGS], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_cflags_$1]),
+ CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
+ )
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+ [$2], [$3])
+])
+
+dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
+dnl Check for CFLAG and appends them to CFLAGS if supported
+AC_DEFUN([CC_CHECK_CFLAG_APPEND], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_cflags_$1]),
+ CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
+ )
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+ [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3])
+])
+
+dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not])
+AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [
+ for flag in $1; do
+ CC_CHECK_CFLAG_APPEND($flag, [$2], [$3])
+ done
+])
+
+dnl Check if the flag is supported by linker (cacheable)
+dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_LDFLAGS], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_ldflags_$1]),
+ [ac_save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $1"
+ AC_LINK_IFELSE([int main() { return 1; }],
+ [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
+ [eval "AS_TR_SH([cc_cv_ldflags_$1])="])
+ LDFLAGS="$ac_save_LDFLAGS"
+ ])
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
+ [$2], [$3])
+])
+
+dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
+dnl the current linker to avoid undefined references in a shared object.
+AC_DEFUN([CC_NOUNDEFINED], [
+ dnl We check $host for which systems to enable this for.
+ AC_REQUIRE([AC_CANONICAL_HOST])
+
+ case $host in
+ dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
+ dnl are requested, as different implementations are present; to avoid problems
+ dnl use -Wl,-z,defs only for those platform not behaving this way.
+ *-freebsd* | *-openbsd*) ;;
+ *)
+ dnl First of all check for the --no-undefined variant of GNU ld. This allows
+ dnl for a much more readable commandline, so that people can understand what
+ dnl it does without going to look for what the heck -z defs does.
+ for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
+ CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
+ break
+ done
+ ;;
+ esac
+
+ AC_SUBST([LDFLAGS_NOUNDEFINED])
+])
+
+dnl Check for a -Werror flag or equivalent. -Werror is the GCC
+dnl and ICC flag that tells the compiler to treat all the warnings
+dnl as fatal. We usually need this option to make sure that some
+dnl constructs (like attributes) are not simply ignored.
+dnl
+dnl Other compilers don't support -Werror per se, but they support
+dnl an equivalent flag:
+dnl - Sun Studio compiler supports -errwarn=%all
+AC_DEFUN([CC_CHECK_WERROR], [
+ AC_CACHE_CHECK(
+ [for $CC way to treat warnings as errors],
+ [cc_cv_werror],
+ [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
+ [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
+ ])
+])
+
+AC_DEFUN([CC_CHECK_ATTRIBUTE], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
+ AS_TR_SH([cc_cv_attribute_$1]),
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
+ [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
+ [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
+ [AC_DEFINE(
+ AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
+ [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
+ )
+ $4],
+ [$5])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
+ CC_CHECK_ATTRIBUTE(
+ [constructor],,
+ [void __attribute__((constructor)) ctor() { int a; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
+ CC_CHECK_ATTRIBUTE(
+ [format], [format(printf, n, n)],
+ [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
+ CC_CHECK_ATTRIBUTE(
+ [format_arg], [format_arg(printf)],
+ [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
+ CC_CHECK_ATTRIBUTE(
+ [visibility_$1], [visibility("$1")],
+ [void __attribute__((visibility("$1"))) $1_function() { }],
+ [$2], [$3])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
+ CC_CHECK_ATTRIBUTE(
+ [nonnull], [nonnull()],
+ [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
+ CC_CHECK_ATTRIBUTE(
+ [unused], ,
+ [void some_function(void *foo, __attribute__((unused)) void *bar);],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
+ CC_CHECK_ATTRIBUTE(
+ [sentinel], ,
+ [void some_function(void *foo, ...) __attribute__((sentinel));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
+ CC_CHECK_ATTRIBUTE(
+ [deprecated], ,
+ [void some_function(void *foo, ...) __attribute__((deprecated));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
+ CC_CHECK_ATTRIBUTE(
+ [alias], [weak, alias],
+ [void other_function(void *foo) { }
+ void some_function(void *foo) __attribute__((weak, alias("other_function")));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
+ CC_CHECK_ATTRIBUTE(
+ [malloc], ,
+ [void * __attribute__((malloc)) my_alloc(int n);],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_PACKED], [
+ CC_CHECK_ATTRIBUTE(
+ [packed], ,
+ [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_CONST], [
+ CC_CHECK_ATTRIBUTE(
+ [const], ,
+ [int __attribute__((const)) twopow(int n) { return 1 << n; } ],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_FLAG_VISIBILITY], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
+ [cc_cv_flag_visibility],
+ [cc_flag_visibility_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
+ cc_cv_flag_visibility='yes',
+ cc_cv_flag_visibility='no')
+ CFLAGS="$cc_flag_visibility_save_CFLAGS"])
+
+ AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
+ [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
+ [Define this if the compiler supports the -fvisibility flag])
+ $1],
+ [$2])
+])
+
+AC_DEFUN([CC_FUNC_EXPECT], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([if compiler has __builtin_expect function],
+ [cc_cv_func_expect],
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+ [int some_function() {
+ int a = 3;
+ return (int)__builtin_expect(a, 3);
+ }])],
+ [cc_cv_func_expect=yes],
+ [cc_cv_func_expect=no])
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ AS_IF([test "x$cc_cv_func_expect" = "xyes"],
+ [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
+ [Define this if the compiler supports __builtin_expect() function])
+ $1],
+ [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
+ [cc_cv_attribute_aligned],
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ for cc_attribute_align_try in 64 32 16 8 4 2; do
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+ int main() {
+ static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
+ return c;
+ }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
+ done
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ if test "x$cc_cv_attribute_aligned" != "x"; then
+ AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
+ [Define the highest alignment supported])
+ fi
+])
diff --git a/rules/templates/src-autoconf-lib/wizard.sh b/rules/templates/src-autoconf-lib/wizard.sh
index f8db60e..89b1ba0 100644
--- a/rules/templates/src-autoconf-lib/wizard.sh
+++ b/rules/templates/src-autoconf-lib/wizard.sh
@@ -11,14 +11,18 @@ NAME_UP=$(echo $NAME | tr '[a-z-]' '[A-Z_]')
NAME_NODASH=$(echo $NAME | tr '-' '_')
mv "@name@.c" "${NAME}.c"
+mv "lib@name@.h" "lib${NAME}.h"
+mv "lib@name@.pc.in" "lib${NAME}.pc.in"
for i in \
configure.ac \
+ lib${NAME}.pc.in \
+ README \
Makefile.am \
${NAME}.c \
+ lib${NAME}.h \
; do
sed -i -e "s/\@name\@/${NAME}/g" $i
sed -i -e "s/\@namenodash\@/${NAME_NODASH}/g" $i
sed -i -e "s/\@NAME\@/${NAME_UP}/g" $i
done
-
--
Pengutronix e.K. | Juergen Beisert |
Linux Solutions for Science and Industry | http://www.pengutronix.de/ |
--
ptxdist mailing list
ptxdist@pengutronix.de
next reply other threads:[~2012-06-13 18:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-13 18:04 Juergen Beisert [this message]
2012-06-18 13:04 ` [ptxdist] [PATCH v2] src-autoconf-lib package template: " Juergen Beisert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201206132004.51279.jbe@pengutronix.de \
--to=jbe@pengutronix.de \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox