* Add fix for Debian bug #536574 -- Can be enabled by -DACCTON_OFF
[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 = -DUSE_PAM
12 CFLAGS ?= -ansi -O2 -fomit-frame-pointer
13 override CFLAGS += -W -Wall -D_GNU_SOURCE
14 STATIC =
15
16 # For some known distributions we do not build all programs, otherwise we do.
17 BIN =
18 SBIN = init halt shutdown runlevel killall5 fstab-decode
19 USRBIN = last mesg
20
21 MAN1 = last.1 lastb.1 mesg.1
22 MAN5 = initscript.5 inittab.5
23 MAN8 = halt.8 init.8 killall5.8 pidof.8 poweroff.8 reboot.8 runlevel.8
24 MAN8 += shutdown.8 telinit.8 fstab-decode.8
25
26 ifeq ($(DISTRO),)
27 BIN += mountpoint
28 SBIN += sulogin bootlogd
29 USRBIN += utmpdump wall
30 MAN1 += utmpdump.1 mountpoint.1 wall.1
31 MAN8 += sulogin.8 bootlogd.8
32 endif
33
34 ifeq ($(DISTRO),Debian)
35 CPPFLAGS+= -DACCTON_OFF
36 BIN += mountpoint
37 SBIN += sulogin bootlogd
38 MAN1 += mountpoint.1
39 MAN8 += sulogin.8 bootlogd.8
40 endif
41
42 ifeq ($(DISTRO),Owl)
43 USRBIN += wall
44 MAN1 += wall.1
45 endif
46
47 ifeq ($(DISTRO),SuSE)
48 CPPFLAGS+= -DUSE_SYSFS -DSANE_TIO -DSIGINT_ONLYONCE
49 BIN += mountpoint
50 SBIN += sulogin
51 USRBIN += utmpdump
52 MAN1 += utmpdump.1 mountpoint.1
53 MAN8 += sulogin.8
54 endif
55
56 ID = $(shell id -u)
57 BIN_OWNER = root
58 BIN_GROUP = root
59 BIN_COMBO = $(BIN_OWNER):$(BIN_GROUP)
60 STRIP = strip -s -R .comment
61 ifeq ($(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
64 else
65 INSTALL_EXEC = install -m 755
66 INSTALL_DATA = install -m 644
67 endif
68 INSTALL_DIR = install -m 755 -d
69 MANDIR = /usr/share/man
70
71 ifeq ($(WITH_SELINUX),yes)
72 SELINUX_DEF = -DWITH_SELINUX
73 INITLIBS += -lsepol -lselinux
74 SULOGINLIBS = -lselinux
75 else
76 SELINUX_DEF =
77 INITLIBS =
78 SULOGINLIBS =
79 endif
80
81 # Additional libs for GNU libc.
82 ifneq ($(findstring -DUSE_PAM,$(CPPFLAGS)),)
83 INITLIBS += -lpam -lpam_misc
84 endif
85
86 # Additional libs for GNU libc.
87 ifneq ($(wildcard /usr/lib*/libcrypt.a),)
88 SULOGINLIBS += -lcrypt
89 endif
90
91 all: $(BIN) $(SBIN) $(USRBIN)
92
93 #%: %.o
94 # $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
95 #%.o: %.c
96 # $(CC) $(CFLAGS) $(CPPFLAGS) -c $^ -o $@
97
98 init: LDLIBS += $(INITLIBS) $(STATIC)
99 init: init.o init_utmp.o
100
101 halt: halt.o ifdown.o hddown.o utmp.o reboot.h
102
103 last: last.o oldutmp.h
104
105 mesg: mesg.o
106
107 mountpoint: mountpoint.o
108
109 utmpdump: utmpdump.o
110
111 runlevel: runlevel.o
112
113 sulogin: LDLIBS += $(SULOGINLIBS) $(STATIC)
114 sulogin: sulogin.o
115
116 wall: dowall.o wall.o
117
118 shutdown: dowall.o shutdown.o utmp.o reboot.h
119
120 bootlogd: LDLIBS += -lutil
121 bootlogd: bootlogd.o
122
123 sulogin.o: CPPFLAGS += $(SELINUX_DEF)
124 sulogin.o: sulogin.c
125
126 init.o: CPPFLAGS += $(SELINUX_DEF)
127 init.o: init.c init.h set.h reboot.h initreq.h
128
129 utmp.o: utmp.c init.h
130
131 init_utmp.o: CPPFLAGS += -DINIT_MAIN
132 init_utmp.o: utmp.c init.h
133 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
134
135 cleanobjs:
136 rm -f *.o *.bak
137
138 clean: cleanobjs
139 @echo Type \"make clobber\" to really clean up.
140
141 clobber: cleanobjs
142 rm -f $(BIN) $(SBIN) $(USRBIN)
143
144 distclean: clobber
145
146 install:
147 $(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/
148 $(INSTALL_DIR) $(ROOT)/usr/bin/
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
169 $(INSTALL_DIR) $(ROOT)/usr/include/
170 $(INSTALL_DATA) initreq.h $(ROOT)/usr/include/
171 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man1/
172 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man5/
173 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man8/
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
183 ifeq ($(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
191 endif