Skip to content

Commit

Permalink
Add build date from git and dont add debug info by default (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbish authored Jan 30, 2024
1 parent 1c0a8d6 commit f10ff96
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ test.conf
__pycache__/
Vagrantfile
.isort.cfg
.vagrant/
.vagrant/
build-date
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#

ACLOCAL_AMFLAGS = -I autotools
SOURCE_DATE_EPOCH=$(shell cat $(builddir)/build-date)

SUBDIRS = compat lib login_duo duo_unix_support

Expand All @@ -18,7 +19,7 @@ endif
SUBDIRS += tests
SUBDIRS += tests/unity_tests

dist_doc_DATA = README.md CONTRIBUTING.md AUTHORS CHANGES $(wildcard sbom.spdx)
dist_doc_DATA = README.md CONTRIBUTING.md AUTHORS CHANGES $(wildcard $(builddir)/build-date) $(wildcard sbom.spdx)

LICENSES = $(wildcard LICENSES/*.txt)

Expand All @@ -30,3 +31,5 @@ DISTCHECK_CONFIGURE_FLAGS = --sysconfdir='$${prefix}/etc'
if PAM
DISTCHECK_CONFIGURE_FLAGS += --with-pam='$${prefix}/lib/security'
endif

DISTCLEANFILES = $(builddir)/build-date
44 changes: 44 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,36 @@ AC_PROG_INSTALL
AC_PROG_MKDIR_P
LT_INIT

AC_MSG_NOTICE(checking if we can establish a build date)
AC_PATH_TOOL(GIT,[git])
AS_IF([test x"$GIT" != x], [
AC_MSG_CHECKING(are we configuring inside a git repository)
$GIT rev-parse 2>/dev/null
is_git_repo=$?
AS_IF([test $is_git_repo == 0], [
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(is the current working tree clean)
$GIT update-index --really-refresh
$GIT diff-index --quiet HEAD
AS_IF([test $? == 0],
[
AC_MSG_RESULT(yes)
source_date_epoch=`$GIT show -s --format=%ct`
AC_MSG_NOTICE(setting build-date to $source_date_epoch)
echo "$source_date_epoch" > build-date
],
[
AC_MSG_RESULT(no current working tree is dirty)
AC_MSG_NOTICE(removing build-date)
rm -f build-date
]
)
],
[
AC_MSG_RESULT(no)
])
])

# Set third party library versions
unity_version=Unity-2.5.2
AC_DEFINE_DIR([UNITY_VERSION], [unity_version], [Unity directory name])
Expand Down Expand Up @@ -127,6 +157,20 @@ AS_IF([test "x$with_coverage" != "xno"], [
AC_MSG_NOTICE([--coverage enabled in CFLAGS])
])

AC_ARG_WITH(debug,
AS_HELP_STRING([--with-debug=DBG],[build with debug info]),
[],
[ with_debug=no ]
)
AM_CONDITIONAL([DEBUG], [ test "x$with_debug" != "xno" ])
AS_IF([test "x$with_debug" != "xno"], [
CFLAGS="$CFLAGS -g2"
AC_MSG_NOTICE([debugging enabled in CFLAGS])
])
AS_IF([test "x$with_debug" == "xno"], [
CFLAGS="$CFLAGS -g0"
])

# Check PAM
AC_ARG_WITH(pam,
AS_HELP_STRING([--with-pam=DIR],[build PAM module (and optionally override the default install DIR)]),
Expand Down

0 comments on commit f10ff96

Please sign in to comment.