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