Skip to content

Move headers from configure to compats.h#26

Open
paravoid wants to merge 10 commits intokristapsdz:masterfrom
paravoid:compats-h
Open

Move headers from configure to compats.h#26
paravoid wants to merge 10 commits intokristapsdz:masterfrom
paravoid:compats-h

Conversation

@paravoid
Copy link
Copy Markdown
Contributor

configure currently has a lot of ${HAVE_...} -eq 0 ] if blocks, printing out header code for compats.c, to config.h. This is a lot of repetition, does not allow for splitting the code up properly, and makes the configure code a bit less maintainable.

Introduce instead a "compats.h" that should now be included by downstreams, alongside compats.c. Also, add Makefile.regen code to generate said file from the different compat_*.h parts, in the same way compats.c is generated.

The PR is doing this gradually, initially moving all the code that does:

 if [ ${HAVE_...} -eq 0 ]; then
        cat << __HEREDOC__
        ...
__HEREDOC__

Later on, the more tricky ones are being handled, one by one in a separate commit. This is a breaking change for downstreams, in the sense that they're going to need to add another file to their tree.

To review, it may be worth to look at configure.in at the end of the PR, and then review the commits one by one.

I understand this is a wider change, and I expect it to be somewhat controversial :) I didn't open an issue first because I wanted to see how the end result will look like, and now that I see it I think it is much cleaner. YMMV, and no hard feelings if you outright reject it!

paravoid added 10 commits March 30, 2023 19:21
Adjust the whitespace in the target definition, to avoid the need for
spurious -/+ to realign when adding additional targets.
configure currently has a lot of ${HAVE_...} -eq 0 ] if blocks, printing
out header code for compats.c, to config.h. This is a lot of repetition,
does not allow for splitting the code up properly, and makes the
configure code a bit less maintainable.

Introduce instead a "compats.h" that should now be included by
downstreams, alongside compats.c. Also, add Makefile.regen code to
generate said file from the different compat_*.h parts, in the same way
compats.c is generated.
Use the new compats.h facility to include the sys_queue.h and sys_tree.h
code. This removes the special-casing of that header code, and the
configure.in/configure.1/configure.2 sed replacements, making the code
cleaner and more aligned to the rest of the compatibility code.
Remove more "if HAVE_..." code from configure, relying on simple
"#include" statements in compat_*.h code instead.
They use size_t but have not been including it (even pre-refactor)
Given this is now a header file, also convert it from using sh/uname to
define it conditionally, to using preprocessor macros.
This lets compats.h define _GNU_SOURCE etc., rather than config.h, and
moves these ifdefs outside of configure.
@paravoid
Copy link
Copy Markdown
Contributor Author

paravoid commented Jan 3, 2026

It's been a long while, I'm wondering if you've given this any thought. There are conflicts now of course, but it shouldn't be too hard to reconcile. First and foremost it'd be good to hear your opinion on the concept itself :) TIA!

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.

1 participant