[yocto] RFC: autotooler: generation of "configure.ac" and "Makefile.am" using Kconfig

Aaron Schwartz aaron.schwartz at logicsupply.com
Mon Oct 2 11:01:20 PDT 2017


Are you looking to use menuconfig to configure your packages?  BusyBox does
this [0] pretty well in my experience, you might take a look at how they've
put that together.

0) https://busybox.net/FAQ.html#configure

On Sat, Sep 30, 2017 at 10:49 AM, Ulf Samuelsson <yocto at emagii.com> wrote:

> Have a need to convert a large number of libraries to use autotools.
>
> I came up with the following idea:
>
> I create an Kconfig based configuration system, where you define a number
> of configuration items needed by configure.ac and Makefile.am
>
> You choose if you want to build an application, a shared library or a
> static library.
>
> The build normally depends on other libraries, and you checkmarks
> which library you are interested in from a (small) number of supported
> libraries.
> You can likewise select to support options like "--enable-openssl",
> again from a (small) number of supported options.
>
> If you have stuff not supported, the autotooler will include Config.in
> files allowing you to add your own items.
>
> Once the configuration is complete, you will compile an application
> which will generate "configure.ac" from the configuration file.
>
> Again, if you have stuff not supported in the code, you can add it
> in a user include file.
>
> The generator will read a user-headers.inc file and
> generate an AC_CHECK_HEADERS entry.
>
>
> The autotooler is available on
>         https://www.github.com/emagii/autotooler.git
>
> ===================================================================
> Currently, it does not generate any Makefile.am files, but
> the idea is to separate the source files into
> * C source
> * Public Headers
> * Local Headers
>
> A tool would then scan the directories and classify them accordingly,
> so Makefile.am files should be possible to generate fairly easy.
>
> ===================================================================
> A final step would clone a empty git tree, and populate it
> with all the files needed for a complete package.
> ===================================================================
>
> Comments appreciated.
>
> Best Regards
> Ulf Samuelsson
> ===================================================================
> Here is a typical "autoconh.h" generated by Kconfig.
>
> /*
>  * Automatically generated C config: don't edit
>  * Sat Sep 30 16:27:24 2017
>  */
> #define CONFIG_SHARED_LIB 1
> #define CONFIG_PTHREAD 1
> #define CONFIG_LIBRARY 1
> #define CONFIG_PROJECT "myproject"
> #define CONFIG_WORKDIR "${HOME}/projects/autotooler"
> #define CONFIG_OPENSSL 1
> #define CONFIG_CURL 1
> #define CONFIG_COPYRIGHT_DATE "2017"
> #define CONFIG_HOMEPAGE "http://www.emagii.com/"
> #define CONFIG_EXAMPLES 1
> #define CONFIG_DEBUG 1
> #define HAVE_DOT_CONFIG 1
> #define CONFIG_AC_PRERQ "2.59"
> #define CONFIG_BOOST 1
> #define CONFIG_OS_LINUX 1
> #define CONFIG_LIBRARY_NAME "libyocto"
> #define CONFIG_AUTHOR_EMAIL "ulf at emagii.com"
> #define CONFIG_LIBRARY_VERSION "1.0"
> #define CONFIG_AC_CONFIG_HEADER "src/include/config.h"
> #define CONFIG_OS "Linux"
> #define CONFIG_EXAMPLES_VAR "examples"
> #define CONFIG_AC_CONFIG_MACRO_DIR "m4"
> #define CONFIG_DEBUG_VAR "debug"
> #define CONFIG_PROJECT_TYPE "library"
> #define CONFIG_SRCDIR "src"
> #define CONFIG_SRC_URI_REPO ""
> #define CONFIG_AUTHOR "Ulf Samuelsson"
> #define CONFIG_SRC_URI_HOST "https://www.github.com/emagii"
> #define CONFIG_CURLPP 1
> #define CONFIG_AM_INIT_AUTOMAKE "1.10 -Wall no-define"
>
> The application will from this information generate:
>
> AC_INIT([libyocto],
>         [1.0],
>         [Ulf Samuelsson],
>         [libyocto-1.0],
>         [http://www.emagii.com/])
>
> AC_PRERQ([2.59])
>
> AC_CONFIG_HEADER([src/include/config.h])
>
> AC_CONFIG_SRCDIR([src])
>
> AC_PROG_CPP
> AC_PROG_CC
> AC_INIT_AUTOMAKE([1.10 -Wall no-define])
>
> AC_PROG_MAKE_SET
> AM_MAINTAINER_MODE
> AC_HEADER_STDC
> AC_ENABLE_SHARED
> AC_DISABLE_STATIC
> AC_PROG_LIBTOOL
> AC_HEADER_STDC
>
> AC_CHECK_HEADERS( \
>         ctype.h \
>         errno.h \
>         fcntl.h \
>         openssl/bio.h \
>         openssl/err.h \
>         openssl/opensslconf.h \
>         openssl/rand.h \
>         openssl/ssl.h \
>         pthread.h \
>         stdio.h \
>         stdlib.h \
>         stdarg.h \
>         stdint.h \
>         string.h \
>         signal.h \
>         sys/ioctl.h \
>         sys/socket.h \
>         sys/time.h \
>         sys/types.h \
>         time.h \
>         unistd.h \
>          \
>         ,
> dnl to do if not found
>         [],
> dnl to do if not found
>         [],
> dnl default includes
>         [
> #ifdef HAVE_SYS_TYPES_H
> #include <sys/types.h>
> #endif
> #ifdef HAVE_SYS_TIME_H
> #include <sys/time.h>
> #endif
> dnl We do this default-include simply to make sure that the
> nameser_compat.h
> dnl header *REALLY* can be include after the new nameser.h. It seems AIX
> 5.1
> dnl (and others?) is not designed to allow this.
> #ifdef HAVE_ARPA_NAMESER_H
> #include <arpa/nameser.h>
> #endif
>
> dnl *Sigh* these are needed in order for net/if.h to get properly detected.
> #ifdef HAVE_SYS_SOCKET_H
> #include <sys/socket.h>
> #endif
> #ifdef HAVE_NETINET_IN_H
> #include <netinet/in.h>
> #endif
> ]
> )
>
> # ==== Boost Libraries
> AC_ARG_WITH([boost-include-path],
>         [AS_HELP_STRING([--with-boost-include-path],[location of the
> Boost headers, defaults to /usr/include/boost])],
>         [CXXFLAGS_BOOST="-I$withval"],
>         [CXXFLAGS_BOOST="-I/usr/include/boost"])
> AC_SUBST([BOOST_CFLAGS])
>
> AC_ARG_WITH([boost-lib-path],
>         [AS_HELP_STRING([--with-boost-lib-path],[location of the Boost
> libraries, defaults to /usr/lib])],
>         [BOOST_LIBS="-L$withval" -lboost_system -lboost_filesystem
> -lboost_program_options -lboost_thread -lpthread],
>         [BOOST_LIBS="-L/usr/lib -lboost_system -lboost_filesystem
> -lboost_program_options -lboost_thread -lpthread"])
> AC_SUBST([BOOST_LIBS])
>
> AC_ARG_ENABLE(boost,
>         [--enable-boost Include Boost Libraries],
>         [case "${enableval}" in
>                 yes)    use_boost=true  ;;
>                 no)     use_boost=false ;;
>                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-boost)
> ;;
>          esac
>         ],
>         [use_boost=false])
> AM_CONDITIONAL(CONFIG_BOOST, test x$boost = xtrue)
>
> # ==== cURL Libraries
> AC_ARG_WITH([curl-include-path],
>         [AS_HELP_STRING([--with-curl-include-path],[location of the cURL
> headers, defaults to /usr/include])],
>         [CXXFLAGS_CURL="-I$withval"],
>         [CXXFLAGS_CURL="-I/usr/include"])
> AC_SUBST([CURL_CFLAGS])
>
> AC_ARG_WITH([curl-lib-path],
>         [AS_HELP_STRING([--with-curl-lib-path],[location of the cURL
> libraries, defaults to /usr/lib])],
>         [CURL_LIBS="-L$withval" -lcurl],
>         [CURL_LIBS="-L/usr/lib -lcurl"])
> AC_SUBST([CURL_LIBS])
>
> AC_ARG_ENABLE(curl,
>         [--enable-curl  Include cURL],
>         [case "${enableval}" in
>                 yes)    use_curl=true  ;;
>                 no)     use_curl=false ;;
>                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-curl)
> ;;
>          esac
>         ],
>         [use_curl=false])
> AM_CONDITIONAL(CONFIG_CURL, test x$curl = xtrue)
>
> # ==== cURLPP Libraries
> AC_ARG_WITH([curlpp-include-path],
>         [AS_HELP_STRING([--with-curlpp-include-path],[location of the
> cURLPP headers, defaults to /usr/include])],
>         [CXXFLAGS_CURLPP="-I$withval"],
>         [CXXFLAGS_CURLPP="-I/usr/include"])
> AC_SUBST([CURLPP_CFLAGS])
>
> AC_ARG_WITH([curlpp-lib-path],
>         [AS_HELP_STRING([--with-curlpp-lib-path],[location of the cURLPP
> libraries, defaults to /usr/lib])],
>         [CURLPP_LIBS="-L$withval" -lcurlpp -lutilspp],
>         [CURLPP_LIBS="-L/usr/lib -lcurlpp -lutilspp"])
> AC_SUBST([CURLPP_LIBS])
>
> AC_ARG_ENABLE(curlpp,
>         [--enable-curlpp        Include cURLPP],
>         [case "${enableval}" in
>                 yes)    use_curlpp=true  ;;
>                 no)     use_curlpp=false ;;
>                 *) AC_MSG_ERROR(bad value ${enableval} for
> --enable-curlpp) ;;
>          esac
>         ],
>         [use_curlpp=false])
> AM_CONDITIONAL(CONFIG_CURLPP, test x$curlpp = xtrue)
>
> # ==== OpenSSL Libraries
> AC_ARG_WITH([openssl-include-path],
>         [AS_HELP_STRING([--with-openssl-include-path],[location of the
> OpenSSL headers, defaults to /usr/include])],
>         [CFLAGS_OPENSSL="-I$withval"],
>         [CFLAGS_OPENSSL="-I/usr/include"])
> AC_SUBST([OPENSSL_CFLAGS])
>
> AC_ARG_WITH([openssl-lib-path],
>         [AS_HELP_STRING([--with-openssl-lib-path],[location of the
> OpenSSL libraries, defaults to /usr/lib])],
>         [OPENSSL_LIBS="-L$withval" -lssl],
>         [OPENSSL_LIBS="-L/usr/lib -lssl"])
> AC_SUBST([OPENSSL_LIBS])
>
> AC_ARG_ENABLE(openssl,
>         [--enable-openssl       Include OpenSSL],
>         [case "${enableval}" in
>                 yes)    use_openssl=true  ;;
>                 no)     use_openssl=false ;;
>                 *) AC_MSG_ERROR(bad value ${enableval} for
> --enable-openssl) ;;
>          esac
>         ],
>         [use_openssl=false])
> AM_CONDITIONAL(CONFIG_OPENSSL, test x$openssl = xtrue)
>
> # ==== Pthread Libraries
> AC_ARG_WITH([pthread-include-path],
>         [AS_HELP_STRING([--with-pthread-include-path],[location of the
> PThread headers, defaults to /usr/include])],
>         [CFLAGS_PTHREAD="-I$withval"],
>         [CFLAGS_PTHREAD="-I/usr/include"])
> AC_SUBST([PTHREAD_CFLAGS])
>
> AC_ARG_WITH([pthread-lib-path],
>         [AS_HELP_STRING([--with-pthread-lib-path],[location of the
> PThread libraries, defaults to /usr/include])],
>         [PTHREAD_LIBS="-L$withval" -lpthread],
>         [PTHREAD_LIBS="-L/usr/include -lpthread"])
> AC_SUBST([PTHREAD_LIBS])
>
> AC_ARG_ENABLE(pthread,
>         [--enable-pthread       Include PThreads],
>         [case "${enableval}" in
>                 yes)    use_pthread=true  ;;
>                 no)     use_pthread=false ;;
>                 *) AC_MSG_ERROR(bad value ${enableval} for
> --enable-pthread) ;;
>          esac
>         ],
>         [use_pthread=false])
> AM_CONDITIONAL(CONFIG_PTHREAD, test x$pthread = xtrue)
>
> # ==== Debug
> AC_ARG_ENABLE(debug,
>         [--enable-debug Build with DEBUG enabled],
>         [case "${enableval}" in
>                 yes)    debug=true  ;;
>                 no)     debug=false ;;
>                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
> ;;
>          esac
>         ],
>         [debug=false])
> AM_CONDITIONAL(CONFIG_DEBUG, test x$debug = xtrue)
>
> AC_ARG_ENABLE(examples,
>         [--enable-examples      Build examples],
>         [case "${enableval}" in
>                 yes)    examples=true  ;;
>                 no)     examples=false ;;
>                 *) AC_MSG_ERROR(bad value ${enableval} for
> --enable-examples) ;;
>          esac
>         ],
>         [examples=false])
> AM_CONDITIONAL(CONFIG_EXAMPLES, test x$examples = xtrue)
>
> AC_SUBST([CFLAGS])
> AC_CONFIG_FILES([Makefile  libyocto.pc])
> AC_OUTPUT
> --
> _______________________________________________
> yocto mailing list
> yocto at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>



-- 

Aaron Schwartz
Production
Logic Supply
Direct: +1 802 861 2300 Ext. 530
Main: +1 802 861 2300
www.logicsupply.com

Google+ <https://plus.google.com/+Logicsupply/posts> | Twitter
<https://twitter.com/logicsupply> | LinkedIn
<https://www.linkedin.com/company/logic-supply> | YouTube
<https://www.youtube.com/user/logicsupply>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20171002/8a12d5f3/attachment.html>


More information about the yocto mailing list