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