* fix typo
[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
55f242bf 11CPPFLAGS = -DUSE_PAM
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)
55f242bf 48CPPFLAGS+= -DUSE_SYSFS -DSANE_TIO -DSIGINT_ONLYONCE
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)
60STRIP = strip -s -R .comment
55f242bf
DWF
61ifeq ($(ID),0)
62 INSTALL_EXEC = install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 755
63 INSTALL_DATA = install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 644
64else
65 INSTALL_EXEC = install -m 755
66 INSTALL_DATA = install -m 644
67endif
bcbe7f89 68INSTALL_DIR = install -m 755 -d
a74aeac6
PR
69MANDIR = /usr/share/man
70
71ifeq ($(WITH_SELINUX),yes)
55f242bf
DWF
72 SELINUX_DEF = -DWITH_SELINUX
73 INITLIBS += -lsepol -lselinux
74 SULOGINLIBS = -lselinux
a74aeac6 75else
55f242bf
DWF
76 SELINUX_DEF =
77 INITLIBS =
78 SULOGINLIBS =
79endif
80
81# Additional libs for GNU libc.
82ifneq ($(findstring -DUSE_PAM,$(CPPFLAGS)),)
83 INITLIBS += -lpam -lpam_misc
a74aeac6
PR
84endif
85
a74aeac6 86# Additional libs for GNU libc.
63a2c981 87ifneq ($(wildcard /usr/lib*/libcrypt.a),)
55f242bf 88 SULOGINLIBS += -lcrypt
a74aeac6
PR
89endif
90
91all: $(BIN) $(SBIN) $(USRBIN)
92
bcbe7f89
PR
93#%: %.o
94# $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
95#%.o: %.c
96# $(CC) $(CFLAGS) $(CPPFLAGS) -c $^ -o $@
97
55f242bf 98init: LDLIBS += $(INITLIBS) $(STATIC)
a74aeac6 99init: init.o init_utmp.o
a74aeac6
PR
100
101halt: halt.o ifdown.o hddown.o utmp.o reboot.h
a74aeac6
PR
102
103last: last.o oldutmp.h
a74aeac6
PR
104
105mesg: mesg.o
a74aeac6
PR
106
107mountpoint: mountpoint.o
a74aeac6
PR
108
109utmpdump: utmpdump.o
a74aeac6
PR
110
111runlevel: runlevel.o
a74aeac6 112
55f242bf 113sulogin: LDLIBS += $(SULOGINLIBS) $(STATIC)
a74aeac6 114sulogin: sulogin.o
a74aeac6
PR
115
116wall: dowall.o wall.o
a74aeac6
PR
117
118shutdown: dowall.o shutdown.o utmp.o reboot.h
a74aeac6 119
bcbe7f89 120bootlogd: LDLIBS += -lutil
a74aeac6 121bootlogd: bootlogd.o
a74aeac6 122
bcbe7f89 123sulogin.o: CPPFLAGS += $(SELINUX_DEF)
a74aeac6 124sulogin.o: sulogin.c
a74aeac6 125
bcbe7f89 126init.o: CPPFLAGS += $(SELINUX_DEF)
a74aeac6 127init.o: init.c init.h set.h reboot.h initreq.h
a74aeac6
PR
128
129utmp.o: utmp.c init.h
a74aeac6 130
bcbe7f89 131init_utmp.o: CPPFLAGS += -DINIT_MAIN
a74aeac6 132init_utmp.o: utmp.c init.h
bcbe7f89 133 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
a74aeac6
PR
134
135cleanobjs:
136 rm -f *.o *.bak
137
138clean: cleanobjs
139 @echo Type \"make clobber\" to really clean up.
140
141clobber: cleanobjs
142 rm -f $(BIN) $(SBIN) $(USRBIN)
143
144distclean: clobber
145
146install:
bcbe7f89
PR
147 $(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/
148 $(INSTALL_DIR) $(ROOT)/usr/bin/
a74aeac6
PR
149 for i in $(BIN); do \
150 $(STRIP) $$i ; \
151 $(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \
152 done
153 for i in $(SBIN); do \
154 $(STRIP) $$i ; \
155 $(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \
156 done
157 for i in $(USRBIN); do \
158 $(STRIP) $$i ; \
159 $(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
160 done
161 # $(INSTALL_EXEC) etc/initscript.sample $(ROOT)/etc/
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