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