2009-09-10 13:58:49 +05:30
|
|
|
#
|
|
|
|
# Makefile Makefile for the systemV init suite.
|
|
|
|
# Targets: all compiles everything
|
|
|
|
# install installs the binaries (not the scripts)
|
|
|
|
# clean cleans up object files
|
|
|
|
# clobber really cleans up
|
|
|
|
#
|
|
|
|
# Version: @(#)Makefile 2.85-13 23-Mar-2004 miquels@cistron.nl
|
|
|
|
#
|
|
|
|
|
2010-04-01 14:36:35 +05:30
|
|
|
CPPFLAGS =
|
2018-06-22 04:04:25 +05:30
|
|
|
CFLAGS ?= -O2
|
2018-07-02 03:14:57 +05:30
|
|
|
override CFLAGS += -ansi -fomit-frame-pointer -fstack-protector-strong -W -Wall -Wunreachable-code -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE -D_GNU_SOURCE -DVERSION=\"$(VERSION)\"
|
2018-02-21 04:56:09 +05:30
|
|
|
override CFLAGS += $(shell getconf LFS_CFLAGS)
|
2009-09-10 13:58:49 +05:30
|
|
|
STATIC =
|
2011-04-27 19:11:04 +05:30
|
|
|
MANDB := s@^\('\\\\\"\)[^\*-]*-\*- coding: [^[:blank:]]\+ -\*-@\1@
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2011-07-01 19:26:45 +05:30
|
|
|
#
|
|
|
|
# Leave empty if the mountpoint(1) command from util-linux 2.20
|
|
|
|
# and above should be used, otherwise set it to yes.
|
|
|
|
#
|
|
|
|
MNTPOINT=
|
|
|
|
|
2009-09-10 13:58:49 +05:30
|
|
|
# For some known distributions we do not build all programs, otherwise we do.
|
|
|
|
BIN =
|
2019-01-01 02:01:34 +05:30
|
|
|
SBIN = init halt shutdown runlevel killall5 fstab-decode logsave
|
2018-11-13 06:23:52 +05:30
|
|
|
USRBIN = last mesg readbootlog
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2018-11-13 06:23:52 +05:30
|
|
|
MAN1 = last.1 lastb.1 mesg.1 readbootlog.1
|
2018-04-15 03:49:18 +05:30
|
|
|
MAN5 = initscript.5 inittab.5 initctl.5
|
2009-09-10 13:58:49 +05:30
|
|
|
MAN8 = halt.8 init.8 killall5.8 pidof.8 poweroff.8 reboot.8 runlevel.8
|
2019-01-01 02:01:34 +05:30
|
|
|
MAN8 += shutdown.8 telinit.8 fstab-decode.8 logsave.8
|
2009-09-10 13:58:49 +05:30
|
|
|
|
|
|
|
ifeq ($(DISTRO),)
|
|
|
|
SBIN += sulogin bootlogd
|
|
|
|
USRBIN += utmpdump wall
|
2011-07-01 19:26:45 +05:30
|
|
|
MAN1 += utmpdump.1 wall.1
|
2009-09-10 13:58:49 +05:30
|
|
|
MAN8 += sulogin.8 bootlogd.8
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(DISTRO),Debian)
|
2010-03-23 20:07:01 +05:30
|
|
|
CPPFLAGS+= -DACCTON_OFF
|
2022-11-22 19:54:26 +05:30
|
|
|
SBIN += bootlogd
|
|
|
|
MAN8 += bootlogd.8
|
2011-04-27 19:11:04 +05:30
|
|
|
MANDB :=
|
2009-09-10 13:58:49 +05:30
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(DISTRO),Owl)
|
|
|
|
USRBIN += wall
|
|
|
|
MAN1 += wall.1
|
2011-04-27 19:11:04 +05:30
|
|
|
MANDB :=
|
2009-09-10 13:58:49 +05:30
|
|
|
endif
|
|
|
|
|
2010-02-19 21:21:36 +05:30
|
|
|
ifeq ($(DISTRO),SuSE)
|
2010-03-30 23:09:19 +05:30
|
|
|
CPPFLAGS+= -DUSE_SYSFS -DSANE_TIO -DSIGINT_ONLYONCE -DUSE_ONELINE
|
2010-02-19 21:21:36 +05:30
|
|
|
SBIN += sulogin
|
|
|
|
USRBIN += utmpdump
|
2011-07-01 19:26:45 +05:30
|
|
|
MAN1 += utmpdump.1
|
2010-02-19 21:21:36 +05:30
|
|
|
MAN8 += sulogin.8
|
2011-04-27 19:11:04 +05:30
|
|
|
MANDB :=
|
2010-02-19 21:21:36 +05:30
|
|
|
endif
|
|
|
|
|
2011-07-01 19:26:45 +05:30
|
|
|
ifeq ($(MNTPOINT),yes)
|
|
|
|
BIN += mountpoint
|
|
|
|
MAN1 += mountpoint.1
|
|
|
|
endif
|
|
|
|
|
2022-08-23 23:38:13 +05:30
|
|
|
MANPAGES:=$(MAN1) $(MAN5) $(MAN8)
|
|
|
|
MANPAGES+=$(subst ../man/,,$(foreach man,$(MANPAGES),$(wildcard ../man/??/$(man))))
|
|
|
|
|
2010-03-23 20:07:01 +05:30
|
|
|
ID = $(shell id -u)
|
2009-09-10 13:58:49 +05:30
|
|
|
BIN_OWNER = root
|
|
|
|
BIN_GROUP = root
|
|
|
|
BIN_COMBO = $(BIN_OWNER):$(BIN_GROUP)
|
2010-03-23 20:07:01 +05:30
|
|
|
ifeq ($(ID),0)
|
|
|
|
INSTALL_EXEC = install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 755
|
|
|
|
INSTALL_DATA = install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 644
|
|
|
|
else
|
|
|
|
INSTALL_EXEC = install -m 755
|
|
|
|
INSTALL_DATA = install -m 644
|
|
|
|
endif
|
2009-11-21 04:25:47 +05:30
|
|
|
INSTALL_DIR = install -m 755 -d
|
2022-12-16 22:21:41 +05:30
|
|
|
MANDIR = /usr/share/man
|
2009-09-10 13:58:49 +05:30
|
|
|
|
|
|
|
ifeq ($(WITH_SELINUX),yes)
|
2010-03-23 20:07:01 +05:30
|
|
|
SELINUX_DEF = -DWITH_SELINUX
|
2019-06-15 22:31:01 +05:30
|
|
|
INITLIBS += -lselinux
|
2010-03-23 20:07:01 +05:30
|
|
|
SULOGINLIBS = -lselinux
|
2009-09-10 13:58:49 +05:30
|
|
|
else
|
2010-03-23 20:07:01 +05:30
|
|
|
SELINUX_DEF =
|
|
|
|
INITLIBS =
|
|
|
|
SULOGINLIBS =
|
|
|
|
endif
|
|
|
|
|
2022-12-02 00:58:14 +05:30
|
|
|
ROOT ?= $(DESTDIR)
|
|
|
|
|
2009-09-10 13:58:49 +05:30
|
|
|
# Additional libs for GNU libc.
|
2019-09-13 02:05:55 +05:30
|
|
|
ifneq ($(wildcard $(ROOT)/usr/lib*/libcrypt.*),)
|
2014-01-26 03:27:25 +05:30
|
|
|
SULOGINLIBS += -lcrypt
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Additional libs for GNU libc / multiarch on Debian based systems.
|
2019-09-13 02:05:55 +05:30
|
|
|
ifneq ($(wildcard $(ROOT)/usr/lib/*/libcrypt.*),)
|
|
|
|
ifneq ($(findstring -lcrypt, $(SULOGINLIBS)), -lcrypt)
|
2010-03-23 20:07:01 +05:30
|
|
|
SULOGINLIBS += -lcrypt
|
2009-09-10 13:58:49 +05:30
|
|
|
endif
|
2019-09-13 02:05:55 +05:30
|
|
|
endif
|
2009-09-10 13:58:49 +05:30
|
|
|
|
|
|
|
all: $(BIN) $(SBIN) $(USRBIN)
|
|
|
|
|
2009-11-21 04:25:47 +05:30
|
|
|
#%: %.o
|
|
|
|
# $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
|
|
|
|
#%.o: %.c
|
|
|
|
# $(CC) $(CFLAGS) $(CPPFLAGS) -c $^ -o $@
|
|
|
|
|
2010-03-23 20:07:01 +05:30
|
|
|
init: LDLIBS += $(INITLIBS) $(STATIC)
|
2018-07-08 04:49:03 +05:30
|
|
|
init: init.o init_utmp.o runlevellog.o
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2014-01-29 03:41:34 +05:30
|
|
|
halt: LDLIBS += $(STATIC)
|
2018-07-08 04:49:03 +05:30
|
|
|
halt: halt.o ifdown.o hddown.o utmp.o runlevellog.o
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2014-01-29 03:41:34 +05:30
|
|
|
last: LDLIBS += $(STATIC)
|
2010-05-04 13:20:12 +05:30
|
|
|
last: last.o
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2019-01-01 02:01:34 +05:30
|
|
|
logsave: LDLIBS += $(STATIC)
|
|
|
|
logsave: logsave.o
|
|
|
|
|
2014-01-29 03:41:34 +05:30
|
|
|
mesg: LDLIBS += $(STATIC)
|
2009-09-10 13:58:49 +05:30
|
|
|
mesg: mesg.o
|
|
|
|
|
2014-01-29 03:41:34 +05:30
|
|
|
mountpoint: LDLIBS += $(STATIC)
|
2009-09-10 13:58:49 +05:30
|
|
|
mountpoint: mountpoint.o
|
|
|
|
|
2014-01-29 03:41:34 +05:30
|
|
|
utmpdump: LDLIBS += $(STATIC)
|
2009-09-10 13:58:49 +05:30
|
|
|
utmpdump: utmpdump.o
|
|
|
|
|
2014-01-29 03:41:34 +05:30
|
|
|
runlevel: LDLIBS += $(STATIC)
|
2018-07-08 03:19:04 +05:30
|
|
|
runlevel: runlevel.o runlevellog.o
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2010-03-23 20:07:01 +05:30
|
|
|
sulogin: LDLIBS += $(SULOGINLIBS) $(STATIC)
|
2011-04-04 19:27:54 +05:30
|
|
|
sulogin: sulogin.o consoles.o
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2014-01-29 03:41:34 +05:30
|
|
|
wall: LDLIBS += $(STATIC)
|
2009-09-10 13:58:49 +05:30
|
|
|
wall: dowall.o wall.o
|
|
|
|
|
2014-01-29 03:41:34 +05:30
|
|
|
shutdown: LDLIBS += $(STATIC)
|
2010-05-04 13:20:12 +05:30
|
|
|
shutdown: dowall.o shutdown.o utmp.o
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2014-01-29 03:41:34 +05:30
|
|
|
bootlogd: LDLIBS += -lutil $(STATIC)
|
2019-01-01 02:01:34 +05:30
|
|
|
bootlogd: bootlogd.o
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2018-11-13 06:23:52 +05:30
|
|
|
readbootlog: LDLIBS += $(STATIC)
|
2019-01-01 02:01:34 +05:30
|
|
|
readbootlog: readbootlog.o
|
2018-11-13 06:23:52 +05:30
|
|
|
|
2014-01-29 03:41:34 +05:30
|
|
|
fstab-decode: LDLIBS += $(STATIC)
|
|
|
|
fstab-decode: fstab-decode.o
|
|
|
|
|
2009-11-21 04:25:47 +05:30
|
|
|
sulogin.o: CPPFLAGS += $(SELINUX_DEF)
|
2009-09-10 13:58:49 +05:30
|
|
|
sulogin.o: sulogin.c
|
|
|
|
|
2018-07-08 03:19:04 +05:30
|
|
|
runlevellog.o: runlevellog.h runlevellog.c paths.h
|
|
|
|
|
2009-11-21 04:25:47 +05:30
|
|
|
init.o: CPPFLAGS += $(SELINUX_DEF)
|
2018-12-28 01:01:14 +05:30
|
|
|
init.o: init.c init.h initreq.h paths.h reboot.h runlevellog.h runlevellog.c set.h
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2010-05-04 13:20:12 +05:30
|
|
|
utmp.o:
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2009-11-21 04:25:47 +05:30
|
|
|
init_utmp.o: CPPFLAGS += -DINIT_MAIN
|
2010-05-04 13:20:12 +05:30
|
|
|
init_utmp.o: utmp.c init.h initreq.h paths.h
|
2009-11-21 04:25:47 +05:30
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
2009-09-10 13:58:49 +05:30
|
|
|
|
2019-01-01 02:01:34 +05:30
|
|
|
bootlogd.o: bootlogd.c bootlogd.h
|
|
|
|
|
|
|
|
readbootlog.o: readbootlog.c
|
|
|
|
|
2010-05-04 13:20:12 +05:30
|
|
|
utmpdump.o: utmpdump.c oldutmp.h
|
|
|
|
|
|
|
|
shutdown.o: shutdown.c paths.h reboot.h initreq.h init.h
|
|
|
|
|
2018-07-08 04:49:03 +05:30
|
|
|
halt.o: halt.c reboot.h paths.h runlevellog.c runlevellog.h
|
2010-05-04 13:20:12 +05:30
|
|
|
|
|
|
|
last.o: last.c oldutmp.h
|
|
|
|
|
2019-01-01 02:01:34 +05:30
|
|
|
logsave.o: logsave.c
|
|
|
|
|
2011-03-11 22:59:36 +05:30
|
|
|
consoles.o: consoles.c consoles.h
|
|
|
|
|
2009-09-10 13:58:49 +05:30
|
|
|
cleanobjs:
|
|
|
|
rm -f *.o *.bak
|
|
|
|
|
2019-09-11 23:12:20 +05:30
|
|
|
clean: cleanobjs clobber
|
2009-09-10 13:58:49 +05:30
|
|
|
|
|
|
|
clobber: cleanobjs
|
|
|
|
rm -f $(BIN) $(SBIN) $(USRBIN)
|
|
|
|
|
|
|
|
distclean: clobber
|
|
|
|
|
2018-11-08 02:54:55 +05:30
|
|
|
install: all
|
2022-12-16 22:21:41 +05:30
|
|
|
$(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/
|
|
|
|
$(INSTALL_DIR) $(ROOT)/usr/bin/
|
2009-09-10 13:58:49 +05:30
|
|
|
for i in $(BIN); do \
|
2022-12-16 22:21:41 +05:30
|
|
|
$(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \
|
2009-09-10 13:58:49 +05:30
|
|
|
done
|
|
|
|
for i in $(SBIN); do \
|
2022-12-16 22:21:41 +05:30
|
|
|
$(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \
|
2009-09-10 13:58:49 +05:30
|
|
|
done
|
|
|
|
for i in $(USRBIN); do \
|
2022-12-16 22:21:41 +05:30
|
|
|
$(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
|
2009-09-10 13:58:49 +05:30
|
|
|
done
|
2010-03-26 22:01:05 +05:30
|
|
|
# $(INSTALL_DIR) $(ROOT)/etc/
|
2020-01-09 05:12:43 +05:30
|
|
|
$(INSTALL_DIR) $(ROOT)/etc/inittab.d
|
2018-02-21 05:06:21 +05:30
|
|
|
# $(INSTALL_EXEC) ../doc/initscript.sample $(ROOT)/etc/
|
2009-09-10 13:58:49 +05:30
|
|
|
ln -sf halt $(ROOT)/sbin/reboot
|
|
|
|
ln -sf halt $(ROOT)/sbin/poweroff
|
|
|
|
ln -sf init $(ROOT)/sbin/telinit
|
2022-12-02 08:25:13 +05:30
|
|
|
ln -sf ../sbin/killall5 $(ROOT)/bin/pidof
|
2009-09-10 13:58:49 +05:30
|
|
|
if [ ! -f $(ROOT)/usr/bin/lastb ]; then \
|
|
|
|
ln -sf last $(ROOT)/usr/bin/lastb; \
|
|
|
|
fi
|
2009-11-21 04:25:47 +05:30
|
|
|
$(INSTALL_DIR) $(ROOT)/usr/include/
|
2009-09-10 13:58:49 +05:30
|
|
|
$(INSTALL_DATA) initreq.h $(ROOT)/usr/include/
|
2022-08-23 23:38:13 +05:30
|
|
|
for man in $(MANPAGES) ; do \
|
|
|
|
targetdir=$(ROOT)$(MANDIR)/$$(dirname $$man)/man$${man##*.}; \
|
|
|
|
$(INSTALL_DIR) $$targetdir; \
|
|
|
|
$(INSTALL_DATA) ../man/$$man $$targetdir/$$(basename $$man); \
|
|
|
|
sed -i "1{ $(MANDB); }" $$targetdir/$$(basename $$man); \
|
2009-09-10 13:58:49 +05:30
|
|
|
done
|
|
|
|
ifeq ($(ROOT),)
|
|
|
|
#
|
|
|
|
# This part is skipped on Debian systems, the
|
|
|
|
# debian.preinst script takes care of it.
|
2018-02-21 04:59:08 +05:30
|
|
|
@if [ ! -p /run/initctl ]; then \
|
|
|
|
echo "Creating /run/initctl"; \
|
|
|
|
rm -f /run/initctl; \
|
|
|
|
mknod -m 600 /run/initctl p; fi
|
2009-09-10 13:58:49 +05:30
|
|
|
endif
|