mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
package: make bison a relocatable package
Suggested by David Barto https://lists.gnu.org/archive/html/help-bison/2015-02/msg00004.html and Victor Zverovich. https://lists.gnu.org/archive/html/bison-patches/2018-10/msg00121.html This is very easy to do, thanks to work by Bruno Haible in gnulib. See "Supporting Relocation" in gnulib's documentation. * bootstrap.conf: We need relocatable-prog and relocatable-script (for yacc). * src/yacc.in: New. * configure.ac, src/local.mk: Instantiate it. * src/main.c, src/output.c (main, pkgdatadir): Use relocatable2. * doc/bison.texi (FAQ): Document it.
This commit is contained in:
9
NEWS
9
NEWS
@@ -24,6 +24,15 @@ GNU Bison NEWS
|
||||
|
||||
** New features
|
||||
|
||||
*** Bison is now relocatable
|
||||
|
||||
If you pass '--enable-relocatable' to 'configure', Bison is relocatable.
|
||||
|
||||
A relocatable program can be moved or copied to a different location on
|
||||
the file system. It can also be used through mount points for network
|
||||
sharing. It is possible to make symlinks to the installed and moved
|
||||
programs, and invoke them through the symlink.
|
||||
|
||||
*** %expect and %expect-rr modifiers on individual rules
|
||||
|
||||
One can now document (and check) which rules participate in shift/reduce
|
||||
|
||||
10
README
10
README
@@ -8,6 +8,16 @@ Bison requires GNU m4 1.4.6 or later. See:
|
||||
|
||||
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz
|
||||
|
||||
** Relocatability
|
||||
If you pass '--enable-relocatable' to 'configure', Bison is relocatable.
|
||||
|
||||
A relocatable program can be moved or copied to a different location on the
|
||||
file system. It can also be used through mount points for network sharing.
|
||||
It is possible to make symlinks to the installed and moved programs, and
|
||||
invoke them through the symlink.
|
||||
|
||||
See "Enabling Relocatability" in the documentation.
|
||||
|
||||
** Internationalization
|
||||
Bison supports two catalogs: one for Bison itself (i.e., for the
|
||||
maintainer-side parser generation), and one for the generated parsers (i.e.,
|
||||
|
||||
2
THANKS
2
THANKS
@@ -40,6 +40,7 @@ Dagobert Michelsen dam@baltic-online.de
|
||||
Daniel Frużyński daniel@poradnik-webmastera.com
|
||||
Daniel Galloway dg1751@att.com
|
||||
Daniel Hagerty hag@gnu.org
|
||||
David Barto david.barto@sparqlcity.com
|
||||
David J. MacKenzie djm@gnu.org
|
||||
David Kastrup dak@gnu.org
|
||||
David Michael fedora.dm0@gmail.com
|
||||
@@ -174,6 +175,7 @@ Troy A. Johnson troyj@ecn.purdue.edu
|
||||
Tys Lefering gccbison@gmail.com
|
||||
Valentin Tolmer nitnelave1@gmail.com
|
||||
Victor Khomenko victor.khomenko@newcastle.ac.uk
|
||||
Victor Zverovich victor.zverovich@gmail.com
|
||||
Vin Shelton acs@alumni.princeton.edu
|
||||
W.C.A. Wijngaards wouter@NLnetLabs.nl
|
||||
Wayne Green wayne@infosavvy.com
|
||||
|
||||
@@ -35,6 +35,7 @@ gnulib_modules='
|
||||
quote quotearg
|
||||
readme-release
|
||||
realloc-posix
|
||||
relocatable-prog relocatable-script
|
||||
spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp
|
||||
timevar
|
||||
unistd unistd-safer unlink unlocked-io
|
||||
|
||||
4
build-aux/.gitignore
vendored
4
build-aux/.gitignore
vendored
@@ -23,3 +23,7 @@
|
||||
/useless-if-before-free
|
||||
/vc-list-files
|
||||
/ylwrap
|
||||
/config.libpath
|
||||
/install-reloc
|
||||
/reloc-ldflags
|
||||
/relocatable.sh.in
|
||||
|
||||
@@ -203,6 +203,7 @@ AC_ARG_ENABLE([yacc],
|
||||
[do not build a yacc command or an -ly library])],
|
||||
, [enable_yacc=yes])
|
||||
AM_CONDITIONAL([ENABLE_YACC], [test "$enable_yacc" = yes])
|
||||
AC_CONFIG_FILES([src/yacc], [chmod +x src/yacc])
|
||||
|
||||
# Checks for programs.
|
||||
AM_MISSING_PROG([DOT], [dot])
|
||||
|
||||
1
doc/.gitignore
vendored
1
doc/.gitignore
vendored
@@ -30,3 +30,4 @@
|
||||
/stamp-vti
|
||||
/version.texi
|
||||
/yacc.1
|
||||
/relocatable.texi
|
||||
|
||||
@@ -382,6 +382,7 @@ Frequently Asked Questions
|
||||
* Strings are Destroyed:: @code{yylval} Loses Track of Strings
|
||||
* Implementing Gotos/Loops:: Control Flow in the Calculator
|
||||
* Multiple start-symbols:: Factoring closely related grammars
|
||||
* Enabling Relocatability:: Moving Bison/using it through network shares
|
||||
* Secure? Conform?:: Is Bison POSIX safe?
|
||||
* I can't build Bison:: Troubleshooting
|
||||
* Where can I find help?:: Troubleshouting
|
||||
@@ -12875,6 +12876,7 @@ are addressed.
|
||||
* Implementing Gotos/Loops:: Control Flow in the Calculator
|
||||
* Multiple start-symbols:: Factoring closely related grammars
|
||||
* Secure? Conform?:: Is Bison POSIX safe?
|
||||
* Enabling Relocatability:: Moving Bison/using it through network shares
|
||||
* I can't build Bison:: Troubleshooting
|
||||
* Where can I find help?:: Troubleshouting
|
||||
* Bug Reports:: Troublereporting
|
||||
@@ -13156,6 +13158,8 @@ However, Bison is intended to be a reliable program that conforms to the
|
||||
POSIX specification for Yacc. If you run into problems, please send us a
|
||||
bug report.
|
||||
|
||||
@include relocatable.texi
|
||||
|
||||
@node I can't build Bison
|
||||
@section I can't build Bison
|
||||
|
||||
@@ -13209,7 +13213,7 @@ hearts.
|
||||
I found a bug. What should I include in the bug report?
|
||||
@end quotation
|
||||
|
||||
Before you send a bug report, make sure you are using the latest
|
||||
Before sending a bug report, make sure you are using the latest
|
||||
version. Check @url{https://ftp.gnu.org/pub/gnu/bison/} or one of its
|
||||
mirrors. Be sure to include the version number in your bug report. If
|
||||
the bug is present in the latest version but not in a previous version,
|
||||
|
||||
@@ -19,7 +19,8 @@ info_TEXINFOS = doc/bison.texi
|
||||
doc_bison_TEXINFOS = \
|
||||
$(CROSS_OPTIONS_TEXI) \
|
||||
doc/fdl.texi \
|
||||
doc/gpl-3.0.texi
|
||||
doc/gpl-3.0.texi \
|
||||
doc/relocatable.texi
|
||||
|
||||
# Cannot express dependencies directly on file names because of Automake.
|
||||
# Obfuscate with a variable.
|
||||
|
||||
15
lib/.gitignore
vendored
15
lib/.gitignore
vendored
@@ -294,3 +294,18 @@
|
||||
/bitset/
|
||||
/bitsetv.c
|
||||
/bitsetv.h
|
||||
/allocator.c
|
||||
/allocator.h
|
||||
/areadlink.c
|
||||
/areadlink.h
|
||||
/canonicalize-lgpl.c
|
||||
/careadlinkat.c
|
||||
/careadlinkat.h
|
||||
/progreloc.c
|
||||
/readlink.c
|
||||
/relocatable.c
|
||||
/relocatable.h
|
||||
/relocwrapper.c
|
||||
/setenv.c
|
||||
/xreadlink.c
|
||||
/xreadlink.h
|
||||
|
||||
4
m4/.gitignore
vendored
4
m4/.gitignore
vendored
@@ -191,3 +191,7 @@
|
||||
/sys_resource_h.m4
|
||||
/timespec.m4
|
||||
/intl-thread-locale.m4
|
||||
/canonicalize.m4
|
||||
/readlink.m4
|
||||
/relocatable-lib.m4
|
||||
/relocatable.m4
|
||||
|
||||
18
src/local.mk
18
src/local.mk
@@ -13,10 +13,17 @@
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
|
||||
bin_PROGRAMS = src/bison
|
||||
# Prettify Automake-computed names of compiled objects.
|
||||
src_bison_SHORTNAME = bison
|
||||
|
||||
src_bison_CPPFLAGS = $(AM_CPPFLAGS) -DINSTALLDIR=\"$(bindir)\"
|
||||
if RELOCATABLE_VIA_LD
|
||||
src_bison_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)`
|
||||
endif
|
||||
|
||||
src_bison_CFLAGS = $(AM_CFLAGS) $(WERROR_CFLAGS)
|
||||
src_bison_SOURCES = \
|
||||
src/AnnotationList.c \
|
||||
@@ -127,16 +134,7 @@ src_bison_LDADD = \
|
||||
## ------ ##
|
||||
|
||||
if ENABLE_YACC
|
||||
bin_SCRIPTS = src/yacc
|
||||
nodist_bin_SCRIPTS = src/yacc
|
||||
endif
|
||||
EXTRA_SCRIPTS = src/yacc
|
||||
MOSTLYCLEANFILES += src/yacc
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
|
||||
src/yacc:
|
||||
$(AM_V_GEN)rm -f $@ $@.tmp
|
||||
$(AM_V_at)$(MKDIR_P) src
|
||||
$(AM_V_at)echo '#! /bin/sh' >$@.tmp
|
||||
$(AM_V_at)echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@.tmp
|
||||
$(AM_V_at)chmod a+x $@.tmp
|
||||
$(AM_V_at)mv $@.tmp $@
|
||||
|
||||
11
src/main.c
11
src/main.c
@@ -26,6 +26,7 @@
|
||||
#include <configmake.h>
|
||||
#include <progname.h>
|
||||
#include <quotearg.h>
|
||||
#include <relocatable.h> /* relocate2 */
|
||||
#include <timevar.h>
|
||||
|
||||
#include "LR0.h"
|
||||
@@ -58,10 +59,16 @@
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
#define DEPENDS_ON_LIBINTL 1
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
(void) bindtextdomain ("bison-runtime", LOCALEDIR);
|
||||
{
|
||||
char *cp = NULL;
|
||||
char const *localedir = relocate2 (LOCALEDIR, &cp);
|
||||
(void) bindtextdomain (PACKAGE, localedir);
|
||||
(void) bindtextdomain ("bison-runtime", localedir);
|
||||
free (cp);
|
||||
}
|
||||
(void) textdomain (PACKAGE);
|
||||
|
||||
{
|
||||
|
||||
14
src/output.c
14
src/output.c
@@ -26,6 +26,7 @@
|
||||
#include <get-errno.h>
|
||||
#include <path-join.h>
|
||||
#include <quotearg.h>
|
||||
#include <relocatable.h> /* relocate2 */
|
||||
#include <spawn-pipe.h>
|
||||
#include <timevar.h>
|
||||
#include <wait-process.h>
|
||||
@@ -44,6 +45,9 @@
|
||||
|
||||
static struct obstack format_obstack;
|
||||
|
||||
/* Memory allocated by relocate2, to free. */
|
||||
static char *relocate_buffer = NULL;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------.
|
||||
| Create a function NAME which associates to the muscle NAME the |
|
||||
@@ -718,11 +722,17 @@ output (void)
|
||||
unlink_generated_sources ();
|
||||
|
||||
obstack_free (&format_obstack, NULL);
|
||||
free (relocate_buffer);
|
||||
}
|
||||
|
||||
char const *
|
||||
pkgdatadir (void)
|
||||
{
|
||||
char const *cp = getenv ("BISON_PKGDATADIR");
|
||||
return cp ? cp : PKGDATADIR;
|
||||
if (relocate_buffer)
|
||||
return relocate_buffer;
|
||||
else
|
||||
{
|
||||
char const *cp = getenv ("BISON_PKGDATADIR");
|
||||
return cp ? cp : relocate2 (PKGDATADIR, &relocate_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
22
src/yacc.in
Normal file
22
src/yacc.in
Normal file
@@ -0,0 +1,22 @@
|
||||
#! /bin/sh
|
||||
|
||||
@relocatable_sh@
|
||||
if test "@RELOCATABLE@" = yes; then
|
||||
exec_prefix="@exec_prefix@"
|
||||
bindir="@bindir@"
|
||||
orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables
|
||||
func_find_curr_installdir # determine curr_installdir
|
||||
func_find_prefixes
|
||||
relocate () {
|
||||
echo "$1/" \
|
||||
| sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" \
|
||||
| sed -e 's,/$,,'
|
||||
}
|
||||
else
|
||||
relocate () {
|
||||
echo "$1"
|
||||
}
|
||||
fi
|
||||
|
||||
bindir=`relocate "@bindir@"`
|
||||
exec "$bindir/bison" -y "$@"
|
||||
Reference in New Issue
Block a user