From 8b757f7584b7dc3b6997477a7d250901350fa0a2 Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Thu, 12 Sep 2019 19:57:05 -0300 Subject: [PATCH] Make sure we define "extension" for older versions of GCC (5 and under). Make systemd/dbus support optional in Makefile using WANT_SYSTEMD flag. Make sure "extension" keyword is defined for older versions of GCC (5 and under). - Patches provided by Petr Ovtchenkov and Dmitry Bogatov. --- CHANGES | 5 +++++ Makefile | 24 ++++++++++++++++++++---- insserv.c | 2 ++ listing.h | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index d01ce12..bfb19b4 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,11 @@ October 2019 (1.22.0) - jsmith@resonatingmedia.com Added PREFIX variable to Makefile to better control where manual page and insserv executable are stored. Defaults to /usr. This effectively moves insserv executable from /sbin to /usr/sbin. +- Make sure we define "extension" for older versions of GCC (5 and under). + Make systemd/dbus support optional in Makefile using WANT_SYSTEMD + flag. + - Patches provided by Petr Ovtchenkov and Dmitry Bogatov. + July 2019 (1.21.0) - jsmith@resonatingmedia.com diff --git a/Makefile b/Makefile index dacf560..052342d 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,12 @@ DESTDIR = VERSION = 1.21.0 TARBALL = $(PACKAGE)-$(VERSION).tar.xz DATE = $(shell date +'%d%b%y' | tr '[:lower:]' '[:upper:]') -CFLDBUS = $(shell pkg-config --cflags dbus-1) PREFIX ?= /usr +ifdef WANT_SYSTEMD +CFLDBUS = $(shell pkg-config --cflags dbus-1) +else +CFLDBUS = +endif # # Architecture @@ -32,7 +36,10 @@ else endif endif CFLAGS = -W -Wall -Wunreachable-code $(COPTS) $(DEBUG) $(LOOPS) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 \ - $(ISSUSE) -DINITDIR=\"$(INITDIR)\" -DINSCONF=\"$(INSCONF)\" -pipe + $(ISSUSE) -DINITDIR=\"$(INITDIR)\" -DINSCONF=\"$(INSCONF)\" -pipe +ifdef WANT_SYSTEMD + CFLAGS += -DWANT_SYSTEMD=1 +endif CLOOP = # -falign-loops=0 LDFLAGS ?= -Wl,-O,3,--relax LIBS = @@ -41,7 +48,9 @@ ifdef USE_RPMLIB LDFLAGS += -Wl,--as-needed LIBS += -lrpm endif +ifdef WANT_SYSTEMD LIBS += $(shell pkg-config --libs dbus-1) +endif CC ?= gcc RM = rm -f MKDIR = mkdir -p @@ -74,11 +83,16 @@ endif # The rules # +ifdef WANT_SYSTEMD +SYSTEMD_O = systemd.o +SYSTEMD_H = systemd.h +endif + TODO = insserv insserv.8 all: $(TODO) -insserv: insserv.o listing.o systemd.o map.o +insserv: insserv.o listing.o ${SYSTEMD_O} map.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) listing.o: listing.c insserv.c listing.h config.h .system @@ -87,11 +101,13 @@ listing.o: listing.c insserv.c listing.h config.h .system map.o: map.c listing.h config.h .system $(CC) $(CFLAGS) $(CLOOP) $(CFLDBUS) -c $< -insserv.o: insserv.c map.o listing.h systemd.h config.h .system +insserv.o: insserv.c map.o listing.h ${SYSTEMD_H} config.h .system $(CC) $(CFLAGS) $(CLOOP) $(CFLDBUS) insserv.c -c +ifdef WANT_SYSTEMD systemd.o: systemd.c map.o listing.h systemd.h config.h .system $(CC) $(CFLAGS) $(CLOOP) $(CFLDBUS) -c $< +endif listing.h: .system diff --git a/insserv.c b/insserv.c index 1e43bf0..f59b87e 100644 --- a/insserv.c +++ b/insserv.c @@ -23,11 +23,13 @@ * */ +#ifdef WANT_SYSTEMD /* * Systemd integration */ #define SYSTEMD_SERVICE_PATH "/lib/systemd/system" #define SYSTEMD_BINARY_PATH "/bin/systemd" +#endif /* WANT_SYSTEMD */ #define MINIMAL_MAKE 1 /* Remove disabled scripts from .depend.boot, * .depend.start, .depend.halt, and .depend.stop */ diff --git a/listing.h b/listing.h index 4247968..b7d8b84 100644 --- a/listing.h +++ b/listing.h @@ -47,10 +47,10 @@ typedef unsigned int uint; # ifndef asm # define asm __asm__ # endif +#endif # ifndef extension # define extension __extension__ # endif -#endif #ifndef attribute # define attribute(attr) __attribute__(attr) #endif