* ditto
[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)),)
23d97522
DWF
83 INITLIBS += -lpam
84 PAMDOTD = /etc/pam.d
85 PAMINIT = $(PAMDOTD)/init
a74aeac6
PR
86endif
87
a74aeac6 88# Additional libs for GNU libc.
63a2c981 89ifneq ($(wildcard /usr/lib*/libcrypt.a),)
55f242bf 90 SULOGINLIBS += -lcrypt
a74aeac6
PR
91endif
92
93all: $(BIN) $(SBIN) $(USRBIN)
94
bcbe7f89
PR
95#%: %.o
96# $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
97#%.o: %.c
98# $(CC) $(CFLAGS) $(CPPFLAGS) -c $^ -o $@
99
55f242bf 100init: LDLIBS += $(INITLIBS) $(STATIC)
a74aeac6 101init: init.o init_utmp.o
a74aeac6
PR
102
103halt: halt.o ifdown.o hddown.o utmp.o reboot.h
a74aeac6
PR
104
105last: last.o oldutmp.h
a74aeac6
PR
106
107mesg: mesg.o
a74aeac6
PR
108
109mountpoint: mountpoint.o
a74aeac6
PR
110
111utmpdump: utmpdump.o
a74aeac6
PR
112
113runlevel: runlevel.o
a74aeac6 114
55f242bf 115sulogin: LDLIBS += $(SULOGINLIBS) $(STATIC)
a74aeac6 116sulogin: sulogin.o
a74aeac6
PR
117
118wall: dowall.o wall.o
a74aeac6
PR
119
120shutdown: dowall.o shutdown.o utmp.o reboot.h
a74aeac6 121
bcbe7f89 122bootlogd: LDLIBS += -lutil
a74aeac6 123bootlogd: bootlogd.o
a74aeac6 124
bcbe7f89 125sulogin.o: CPPFLAGS += $(SELINUX_DEF)
a74aeac6 126sulogin.o: sulogin.c
a74aeac6 127
bcbe7f89 128init.o: CPPFLAGS += $(SELINUX_DEF)
a74aeac6 129init.o: init.c init.h set.h reboot.h initreq.h
a74aeac6
PR
130
131utmp.o: utmp.c init.h
a74aeac6 132
bcbe7f89 133init_utmp.o: CPPFLAGS += -DINIT_MAIN
a74aeac6 134init_utmp.o: utmp.c init.h
bcbe7f89 135 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
a74aeac6
PR
136
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
PR
151 for i in $(BIN); do \
152 $(STRIP) $$i ; \
153 $(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \
154 done
155 for i in $(SBIN); do \
156 $(STRIP) $$i ; \
157 $(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \
158 done
159 for i in $(USRBIN); do \
160 $(STRIP) $$i ; \
161 $(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
162 done
23d97522
DWF
163ifneq ($(findstring -DUSE_PAM,$(CPPFLAGS)),)
164 $(INSTALL_DIR) $(ROOT)$(PAMDOTD)
165 test -s $(ROOT)$(PAMINIT) || \
166 $(INSTALL_DATA) init.sample $(ROOT)$(PAMINIT)
167endif
168 # $(INSTALL_DIR) $(ROOT)/etc/
169 # $(INSTALL_EXEC) initscript.sample $(ROOT)/etc/
a74aeac6
PR
170 ln -sf halt $(ROOT)/sbin/reboot
171 ln -sf halt $(ROOT)/sbin/poweroff
172 ln -sf init $(ROOT)/sbin/telinit
173 ln -sf /sbin/killall5 $(ROOT)/bin/pidof
174 if [ ! -f $(ROOT)/usr/bin/lastb ]; then \
175 ln -sf last $(ROOT)/usr/bin/lastb; \
176 fi
bcbe7f89 177 $(INSTALL_DIR) $(ROOT)/usr/include/
a74aeac6 178 $(INSTALL_DATA) initreq.h $(ROOT)/usr/include/
bcbe7f89
PR
179 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man1/
180 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man5/
181 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man8/
a74aeac6
PR
182 for i in $(MAN1); do \
183 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man1/; \
184 done
185 for i in $(MAN5); do \
186 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man5/; \
187 done
188 for i in $(MAN8); do \
189 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man8/; \
190 done
191ifeq ($(ROOT),)
192 #
193 # This part is skipped on Debian systems, the
194 # debian.preinst script takes care of it.
195 @if [ ! -p /dev/initctl ]; then \
196 echo "Creating /dev/initctl"; \
197 rm -f /dev/initctl; \
198 mknod -m 600 /dev/initctl p; fi
199endif