The context: learning GDB through Stallman’s GDB book.
My purpose is to set the bugs proposed in the book and then do: gdb ./m4
to check that everything went as the text demands.
The program chosen by the author to teach GDB, was this (very old from today. Also related post from different asker) m4
macro processor. As expected, a recent and modern version of m4
is already present in my linux. Sure not a good idea to overwrite it with that old one used in the book.
I choosed the second option (m4
’s year 2000 repo version) out of previous post answers (post). Reason: suggested that older m4
versions likely to need also an old gcc
version.
My present question is:
Wouldn't be possible to just do a gcc -o m4 foo.c bar.c
.... etc... and generate an executable purely local to the folder to experiment directly with GDB (that was from the beginning the main objective of all this). Avoiding any conflict with the legitimate/native m4
. Is this simply a matter of “flags” on the building scripts? How can this be done?
This all was retrieved with git
:
$ git clone git://git.sv.gnu.org/m4
$ git checkout branch-1.4
This is what I did: This is how the folder looks like:
$ ls
acinclude.m4 build-aux configure gnulib NEWS TODO
AUTHORS c-boxes.el configure.ac HACKING po
autom4te.cache cfg.mk COPYING INSTALL README
BACKLOG ChangeLog-2014 doc lib src
bootstrap checks examples m4 tests
bootstrap.conf config.log gl Makefile.am THANKS
This when I type autoreconf
:
$ autoreconf
configure.ac:230: warning: macro 'AM_GNU_GETTEXT' not found in library
configure.ac:231: warning: macro 'AM_GNU_GETTEXT_VERSION' not found in library
sh: 1: build-aux/git-version-gen: not found
configure.ac:25: error: AC_INIT should be called with package and version arguments
/usr/share/aclocal-1.16/init.m4:29: AM_INIT_AUTOMAKE is expanded from...
configure.ac:25: the top level
autom4te: error: /usr/bin/m4 failed with exit status: 1
aclocal: error: /usr/bin/autom4te failed with exit status: 1
autoreconf: error: aclocal failed with exit status: 1
This when I type autoconf configure.ac
:
$ autoconf configure.ac
-- snippet (just the errors) --
configure.ac:25: error: possibly undefined macro: AM_INIT_AUTOMAKE
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:27: error: possibly undefined macro: AM_SILENT_RULES
configure.ac:36: error: possibly undefined macro: M4_EARLY
configure.ac:155: error: possibly undefined macro: M4_INIT
configure.ac:223: error: possibly undefined macro: M4_WITH_DMALLOC
configure.ac:230: error: possibly undefined macro: AM_GNU_GETTEXT
configure.ac:231: error: possibly undefined macro: AM_GNU_GETTEXT_VERSION
This when I type ./configure
:
$ ./configure
./configure: line 2273: syntax error near unexpected token `1.11.6'
./configure: line 2273: `AM_INIT_AUTOMAKE(1.11.6 dist-bzip2 dist-xz color-tests parallel-tests'
Mark Plotnik> run ./bootstrap
, then autoreconf
.
Thank you Mr @MarkPlotnick, sounds great. The thing is... That overwrites the native m4 installation
No, it does not.
It creates a Makefile
, which you can use to build and debug a local build of m4
.
The Makefile
would overwrite native m4
installation only if you do make install
(don't do that).
P.S. To answer the original "possible to just do a gcc -o m4 foo.c bar.c ....
", the answer is yes, but it requires a config.h
file.
You could write config.h
by hand, but that is somewhat hard to do. Normally this file is produced by running ./configure
, and you'll be much better off getting a working ./configure
by using ./bootstrap
and autoreconf
.