Do not hardcode paths in scripts

Try to reuse the configured paths as much as possible. Unfortunately, to
be able to fully expand some variable (e.g. `bindir`), these files must
be expanded by make, not by configure. This adds some complexity:

https://www.gnu.org/software/automake/manual/html_node/Scripts.html
This commit is contained in:
Nicola Fontana
2021-07-22 14:23:26 +02:00
parent 673e50e692
commit 4c8ffd9a57
4 changed files with 27 additions and 8 deletions

View File

@@ -1149,8 +1149,6 @@ AC_CONFIG_FILES([
master/Kbuild
master/Makefile
script/Makefile
script/ethercat.service
script/ethercatctl
script/init.d/Makefile
script/init.d/ethercat
script/sysconfig/Makefile

View File

@@ -37,13 +37,34 @@ sbin_SCRIPTS = ethercatctl
dist_sysconf_DATA = ethercat.conf
EXTRA_DIST = \
script_templates = \
ethercatctl.in \
ethercat.service.in \
ethercat.service.in
EXTRA_DIST = \
$(script_templates) \
ifup-eoe.sh
CLEANFILES = \
ethercatctl \
ethercat.service
if HAVE_SYSTEMD
systemdsystemunit_DATA = ethercat.service
endif
# Any precious variable used inside script_templates should appear here
expand_script = $(SED) \
-e 's,[@]VERSION[@],$(VERSION),g' \
-e 's,[@]bindir[@],$(bindir),g' \
-e 's,[@]sbindir[@],$(sbindir),g' \
-e 's,[@]sysconfdir[@],$(sysconfdir),g'
ethercatctl: $(srcdir)/ethercatctl.in Makefile
$(expand_script) < $< > $@
ethercat.service: $(srcdir)/ethercat.service.in Makefile
$(expand_script) < $< > $@
#------------------------------------------------------------------------------

View File

@@ -22,8 +22,8 @@ Description=EtherCAT Master Kernel Modules
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=@prefix@/sbin/ethercatctl start
ExecStop=@prefix@/sbin/ethercatctl stop
ExecStart=@sbindir@/ethercatctl start
ExecStop=@sbindir@/ethercatctl stop
[Install]
WantedBy=multi-user.target

View File

@@ -38,11 +38,11 @@ MODPROBE=/sbin/modprobe
RMMOD=/sbin/rmmod
MODINFO=/sbin/modinfo
ETHERCAT=@prefix@/bin/ethercat
ETHERCAT=@bindir@/ethercat
#------------------------------------------------------------------------------
ETHERCAT_CONFIG=/etc/ethercat.conf
ETHERCAT_CONFIG=@sysconfdir@/ethercat.conf
if [ ! -r ${ETHERCAT_CONFIG} ]; then
echo ${ETHERCAT_CONFIG} not existing;