From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from gallifrey.ext.pengutronix.de ([2001:6f8:1178:4:5054:ff:fe8d:eefb] helo=localhost) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1SerxY-0001zZ-W0 for ptxdist@pengutronix.de; Wed, 13 Jun 2012 20:06:25 +0200 From: Juergen Beisert Date: Wed, 13 Jun 2012 20:04:50 +0200 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <201206132004.51279.jbe@pengutronix.de> Subject: [ptxdist] [RFC] src-autoconf-lib package template, this is a try to make it more 'feature' complete Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de Signed-off-by: Juergen Beisert diff --git a/rules/templates/src-autoconf-lib/@name@.c b/rules/templates/sr= c-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 + * + * 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 opt= ion) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or F= ITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for= more + * details. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include #include = -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. + 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 lice= nse + 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 =3D --no-print-directory +endif + +ACLOCAL_AMFLAGS =3D -I m4 ${ACLOCAL_FLAGS} + +# pkg's stuff +pkgconfigdir =3D \ + $(libdir)/pkgconfig + +pkgconfig_DATA =3D \ + lib@name@.pc + +# this one gets not installed, only internally used +noinst_HEADERS =3D \ + internal.h + +# this one gets installed to enable others to link against your library +include_HEADERS =3D \ + lib@name@.h + +# +# What is to build here +# lib_LTLIBRARIES =3D \ lib@name@.la = -AM_CPPFLAGS =3D \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include -# $(some_CFLAGS) - EXTRA_DIST =3D \ - autogen.sh + autogen.sh \ + m4/attributes.m4 \ + lib@name@.pc.in \ + COPYING = MAINTAINERCLEANFILES =3D \ - 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 =3D \ - @name@.c +# lib@namenodash@_la_CPPFLAGS =3D \ +# $(some_pre_processor_flags) + +# lib@namenodash@_la_CFLAGS =3D \ +# $(some_compiler_flags) = -#@namenodash@_LDADD =3D \ -# $(some_LIBS) +# lib@namenodash@_la_LIBADD =3D \ +# $(some_libs) = +# Note: It overrides the AM_LDFLAGS variable +lib@namenodash@_la_LDFLAGS =3D \ + $(AM_LDFLAGS) \ + @LDFLAGS_NOUNDEFINED@ \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ + -release $(API_RELEASE) + +lib@namenodash@_la_SOURCES =3D \ + @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 + -------- + + + + 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 check= s. + 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 symbo= ls + are visible. + + Environment Variables + --------------------- + + You can overwrite CPPFLAGS, CFLAGS and LDFLAGS from the environment. B= ut + keep in mind to not forget to add the "-O2 -g", if you use your own CF= LAGS + 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/template= s/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=3D$(basename $(pwd)); if test \"${d= ir%%-trunk}\" !=3D \"$dir\"; then echo 99999999-9; = else prefix=3D${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.y= ourdomain.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' chang= e it here +# AC_PREFIX_DEFAULT() = -CFLAGS=3D"${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=3D0 -# Interfaces added: AGE++ -# Interfaces removed: AGE=3D0 +# Using this variables results into +# +# lib-.so. +# +# API_RELEASE: API compatibility. Its up to you to define a specific versi= on 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 =3D 0 +# - interfaces added: LT_AGE++ +# - interfaces removed: LT_AGE =3D 0 +# +API_RELEASE=3D0.0 +AC_SUBST(API_RELEASE) + +# Library release LT_CURRENT=3D0 LT_REVISION=3D0 LT_AGE=3D0 + 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 compile= time. +# This means it will not be compiled by a cross compiler, the host compile= r is +# used instead. For the non cross compile case nothing change +# + +# AC_MSG_CHECKING([if cross compiling]) +# if test "x${cross_compiling}" =3D "xno"; then +# CC_FOR_BUILD=3D${CC_FOR_BUILD-${CC-gcc}} +# else +# CC_FOR_BUILD=3D${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, C= FLAGS +# 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 def= ault! +# Keep the user informed about this behaviour. = -## -# libsomething -## -#REQUIRES_LIBSOMETHING=3D"libsomething >=3D 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 fi= les. +# These libraries _must_ be listed in the *.pc file. +# +# Don't add libraries without a check. Even if you know the 'sqrt()' requi= res +# 'libm' on most systems, check for its real need with 'AC_SEARCH_LIBS(sqr= t, 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 p= lease +# 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 'config= ure.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=3Dyes@:= >@]), - [case "$enableval" in - y | yes) CONFIG_DEBUG=3Dyes ;; - *) CONFIG_DEBUG=3Dno ;; - esac], - [CONFIG_DEBUG=3Dyes]) -AC_MSG_RESULT([${CONFIG_DEBUG}]) -if test "${CONFIG_DEBUG}" =3D "yes"; then - CFLAGS=3D"${CFLAGS} -Werror -Wsign-compare -Wfloat-equal -Wformat-secu= rity -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=3Ddisabled@:>@])], + [], + [enable_debug=3Dno]) +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=3Ddisabled@:>@])], + [], + [enable_profile=3Dno]) +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=3Ddisabled@:>@])], + [], + [enable_coverage=3Dno]) +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=3Denabled@:>@])], + [], + [enable_hide=3Dyes]) +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=3D"${AM_CFLAGS} -pipe"]) +CC_CHECK_CFLAGS_SILENT([-W],[AM_CFLAGS=3D"${AM_CFLAGS} -W"]) +CC_CHECK_CFLAGS_SILENT([-Wall],[AM_CFLAGS=3D"${AM_CFLAGS} -Wall"]) +CC_CHECK_CFLAGS_SILENT([-Wsign-compare],[AM_CFLAGS=3D"${AM_CFLAGS} -Wsign-= compare"]) +CC_CHECK_CFLAGS_SILENT([-Wfloat-equal],[AM_CFLAGS=3D"${AM_CFLAGS} -Wfloat-= equal"]) +CC_CHECK_CFLAGS_SILENT([-Wformat-security],[AM_CFLAGS=3D"${AM_CFLAGS} -Wfo= rmat-security"]) +CC_CHECK_CFLAGS_SILENT([-Wno-unused-parameter],[AM_CFLAGS=3D"${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=3D"${AM_LDFLAGS} -Wl,--as-= needed"],[]) + +# -------------------------- use all the settings ------------------------= ---- + +# +# we must add the optimization downgrade at the end of CFLAGS, as the comp= iler +# 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_C= FLAGS +# +if test "${enable_debug}" =3D "yes"; then + CFLAGS=3D"${CFLAGS} -O1" + if test "${enable_hide}" =3D "yes"; then + AC_MSG_NOTICE([Hiding library symbols disabled due to debugging enabled]) + fi + enable_hide=3Dno + AC_DEFINE(DEBUG, 1, [debugging]) else - CFLAGS=3D"${CFLAGS} -O2" + AC_DEFINE(NDEBUG, 1, [no debugging]) +fi + +if test "${enable_profile}" =3D "yes"; then + CC_CHECK_CFLAGS_SILENT([-pg], [], [enable_profile=3Dno]) + CC_CHECK_LDFLAGS([-pg], [], [enable_profile=3Dno]) +# still enabled? + if test "${enable_profile}" =3D "yes"; then + AC_DEFINE(PROFILING, 1, [profiling]) + AM_CFLAGS=3D"${AM_CFLAGS} -pg" + AM_LDFLAGS=3D"${AM_LDFLAGS} -pg" + else + AC_MSG_NOTICE([Toolchain does not support profiling]) + fi +fi + +if test "${enable_coverage}" =3D "yes"; then + CC_CHECK_CFLAGS_SILENT([-fprofile-arcs -ftest-coverage], [], [enable_cove= rage=3Dno]) + CC_CHECK_LDFLAGS([-lgcov], [], [enable_coverage=3Dno]) +# still enabled? + if test "${enable_coverage}" =3D "yes"; then + AC_DEFINE(COVERAGE, 1, [coverage]) + AM_CFLAGS=3D"${AM_CFLAGS} -fprofile-arcs -ftest-coverage" + AM_LDFLAGS=3D"${AM_LDFLAGS} -lgcov" + else + AC_MSG_NOTICE([Toolchain does not support coverage]) + fi +fi + +# +# Enable "-fvisibility=3Dhidden" only if the used compiler supports it +# +if test "${enable_hide}" =3D "yes"; then + + AC_MSG_CHECKING([whether the compiler supports -fvisibility=3Dhidden]) + CC_CHECK_CFLAGS_SILENT([-fvisibility=3Dhidden], [], [enable_hide=3Dno]) +# still enabled? + if test "${enable_hide}" =3D "yes"; then + AC_DEFINE(DSO_HIDDEN, 1, [hide internal library symbols]) + AM_CFLAGS=3D"${AM_CFLAGS} -fvisibility=3Dhidden" + fi + AC_MSG_RESULT([${enable_hide}]); fi = +# ------------------------------- homework ------------------------------ + +# +# this library provides a pkg config file +# +pkgconfigdir=3D${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" =3D 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 + * + * 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 opt= ion) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or F= ITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for= more + * details. + */ + +#include + +#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 + * + * 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 opt= ion) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or F= ITNESS + * 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/templ= ates/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=3D@prefix@ +exec_prefix=3D@exec_prefix@ +libdir=3D@libdir@ +includedir=3D@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/temp= lates/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=C3=B2 +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=3D"$CFLAGS" + CFLAGS=3D"$CFLAGS $1" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])], + [eval "AS_TR_SH([cc_cv_cflags_$1])=3D'yes'"], + [eval "AS_TR_SH([cc_cv_cflags_$1])=3D'no'"]) + CFLAGS=3D"$ac_save_CFLAGS" + ]) + + AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ =3D 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])[ =3D 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])[ =3D xyes], + [CFLAGS=3D"$CFLAGS $1"; DEBUG_CFLAGS=3D"$DEBUG_CFLAGS $1"; $2], [$3]) +]) + +dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-no= t]) +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=3D"$LDFLAGS" + LDFLAGS=3D"$LDFLAGS $1" + AC_LINK_IFELSE([int main() { return 1; }], + [eval "AS_TR_SH([cc_cv_ldflags_$1])=3D'yes'"], + [eval "AS_TR_SH([cc_cv_ldflags_$1])=3D"]) + LDFLAGS=3D"$ac_save_LDFLAGS" + ]) + + AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ =3D 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 whe= n 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. T= his allows + dnl for a much more readable commandline, so that people can under= stand 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=3D"$pos= sible_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=3D%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=3D-Werror], + [CC_CHECK_CFLAGS_SILENT([-errwarn=3D%all], [cc_cv_werror=3D-errwarn= =3D%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=3D"$CFLAGS" + CFLAGS=3D"$CFLAGS $cc_cv_werror" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])], + [eval "AS_TR_SH([cc_cv_attribute_$1])=3D'yes'"], + [eval "AS_TR_SH([cc_cv_attribute_$1])=3D'no'"]) + CFLAGS=3D"$ac_save_CFLAGS" + ]) + + AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ =3D 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 =3D (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) { f= mt =3D (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 =3D (void*)0; bar =3D (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_funct= ion")));], + [$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=3Dhidden], + [cc_cv_flag_visibility], + [cc_flag_visibility_save_CFLAGS=3D"$CFLAGS" + CFLAGS=3D"$CFLAGS $cc_cv_werror" + CC_CHECK_CFLAGS_SILENT([-fvisibility=3Dhidden], + cc_cv_flag_visibility=3D'yes', + cc_cv_flag_visibility=3D'no') + CFLAGS=3D"$cc_flag_visibility_save_CFLAGS"]) + + AS_IF([test "x$cc_cv_flag_visibility" =3D "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=3D"$CFLAGS" + CFLAGS=3D"$CFLAGS $cc_cv_werror" + AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [int some_function() { + int a =3D 3; + return (int)__builtin_expect(a, 3); + }])], + [cc_cv_func_expect=3Dyes], + [cc_cv_func_expect=3Dno]) + CFLAGS=3D"$ac_save_CFLAGS" + ]) + + AS_IF([test "x$cc_cv_func_expect" =3D "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=3D"$CFLAGS" + CFLAGS=3D"$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)= )) =3D 0; + return c; + }])], [cc_cv_attribute_aligned=3D$cc_attribute_align_try; break]) + done + CFLAGS=3D"$ac_save_CFLAGS" + ]) + + if test "x$cc_cv_attribute_aligned" !=3D "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/s= rc-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=3D$(echo $NAME | tr '[a-z-]' '[A-Z_]') NAME_NODASH=3D$(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