Skip to content

Commit b1bb7d7

Browse files
committed
Export 'SOURCE_DATE_EPOCH' in makefiles
Add configure check for 'export' (GNU make) or '.export' (BSD make) makefile statements. Remove no longer needed 'export' statements from workflows. Signed-off-by: Christian Franke <christian.franke@t-online.de>
1 parent 5130997 commit b1bb7d7

7 files changed

Lines changed: 45 additions & 20 deletions

File tree

.github/workflows/build-manually.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ jobs:
146146
tar -xf "$distfile" &&
147147
version_sh=$("${distfile%.tar.gz}/src/getversion.sh" -s) && eval "${version_sh}" &&
148148
cd smartmontools-${SMARTMONTOOLS_PKG_VER} && mkdir build && cd build &&
149-
export SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
150149
../configure --with-build-info='(GHA/clang/${{ github.event.inputs.suffix }})' \
151150
CC=clang CXX=clang++ \
152-
${{ github.event.inputs.cfg-options }} &&
151+
${{ github.event.inputs.cfg-options }} \
152+
SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
153153
../src/clang-scan-build.sh \
154154
-f "../../smartmontools-ubuntu-x86_64-clang-report-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz" \
155155
make ${{ github.event.inputs.make-options }} &&
@@ -191,10 +191,10 @@ jobs:
191191
tar -xf "$distfile" &&
192192
version_sh=$("${distfile%.tar.gz}/src/getversion.sh" -s) && eval "${version_sh}" &&
193193
cd smartmontools-${SMARTMONTOOLS_PKG_VER} && mkdir build && cd build &&
194-
export SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
195194
../configure --with-build-info='(GHA/clang/${{ github.event.inputs.suffix }})' \
196195
CC=clang CXX=clang++ \
197-
${{ github.event.inputs.cfg-options }} &&
196+
${{ github.event.inputs.cfg-options }} \
197+
SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
198198
../src/clang-scan-build.sh \
199199
-f "../../smartmontools-ubuntu-arm64-clang-report-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz" \
200200
make ${{ github.event.inputs.make-options }} &&

.github/workflows/cygwin.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ jobs:
4444
- name: Build with x86_64 gcc
4545
run: |
4646
mkdir build-gcc && cd build-gcc &&
47-
export SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
48-
../configure --with-build-info='(GHA/Cygwin)' &&
47+
../configure --with-build-info='(GHA/Cygwin)' \
48+
SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
4949
make -j && make check &&
5050
make bin-dist bin_distfile="smartmontools-cygwin-x86_64-gcc-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz"
5151
shell: bash --noprofile --norc -e -o igncr '{0}'
@@ -60,8 +60,8 @@ jobs:
6060
- name: Build with x86_64 clang
6161
run: |
6262
mkdir build-clang && cd build-clang &&
63-
export SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
64-
../configure --with-build-info='(GHA/Cygwin)' CC=clang CXX=clang++ &&
63+
../configure --with-build-info='(GHA/Cygwin)' CC=clang CXX=clang++ \
64+
SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
6565
../src/clang-scan-build.sh \
6666
-f "smartmontools-cygwin-clang-report-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz" \
6767
make -j &&

.github/workflows/macos.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ jobs:
3030
- name: Build (multiarch)
3131
run: |
3232
mkdir build && cd build &&
33-
export SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
34-
../configure --with-build-info='(GHA/macOS)' 'CFLAGS=-arch arm64 -arch x86_64' 'CXXFLAGS=-arch arm64 -arch x86_64' &&
33+
../configure --with-build-info='(GHA/macOS)' \
34+
CFLAGS=-'arch arm64 -arch x86_64' CXXFLAGS='-arch arm64 -arch x86_64' \
35+
SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
3536
make -j && make check &&
3637
make bin-dist bin_distfile="smartmontools-macos-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz"
3738

.github/workflows/msys2.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ jobs:
4242
fetch-tags: true
4343

4444
- name: Build (${{matrix.env}})
45-
run: | # 'export SOURCE_DATE_EPOCH' suppresses an extra timestamp set by Clang LLD only
45+
run: |
4646
version_sh=$(src/getversion.sh -s) && eval "${version_sh}" &&
4747
./autogen.sh && mkdir build && cd build &&
48-
SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
4948
../configure --with-build-info='(GHA/MSYS2)' --enable-static-link \
50-
SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} &&
51-
case ${{matrix.env}} in clang*) export SOURCE_DATE_EPOCH ;; esac &&
49+
SOURCE_DATE_EPOCH=$((SMARTMONTOOLS_GIT_REV_EPOCH + 1)) &&
5250
make -j && make check &&
5351
make distinst_win32="smartmontools-mingw64-${{matrix.env}}-${SMARTMONTOOLS_GIT_VER_FNAME}.exe" \
5452
installer-win32

configure.ac

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ case "$host_os" in
8080
esac
8181

8282
source_date_iso=
83+
dot_export="# export"
8384
if test -n "$SOURCE_DATE_EPOCH"; then
8485
# SOURCE_DATE_EPOCH must be either unset or numeric.
8586
test -z "`echo "$SOURCE_DATE_EPOCH" | sed -e 's,^$,X,' -e 's,[[0-9]],,g'`" \
@@ -97,9 +98,23 @@ if test -n "$SOURCE_DATE_EPOCH"; then
9798
cmd="unknown"
9899
done
99100
AC_MSG_RESULT([$cmd])
101+
102+
AC_MSG_CHECKING([how ${MAKE-make} exports environment variables])
103+
dot_export=
104+
# GNU make BSD make
105+
for exp in "export" ".export"; do
106+
printf 'X=42\n%s X\nall:\n\ttest "$(X)" = "$$X"\n' "$exp" > conftest.make
107+
if (unset X && ${MAKE-make} -f conftest.make >/dev/null 2>&1); then
108+
dot_export=$exp; break
109+
fi
110+
done
111+
rm -f conftest.make
112+
AC_MSG_RESULT([${dot_export:-unknown}])
113+
test -n "$dot_export" || dot_export="# unknown export"
100114
fi
101115
AC_SUBST([SOURCE_DATE_EPOCH])
102116
AC_SUBST([source_date_iso])
117+
AC_SUBST([dot_export])
103118
AM_CONDITIONAL(REPRODUCIBLE_BUILD, [test -n "$SOURCE_DATE_EPOCH"])
104119

105120
# Checks for header files.
@@ -1161,6 +1176,14 @@ is not available.
11611176
]) ;;
11621177
esac
11631178

1179+
case $dot_export in
1180+
*unknown*) AC_MSG_WARN([
1181+
This script was unable to determine how '${MAKE-make}' exports environment variables.
1182+
Use 'export SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH' before running '${MAKE-make}'.
1183+
Please inform $PACKAGE_BUGREPORT - Thanks!
1184+
]) ;;
1185+
esac
1186+
11641187
case "$dist_tar:$SOURCE_DATE_EPOCH" in
11651188
false:?*) AC_MSG_WARN([
11661189
Reproducible tarballs require GNU tar which is not available.

lib/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
#
55

66
if REPRODUCIBLE_BUILD
7+
@dot_export@ SOURCE_DATE_EPOCH
78
if OS_DARWIN
8-
export ZERO_AR_DATE := 1
9+
ZERO_AR_DATE = 1
10+
@dot_export@ ZERO_AR_DATE
911
endif
1012
endif
1113

src/Makefile.am

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
#
55

66
if REPRODUCIBLE_BUILD
7-
set_source_date_epoch = SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)
7+
@dot_export@ SOURCE_DATE_EPOCH
88
if OS_DARWIN
9-
export ZERO_AR_DATE := 1
9+
ZERO_AR_DATE = 1
10+
@dot_export@ ZERO_AR_DATE
1011
endif
1112
endif
1213

@@ -490,9 +491,9 @@ update-smart-drivedb.1m: update-smart-drivedb.8
490491

491492
# Convert man pages into .html, .pdf and .txt
492493
MAN2HTML = man2html
493-
#MAN2HTML = $(set_source_date_epoch) groff -man -Thtml
494-
MAN2PDF = $(set_source_date_epoch) man -Tpdf -l
495-
#MAN2PDF = $(set_source_date_epoch) groff -man -Tpdf
494+
#MAN2HTML = groff -man -Thtml
495+
MAN2PDF = man -Tpdf -l
496+
#MAN2PDF = groff -man -Tpdf
496497

497498
# Remove HTTP header and timestamp and fix links in man2html output
498499
FIXHTML = sed -e '1s,^Content-type.*,,' \

0 commit comments

Comments
 (0)