Skip to content

Commit 4a9aa68

Browse files
sameehjMarkAtwood
authored andcommitted
scripts/sbom.am: add SBOM_OPTIONS_H override to unify the fragment
Make the canonical SBOM fragment a true superset of the vendored copies so it can be re-vendored to every product without regressions. Products whose feature macros live in config.h (via AC_DEFINE) keep the existing behaviour: the recipe derives them from a CC -dM -E dump with AM_CPPFLAGS/AM_CFLAGS/CFLAGS and a force-included SBOM_CONFIG_H. Products whose feature flags are NOT in config.h (wolfMQTT, wolfTPM, wolfscep, which record them in a generated options.h) can now set SBOM_OPTIONS_H to point gen-sbom at that header directly. When unset the compiler-dump path is used exactly as before. This folds the options.h capture that had diverged into the wolfMQTT/ wolfTPM/wolfscep copies back into the single source of truth, while retaining the SBOM_CONFIG_H override, AM_CFLAGS/CFLAGS capture and $(docdir) install those copies were missing. Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
1 parent c3f4825 commit 4a9aa68

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

scripts/sbom.am

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
# (e.g. $(srcdir)/LICENSING).
2121
#
2222
# Optional (defaults shown):
23+
# SBOM_OPTIONS_H Path to a product-generated options header (e.g.
24+
# wolfMQTT's $(builddir)/wolfmqtt/options.h) that records
25+
# the enabled build macros. Set this for products whose
26+
# feature flags are NOT in config.h (no AC_DEFINE); when
27+
# unset the recipe derives the macros from the compiler +
28+
# config.h. Default: unset.
2329
# SBOM_ARTIFACT lib | bin - which build output to hash. Default: lib.
2430
# SBOM_LIB_STEM Library basename w/o extension. Default: lib$(SBOM_PKGNAME).
2531
# SBOM_BIN_NAME Program name when SBOM_ARTIFACT = bin. Default: $(SBOM_PKGNAME).
@@ -99,8 +105,9 @@ CLEANFILES += $(SBOM_CDX) $(SBOM_SPDX) $(SBOM_SPDX_TV)
99105

100106
# Stage a `make install` into a private tree, discover the installed artifact
101107
# (shared/static library or program; ELF/Mach-O/PE), hash it, capture the
102-
# configured build macros (AM_CPPFLAGS/AM_CFLAGS/CFLAGS + config.h; some
103-
# products carry their feature -D flags in AM_CFLAGS rather than AM_CPPFLAGS),
108+
# configured build macros (from SBOM_OPTIONS_H if set, else AM_CPPFLAGS/
109+
# AM_CFLAGS/CFLAGS + config.h; some products carry their feature -D flags in
110+
# AM_CFLAGS rather than AM_CPPFLAGS, and some outside config.h entirely),
104111
# generate SPDX+CDX, validate
105112
# the SPDX, then convert to tag-value. The staging tree and temp defines file
106113
# are removed unconditionally via `trap`, even on failure. SOURCE_DATE_EPOCH is
@@ -143,10 +150,14 @@ sbom:
143150
exit 1; \
144151
fi; \
145152
echo "SBOM: hashing $$sbom_art"; \
146-
$(CC) -dM -E $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
147-
$(AM_CFLAGS) $(CFLAGS) \
148-
$(if $(wildcard $(SBOM_CONFIG_H)),-include $(SBOM_CONFIG_H)) \
149-
-x c /dev/null > "$$_defines"; \
153+
opts_h="$(SBOM_OPTIONS_H)"; \
154+
if test -z "$$opts_h"; then \
155+
opts_h="$$_defines"; \
156+
$(CC) -dM -E $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
157+
$(AM_CFLAGS) $(CFLAGS) \
158+
$(if $(wildcard $(SBOM_CONFIG_H)),-include $(SBOM_CONFIG_H)) \
159+
-x c /dev/null > "$$_defines"; \
160+
fi; \
150161
if test -z "$${SOURCE_DATE_EPOCH:-}" && test -n "$(GIT)" && \
151162
$(GIT) -C "$(srcdir)" rev-parse --git-dir >/dev/null 2>&1; then \
152163
sde=`$(GIT) -C "$(srcdir)" log -1 --format=%ct 2>/dev/null`; \
@@ -190,7 +201,7 @@ sbom:
190201
--version $(PACKAGE_VERSION) \
191202
--supplier "wolfSSL Inc." \
192203
--license-file $(SBOM_LICENSE_FILE) \
193-
--options-h "$$_defines" \
204+
--options-h "$$opts_h" \
194205
--lib "$$sbom_art" \
195206
$$dep_args \
196207
$(if $(SBOM_LICENSE_OVERRIDE),--license-override '$(SBOM_LICENSE_OVERRIDE)') \

0 commit comments

Comments
 (0)