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

build: Respect DESTDIR and systemdsystemunitdir #184

Merged
merged 3 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ includedir = @includedir@
datadir = @datarootdir@
localstatedir = @localstatedir@
sysconfdir = @sysconfdir@
systemdsystemunitdir = @systemdsystemunitdir@

VPATH = @srcdir@
srcdir = @srcdir@
Expand Down Expand Up @@ -97,7 +98,8 @@ distclean:
do (cd $$i && $(MAKE) $(MFLAGS) $@); done

systemd:
${INSTALL} clixon-controller.service /usr/lib/systemd/system/
mkdir -p $(DESTDIR)$(systemdsystemunitdir)
${INSTALL} clixon-controller.service $(DESTDIR)$(systemdsystemunitdir)
@echo "systemd service installed, run systemctl enable clixon-controller.service to enable it"

TAGS:
Expand Down
193 changes: 192 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,12 @@ ac_includes_default="\
ac_header_c_list=
ac_subst_vars='LTLIBOBJS
LIBOBJS
HAVE_SYSTEMD_FALSE
HAVE_SYSTEMD_TRUE
systemdsystemunitdir
PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
CLICON_GROUP
CLICON_USER
SSH_BIN
Expand Down Expand Up @@ -736,6 +742,7 @@ with_clixon
enable_nls
with_clicon_user
with_clicon_group
with_systemdsystemunitdir
'
ac_precious_vars='build_alias
host_alias
Expand All @@ -745,7 +752,10 @@ CFLAGS
LDFLAGS
LIBS
CPPFLAGS
CPP'
CPP
PKG_CONFIG
PKG_CONFIG_PATH
PKG_CONFIG_LIBDIR'


# Initialize some variables set by options.
Expand Down Expand Up @@ -1380,6 +1390,8 @@ Optional Packages:
--with-clicon-user=user Run as this user in configuration files
--with-clicon-group=group
Run as this group in configuration files
--with-systemdsystemunitdir=DIR
Directory for systemd service files

Some influential environment variables:
CC C compiler command
Expand All @@ -1390,6 +1402,11 @@ Some influential environment variables:
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
PKG_CONFIG path to pkg-config utility
PKG_CONFIG_PATH
directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Expand Down Expand Up @@ -4894,6 +4911,176 @@ if test -n "${CLICON_GROUP}"; then
echo "Using CLICON_GROUP here: ${CLICON_GROUP}"
fi

# handle systemd service







if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
printf %s "checking for $ac_word... " >&6; }
if test ${ac_cv_path_PKG_CONFIG+y}
then :
printf %s "(cached) " >&6
else $as_nop
case $PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
case $as_dir in #(((
'') as_dir=./ ;;
*/) ;;
*) as_dir=$as_dir/ ;;
esac
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
ac_cv_path_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext"
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS

;;
esac
fi
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
if test -n "$PKG_CONFIG"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
printf "%s\n" "$PKG_CONFIG" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi


fi
if test -z "$ac_cv_path_PKG_CONFIG"; then
ac_pt_PKG_CONFIG=$PKG_CONFIG
# Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
printf %s "checking for $ac_word... " >&6; }
if test ${ac_cv_path_ac_pt_PKG_CONFIG+y}
then :
printf %s "(cached) " >&6
else $as_nop
case $ac_pt_PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
case $as_dir in #(((
'') as_dir=./ ;;
*/) ;;
*) as_dir=$as_dir/ ;;
esac
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
ac_cv_path_ac_pt_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext"
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS

;;
esac
fi
ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
if test -n "$ac_pt_PKG_CONFIG"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
printf "%s\n" "$ac_pt_PKG_CONFIG" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi

if test "x$ac_pt_PKG_CONFIG" = x; then
PKG_CONFIG=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
PKG_CONFIG=$ac_pt_PKG_CONFIG
fi
else
PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
fi

fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=0.9.0
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
printf %s "checking pkg-config is at least version $_pkg_min_version... " >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
PKG_CONFIG=""
fi
fi

# Check whether --with-systemdsystemunitdir was given.
if test ${with_systemdsystemunitdir+y}
then :
withval=$with_systemdsystemunitdir;
else $as_nop
with_systemdsystemunitdir=auto
fi

if test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"
then :

def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)

if test "x$def_systemdsystemunitdir" = "x"
then :
if test "x$with_systemdsystemunitdir" = "xyes"
then :
as_fn_error $? "systemd support requested but pkg-config unable to query systemd package" "$LINENO" 5
fi
with_systemdsystemunitdir=no
else $as_nop
with_systemdsystemunitdir="$def_systemdsystemunitdir"
fi
fi
if test "x$with_systemdsystemunitdir" != "xno"
then :
systemdsystemunitdir=$with_systemdsystemunitdir

fi
if test "x$with_systemdsystemunitdir" != "xno"; then
HAVE_SYSTEMD_TRUE=
HAVE_SYSTEMD_FALSE='#'
else
HAVE_SYSTEMD_TRUE='#'
HAVE_SYSTEMD_FALSE=
fi


ac_config_files="$ac_config_files Makefile clixon-controller.service src/Makefile src/controller.xml yang/Makefile util/Makefile docker/Makefile test/config.sh doc/Makefile plugins/Makefile plugins/junos-native/Makefile"

cat >confcache <<\_ACEOF
Expand Down Expand Up @@ -5041,6 +5228,10 @@ LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs


if test -z "${HAVE_SYSTEMD_TRUE}" && test -z "${HAVE_SYSTEMD_FALSE}"; then
as_fn_error $? "conditional \"HAVE_SYSTEMD\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi

: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
Expand Down
17 changes: 17 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@ if test -n "${CLICON_GROUP}"; then
echo "Using CLICON_GROUP here: ${CLICON_GROUP}"
fi

# handle systemd service
PKG_PROG_PKG_CONFIG()
AC_ARG_WITH([systemdsystemunitdir],
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
[with_systemdsystemunitdir=auto])
AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)

AS_IF([test "x$def_systemdsystemunitdir" = "x"],
[AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemdsystemunitdir=no],
[with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
[AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])

AC_CONFIG_FILES([Makefile
clixon-controller.service
src/Makefile
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ install: $(CLISPECS) $(PLUGINS) $(APPNAME).xml autocli.xml
install -m 0644 $(INSTALLFLAGS) $(BE_PLUGIN) $(DESTDIR)$(libdir)/$(APPNAME)/backend
install -m 0644 $(INSTALLFLAGS) $(CLI_PLUGIN) $(DESTDIR)$(libdir)/$(APPNAME)/cli
install -d -m 0775 -o @CLICON_USER@ -g @CLICON_GROUP@ $(DESTDIR)$(runstatedir)/controller
install -d -m 0755 $(datarootdir)/$(APPNAME)/pipe
install -d -m 0755 $(DESTDIR)$(datarootdir)/$(APPNAME)/pipe

uninstall:
rm -f $(DESTDIR)$(sysconfdir)/clixon/$(APPNAME).xml
Expand Down