]> git.wh0rd.org - sysvinit.git/blob - src/Makefile
* Test out PAM support, extend PAM support by providing environment
[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
84 PAMDOTD = /etc/pam.d
85 PAMINIT = $(PAMDOTD)/init
86 endif
87
88 # Additional libs for GNU libc.
89 ifneq ($(wildcard /usr/lib*/libcrypt.a),)
90 SULOGINLIBS += -lcrypt
91 endif
92
93 all: $(BIN) $(SBIN) $(USRBIN)
94
95 #%: %.o
96 # $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
97 #%.o: %.c
98 # $(CC) $(CFLAGS) $(CPPFLAGS) -c $^ -o $@
99
100 init: LDLIBS += $(INITLIBS) $(STATIC)
101 init: init.o init_utmp.o
102
103 halt: halt.o ifdown.o hddown.o utmp.o reboot.h
104
105 last: last.o oldutmp.h
106
107 mesg: mesg.o
108
109 mountpoint: mountpoint.o
110
111 utmpdump: utmpdump.o
112
113 runlevel: runlevel.o
114
115 sulogin: LDLIBS += $(SULOGINLIBS) $(STATIC)
116 sulogin: sulogin.o
117
118 wall: dowall.o wall.o
119
120 shutdown: dowall.o shutdown.o utmp.o reboot.h
121
122 bootlogd: LDLIBS += -lutil
123 bootlogd: bootlogd.o
124
125 sulogin.o: CPPFLAGS += $(SELINUX_DEF)
126 sulogin.o: sulogin.c
127
128 init.o: CPPFLAGS += $(SELINUX_DEF)
129 init.o: init.c init.h set.h reboot.h initreq.h
130
131 utmp.o: utmp.c init.h
132
133 init_utmp.o: CPPFLAGS += -DINIT_MAIN
134 init_utmp.o: utmp.c init.h
135 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
136
137 cleanobjs:
138 rm -f *.o *.bak
139
140 clean: cleanobjs
141 @echo Type \"make clobber\" to really clean up.
142
143 clobber: cleanobjs
144 rm -f $(BIN) $(SBIN) $(USRBIN)
145
146 distclean: clobber
147
148 install:
149 $(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/
150 $(INSTALL_DIR) $(ROOT)/usr/bin/
151 for i in $(BIN); do \
152 $(STRIP) $$i ; \
153 $(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \
154 done
155 for i in $(SBIN); do \
156 $(STRIP) $$i ; \
157 $(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \
158 done
159 for i in $(USRBIN); do \
160 $(STRIP) $$i ; \
161 $(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
162 done
163 ifneq ($(findstring -DUSE_PAM,$(CPPFLAGS)),)
164 $(INSTALL_DIR) $(ROOT)$(PAMDOTD)
165 test -s $(ROOT)$(PAMINIT) || \
166 $(INSTALL_DATA) init.sample $(ROOT)$(PAMINIT)
167 endif
168 # $(INSTALL_DIR) $(ROOT)/etc/
169 # $(INSTALL_EXEC) initscript.sample $(ROOT)/etc/
170 ln -sf halt $(ROOT)/sbin/reboot
171 ln -sf halt $(ROOT)/sbin/poweroff
172 ln -sf init $(ROOT)/sbin/telinit
173 ln -sf /sbin/killall5 $(ROOT)/bin/pidof
174 if [ ! -f $(ROOT)/usr/bin/lastb ]; then \
175 ln -sf last $(ROOT)/usr/bin/lastb; \
176 fi
177 $(INSTALL_DIR) $(ROOT)/usr/include/
178 $(INSTALL_DATA) initreq.h $(ROOT)/usr/include/
179 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man1/
180 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man5/
181 $(INSTALL_DIR) $(ROOT)$(MANDIR)/man8/
182 for i in $(MAN1); do \
183 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man1/; \
184 done
185 for i in $(MAN5); do \
186 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man5/; \
187 done
188 for i in $(MAN8); do \
189 $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man8/; \
190 done
191 ifeq ($(ROOT),)
192 #
193 # This part is skipped on Debian systems, the
194 # debian.preinst script takes care of it.
195 @if [ ! -p /dev/initctl ]; then \
196 echo "Creating /dev/initctl"; \
197 rm -f /dev/initctl; \
198 mknod -m 600 /dev/initctl p; fi
199 endif