* Try to make utmpdump IPv6 valid, change based on suggestion from
[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
a74aeac6
PR
137cleanobjs:
138 rm -f *.o *.bak
139
140clean: cleanobjs
141 @echo Type \"make clobber\" to really clean up.
142
143clobber: cleanobjs
144 rm -f $(BIN) $(SBIN) $(USRBIN)
145
146distclean: clobber
147
148install:
bcbe7f89
PR
149 $(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/
150 $(INSTALL_DIR) $(ROOT)/usr/bin/
a74aeac6 151 for i in $(BIN); do \
a74aeac6
PR
152 $(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \
153 done
154 for i in $(SBIN); do \
a74aeac6
PR
155 $(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \
156 done
157 for i in $(USRBIN); do \
a74aeac6
PR
158 $(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
159 done
23d97522
DWF
160 # $(INSTALL_DIR) $(ROOT)/etc/
161 # $(INSTALL_EXEC) initscript.sample $(ROOT)/etc/
a74aeac6
PR
162 ln -sf halt $(ROOT)/sbin/reboot
163 ln -sf halt $(ROOT)/sbin/poweroff
164 ln -sf init $(ROOT)/sbin/telinit
165 ln -sf /sbin/killall5 $(ROOT)/bin/pidof
166 if [ ! -f $(ROOT)/usr/bin/lastb ]; then \
167 ln -sf last $(ROOT)/usr/bin/lastb; \
168 fi
bcbe7f89 169 $(INSTALL_DIR) $(ROOT)/usr/include/
a74aeac6 170 $(INSTALL_DATA) initreq.h $(ROOT)/usr/include/
bcbe7f89
PR
171 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man1/
172 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man5/
173 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man8/
a74aeac6
PR
174 for i in $(MAN1); do \
175 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man1/; \
176 done
177 for i in $(MAN5); do \
178 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man5/; \
179 done
180 for i in $(MAN8); do \
181 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man8/; \
182 done
183ifeq ($(ROOT),)
184 #
185 # This part is skipped on Debian systems, the
186 # debian.preinst script takes care of it.
187 @if [ ! -p /dev/initctl ]; then \
188 echo "Creating /dev/initctl"; \
189 rm -f /dev/initctl; \
190 mknod -m 600 /dev/initctl p; fi
191endif