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