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