* Add option -w to the last command to display the full user and
[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 CFLAGS ?= -ansi -O2 -fomit-frame-pointer
12 CFLAGS += -W -Wall -D_GNU_SOURCE
13 STATIC =
14
15 # For some known distributions we do not build all programs, otherwise we do.
16 BIN =
17 SBIN = init halt shutdown runlevel killall5
18 USRBIN = last mesg
19
20 MAN1 = last.1 lastb.1 mesg.1
21 MAN5 = initscript.5 inittab.5
22 MAN8 = halt.8 init.8 killall5.8 pidof.8 poweroff.8 reboot.8 runlevel.8
23 MAN8 += shutdown.8 telinit.8
24
25 ifeq ($(DISTRO),)
26 BIN += mountpoint
27 SBIN += sulogin bootlogd
28 USRBIN += utmpdump wall
29 MAN1 += utmpdump.1 mountpoint.1 wall.1
30 MAN8 += sulogin.8 bootlogd.8
31 endif
32
33 ifeq ($(DISTRO),Debian)
34 BIN += mountpoint
35 SBIN += sulogin bootlogd
36 MAN1 += mountpoint.1
37 MAN8 += sulogin.8 bootlogd.8
38 endif
39
40 ifeq ($(DISTRO),Owl)
41 USRBIN += wall
42 MAN1 += wall.1
43 endif
44
45 ifeq ($(DISTRO),SuSE)
46 BIN += mountpoint
47 SBIN += sulogin
48 USRBIN += utmpdump
49 MAN1 += utmpdump.1 mountpoint.1
50 MAN8 += sulogin.8
51 endif
52
53 BIN_OWNER = root
54 BIN_GROUP = root
55 BIN_COMBO = $(BIN_OWNER):$(BIN_GROUP)
56 STRIP = strip -s -R .comment
57 INSTALL_EXEC = install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 755
58 INSTALL_DATA = install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 644
59 INSTALL_DIR = install -m 755 -d
60 MANDIR = /usr/share/man
61
62 ifeq ($(WITH_SELINUX),yes)
63 SELINUX_DEF=-DWITH_SELINUX
64 INIT_SELIBS=-lsepol -lselinux
65 SULOGIN_SELIBS=-lselinux
66 else
67 SELINUX_DEF=
68 INIT_SELIBS=
69 SULOGIN_SELIBS=
70 endif
71
72 # Additional libs for GNU libc.
73 ifneq ($(wildcard /usr/lib*/libcrypt.a),)
74 LCRYPT = -lcrypt
75 endif
76
77 all: $(BIN) $(SBIN) $(USRBIN)
78
79 #%: %.o
80 # $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
81 #%.o: %.c
82 # $(CC) $(CFLAGS) $(CPPFLAGS) -c $^ -o $@
83
84 init: LDLIBS += $(INIT_SELIBS) $(STATIC)
85 init: init.o init_utmp.o
86
87 halt: halt.o ifdown.o hddown.o utmp.o reboot.h
88
89 last: last.o oldutmp.h
90
91 mesg: mesg.o
92
93 mountpoint: mountpoint.o
94
95 utmpdump: utmpdump.o
96
97 runlevel: runlevel.o
98
99 sulogin: LDLIBS += $(LCRYPT) $(SULOGIN_SELIBS) $(STATIC)
100 sulogin: sulogin.o
101
102 wall: dowall.o wall.o
103
104 shutdown: dowall.o shutdown.o utmp.o reboot.h
105
106 bootlogd: LDLIBS += -lutil
107 bootlogd: bootlogd.o
108
109 sulogin.o: CPPFLAGS += $(SELINUX_DEF)
110 sulogin.o: sulogin.c
111
112 init.o: CPPFLAGS += $(SELINUX_DEF)
113 init.o: init.c init.h set.h reboot.h initreq.h
114
115 utmp.o: utmp.c init.h
116
117 init_utmp.o: CPPFLAGS += -DINIT_MAIN
118 init_utmp.o: utmp.c init.h
119 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
120
121 cleanobjs:
122 rm -f *.o *.bak
123
124 clean: cleanobjs
125 @echo Type \"make clobber\" to really clean up.
126
127 clobber: cleanobjs
128 rm -f $(BIN) $(SBIN) $(USRBIN)
129
130 distclean: clobber
131
132 install:
133 $(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/
134 $(INSTALL_DIR) $(ROOT)/usr/bin/
135 for i in $(BIN); do \
136 $(STRIP) $$i ; \
137 $(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \
138 done
139 for i in $(SBIN); do \
140 $(STRIP) $$i ; \
141 $(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \
142 done
143 for i in $(USRBIN); do \
144 $(STRIP) $$i ; \
145 $(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
146 done
147 # $(INSTALL_EXEC) etc/initscript.sample $(ROOT)/etc/
148 ln -sf halt $(ROOT)/sbin/reboot
149 ln -sf halt $(ROOT)/sbin/poweroff
150 ln -sf init $(ROOT)/sbin/telinit
151 ln -sf /sbin/killall5 $(ROOT)/bin/pidof
152 if [ ! -f $(ROOT)/usr/bin/lastb ]; then \
153 ln -sf last $(ROOT)/usr/bin/lastb; \
154 fi
155 $(INSTALL_DIR) $(ROOT)/usr/include/
156 $(INSTALL_DATA) initreq.h $(ROOT)/usr/include/
157 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man1/
158 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man5/
159 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man8/
160 for i in $(MAN1); do \
161 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man1/; \
162 done
163 for i in $(MAN5); do \
164 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man5/; \
165 done
166 for i in $(MAN8); do \
167 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man8/; \
168 done
169 ifeq ($(ROOT),)
170 #
171 # This part is skipped on Debian systems, the
172 # debian.preinst script takes care of it.
173 @if [ ! -p /dev/initctl ]; then \
174 echo "Creating /dev/initctl"; \
175 rm -f /dev/initctl; \
176 mknod -m 600 /dev/initctl p; fi
177 endif