aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-19 02:28:16 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-19 02:28:16 +0100
commit34eb0d9bb4b92c318e0ac3e05a76b47dd070d0f9 (patch)
tree32d2ce0fd3c87c3159b009ccf2bf633ac9dcb78d
parentadd code (diff)
downloadsleeping-getty-34eb0d9bb4b92c318e0ac3e05a76b47dd070d0f9.tar.gz
sleeping-getty-34eb0d9bb4b92c318e0ac3e05a76b47dd070d0f9.tar.bz2
sleeping-getty-34eb0d9bb4b92c318e0ac3e05a76b47dd070d0f9.tar.xz
add support in make files for sbin and libexec
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
-rw-r--r--Makefile.in5
-rw-r--r--mk/lang-c.mk58
2 files changed, 50 insertions, 13 deletions
diff --git a/Makefile.in b/Makefile.in
index 1f35660..a15afba 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -56,10 +56,11 @@ _VERSION = 1.0
# Used by mk/lang-c.mk
_C_STD = c99
_PEDANTIC = yes
-_BIN = sleeping-getty
+_SBIN = sleeping-getty
_OBJ_sleeping-getty = sleeping-getty
_HEADER_DIRLEVELS = 0
_CPPFLAGS = -D'PACKAGE="$(PKGNAME)"' -D'PROGRAM_VERSION="$(_VERSION)"'
+_BINDIR = SBINDIR
# Used by mk/texinfo.mk
_TEXINFO_DIRLEVELS = 2
@@ -81,7 +82,7 @@ ___EVERYTHING_INFO = sleeping-getty titlepage-data content hardcopy-copying \
chap/invoking chap/overview \
reusable/macros reusable/paper reusable/titlepage
___EVERYTHING_H = common
-_SRC = $(foreach B,$(_BIN),$(foreach F,$(_OBJ_$(B)),$(F).c))
+_SRC = $(foreach B,$(_SBIN),$(foreach F,$(_OBJ_$(B)),$(F).c))
_EVERYTHING = $(foreach F,$(___EVERYTHING_INFO),doc/info/$(F).texinfo) \
$(foreach F,$(___EVERYTHING_H),src/$(F).h) \
$(__EVERYTHING_ALL_COMMON) DEPENDENCIES INSTALL NEWS
diff --git a/mk/lang-c.mk b/mk/lang-c.mk
index 7e9a15a..5bc5197 100644
--- a/mk/lang-c.mk
+++ b/mk/lang-c.mk
@@ -36,6 +36,20 @@
# that lists all objects files (without the
# suffix and without the aux/ prefix) that
# are required to build the command.
+#
+# Binary you want installed to /sbin rather than
+# /bin shall be listed in _SBIN rather than in
+# _BIN. _SBIN and _BIN may not list binaries
+# with identical names. Analogically, you may
+# add _LIBEXEC for binary to be installed to
+# /libexec.
+#
+# If you only have one binary, you may select
+# to define _BINDIR to name the variable with
+# the pathname for the directory the binary
+# shall be installed. For example, if you want
+# the binary to be installed to /usr/sbin,
+# define _BINDIR = SBINDIR.
ifdef _C_STD
@@ -110,9 +124,6 @@ endif
# Add CPP definitions for all directories.
_CPPFLAGS += $(foreach D,$(_ALL_DIRS),-D'$(D)="$($(D))"')
-
-# MORE HELP VARIABLES:
-
# Compilation and linking flags, and command.
ifndef CPPFLAGS
CPPFLAGS =
@@ -147,11 +158,16 @@ endif
endif
endif
+# Directory for the binary if there is only one binary.
+ifndef _BINDIR
+_BINDIR = BINDIR
+endif
+
# BUILD RULES:
.PHONY: cmd-c
-cmd-c: $(foreach B,$(_BIN),bin/$(B))
+cmd-c: $(foreach B,$(_BIN) $(_SBIN) $(_LIBEXEC),bin/$(B))
# Compile a C file into an object file.
aux/%.o: $(v)src/%.c $(foreach H,$(__H),$(v)$(H))
@@ -173,20 +189,31 @@ include aux/lang-c.mk
aux/lang-c.mk: Makefile
@$(MKDIR) -p aux
@$(ECHO) > aux/lang-c.mk
- @$(foreach B,$(_BIN),$(ECHO) bin/$(B): $(foreach O,$(_OBJ_$(B)),aux/$(O).o) >> aux/lang-c.mk &&) $(TRUE)
+ @$(foreach B,$(_BIN) $(_SBIN) $(_LIBEXEC),$(ECHO) bin/$(B): $(foreach O,$(_OBJ_$(B)),aux/$(O).o) >> aux/lang-c.mk &&) $(TRUE)
# INSTALL RULES:
.PHONY: install-cmd-c
-install-cmd-c: $(foreach B,$(_BIN),bin/$(B))
+install-cmd-c: $(foreach B,$(_BIN) $(_SBIN) $(_LIBEXEC),bin/$(B))
@$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
+ifndef COMMAND
+ifdef _BIN
$(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(BINDIR)"
-ifdef COMMAND
- $(Q)$(INSTALL_PROGRAM) $(__STRIP) $^ -- "$(DESTDIR)$(BINDIR)"
+ $(Q)$(INSTALL_PROGRAM) $(__STRIP) $(foreach B,$(_BIN),bin/$(B)) -- "$(DESTDIR)$(BINDIR)"
endif
-ifndef COMMAND
- $(Q)$(INSTALL_PROGRAM) $(__STRIP) $^ -- "$(DESTDIR)$(BINDIR)/$(COMMAND)"
+ifdef _SBIN
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(SBINDIR)"
+ $(Q)$(INSTALL_PROGRAM) $(__STRIP) $(foreach B,$(_SBIN),bin/$(B)) -- "$(DESTDIR)$(SBINDIR)"
+endif
+ifdef _LIBEXEC
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)"
+ $(Q)$(INSTALL_PROGRAM) $(__STRIP) $(foreach B,$(_LIBEXEC),bin/$(B)) -- "$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)"
+endif
+endif
+ifdef COMMAND
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$($(_BINDIR))"
+ $(Q)$(INSTALL_PROGRAM) $(__STRIP) $^ -- "$(DESTDIR)$($(_BINDIR))/$(COMMAND)"
endif
@$(ECHO_EMPTY)
@@ -196,11 +223,20 @@ endif
.PHONY: uninstall-cmd-c
uninstall-cmd-c:
ifdef COMMAND
- -$(Q)$(RM) -- "$(DESTDIR)$(BINDIR)/$(COMMAND)"
+ -$(Q)$(RM) -- "$(DESTDIR)$($(_BINDIR))/$(COMMAND)"
endif
ifndef COMMAND
+ifdef _BIN
-$(Q)$(RM) -- $(foreach B,$(_BIN),"$(DESTDIR)$(BINDIR)/$(B)")
endif
+ifdef _SBIN
+ -$(Q)$(RM) -- $(foreach B,$(_SBIN),"$(DESTDIR)$(SBINDIR)/$(B)")
+endif
+ifdef _LIBEXEC
+ -$(Q)$(RM) -- $(foreach B,$(_LIBEXEC),"$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)/$(B)")
+ -$(Q)$(RMDIR) -- "$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)"
+endif
+endif
endif