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

Portable makefiles 8 #1098

Merged
merged 4 commits into from
Dec 19, 2024
Merged

Portable makefiles 8 #1098

merged 4 commits into from
Dec 19, 2024

Conversation

tleedjarv
Copy link
Contributor

This PR concludes the series aimed at making the makefiles portable. (Build instructions are yet to be updated.)

As a result, building Unison now works with GNU Make, BSD make, Solaris make and NMAKE. GNU tools and a POSIX shell are no longer needed. Additionally, building the manpage and docs works with all of the above, except with NMAKE.

The first commit could theoretically be split into smaller pieces but I chose not to do it for a few reasons. First, I wanted to keep it together for the history. Reviewing it in detail is likely not feasible anyway, and ensuring it does not break anything is a task better achieved via CI and manual testing.

A short summary of what is going on: The series of PRs so far has gradually changed/simplified the makefile contents so that it becomes acceptable for serveral make implementations. Any remaining parts that can't be made portable with simple syntax changes have been moved out into a separate script (the first commit in this PR). The script is written in OCaml because OCaml is required for building anyway and this way we can be completely portable. Any remaining shell invocations in the makefiles have been simplified to the degree that they become acceptable for the shell in Windows. This way we no longer depend on GNU tools, a POSIX shell, or otherwise have specific expectations on the environment. The separate script is invoked automatically every time make is run to generate configuration files that are included in the makefile. The script uses a syntax that, if you squint really hard, resembles the makefile a little bit.

Nothing changes from the user's perspective, except they no longer have to use gmake.

I have tested this with all of the make implementations mentioned above (some manually, some with CI). BSD make has been tested in NetBSD, FreeBSD, OpenBSD and DragonFly BSD. Solaris (d)make has been tested in OmniOS and Oracle Solaris.

There is no portable syntax for conditionals and other more complex
constructs, including shell scripts. This patch moves non-portable
conditionals and other such parts into a separate script written in
OCaml. The script itself is fully portable, it does not require GNU
tools or even a POSIX shell.

With this patch the main makefile becomes fully portable and currently
works with GNU Make, BSD make, Solaris make and NMAKE.
... and build it only on POSIX-y platforms (not used in Windows anyway).
... and build docs only on POSIX-y platforms (can't easily build in
Windows).
This patch makes the docs makefile portable with GNU Make, BSD make and
Solaris make by:
 - removing all pattern rules
 - removing all conditionals from makefile (ok in shell)
 - removing all obscure macro functions
@gdt
Copy link
Collaborator

gdt commented Dec 19, 2024

Builds on NetBSD 10 with gmake, make(bsd), with and without -j32.

@gdt gdt merged commit c9fc0bc into bcpierce00:master Dec 19, 2024
31 checks passed
@tleedjarv tleedjarv deleted the portable-make-8 branch December 19, 2024 15:12
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