GNOME Bugzilla – Bug 606077
configure option --program-suffix broken
Last modified: 2018-06-29 22:32:54 UTC
When doing something like ./configure --prefix=/usr --program-suffix=-2.3.8, the programs are installed as expected, e.g. /usr/bin/gnucash-2.3.8 /usr/bin/gnucash-bin-2.3.8 /usr/bin/gnucash-setup-env-2.3.8 etc. However, the installed scripts don't contain the modified names internally, e.g.: $ cat /usr/bin/gnucash-2.3.8 #!/bin/sh . /usr/bin/gnucash-setup-env exec gnucash-bin "$@" So calling gnucash-2.3.8 will still invoke the default installed version of gnucash-bin, rather than gnucash-bin-2.3.8 as I would have expected. A similar problem may apply to --program-prefix as well. Possible solution: configure.in could precompute the installed program names, e.g. GNUCASH_BIN=`echo gnucash-bin | sed "$program_transform_name"`, then do additional substitutions on files like src/bin/gnucash.in.
Wow, I think you're the first person in a decade to ever use this functionality! Yeah, fixing this would be fine. Care to take a gander at a patch?
I'll give it a shot, but first a question: is there a particular reason for this code in src/bin/Makefile.am: gnucash: gnucash.in gnucash-setup-env ${top_builddir}/config.status Makefile rm -f $@.tmp sed < $< > $@.tmp \ -e 's#@-BIN_DIR-@#${bindir}#g' mv $@.tmp $@ chmod u+x $@ It seems that the only purpose is to set ${bindir} in the script. A more canonical solution would be to do this at configure time, i.e., just add usr/bin/gnucash to AC_CONFIG_FILES() in ./configure.in. And ditto for the other scripts in src/bin.
I tracked the above Makefile.am code and it comes from revision 11160 in the gnucash-gnome2-dev branch (16 Jul 2005). http://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev/src/bin/Makefile.am Since then, the substitution code has just been copied and expanded to more scripts. No rationale was given in the original commit for why to do these substitutions at compile time, rather than configure time.
Right, never mind. I found the relevant information in doc/README.build-system. Apparently it is necessary to do those substitutions at compile time, because variables such as $prefix can be overridden at compile time.
Created attachment 150881 [details] [review] patch re 18551
OK, the attached patch fixes part of this problem. Specifically, it applies the specified transform (from ./configure option --program-suffix, --program-prefix, or --program-transform-name) to the files src/bin/gnucash-valgrind src/bin/gnucash-gdb src/bin/gnucash This is done in the Makefile at compile time. There are a number of problems this patch does not (yet) fix. At least the following files in the gnucash source tree also contain hardcoded executable filenames: packaging/win32/install.sh packaging/win32/gnucash.iss.in packaging/win32/install-fq-mods.cmd I didn't touch these because I am not very familiar with the build process on Windows. src/engine/binreloc.c src/gnome-utils/druid-gconf-setup.c I didn't touch these yet, because it requires passing additional -D options to the compiler, or putting something into config.h; but the autoconf system generates ${program_transform_name} in a way that has been specially escaped and can only be meaningfully processed in a Makefile. In other words, those parameters can't be set at configuration time, which is when the rest of config.h and the CFLAGS are computed. Maybe the only way to do this is to use something like src/engine/binreloc.c.in, but that will be a nightmare to maintain. src/scm/price-quotes.scm Ditto, but scheme is not even compiled. So we'd have to substitute the program names into the script using a .in mechanism, which is ugly, or some kind of run-time include. src/quotes/gnc-fq-check.in src/quotes/gnc-fq-helper.in Analogous problem, for Perl. src/bin/overrides/gnucash-make-guids src/bin/gnucash-env src/bin/gnucash-make-guids I didn't touch this, because I am not quite sure if these scripts are supposed to be installed, or if they are supposed to be run in the source tree. Some of this stuff actually gets installed in $prefix/usr/libexec/gnucash/overrides. But I am not sure how this overrides system works. For example, if the configure option --program-suffix=-2.3.8 is specified, then something called $prefix/usr/libexec/gnucash/overrides/guile-2.3.8 will be installed, which is a wrapper script for guile. I am not sure if it makes any sense. In the end, I am not sure why the GnuCash configure.in provides the --program-suffix mechanism at all, since apparently it hasn't been used in 10 years. According to info autoconf, these are supposed to be enabled by the macro AC_ARG_PROGRAM, but I don't see this in configure.in. So perhaps it has been enabled by accident and shouldn't really be there.
Thanks for the patch. As for the win32 build: We control the configure, the build, and the installation (through the .iss file), so we can control the executable name as well and we can decide to use it without --program-suffix feature, so we don't have to adapt it here. As for your final question: Indeed I do not understand as well why this mechanism is active in the first place. To my knowledge, it has never been enabled by intention. I'd rather propose to make sure to disable it completely, so that we don't run into all the other problems you mentioned.
Comment on attachment 150881 [details] [review] patch re 18551 r18572, thanks! (However, the option should probably rather be disabled anyway...)
I tried to find a way to disable this, but it appears this is an option of autoconf which we cannot control. This can probably be closed, unless there are other outstanding issues related to this defect.
> This can probably be closed Ok
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=606077. Please update any external references or bookmarks.