From 2e5b48374d80959256e535bc1973f032158bde9e Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 15 Aug 2012 16:46:33 -0400 Subject: [PATCH] Import exported.sh from cdecl99. This script is required for the glconfig.mk snippet to actually work, but it somehow got forgotten when that snippet was imported. Bring in the script, and add M4 plumbing to support finding auxilliary files in the dxcommon source directory. The result should be totally automatic, although this unfortunately means that users of fix-gnulib.pl that don't need or want to use glconfig.mk are stuck with some extra dependencies (including libtool) to generate the exported.sh script. Currently, I can't think of a way to keep the automatic glconfig.mk support (i.e., the only thing users really have to do is include the snippet for it to work) without this spurious dependency. So things may need to change later, but let's just get the support in for now. --- m4/base.m4 | 55 ++++++++++++++++++++++++++++++++++++++++++ m4/dx-stamp.m4 | 4 +++ m4/exported.m4 | 16 ++++++++++++ scripts/fix-gnulib.pl | 6 ++++- snippet/exported.sh.in | 44 +++++++++++++++++++++++++++++++++ 5 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 m4/base.m4 create mode 100644 m4/dx-stamp.m4 create mode 100644 m4/exported.m4 create mode 100644 snippet/exported.sh.in diff --git a/m4/base.m4 b/m4/base.m4 new file mode 100644 index 0000000..5be583c --- /dev/null +++ b/m4/base.m4 @@ -0,0 +1,55 @@ +dnl Copyright © 2012 Nick Bowler +dnl +dnl Base definitions for dxcommon. +dnl +dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2. +dnl This is free software: you are free to do what the fuck you want to. +dnl There is NO WARRANTY, to the extent permitted by law. + +m4_pattern_forbid([^_?DX_]) + +dnl DX_INIT([directory]) +dnl +dnl Sets the directory of the dxcommon checkout, which is used by other macros +dnl to find any source files that they may need. If this file was included +dnl from its original location using m4_include, which normally happens when +dnl using aclocal, then the directory will be determined automatically (and +dnl this macro does not need to be called in configure.ac at all). Otherwise, +dnl this should be called prior to any other dxcommon macro. + +m4_define([_DX_BASE_FILE], __file__) +AC_DEFUN_ONCE([DX_INIT], [dnl + +dnl Care must be taken to avoid spurious expansions of things that look like +dnl macros in the filename; this is made especially difficult since +dnl m4_bpatsubst does not expand to a quoted string. +m4_define([_DX_BASEDIR], m4_if([$1], [], + [m4_bpatsubst(m4_dquote(m4_defn([_DX_BASE_FILE])), + [/m4/[^/]*\.m4\(.\)$], [\1])], + [[$1]])) + +dnl Include the stamp file, which will cause a failure at autoconf time +dnl if it does not exist in the checkout. We circumvent m4_include to +dnl avoid warnings about multiple inclusions. +m4_builtin([include], m4_defn([_DX_BASEDIR])[/m4/dx-stamp.m4]) +_DX_STAMP_DUMMY + +dnl Autoconf scripts should use the DX_BASEDIR m4 macro instead of the +dnl AC_SUBSTed shell variable, but we use the same name for the macro since +dnl it means the same thing as the substituted variable. +dnl +dnl Autoconf versions <= 2.69 have a bug which causes the first argument of +dnl AC_SUBST to be expanded as a macro when using the two-argument form. So +dnl until we require a newer version of autoconf, we must use the one-argument +dnl form of AC_SUBST. + +[DX_BASEDIR]="AS_ESCAPE(m4_dquote(m4_defn([_DX_BASEDIR])))" +m4_pushdef([m4_pattern_allow]) +AC_SUBST([DX_BASEDIR]) +m4_popdef([m4_pattern_allow]) +]) + +AC_DEFUN([DX_BASEDIR], [dnl +AC_REQUIRE([DX_INIT])dnl +m4_defn([_DX_BASEDIR])dnl +]) diff --git a/m4/dx-stamp.m4 b/m4/dx-stamp.m4 new file mode 100644 index 0000000..5b64a7c --- /dev/null +++ b/m4/dx-stamp.m4 @@ -0,0 +1,4 @@ +dnl This m4 snippet does nothing; its existence is used to identify the +dnl dxcommon checkout location. We define a dummy macro so that aclocal +dnl can pick it up. +AC_DEFUN([_DX_STAMP_DUMMY]) diff --git a/m4/exported.m4 b/m4/exported.m4 new file mode 100644 index 0000000..d4a613b --- /dev/null +++ b/m4/exported.m4 @@ -0,0 +1,16 @@ +dnl Copyright © 2012 Nick Bowler +dnl +dnl Generate the exported.sh script used to determine the exported symbols of +dnl a (libtool) object file. This is required by the glconfig Automake +dnl fragment, but will be called automatically in that case. +dnl +dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2. +dnl This is free software: you are free to do what the fuck you want to. +dnl There is NO WARRANTY, to the extent permitted by law. + +AC_DEFUN([DX_EXPORTED_SH], [dnl +AC_REQUIRE([DX_INIT]) + +AC_CONFIG_FILES([exported.sh:]DX_BASEDIR[/snippet/exported.sh.in], + [chmod +x exported.sh]) +]) diff --git a/scripts/fix-gnulib.pl b/scripts/fix-gnulib.pl index 8b61163..e043d77 100755 --- a/scripts/fix-gnulib.pl +++ b/scripts/fix-gnulib.pl @@ -236,7 +236,11 @@ if FALSE ], [dnl M4 code follows AC_SUBST([GLSRC], [lib]) -AC_DEFUN_ONCE([DX_GLSYM_PREFIX], [AC_SUBST([GLSYM_PREFIX], [$1])]) + +AC_DEFUN_ONCE([DX_GLSYM_PREFIX], [dnl +AC_REQUIRE([DX_EXPORTED_SH]) +AC_SUBST([GLSYM_PREFIX], [$1]) +]) AC_CONFIG_COMMANDS_PRE([DX_GLSYM_PREFIX([${PACKAGE}__])]) m4_foreach([gl_objvar], [[gl_LIBOBJS], [gl_LTLIBOBJS]], [dnl diff --git a/snippet/exported.sh.in b/snippet/exported.sh.in new file mode 100644 index 0000000..762600a --- /dev/null +++ b/snippet/exported.sh.in @@ -0,0 +1,44 @@ +#!@SHELL@ +# +# Copyright © 2011 Nick Bowler +# +# Determine the list of exported symbols from archives or (libtool) object +# files. +# +# License WTFPL2: Do What The Fuck You Want To Public License, version 2. +# This is free software: you are free to do what the fuck you want to. +# There is NO WARRANTY, to the extent permitted by law. + +OBJS= + +while test $# -gt 0 +do + case $1 in + /*) arg=$1 ;; + *) arg=./$1 ;; + esac + + if expr "$arg" : '.*\.lo' >/dev/null; then + non_pic_object= + pic_object= + . "$arg" + + dir=`expr "$arg" : '\(.*\)/'` + if test x"$pic_object" != x"none"; then + OBJS="$OBJS $dir/$pic_object" + fi + if test x"$non_pic_object" != x"none"; then + OBJS="$OBJS $dir/$non_pic_object" + fi + else + OBJS="$OBJS $arg" + fi + + shift +done + +set x $OBJS; shift +case $# in +0) : ;; +*) @NM@ $OBJS | @GLOBAL_SYMBOL_PIPE@ | @SED@ 's/^.* //' | sort | uniq ;; +esac -- 2.43.0