Skip to content

Conversation

@elmarco
Copy link
Contributor

@elmarco elmarco commented Aug 4, 2025

meson is much more friendly and modern than autotools.

I wanted to see how gemini could help with this. It did fairly well, except with the tests and various minor cleanups.

I didn't delete autotools, but I think we should consider its deprecation after this is accepted to avoid the duplication of effort.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
elmarco added 17 commits August 5, 2025 10:49
This commit introduces the initial Meson build system for libtpms.
This first step allows compiling a minimal shared library and serves
as the foundation for the full migration from Autotools.

The following files are added:
- meson.build: The main build file.
- src/meson.build: The build file for the src directory.
- config.h.in: The template for the configuration header.
- meson_migration_plan.md: The plan for the migration.

This corresponds to Step 1 of the migration plan.

Signed-off-by: Gemini <gemini@google.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Gemini didn't get the license correctly.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit implements Step 2 of the Meson migration plan.

- The build system now finds and links against the OpenSSL library.
- Public header files are now installed to the correct location.
- The 'include' directory has been added to the Meson build process.

Signed-off-by: Gemini <gemini@google.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit implements Step 3 of the Meson migration plan.

 - Added meson_options.txt to define build options.

 - Introduced 'tpm1' and 'tpm2' boolean options to control which parts of the library are built.

 - The build logic in src/meson.build now checks these options.

Signed-off-by: Gemini <gemini@google.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit implements Step 4 of the Meson migration plan.

- Populates the build with the full list of source files for both TPM 1.2 and TPM 2.0 implementations.

- Refactors the build to use intermediate static libraries for TPM1 and TPM2, allowing for implementation-specific compiler flags.

- Adds necessary preprocessor definitions to successfully compile the full library.

- Adds header checks for arpa/inet.h and time.h.

Signed-off-by: Gemini <gemini@google.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit implements Step 5 of the Meson migration plan.

- Adds a comprehensive set of compiler warning flags, such as -Wall and -Werror, checking for compiler support first.

- Adds security hardening flags (-fstack-protector-strong, -D_FORTIFY_SOURCE=2, -Wl,-z,relro, -Wl,-z,now), also checking for compiler and linker support.

- Conditionally applies _FORTIFY_SOURCE only when optimizations are enabled to prevent build failures in debug mode.

- Adds -DOPENSSL_SUPPRESS_DEPRECATED to handle deprecation warnings in OpenSSL and allow the build to succeed with -Werror.

Signed-off-by: Gemini <gemini@google.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit implements Step 6 of the Meson migration plan.

- Adds a 'crypto_backend' option to 'meson_options.txt' to allow selecting between 'openssl' and 'freebl'.

- The build logic in 'src/meson.build' now conditionally selects the appropriate crypto source files and dependencies.

- Adds a forward declaration to 'tpm_crypto_freebl.c' to fix a compilation error when building with '-Werror'.

Signed-off-by: Gemini <gemini@google.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit implements step 7 of the Meson migration plan.

It introduces a new boolean option, 'use_openssl_functions', to control whether to use OpenSSL's own crypto functions or the library's internal ones. This mirrors the behavior of the '--disable-use-openssl-functions' flag in the Autotools build system.

The option is added to 'meson_options.txt' and the corresponding C defines are conditionally applied in 'src/meson.build' for both TPM 1.2 and TPM 2.0 builds when using the OpenSSL backend.

Signed-off-by: Gemini <gemini@google.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit implements the man page portion of step 8 of the Meson migration plan.

It adds the necessary 'meson.build' files to the 'man' and 'man/man3' directories to find 'pod2man' and generate the man pages from the '.pod' source files. The generated man pages are also installed.

Signed-off-by: Gemini <gemini@google.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
For various reasons Gemini wasn't capable of adding the tests.
It kept following rabbit-holes in a loop. Do it by hand instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Implement step 10 of the meson migration plan.

This adds the library versioning information to the shared library
target, including soversion, and handles symbol exports using a
version script, mirroring the behavior of the Autotools build system.

Signed-off-by: Gemini <gemini@google.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Build both libraries, drop need for "static_tests" option.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit adds a meson build to the GitHub CI workflow.
It also updates the README with build instructions for both
autotools and meson.

Signed-off-by: Gemini <gemini@google.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
For some reason, gemini choose a compact form instead.

Also split the libtpms-sepecific files out as did the original Makefile.am.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

To build with meson, run the following commands:

$ meson setup build --prefix=/usr
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add pip install meson here maybe? Do we need ninja to build?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe we add link to https://mesonbuild.com/Quick-guide.html

@stefanberger
Copy link
Owner

FYI: I intend to take this but need to defer it until after rev155 has been merged. There are major changes coming with following upstream to rev155 and I prefer not doubling the effort in every step with automake and meson build.

@elmarco
Copy link
Contributor Author

elmarco commented Aug 10, 2025

no problem, there is no rush, I did this mostly on my spare time for fun :)

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