Mention where the license text is on Debian systems.
[sysvinit.git] / src / Makefile
CommitLineData
a74aeac6
PR
1#
2# Makefile Makefile for the systemV init suite.
3# Targets: all compiles everything
4# install installs the binaries (not the scripts)
5# clean cleans up object files
6# clobber really cleans up
7#
8# Version: @(#)Makefile 2.85-13 23-Mar-2004 miquels@cistron.nl
9#
10
bcbe7f89
PR
11CFLAGS ?= -ansi -O2 -fomit-frame-pointer
12CFLAGS += -W -Wall -D_GNU_SOURCE
a74aeac6
PR
13STATIC =
14
15# For some known distributions we do not build all programs, otherwise we do.
16BIN =
17SBIN = init halt shutdown runlevel killall5
18USRBIN = last mesg
19
20MAN1 = last.1 lastb.1 mesg.1
21MAN5 = initscript.5 inittab.5
22MAN8 = halt.8 init.8 killall5.8 pidof.8 poweroff.8 reboot.8 runlevel.8
23MAN8 += shutdown.8 telinit.8
24
25ifeq ($(DISTRO),)
26BIN += mountpoint
27SBIN += sulogin bootlogd
28USRBIN += utmpdump wall
1414572e 29MAN1 += utmpdump.1 mountpoint.1 wall.1
a74aeac6
PR
30MAN8 += sulogin.8 bootlogd.8
31endif
32
33ifeq ($(DISTRO),Debian)
34BIN += mountpoint
35SBIN += sulogin bootlogd
36MAN1 += mountpoint.1
37MAN8 += sulogin.8 bootlogd.8
38endif
39
40ifeq ($(DISTRO),Owl)
41USRBIN += wall
42MAN1 += wall.1
43endif
44
1414572e
DWF
45ifeq ($(DISTRO),SuSE)
46BIN += mountpoint
47SBIN += sulogin
48USRBIN += utmpdump
49MAN1 += utmpdump.1 mountpoint.1
50MAN8 += sulogin.8
51endif
52
a74aeac6
PR
53BIN_OWNER = root
54BIN_GROUP = root
55BIN_COMBO = $(BIN_OWNER):$(BIN_GROUP)
56STRIP = strip -s -R .comment
57INSTALL_EXEC = install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 755
58INSTALL_DATA = install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 644
bcbe7f89 59INSTALL_DIR = install -m 755 -d
a74aeac6
PR
60MANDIR = /usr/share/man
61
62ifeq ($(WITH_SELINUX),yes)
63 SELINUX_DEF=-DWITH_SELINUX
64 INIT_SELIBS=-lsepol -lselinux
65 SULOGIN_SELIBS=-lselinux
66else
67 SELINUX_DEF=
68 INIT_SELIBS=
69 SULOGIN_SELIBS=
70endif
71
a74aeac6 72# Additional libs for GNU libc.
63a2c981 73ifneq ($(wildcard /usr/lib*/libcrypt.a),)
a74aeac6
PR
74LCRYPT = -lcrypt
75endif
76
77all: $(BIN) $(SBIN) $(USRBIN)
78
bcbe7f89
PR
79#%: %.o
80# $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
81#%.o: %.c
82# $(CC) $(CFLAGS) $(CPPFLAGS) -c $^ -o $@
83
84init: LDLIBS += $(INIT_SELIBS) $(STATIC)
a74aeac6 85init: init.o init_utmp.o
a74aeac6
PR
86
87halt: halt.o ifdown.o hddown.o utmp.o reboot.h
a74aeac6
PR
88
89last: last.o oldutmp.h
a74aeac6
PR
90
91mesg: mesg.o
a74aeac6
PR
92
93mountpoint: mountpoint.o
a74aeac6
PR
94
95utmpdump: utmpdump.o
a74aeac6
PR
96
97runlevel: runlevel.o
a74aeac6 98
bcbe7f89 99sulogin: LDLIBS += $(LCRYPT) $(SULOGIN_SELIBS) $(STATIC)
a74aeac6 100sulogin: sulogin.o
a74aeac6
PR
101
102wall: dowall.o wall.o
a74aeac6
PR
103
104shutdown: dowall.o shutdown.o utmp.o reboot.h
a74aeac6 105
bcbe7f89 106bootlogd: LDLIBS += -lutil
a74aeac6 107bootlogd: bootlogd.o
a74aeac6 108
bcbe7f89 109sulogin.o: CPPFLAGS += $(SELINUX_DEF)
a74aeac6 110sulogin.o: sulogin.c
a74aeac6 111
bcbe7f89 112init.o: CPPFLAGS += $(SELINUX_DEF)
a74aeac6 113init.o: init.c init.h set.h reboot.h initreq.h
a74aeac6
PR
114
115utmp.o: utmp.c init.h
a74aeac6 116
bcbe7f89 117init_utmp.o: CPPFLAGS += -DINIT_MAIN
a74aeac6 118init_utmp.o: utmp.c init.h
bcbe7f89 119 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
a74aeac6
PR
120
121cleanobjs:
122 rm -f *.o *.bak
123
124clean: cleanobjs
125 @echo Type \"make clobber\" to really clean up.
126
127clobber: cleanobjs
128 rm -f $(BIN) $(SBIN) $(USRBIN)
129
130distclean: clobber
131
132install:
bcbe7f89
PR
133 $(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/
134 $(INSTALL_DIR) $(ROOT)/usr/bin/
a74aeac6
PR
135 for i in $(BIN); do \
136 $(STRIP) $$i ; \
137 $(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \
138 done
139 for i in $(SBIN); do \
140 $(STRIP) $$i ; \
141 $(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \
142 done
143 for i in $(USRBIN); do \
144 $(STRIP) $$i ; \
145 $(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
146 done
147 # $(INSTALL_EXEC) etc/initscript.sample $(ROOT)/etc/
148 ln -sf halt $(ROOT)/sbin/reboot
149 ln -sf halt $(ROOT)/sbin/poweroff
150 ln -sf init $(ROOT)/sbin/telinit
151 ln -sf /sbin/killall5 $(ROOT)/bin/pidof
152 if [ ! -f $(ROOT)/usr/bin/lastb ]; then \
153 ln -sf last $(ROOT)/usr/bin/lastb; \
154 fi
bcbe7f89 155 $(INSTALL_DIR) $(ROOT)/usr/include/
a74aeac6 156 $(INSTALL_DATA) initreq.h $(ROOT)/usr/include/
bcbe7f89
PR
157 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man1/
158 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man5/
159 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man8/
a74aeac6
PR
160 for i in $(MAN1); do \
161 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man1/; \
162 done
163 for i in $(MAN5); do \
164 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man5/; \
165 done
166 for i in $(MAN8); do \
167 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man8/; \
168 done
169ifeq ($(ROOT),)
170 #
171 # This part is skipped on Debian systems, the
172 # debian.preinst script takes care of it.
173 @if [ ! -p /dev/initctl ]; then \
174 echo "Creating /dev/initctl"; \
175 rm -f /dev/initctl; \
176 mknod -m 600 /dev/initctl p; fi
177endif