blob: 1cd97f3cea7a5a3908452bb77a2494c9ed6a935a [file] [log] [blame] [raw]
# 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
#
ifndef KERNEL_NAME
KERNEL_NAME = $(shell uname -s)
endif
ifeq ($(CC),cc)
CC = gcc
endif
CFLAGS += -Wall -Os -fomit-frame-pointer -D _GNU_SOURCE=1 -D _ALL_SOURCE=1
LDFLAGS += -s
STATIC =
ifeq ($(KERNEL_NAME),Interix)
CFLAGS += -I /usr/local/include/bind
LIBBIND += -L /usr/local/lib/bind -l bind -l db
else ifeq ($(KERNEL_NAME),SunOS)
#SOCKET_LIBS += -l socket
LIBSOCKET = -l socket -l nsl
LIBRT = -l rt
ifeq ($(shell uname -r),5.10)
CFLAGS += -D NEED_STRSEP=1
endif
else ifeq ($(KERNEL_NAME),AIX)
else
LIBUTIL = -l util
endif
# For some known distributions we do not build all programs, otherwise we do.
BIN =
SBIN = init halt shutdown runlevel killall5
USRBIN = last mesg
MAN1 = last.1 lastb.1 mesg.1
MAN5 = initscript.5 inittab.5
MAN8 = halt.8 init.8 killall5.8 pidof.8 poweroff.8 reboot.8 runlevel.8
MAN8 += shutdown.8 telinit.8
ifeq ($(DISTRO),)
BIN += mountpoint
SBIN += sulogin bootlogd
USRBIN += utmpdump wall
MAN1 += mountpoint.1 wall.1
MAN8 += sulogin.8 bootlogd.8
endif
ifeq ($(DISTRO),Debian)
BIN += mountpoint
SBIN += sulogin bootlogd
MAN1 += mountpoint.1
MAN8 += sulogin.8 bootlogd.8
endif
ifeq ($(DISTRO),Owl)
USRBIN += wall
MAN1 += wall.1
endif
BIN_OWNER = root
BIN_GROUP = root
BIN_COMBO = $(BIN_OWNER):$(BIN_GROUP)
STRIP = strip -s -R .comment
INSTALL_EXEC = install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 755
INSTALL_DATA = install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 644
MANDIR = /usr/share/man
ifeq ($(WITH_SELINUX),yes)
SELINUX_DEF=-DWITH_SELINUX
INIT_SELIBS=-lsepol -lselinux
SULOGIN_SELIBS=-lselinux
else
SELINUX_DEF=
INIT_SELIBS=
SULOGIN_SELIBS=
endif
all: $(BIN) $(SBIN) $(USRBIN)
ifeq ($(shell echo $(KERNEL_NAME) | grep -Fo CYGWIN),CYGWIN)
sulogin: crypt/libcrypt.a
init halt last utmpdump runlevel wall shutdown: utmpx/libutmpx.a
CFLAGS += -I crypt -I utmpx
LIBCRYPT = -L crypt -l crypt
LIBUTMPX = -L utmpx -l utmpx
else
# Additional libs for GNU libc.
ifneq ($(wildcard /usr/lib/*/libcrypt.a),)
LIBCRYPT = -lcrypt
endif
ifneq ($(wildcard /usr/lib/libcrypt.a),)
LIBCRYPT = -lcrypt
endif
endif
init: init.o init_utmpx.o
$(CC) $(LDFLAGS) $(STATIC) init.o init_utmpx.o -o $@ $(INIT_SELIBS) $(LIBUTMPX)
halt: halt.o ifdown.o hddown.o utmpx.o reboot.h
$(CC) $(LDFLAGS) -o $@ halt.o ifdown.o hddown.o utmpx.o $(LIBSOCKET) $(LIBUTMPX)
last: last.o oldutmp.h
$(CC) $(LDFLAGS) -o $@ last.o $(LIBBIND) $(LIBSOCKET) $(LIBUTMPX)
mesg: mesg.o
$(CC) $(LDFLAGS) -o $@ mesg.o
mountpoint: mountpoint.o
$(CC) $(LDFLAGS) -o $@ mountpoint.o
utmpdump: utmpdump.o
$(CC) $(LDFLAGS) -o $@ utmpdump.o $(LIBUTMPX)
runlevel: runlevel.o
$(CC) $(LDFLAGS) -o $@ runlevel.o $(LIBUTMPX)
sulogin: sulogin.o
$(CC) $(LDFLAGS) $(STATIC) $(SELINUX_DEF) -o $@ $^ $(LIBCRYPT) $(SULOGIN_SELIBS)
wall: dowall.o wall.o
$(CC) $(LDFLAGS) -o $@ dowall.o wall.o $(LIBUTMPX)
shutdown: dowall.o shutdown.o utmpx.o reboot.h
$(CC) $(LDFLAGS) -o $@ dowall.o shutdown.o utmpx.o $(LIBRT) $(LIBUTMPX)
bootlogd: bootlogd.o
$(CC) $(LDFLAGS) -o $@ bootlogd.o $(LIBUTIL) $(LIBRT)
sulogin.o: sulogin.c
$(CC) -c $(CFLAGS) $(SELINUX_DEF) sulogin.c
init.o: init.c init.h set.h reboot.h initreq.h
$(CC) -c $(CFLAGS) $(SELINUX_DEF) init.c
utmpx.o: utmpx.c init.h
$(CC) -c $(CFLAGS) utmpx.c
init_utmpx.o: utmpx.c init.h
$(CC) -c $(CFLAGS) -D INIT_MAIN=1 utmpx.c -o init_utmpx.o
crypt/libcrypt.a:
$(MAKE) -C crypt libcrypt.a
utmpx/libutmpx.a:
$(MAKE) -C utmpx libutmpx.a
cleancrypt:
$(MAKE) -C crypt clean
cleanutmpx:
$(MAKE) -C utmpx clean
cleanobjs:
rm -f *.o *.bak
clean: cleanobjs cleancrypt cleanutmpx
@echo Type \"make clobber\" to really clean up.
clobber: cleanobjs cleancrypt cleanutmpx
rm -f $(BIN) $(SBIN) $(USRBIN)
distclean: clobber
install:
for i in $(BIN); do \
$(STRIP) $$i ; \
$(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \
done
for i in $(SBIN); do \
$(STRIP) $$i ; \
$(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \
done
for i in $(USRBIN); do \
$(STRIP) $$i ; \
$(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
done
# $(INSTALL_EXEC) etc/initscript.sample $(ROOT)/etc/
ln -sf halt $(ROOT)/sbin/reboot
ln -sf halt $(ROOT)/sbin/poweroff
ln -sf init $(ROOT)/sbin/telinit
ln -sf /sbin/killall5 $(ROOT)/bin/pidof
if [ ! -f $(ROOT)/usr/bin/lastb ]; then \
ln -sf last $(ROOT)/usr/bin/lastb; \
fi
$(INSTALL_DATA) initreq.h $(ROOT)/usr/include/
for i in $(MAN1); do \
$(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man1/; \
done
for i in $(MAN5); do \
$(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man5/; \
done
for i in $(MAN8); do \
$(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man8/; \
done
ifeq ($(ROOT),)
#
# This part is skipped on Debian systems, the
# debian.preinst script takes care of it.
@if [ ! -p /dev/initctl ]; then \
echo "Creating /dev/initctl"; \
rm -f /dev/initctl; \
mknod -m 600 /dev/initctl p; fi
endif