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