Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buildsystem cleanups #17

Closed
wants to merge 20 commits into from
Closed

Buildsystem cleanups #17

wants to merge 20 commits into from

Conversation

ndim
Copy link
Contributor

@ndim ndim commented Nov 19, 2022

This tries to fix a few obvious problems with the build system, such as

  • make dist trying to distribute a non-existing file .xnec2c
  • make dist not distribute required files resources/*
  • m4 macros potentially ending up in configure up unexpanded
  • .gitignore ignoring some files where they should not be ignored and ignoring some files only in some places but not in others where they should be ignored
  • using $(shell ...) in src/Makefile.am

I am creating this as a draft pull request as I have a few questions about the dependency tracking for built sources which I still need to clarify.

(FYI, I am not an xnec2c user. I am just running into questions about its build system on stackoverflow again and again.)

@ndim ndim force-pushed the buildsystem-cleanups branch 2 times, most recently from 73f9539 to fa6ff74 Compare November 20, 2022 13:12
@KJ7LNW
Copy link
Owner

KJ7LNW commented Nov 22, 2022

Hi Hans, thanks for the contribution! It is nice to get the build system cleaned up.

  • Question: Was automake 1.13 already required to build it as it was, or is that version now required to build it after your changes (and if so, what causes newer version dependency)?

  • Comment: The resources/ directory was intentionally excluded because they are built into the xnec2c binary directly using $(GLIB_COMPILE_RESOURCES) (see e57c92f). However, one exception to that is xnec2c.svg; it is copied to $(DESTDIR)$(datarootdir)/pixmaps/ during make install so that files/x-nec2.xml will find <icon name="xnec2c"/> if the user choose to do make desktop-install. I'm open to suggestions on cleaning that up if you have ideas. IMHO, at least these files should not be packaged:

    • resources/link.svg
    • resources/unlink.svg
    • resources/xnec2c.glade
    • resources/xnec2c.gresource.xml

I will look at this in detail over the next few days and let you know if I have any other questions or comments. By the way, what motivated your interest in the build system cleanup?

Thanks again!

-Eric

@KJ7LNW
Copy link
Owner

KJ7LNW commented Nov 22, 2022

See above, too, but clearly you are more familiar with autoconf and its interaction with glib-compile-resources.

Question: Is it best practice to distribute the files in resources/ for users at make install time, even though they are built directly into the xnec2c binary? If so, why would users want build-time files (like, for example, xnec2c.gresource.xml)?

@ndim
Copy link
Contributor Author

ndim commented Nov 22, 2022

Why require automake >= 1.13?

Because you have already been using AC_CONFIG_MACRO_DIRS() for a long time (note the plural S at the end) for which an important bug was fixed in automake 1.13.

Also note that automake-1.13 was released in 2012-12-28, which is quite close to the 2012-04-25 release of autoconf-2.69 from a 2022 perspective - and you have had AC_PREREQ([2.69]) in configure.ac since commit 56d022c from 2013, so you have already been requiring tools from the 2012 era for a good nine years. So this does significantly change the vintage of build tools xnec2c requires.

Side note: I have found either libtool or gettext to not properly handle AC_CONFIG_MACRO_DIRS (with the letter S) and have reverted to using a combination AC_CONFIG_MACRO_DIR and ACLOCAL_AMFLAGS in other projects. I will need to look that up, at least if you want actually use that po/ subdir and the translations for xnec2c.

Why distribute the files inside the resources/ directory?

I think you are confusing two things:

  • The files in the dist tarball. The idea behind the GNU build system (i.e. Automake) is that you have a dist tarball (e.g. xnec2c-4.4.12.tar.gz) which contains everything you need to build the software: Sources, build scripts, etc. The files from resources/ are required to build xnec2c, as they are built into the xnec2c executable, so the files from resources/ belong into the dist tarball, and as Automake does not know about them like it knows about e.g. the source files you have added to xnec2c_SOURCES, I tell Automake to distribute them via EXTRA_DIST.

  • The files which are installed upon make install. I have not changed the set of installed files at all.

Why am I interested in this build system cleanup?

Observing you asking buildsystem questions on stackoverflow again and again over the past months and years interested me into helping more directly.

@KJ7LNW
Copy link
Owner

KJ7LNW commented Nov 23, 2022

Awesome, I appreciate it! Thanks for clarifying my various questions.

About AC_CONFIG_MACRO_DIRS(): If AC_CONFIG_MACRO_DIR() without the "s" would be better then I'm all for it!

@KJ7LNW KJ7LNW marked this pull request as ready for review November 23, 2022 01:49
@KJ7LNW
Copy link
Owner

KJ7LNW commented Nov 23, 2022

All of my systems are based on CentOS 7 and probably will be for at least the next year or so, which is the reason for the Autoconf 2.69 target. I tried running autogen.sh (which should probably be cleaned up, too, but that isn't the issue here) and we get the following errors:

autogen.sh

]# ./autogen.sh 
Preparing the xnec2c build system...please wait

Found GNU Autoconf version 2.69
Found GNU Automake version 1.13.4
Found GNU Libtool version 2.4.2

Automatically preparing build ... Warning: autoreconf failed
Attempting to run the preparation steps individually

Preparing build ... 
Warning:  Unsupported macros were found in ./configure.ac

The configure.ac file was scanned in order to determine if any
unsupported macros are used that exceed the minimum version
settings specified within this file.  As such, the following macros
should be removed from configure.ac or the version numbers in this
file should be increased:

AC_FUNC_REALLOC

Ignorantly continuing build preparation ... 
Warning: autoconf seems to have succeeded by removing the following options:
	AUTOCONF_OPTIONS="-f"

Removing those options should not be necessary and indicate some other
problem with the build system.  The build preparation is highly suspect
and may result in configuration or compilation errors.  Consider
rerunning the build preparation with verbose output enabled.
	./autogen.sh --verbose

Continuing build preparation ... done

The xnec2c build system is now prepared.  To build here, run:
  ./configure
  make

./configure

Then running ./configure I get this:

]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking whether configure should try to set CFLAGS... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking for glib-compile-resources... ./configure: line 4031: syntax error near unexpected token `GLIB_COMPILE_RESOURCES,'
./configure: line 4031: `PKG_CHECK_VAR(GLIB_COMPILE_RESOURCES, gio-2.0, glib_compile_resources)'

According to Red Hat, they do not ship PKG_CHECK_VAR with pkgconfig-0.27.1-4 which explains why grep PKG_CHECK_VAR /usr/share/aclocal/pkg.m4 returns nothing.

Do you have a work-around for PKG_CHECK_VAR?

@ndim
Copy link
Contributor Author

ndim commented Nov 23, 2022

Quick note: This is not ready for merge, for a number of reasons. That is why I filed this as a Draft PR.

I am still clarifying some details regarding the auto dependencies for the resource compilation.

Regarding AC_CONFIG_MACRO_DIRS: Automake appear to have deprecated AC_CONFIG_MACRO_DIR (without S) in favour of AC_CONFIG_MACRO_DIR (with S), but last time I checked, that news had not reached the real world gettext/libtool (whichever of the two it was). I want to check the details of as well before this can be merged.

Regarding autogen.sh: What does autogen.sh do which autoreconf does not do? If the answer to that is "nothing", I would remove autogen.sh, or replace it with exec autoreconf --install --force. However, I have not checked what your autogen.sh does - it is a huge amount of code to read and for my purposes, autoreconf just did the job.

And let me try building on CentOS 7 (my Fedora 37 system has a mock config for CentOS 7) and a few more systems.

@ndim
Copy link
Contributor Author

ndim commented Nov 23, 2022

As to PKG_CHECK_VAR, that can be worked around easily if necessary.

@KJ7LNW
Copy link
Owner

KJ7LNW commented Nov 24, 2022

I'm guessing that autoreconf --install --force is fine...or at least, it builds ok with these warnings:

]$ autoreconf --install --force
src/Makefile.am:63: warning: shell which pkg-config: non-POSIX variable name
src/Makefile.am:63: (probably a GNU make extension)
src/Makefile.am:64: warning: shell $(PKGCONFIG: non-POSIX variable name
src/Makefile.am:64: (probably a GNU make extension)
src/Makefile.am:66: warning: shell $(GLIB_COMPILE_RESOURCES: non-POSIX variable name
src/Makefile.am:66: (probably a GNU make extension)

I inherited the code as the new maintainer from Neoklis (the original developer) and I think he was using a default autoconf stack way back in 2008. Looking at the header it appears that autogen.sh was canned and copied by Neoklis for this project since the original authors have nothing to do with xnec2c:

# Author:
#   Christopher Sean Morrison <morrison@brlcad.org>
#
# Patches:
#   Sebastian Pipping <sebastian@pipping.org>

The only exception to to this is that I've added some checks for missing packages that autogen.sh needed to succeed to help xnec2c users build the package without opening a github issue. These are the only changes I've made ti autogen.sh for that purpose and perhaps there is a better way to do these sanity checks in configure.ac instead shell script hacks in autogen.sh:

if [ ! -x "$(command -v gettext)" ]; then
        echo "gettext does not exist: install the gettext package."
        exit 1
fi

if [ ! -x "$(command -v gettextize)" ]; then
        echo "gettextize does not exist: install the gettext package."
        exit 1
fi

if [ ! -x "$(command -v autopoint)" ]; then
        echo "autopoint does not exist: install the autopoint or gettext-devel package."
        exit 1
fi

if [ ! -x "$(command -v glib-compile-resources)" ]; then
        echo "glib-compile-resources does not exist: install the libglib2.0-dev-bin or glib2-devel package."
        exit 1
fi

if [ ! -x "$(command -v pkg-config)" ]; then
        echo "pkgconfig does not exist: install the pkgconfig or pkg-config package."
        exit 1
fi

... so if we can fix whatever is triggering the autoreconf warnings above (and I think you already addressed some of that in your patch) then the simple command checks above (or refactored into configure.ac) with exec autoreconf --install --force would be much better solution!

What do you think?

@KJ7LNW KJ7LNW marked this pull request as draft November 24, 2022 01:11
@KJ7LNW
Copy link
Owner

KJ7LNW commented Nov 24, 2022

Regarding mock builds for el7: there is an xnec2c.spec in the git tree if that is helpful.

Beware of version tagging issues:

There is a v before the version in the package name (like v4.4.12), which probably deviates from the .tar.gz that make dist creates. I plan to drop v from tags starting in version 4.5 because of the issues it creates: this was an unintended consequence of using the Linux Kernel's tagging convention that didn't play well with the .spec's %setup macro and github's automatic /archive/<name>-<tag>.tar.gz generator. I'm open to suggestions here if you care to comment. Feel free to modify the .spec if you see a better way.

Someday I would like to make xnec2c.spec.in as suggested on SE so the @PACKAGE_VERSION@ can be populated easier. You might recognize the author of that answer ;)

I've not gotten around to cleaning up the auto-version stuff yet; right now these are the files that have the version hard-coded that would benefit from a .in version of the file:

  • configure.ac
  • doc/xnec2c.1
  • xnec2c.spec

@ndim
Copy link
Contributor Author

ndim commented Nov 24, 2022

Quick note on build tool versions: xnec2c requires gettext version 0.19.7 from 2015-12, which is 3 years younger than automake 1.13 and 3.5 years younger than autoconf 2.69. And that is even without any translations.

@ndim
Copy link
Contributor Author

ndim commented Nov 24, 2022

Beware of version tagging issues:

There is a v before the version in the package name (like v4.4.12), which probably deviates from the .tar.gz that make dist creates. I plan to drop v from tags starting in version 4.5 because of the issues it creates: this was an unintended consequence of using the Linux Kernel's tagging convention that didn't play well with the .spec's %setup macro and github's automatic /archive/<name>-<tag>.tar.gz generator. I'm open to suggestions here if you care to comment. Feel free to modify the .spec if you see a better way.

Do not rush into changing the git release tags.

github releases (which happen via git tags) versus GNU buildsystem dist tarball releases.

First,
https://github.com/KJ7LNW/xnec2c/archive/refs/tags/v4.4.12.tar.gz actually downloads a tarball named xnec2c-4.4.12.tar.gz. However, while this has the same name as the dist tarball the GNU buildsystem creates by make dist or make distcheck, the content is very different:

  • The github xnec2c-4.4.12.tar.gz tarball linked as v4.4.12.tar.gz contains exactly the same files you would get by running "git checkout v4.4.12". So whether you are building from that kind of tarball, or from a git clone, you will need to run the following four steps:

    • autoreconf to generate the buildsystem, e.g. the configure script for the next step. This requires automake, autoconf, pkg.m4 from the pkg-config devel package, autopoint from the gettext devel package are installed.

    • configure to generate the Makefile for the next steps.

    • make

    • make install

  • The dist tarball as generated by make dist or make distcheck. This tarball contains a working buildsystem, so you will need to run the following three steps:

    • configure to generate the Makefile for the next steps.
    • make
    • make install

    Note that while you will need a C compiler, glib-resource-compiler, and a few other tools like e.g. pkg-config for this step, you do NOT need to have Automake, Autoconf, or pkg.m4 from the pkg-config devel package, or autopoint from the gettext devel package installed.

Unfortunately, you cannot disable the repo dump tarballs on Github releases, but you can attach other binaries to a release, either manually or with a Github workflow. See e.g. the https://github.com/gphoto/libgphoto2/releases/tag/v2.5.30 release: While there is a "Source Code" tarball with the URL v2.5.30.tar.gz which is just the git source tree dump, there are also dist tarballs available in three compression flavours: libgphoto2-2.5.30.tar.{gz,bz2,xz}.

These days, dist tarballs are starting to become less significant as a method for distributing software releases, with Github's automatic source tree dump tarballs or even "just checkout our release branch" beginning to replace dist tarballs.

Both methods have their advantages and disadvantages.

Anyway, I would keep using the git tags for the git releases at v1.2.3 with the v.

Someday I would like to make xnec2c.spec.in as suggested on SE so the @PACKAGE_VERSION@ can be populated easier. You might recognize the author of that answer ;)

That is easy.

I've not gotten around to cleaning up the auto-version stuff yet; right now these are the files that have the version hard-coded that would benefit from a .in version of the file:

* doc/xnec2c.1
* xnec2c.spec

Agreed about those two. They can take their version information from configure.ac via configure and Makefile and some $(SED) substitutions.

BTW, are you married to the recursive make src/Makefile.am or would a single parallel make run (except for po/) also be OK? Will be a bit faster, but you cannot cd src && make any more.

* configure.ac

I do not see what you would want to accomplish with a .in version of this file. Where would the version information to substitute come from?

What is possible is to have autoreconf call autoconf call an m4_esyscmd() macro call a shell script. That shell script can then figure out the version information to put in AC_INIT, e.g. from

  • git tags (e.g. git describe) if git is installed and there is a .git/ directory
  • a version stamp file which make dist has put into the dist tarball, so that you can build dist tarballs with version information
  • the name of the directory (e.g. xnec2c-1.2.3 would give version 1.2.3)
  • a default string unknown

However, I do not know whether you want to go that route.

I personally am using such a script in my more or less personal projects like https://github.com/ndim/ndim-git-utils https://github.com/ndim/ndim-utils: They both use two number release tags like e.g. v1.2, and then the script will create a version number for AC_INIT like v1.2.23 for the 23rd commit after the v1.2 tag. I do now know how something like that would fare with many developers and users, though. We had something like that about 15 years ago with the xorg-x11-drv-radeonhd driver, but that was short lived as well.

@ndim
Copy link
Contributor Author

ndim commented Nov 24, 2022

I'm guessing that autoreconf --install --force is fine...or at least, it builds ok with these warnings:

]$ autoreconf --install --force
src/Makefile.am:63: warning: shell which pkg-config: non-POSIX variable name
src/Makefile.am:63: (probably a GNU make extension)
src/Makefile.am:64: warning: shell $(PKGCONFIG: non-POSIX variable name
src/Makefile.am:64: (probably a GNU make extension)
src/Makefile.am:66: warning: shell $(GLIB_COMPILE_RESOURCES: non-POSIX variable name
src/Makefile.am:66: (probably a GNU make extension)

That is indeed fixed by the "Remove $(shell) parts from src/Makefile.am" commit.

I inherited the code as the new maintainer from Neoklis (the original developer) and I think he was using a default autoconf stack way back in 2008.

[...]

The only exception to to this is that I've added some checks for missing packages that autogen.sh needed to succeed to help xnec2c users build the package without opening a github issue. These are the only changes I've made to autogen.sh for that purpose and perhaps there is a better way to do these sanity checks in configure.ac instead shell script hacks in autogen.sh:

if [ ! -x "$(command -v gettext)" ]; then
        echo "gettext does not exist: install the gettext package."
        exit 1
fi

if [ ! -x "$(command -v gettextize)" ]; then
        echo "gettextize does not exist: install the gettext package."
        exit 1
fi

if [ ! -x "$(command -v autopoint)" ]; then
        echo "autopoint does not exist: install the autopoint or gettext-devel package."
        exit 1
fi

if [ ! -x "$(command -v glib-compile-resources)" ]; then
        echo "glib-compile-resources does not exist: install the libglib2.0-dev-bin or glib2-devel package."
        exit 1
fi

if [ ! -x "$(command -v pkg-config)" ]; then
        echo "pkgconfig does not exist: install the pkgconfig or pkg-config package."
        exit 1
fi

There is no need to check for glib-compile-resources in autogen.sh: configure will check for glib-compile-resources. It might even be useless, as the system you ran autogen.sh on (the one you run make dist on) might not be the one you build on (the one you run configure && make && make install on

You also do not need the pkg-config executable at autogen.sh time. What you do need is pkg.m4, which is usually part of some -devel package.

A standard build will need autopoint from some gettext devel package at autogen.sh time, and gettext at configure and make time, however only developers will ever need gettextize.

I guess I can take a look through past xnec2c github issues and see what can be done with an autoreconf based buildsystem initialization.

... so if we can fix whatever is triggering the autoreconf warnings above (and I think you already addressed some of that in your patch) then the simple command checks above (or refactored into configure.ac) with exec autoreconf --install --force would be much better solution!

What do you think?

autoreconf will complain if e.g. it finds gettext related macros in configure.ac but autopoint cannot be found.

autoreconf will complain if pkg.m4 is not found because m4_pattern_forbid([PKG_...]) will trigger on unexpanded PKG_ macros.

configure will complain if it cannot find glib-compile-resources.

The exact error messages could maybe be better for some situations, but the exact name of the missing packages and how to install them is highly system specific, so you cannot be expected to prepare error messages with detailed instructions suitable to all operating systems.

I would just use autoreconf and configure and their error messages, and depending on the situation, either document it in README.md or INSTALL.md or something similar, or maybe (if reasonable, possible, and useful, and only if it actually causes people issues) put a more detailed error message in place, e.g. using m4_ifndef([MACRO], [m4_fatal([MACRO required ... macro.m4 ... part of foobar dev package])])dnl instead of just m4_pattern_forbid([MACRO]).

@ndim ndim force-pushed the buildsystem-cleanups branch 2 times, most recently from fac2018 to 7814f8e Compare November 24, 2022 18:20
@ndim
Copy link
Contributor Author

ndim commented Nov 24, 2022

Remark on Centos 7 having an old pkg.m4 without PKG_CHECK_VAR: If you create a dist tarball on a contemporary system, the aclocal.m4 inside the dist tarball will contain the PKG_CHECK_VAR from the contemporary system, and configure && make && make install on Centos 7 from a tarball will work.

However, if you have users who build from git on Centos 7, the alternative implementation of PKG_CHECK_VAR inside configure.ac is required, or shipping pkg.m4 inside m4-*/.

@KJ7LNW
Copy link
Owner

KJ7LNW commented Nov 26, 2022

Do not rush into changing the git release tags. github releases (which happen via git tags) versus GNU buildsystem dist tarball releases.

Great information. I'll stick with v on the tag for now.

What is possible is to have autoreconf call autoconf call an m4_esyscmd() macro call a shell script. That shell script can then figure out the version information to put in AC_INIT ... However, I do not know whether you want to go that route.

For now manually editing the configure.ac with the latest version is the way to go in case I miss a tag or have some other tagging problem.

You also do not need the pkg-config executable at autogen.sh time. What you do need is pkg.m4, which is usually part of some -devel package.

Maybe shipping our own pkg.m4 (or even pkg-check-var.m4 with just the missing bits) because my desk will be el7 for a while. I plan to update my desk to Oracle Linux 8 or Oracle Linux 9 but it might still be a while and all my builds are still on el7 for the near feature.

Also I agree with dropping the binary checks in autogen.sh based on your suggestions so feel free to patch it into just an exec autoreconf ... call.

BTW, are you married to the recursive make src/Makefile.am or would a single parallel make run (except for po/) also be OK? Will be a bit faster, but you cannot cd src && make any more.

Either is fine, very rarely do I do something like cd src && make foo.o or whatever. Usually I just make at the top of the tree.

@ndim
Copy link
Contributor Author

ndim commented Nov 29, 2022

Do not rush into changing the git release tags. github releases (which happen via git tags) versus GNU buildsystem dist tarball releases.

Great information. I'll stick with v on the tag for now.

Consistency (i.e. continuing the existing theme) will also make any future automation and communication MUCH simpler.

What is possible is to have autoreconf call autoconf call an m4_esyscmd() macro call a shell script. That shell script can then figure out the version information to put in AC_INIT ... However, I do not know whether you want to go that route.

For now manually editing the configure.ac with the latest version is the way to go in case I miss a tag or have some other tagging problem.

An m4_esyscmd version script does not need to behave the same as mine does. It is turing complete, so it can do anything. Just keeping using the version from the latest tag and ignoring the commits since could also be a reasonable choice.

But that can always be changed later, we do not need to deal with that now.

You also do not need the pkg-config executable at autogen.sh time. What you do need is pkg.m4, which is usually part of some -devel package.

Maybe shipping our own pkg.m4 (or even pkg-check-var.m4 with just the missing bits) because my desk will be el7 for a while. I plan to update my desk to Oracle Linux 8 or Oracle Linux 9 but it might still be a while and all my builds are still on el7 for the near feature.

Shipping pkg.m4 is a brilliant idea. Why have I not thought about that?

With aclocal's serial mechanism, xnec2c can just contain copy of a modern pkg-config's pkg.m4 in m4-include, and aclocal will always pick the newest pkg.m4 file, be it the one from m4-include/ or the system one from /usr/share/aclocal.

It is also important information that you as the main dev run EL7. I have checked EL7 tool version availability within a mock centos-7 chroot and remarked on what tool versions mean for xnec2c in a comment in configure.ac so that whenever someone needs to deal with tool versions, that information is right there.

Also I agree with dropping the binary checks in autogen.sh based on your suggestions so feel free to patch it into just an exec autoreconf ... call.

I still want to go through past github build issues for ideas there.

BTW, are you married to the recursive make src/Makefile.am or would a single parallel make run (except for po/) also be OK? Will be a bit faster, but you cannot cd src && make any more.

Either is fine, very rarely do I do something like cd src && make foo.o or whatever. Usually I just make at the top of the tree.

Given that you are still on EL7, and that EL7 only has automake 1.13.4 which does not know %reldir% yet (introduced by automake 1.14), I would keep the current recursive three Makefile setup (xnec2c/Makefile xnec2c/src/Makefile xnec2/po/Makefile). The substitutions for xnec2c/doc/xnec2c.1 and xnec2c/xnec2c.spec can be easily dealt with from the top level directory Makefile (or possibly from doc/include.am) with hard coded doc/ in the file names. The same goes for EXTRA_DIST += m4-include/pkg.m4.

@KJ7LNW
Copy link
Owner

KJ7LNW commented Nov 29, 2022

Awesome. This branch builds great on my system.

About past bugs with build issues, see bugs #3 and #6. I thought there were more, maybe from direct email but I couldn't find any.

@KJ7LNW
Copy link
Owner

KJ7LNW commented Nov 29, 2022

About past bugs with build issues, see bugs #3 and #6. I thought there were more, maybe from direct email but I couldn't find any.

Oh, and also see open issues #16 and #14.

@ndim ndim force-pushed the buildsystem-cleanups branch 4 times, most recently from d35ad7d to 04153e8 Compare December 2, 2022 21:42
@KJ7LNW
Copy link
Owner

KJ7LNW commented Dec 3, 2022

Are you still planning to replace autogen.sh?

I tried exec autoreconf --install --force and get this warning:

xnec2c-git]$ autoreconf --install --force
Copying file ABOUT-NLS
[...]
src/Makefile.am:9: warning: compiling 'main.c' with per-target flags requires 'AM_PROG_CC_C_O' in 'configure.ac'

Aside from the warning, your branch builds and runs fine.

Has anything changed that would effect make desktop-install ?

Require at least automake 1.13.2 which made AC_CONFIG_MACRO_DIRS
work properly, and xnec2c has been using AC_CONFIG_MACRO_DIRS
for ages.

This also happens to require CVE-2012-3386 to have been fixed
in the automake version used (1.12.2 or later).

While automake-1.13.2 was released *after* the autoconf-2.69
release xnec2c has been requiring since 2013, both automake-1.13.2
and autoconf-2.69 happend in 2012/2013, so requiring at least
automake-1.13.2 does not change the age of systems significantly
when viewed from 2022.

Also note that Centos 7 comes with automake-1.13.4.
This anchors patterns like the po/foo patterns at the location
of the .gitignore file, and ignores Makefile and Makefile.in
anywhere.

Also ignores some more patterns created by the buildsystem like

    .deps/
    /compile
    /depcomp

etc.
PKG_CHECK_MODULES already makes the _CFLAGS and _LIBS vars
an AC_ARG_VAR which in turn AC_SUBST()s them.
Use more appropriate GTK_(CFLAGS|LIBS) var names for gtk+-3.0
instead of the generic nondescript PACKAGE_(CFLAGS|LIBS).
Catch missing m4 macros when generating the configure script
instead of generating a malformed configure script and then
executing that just to have it fail.
Remove the $(shell ...) parts from src/Makefile.am as not all
make implementations support them and Automake does not support
them either.

  * Generating dependency information has been moved into the
    actual $(GLIB_COMPILE_RESOURCES) recipe to make it a side
    effect of compilation.

  * Finding pkg-config and determining GLIB_COMPILE_RESOURCES
    from the gio-2.0.pc file's glib_compile_resource variable
    has been moved to configure.ac.

Our auto-dependency generation works just like Automakes
auto-dependency generation, but it but does not directly rely
on any of Automake's make recipes, files, or directories.

  * We use our own dependency file directory (analog to .deps)
  * We use our own dep dir variable (analog to DEPDIR)
  * We include the dep file into Makefile.am
  * We generate the dummy dep file as empty like Automake
    will after release 2.71
  * We generate the actual dep file as a side effect of compilation
  * We do not distribute the generated *.c file in the dist tarball

To allow running autoreconf on a system without the PKG_CHECK_VAR
macro in pkg.m4 (e.g. CentOS 7 with older pkg-config), we ship a
copy of a modern pkg.m4 file in m4-include/. aclocal will then
pick the latest (by "serial" number) version of pkg.m4 it can
find in m4/ m4-include/ /usr/share/aclocal etc.

Also fixes out of source tree builds by using the proper $(top_srcdir)
variable to refer to the source files in the make rule recipe.

Also add ax_check_compile_flag.m4 to dist tarball. Someone might
want to autoreconf from a dist tarball after all.
Verify glib-compile-resources works as intended. This comprises
two steps:

  * run glib-compile-resources on a resource file *.xml
    to generate a C source file

  * compile and link that C source file

If any of these steps fails, abort configure.
Enable AM_MAINTAINER_MODE by default, so that you can still run
`./configure --enable-maintainer-mode` without a bit WARNING message,
but so that by default builds actually build properly by default.

The main purpose of AM_MAINTAINER_MODE is to allow broken builds to
happen in some cases.

The argument against AM_MAINTAINER_MODE have convinced even the author
of AM_MAINTAINER_MODE to stop using it:

https://www.gnu.org/software/automake/manual/automake.html#maintainer_002dmode

I am not sure whether AM_MAINTAINER_MODE is actually required for
something with xnec2c, or whether it just seemed like a good idea in
the early 2000s and just was perpetuated without thinking about it
too much. If the latter, we could just remove it altogether at the
cost of `configure --enable-maintainer-mode` then producing

configure: WARNING: unrecognized options: --enable-maintainer-mode
Add list of build tool versions to document why what version
should be required.
Have automake warn about possible problems.
@KJ7LNW
Copy link
Owner

KJ7LNW commented Dec 4, 2022

So the question is what do you do when someone runs ./configure --prefix=PREFIX with PREFIX being neither /usr, /usr/local, or $HOME/.local.

I sort of think that it would be okay to have a special case for make desktop-install since it is a non-standard make target, as follows:

  1. If running as root, put it in /usr/local
  2. Otherwise ~/.local/

Somewhere the make install target tells the user "run make desktop-install for file associations" or something to that effect. The message could be modified to indicate where desktop-install will place files. It could also indicate that they can look at the PACKAGING file and do their own thing if they need more information.

Because they might (or might not) build as a local user and then sudo make install to install, the message that make install presents should describe what will happen if they make desktop-install as root vs non-root so they can decide.

@ndim
Copy link
Contributor Author

ndim commented Dec 5, 2022

I would change the logic a bit and move it to configure.ac, where it defines a few variables like maybe xdgrootdir and then defines some other variables like desktopdir or iconsdir relative to xdgrootdir:

  • If --with-xdg-rootdir= is given, use that
  • If prefix is $HOME/.local, use $HOME/.local based locations
  • If prefix is /usr/local, use /usr/local based locations
  • If prefix is /usr, use /usr based locations
  • If prefix starts with $HOME, use $HOME/.local based location
  • If prefix starts with /usr/local, use /usr/local based location
  • If prefix starts with /usr, use /usr based location
  • Otherwise... abort the configure run and tell the user to use --with-xdg-rootdir

BTW, the RPM spec file contains an *.appdata.xml file which may be useful inside files/ as well.

Also, perhaps part of the RPM spec %install section could be part of our make desktop-install.

As not having any of that does not change the current state of xnec2c, I would push these to after the big PR merge, though. That is becoming big enough as it is.

The .gitignore file is long enough that it can use some structure.

This categorizes the ignore patterns into categories like
"generated by command xy" and "manually generated files".

Also adds a few more generated files like dist tarballs, testsuite
logs (not in use yet), or some buildsystem artefact in po/.
Refactor the xnec2c flags in src/Makefile.am:

  * Stop using AM_* vars. Use xnec2c_* vars instead.
  * One flag per line. Allows for easier diff/patch
    and also easier adding/removing flags via sed.
  * Group library specific --cflags and --libs together as
        xnec2c_CPPFLAGS += $(GTK3_CFLAGS)
        xnec2c_LDADD    += $(GTK3_LIBS)
    This makes it easier to catch when one of them is missing.
  * Use proper quotes for the C preprocessor string macros:
        -DFOO="\"bar\""
  * Add AM_PROG_CC_C_O (required for automake < 1.14)
Move auxiliary files into the auto-aux/ subdir, like

    compile
    config.guess
    config.rpath
    config.sub
    depcomp
    install-sh
    missing
    test-driver

This makes the source tree a bit cleaner.
Look for gmodule-2.0 via PKG_CHECK_MODULES.

This removes the need for the AC_CHECK_LIB() check later.

Not sure why we need to explicitly link against gmodule-2.0
on macOS and not on Linux, but this certainly builds on both.

Fixes one of four from KJ7LNW#16
Use Automake variables to have Automake rules install files instead
of using a homebuilt "make install-data-local" recipe.

This also adds some files to the dist tarball which were
formerly forgotten (MAINTAINER README.md PACKAGING).

This also adds a long list of files (150+) spelled out explicitly
instead of a recursive copy operation just copying everything from
examples/.

This looks like a lot to maintain, but after this initial effort,
the changes should be only limited, when an antenna or two may be
added in the future.

We have also added an automatic consistency check which tells you
explicitly when that list is inconsistent what part of it is.

Advantage: If you add or remove any files in examples/, you
will need to reflect that change in Makefile.am which forces
you to think whether that change was intended or not, and
therefore this will catch unintended changes.

The recursive copy method just copied over everything, including
editor backup files, or anything else which happens to be in one
of the affected directories.
DISTCLEANFILES deleted too much, and therefore broke the
"make distcheck" builds.

Overall, the DISTCLEANFILES looked very much like a copy
of the .gitignore file, but that is not what DISTCLEANFILES
is meant for.

With DISTCLEANFILES deleted, "make distcheck" still runs
without complaining about "make distclean" leaving files
around which should have been deleted, it looks like
DISTCLEANFILES is not needed for xnec2c at all.

If you want to restore a git source tree to the pristine
state of a fresh git clone, use `git clean`.
@ndim
Copy link
Contributor Author

ndim commented Dec 5, 2022

Status Update

These things MUST be addressed before merging this PR and cutting a release:

  • Adapt the documentation for other changes this cleanup may have made without me realizing.

  • Figure out how to release xnec2c and document that.

These things SHOULD be addressed before merging this PR and cutting a release:

  • Reduce or remove autogen.sh and adapt the documentation accordingly. The documentation being at least INSTALL, doc/xnec2c.html. xnec2c.spec.in will also need a change.

  • Solve the issue of installing files to well-known directories outside of $(prefix).

These things COULD be addressed before merging this PR and cutting a release:

  • Silent make rules, which can make the "make" run look as follows but still allow seeing the used command line and flags when necessary.

      CC       xnec2c-rc_config.o
      CC       xnec2c-shared.o
      CC       xnec2c-somnec.o
      GLIB-RES xnec2c-resources.c
      CC       xnec2c-xnec2c-resources.o
      CCLD     xnec2c
    

These things SHOULD be addressed in new PRs after merging this PR, before or after the next release:

  • Translations. My wip-i18n branch has the basics figured out, but someone needs to make some non-technical decisions, and that someone is not me.

  • Convenience RPMs. My wip-rpms branch has make srpm make rpm and make mockbuild working.

It might be useful to merge all changes which change the way people build and install xnec2c at once, so people only need to adapt to build/install changes once, not every few days and every release for some time.

@KJ7LNW
Copy link
Owner

KJ7LNW commented Dec 6, 2022

I would change the logic a bit and move it to configure.ac, where it defines a few variables like maybe xdgrootdir and then defines some other variables like desktopdir or iconsdir relative to xdgrootdir:
[...]

  • Otherwise... abort the configure run and tell the user to use --with-xdg-rootdir

Good idea.

BTW, the RPM spec file contains an *.appdata.xml file which may be useful inside files/ as well.

I saw that too. It came from the original Fedora maintainer's .spec and I just copy-pasted his into the package with some minor tweaks. Popping that out into an XML is a good idea. Added #26 so that doesn't get lost.

Also, perhaps part of the RPM spec %install section could be part of our make desktop-install.

True. The desktop-install bits are hacked in place so adding make desktop-install would clean that up if it is compatible.

As not having any of that does not change the current state of xnec2c, I would push these to after the big PR merge, though. That is becoming big enough as it is.

Agreed, noted in #26.

These things MUST be addressed before merging this PR and cutting a release:

  • Adapt the documentation for other changes this cleanup may have made without me realizing.

I've been watching your commits and nothing particularly noteworthy stands out except that if we use make dist then the call to ./autogen.sh can change to ./autogen.sh # if building from git.

Can you think of anything else?

  • Figure out how to release xnec2c and document that.

What would it take to add github's CI integration (.github) and have make dist upload to a github "Release" .tar.gz file?

These things SHOULD be addressed before merging this PR and cutting a release:

  • Reduce or remove autogen.sh and adapt the documentation accordingly. The documentation being at least INSTALL, doc/xnec2c.html. xnec2c.spec.in will also need a change.

I think we should just replace the content of autogen.sh with exec autoreconf <whatever-is-best> and call it good. Then documentation doesn't need to change much.

  • Solve the issue of installing files to well-known directories outside of $(prefix).

I assume you're referring to make desktop-install and I like your --with-xdg-rootdir suggestion above. If you have other out-of-prefix concerns then please fill me in because I must have missed something.

These things COULD be addressed before merging this PR and cutting a release:

  • Silent make rules, which can make the "make" run look as follows but still allow seeing the used command line and flags when necessary.

Neat! Go for it if its easy.

These things SHOULD be addressed in new PRs after merging this PR, before or after the next release:

  • Translations. My wip-i18n branch has the basics figured out, but someone needs to make some non-technical decisions, and that someone is not me.

I think I'm that someone. :)

  • Convenience RPMs. My wip-rpms branch has make srpm make rpm and make mockbuild working.

Awesome!

It might be useful to merge all changes which change the way people build and install xnec2c at once, so people only need to adapt to build/install changes once, not every few days and every release for some time.

I agree. I'm planning a do this as part of a 4.5 release.

@KJ7LNW
Copy link
Owner

KJ7LNW commented May 13, 2023

Hi @ndim ,

I've merged this branch into master. Your changes made it possible to build on OpenBSD. Thanks for your hard work on this!

If there are other changes you still wish to make for the buildsystem refactor/cleanup then feel free to open another PR.

-Eric, KJ7LNW

@KJ7LNW KJ7LNW closed this May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants