]> git.ipfire.org Git - thirdparty/systemd.git/blame - Makefile
release 103
[thirdparty/systemd.git] / Makefile
CommitLineData
f0083e3d 1#
56f914e6 2# Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
c1979c82 3# Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
f0083e3d
GKH
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; version 2 of the License.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12# General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
27b77df4 16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
f0083e3d
GKH
17#
18
1810a9d7 19VERSION = 103
0e47c219
KS
20
21# set this to make use of syslog
05230184 22USE_LOG = true
54988802 23
0e47c219
KS
24# compile-in development debug messages
25# (export UDEV_LOG="debug" or set udev_log="debug" in udev.conf
26# to print the debug messages to syslog)
29b82deb 27DEBUG = false
f0083e3d 28
a8b38f1c 29# compile with gcc's code coverage option
a8b38f1c
KS
30USE_GCOV = false
31
0e47c219 32# include Security-Enhanced Linux support
9825617b 33USE_SELINUX = false
f0083e3d 34
0e47c219 35# set this to create statically linked binaries
6c18b1fb
KS
36USE_STATIC = false
37
0e47c219
KS
38# to build any of the extras programs pass:
39# make EXTRAS="extras/<extra1> extras/<extra2>"
638b983b 40EXTRAS =
6c18b1fb 41
c1979c82 42# make the build silent
1ef98545 43V =
6c18b1fb 44
0e47c219
KS
45PROGRAMS = \
46 udev \
47 udevd \
0d5be398 48 udevtrigger \
7baada47 49 udevsettle \
0e47c219
KS
50 udevcontrol \
51 udevmonitor \
52 udevinfo \
53 udevtest \
54 udevstart
55
56HEADERS = \
57 udev.h \
b5adfb4f 58 udevd.h \
0e47c219 59 udev_rules.h \
0e47c219 60 logging.h \
dbd16d26 61 udev_sysdeps.h \
0e47c219
KS
62 udev_selinux.h \
63 list.h
64
65UDEV_OBJS = \
0e47c219
KS
66 udev_device.o \
67 udev_config.o \
a4d5ca64 68 udev_node.o \
0e47c219 69 udev_db.o \
1aa1e248 70 udev_sysfs.o \
0e47c219
KS
71 udev_rules.o \
72 udev_rules_parse.o \
73 udev_utils.o \
74 udev_utils_string.o \
75 udev_utils_file.o \
76 udev_utils_run.o \
dbd16d26 77 udev_sysdeps.o
0e47c219
KS
78LIBUDEV = libudev.a
79
80MAN_PAGES = \
2c769419 81 udev.7 \
0e47c219
KS
82 udevmonitor.8 \
83 udevd.8 \
0d5be398 84 udevtrigger.8 \
7baada47 85 udevsettle.8 \
0e47c219
KS
86 udevtest.8 \
87 udevinfo.8 \
88 udevstart.8
89
0e47c219
KS
90GEN_HEADERS = \
91 udev_version.h
977083c2 92
56f914e6 93prefix ?=
9f53b06a 94etcdir = ${prefix}/etc
d7363ee1
KS
95sbindir = ${prefix}/sbin
96usrbindir = ${prefix}/usr/bin
97usrsbindir = ${prefix}/usr/sbin
98libudevdir = ${prefix}/lib/udev
9f53b06a 99mandir = ${prefix}/usr/share/man
aef6bb13 100configdir = ${etcdir}/udev
0e47c219 101udevdir = /dev
0e47c219 102DESTDIR =
9f53b06a
GKH
103
104INSTALL = /usr/bin/install -c
105INSTALL_PROGRAM = ${INSTALL}
d8a57e7c 106INSTALL_DATA = ${INSTALL} -m 644
9f53b06a 107INSTALL_SCRIPT = ${INSTALL_PROGRAM}
89067448
GKH
108PWD = $(shell pwd)
109
56f914e6 110CROSS_COMPILE ?=
4942c78c
KS
111CC = $(CROSS_COMPILE)gcc
112LD = $(CROSS_COMPILE)gcc
113AR = $(CROSS_COMPILE)ar
114RANLIB = $(CROSS_COMPILE)ranlib
f0083e3d 115
f032e0ed
KS
116CFLAGS = -g -Wall -pipe -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
117WARNINGS = -Wstrict-prototypes -Wsign-compare -Wshadow \
118 -Wchar-subscripts -Wmissing-declarations -Wnested-externs \
119 -Wpointer-arith -Wcast-align -Wsign-compare -Wmissing-prototypes
f032e0ed 120CFLAGS += $(WARNINGS)
12901d99 121
638b983b
KS
122LDFLAGS = -Wl,-warn-common
123
c756114f 124OPTFLAGS = -Os
f032e0ed 125CFLAGS += $(OPTFLAGS)
1196e46c 126
05230184 127ifeq ($(strip $(USE_LOG)),true)
6c18b1fb 128 CFLAGS += -DUSE_LOG
54988802
KS
129endif
130
f032e0ed 131# if DEBUG is enabled, then we do not strip
f0083e3d 132ifeq ($(strip $(DEBUG)),true)
638b983b 133 CFLAGS += -DDEBUG
f0083e3d
GKH
134endif
135
a8b38f1c
KS
136ifeq ($(strip $(USE_GCOV)),true)
137 CFLAGS += -fprofile-arcs -ftest-coverage
638b983b 138 LDFLAGS += -fprofile-arcs
a8b38f1c
KS
139endif
140
9825617b 141ifeq ($(strip $(USE_SELINUX)),true)
045b1f0f 142 UDEV_OBJS += udev_selinux.o
586e1a37 143 LIB_OBJS += -lselinux -lsepol
045b1f0f 144 CFLAGS += -DUSE_SELINUX
9825617b
HH
145endif
146
6c18b1fb
KS
147ifeq ($(strip $(USE_STATIC)),true)
148 CFLAGS += -DUSE_STATIC
149 LDFLAGS += -static
150endif
151
1ef98545
KS
152ifeq ($(strip $(V)),)
153 E = @echo
154 Q = @
045b1f0f 155else
1ef98545
KS
156 E = @\#
157 Q =
045b1f0f 158endif
1ef98545 159export E Q
eadb1bbc 160
a8349b33 161all: $(PROGRAMS) $(MAN_PAGES)
1ef98545 162 $(Q) extras="$(EXTRAS)"; for target in $$extras; do \
49fb51c6 163 $(MAKE) CC="$(CC)" \
db28d2ea 164 CFLAGS="$(CFLAGS)" \
977083c2 165 LD="$(LD)" \
db28d2ea 166 LDFLAGS="$(LDFLAGS)" \
1fda06ae
KS
167 AR="$(AR)" \
168 RANLIB="$(RANLIB)" \
db28d2ea 169 LIB_OBJS="$(LIB_OBJS)" \
0e47c219 170 LIBUDEV="$(PWD)/$(LIBUDEV)" \
c699bc48 171 -C $$target $@ || exit 1; \
0e47c219
KS
172 done;
173.PHONY: all
17d3cb12 174.DEFAULT: all
f0083e3d 175
7a526da6
KS
176# clear implicit rules
177.SUFFIXES:
178
179# build the objects
1ef98545
KS
180%.o: %.c $(HEADERS) $(GEN_HEADERS)
181 $(E) " CC " $@
182 $(Q) $(CC) -c $(CFLAGS) $< -o $@
7a526da6
KS
183
184# "Static Pattern Rule" to build all programs
1ef98545
KS
185$(PROGRAMS): %: $(HEADERS) $(GEN_HEADERS) $(LIBUDEV) %.o
186 $(E) " LD " $@
187 $(Q) $(LD) $(LDFLAGS) $@.o -o $@ $(LIBUDEV) $(LIB_OBJS)
0e47c219 188
1ef98545
KS
189$(LIBUDEV): $(HEADERS) $(GEN_HEADERS) $(UDEV_OBJS)
190 $(Q) rm -f $@
191 $(E) " AR " $@
192 $(Q) $(AR) cq $@ $(UDEV_OBJS)
193 $(E) " RANLIB " $@
194 $(Q) $(RANLIB) $@
7c2aae11 195
f0083e3d 196udev_version.h:
1ef98545
KS
197 $(E) " GENHDR " $@
198 $(Q) echo "/* Generated by make. */" > $@
199 $(Q) echo \#define UDEV_VERSION \"$(VERSION)\" >> $@
200 $(Q) echo \#define UDEV_ROOT \"$(udevdir)\" >> $@
c1979c82
KS
201 $(Q) echo \#define UDEV_CONFIG_FILE \"$(configdir)/udev.conf\" >> $@
202 $(Q) echo \#define UDEV_RULES_FILE \"$(configdir)/rules.d\" >> $@
f0083e3d 203
420a506e 204# man pages
9de98988 205%.8 %.7: %.xml
1ef98545
KS
206 $(E) " XMLTO " $@
207 $(Q) xmlto man $?
0e47c219 208.PRECIOUS: %.8
56a8a624 209
f0083e3d 210clean:
1ef98545
KS
211 $(E) " CLEAN "
212 $(Q) - find . -type f -name '*.orig' -print0 | xargs -0r rm -f
213 $(Q) - find . -type f -name '*.rej' -print0 | xargs -0r rm -f
214 $(Q) - find . -type f -name '*~' -print0 | xargs -0r rm -f
215 $(Q) - find . -type f -name '*.[oas]' -print0 | xargs -0r rm -f
216 $(Q) - find . -type f -name "*.gcno" -print0 | xargs -0r rm -f
217 $(Q) - find . -type f -name "*.gcda" -print0 | xargs -0r rm -f
218 $(Q) - find . -type f -name "*.gcov" -print0 | xargs -0r rm -f
219 $(Q) - rm -f udev_gcov.txt
220 $(Q) - rm -f core $(PROGRAMS) $(GEN_HEADERS)
221 $(Q) - rm -f udev-$(VERSION).tar.gz
222 $(Q) - rm -f udev-$(VERSION).tar.bz2
223 @ extras="$(EXTRAS)"; for target in $$extras; do \
c699bc48 224 $(MAKE) -C $$target $@ || exit 1; \
0e47c219 225 done;
49fb51c6 226.PHONY: clean
2761f9b9 227
49fb51c6 228release:
cf686d37 229 git-tar-tree HEAD udev-$(VERSION) | gzip -9v > udev-$(VERSION).tar.gz
d8a57e7c 230 git-tar-tree HEAD udev-$(VERSION) | bzip2 -9v > udev-$(VERSION).tar.bz2
0e47c219 231.PHONY: release
54e3a5d3 232
d8a57e7c 233install-config:
aef6bb13 234 $(INSTALL) -d $(DESTDIR)$(configdir)/rules.d
1ef98545 235 @ if [ ! -r $(DESTDIR)$(configdir)/udev.conf ]; then \
d8a57e7c 236 $(INSTALL_DATA) etc/udev/udev.conf $(DESTDIR)$(configdir); \
7591c18a 237 fi
1ef98545 238 @ if [ ! -r $(DESTDIR)$(configdir)/rules.d/50-udev.rules ]; then \
0e47c219 239 echo; \
d2e8d41b 240 echo "pick a udev rules file from the etc/udev directory that matches your distribution"; \
0e47c219 241 echo; \
7591c18a 242 fi
1ef98545 243 @ extras="$(EXTRAS)"; for target in $$extras; do \
c699bc48 244 $(MAKE) -C $$target $@ || exit 1; \
1ac216b1 245 done;
0e47c219 246.PHONY: install-config
7591c18a 247
487c1b35 248install-man:
2c769419 249 $(INSTALL_DATA) -D udev.7 $(DESTDIR)$(mandir)/man7/udev.7
438ac360
GKH
250 $(INSTALL_DATA) -D udevinfo.8 $(DESTDIR)$(mandir)/man8/udevinfo.8
251 $(INSTALL_DATA) -D udevtest.8 $(DESTDIR)$(mandir)/man8/udevtest.8
438ac360 252 $(INSTALL_DATA) -D udevd.8 $(DESTDIR)$(mandir)/man8/udevd.8
0d5be398 253 $(INSTALL_DATA) -D udevtrigger.8 $(DESTDIR)$(mandir)/man8/udevtrigger.8
7baada47 254 $(INSTALL_DATA) -D udevsettle.8 $(DESTDIR)$(mandir)/man8/udevsettle.8
420a506e 255 $(INSTALL_DATA) -D udevmonitor.8 $(DESTDIR)$(mandir)/man8/udevmonitor.8
420a506e 256 - ln -f -s udevd.8 $(DESTDIR)$(mandir)/man8/udevcontrol.8
1ac216b1 257 @extras="$(EXTRAS)"; for target in $$extras; do \
c699bc48 258 $(MAKE) -C $$target $@ || exit 1; \
1ac216b1 259 done;
0e47c219 260.PHONY: install-man
438ac360
GKH
261
262uninstall-man:
2c769419 263 - rm -f $(DESTDIR)$(mandir)/man7/udev.7
49fb51c6
KS
264 - rm -f $(DESTDIR)$(mandir)/man8/udevinfo.8
265 - rm -f $(DESTDIR)$(mandir)/man8/udevtest.8
49fb51c6 266 - rm -f $(DESTDIR)$(mandir)/man8/udevd.8
0d5be398 267 - rm -f $(DESTDIR)$(mandir)/man8/udevtrigger.8
7baada47 268 - rm -f $(DESTDIR)$(mandir)/man8/udevsettle.8
49fb51c6 269 - rm -f $(DESTDIR)$(mandir)/man8/udevmonitor.8
49fb51c6 270 - rm -f $(DESTDIR)$(mandir)/man8/udevcontrol.8
1ef98545 271 @ extras="$(EXTRAS)"; for target in $$extras; do \
c699bc48 272 $(MAKE) -C $$target $@ || exit 1; \
1ac216b1 273 done;
0e47c219 274.PHONY: uninstall-man
438ac360 275
17d3cb12 276install-bin:
7591c18a 277 $(INSTALL) -d $(DESTDIR)$(udevdir)
0e47c219 278 $(INSTALL_PROGRAM) -D udevd $(DESTDIR)$(sbindir)/udevd
0d5be398 279 $(INSTALL_PROGRAM) -D udevtrigger $(DESTDIR)$(sbindir)/udevtrigger
7baada47 280 $(INSTALL_PROGRAM) -D udevsettle $(DESTDIR)$(sbindir)/udevsettle
0e47c219
KS
281 $(INSTALL_PROGRAM) -D udevcontrol $(DESTDIR)$(sbindir)/udevcontrol
282 $(INSTALL_PROGRAM) -D udevmonitor $(DESTDIR)$(usrsbindir)/udevmonitor
283 $(INSTALL_PROGRAM) -D udevinfo $(DESTDIR)$(usrbindir)/udevinfo
284 $(INSTALL_PROGRAM) -D udevtest $(DESTDIR)$(usrbindir)/udevtest
db28d2ea 285 @extras="$(EXTRAS)"; for target in $$extras; do \
c699bc48 286 $(MAKE) -C $$target $@ || exit 1; \
db28d2ea 287 done;
f070df16 288ifndef DESTDIR
0e47c219 289 - killall udevd
fc55cf68 290 - rm -rf /dev/.udev
0e47c219 291 - $(sbindir)/udevd --daemon
f070df16 292endif
17d3cb12 293.PHONY: install-bin
6785820d 294
17d3cb12 295uninstall-bin:
49fb51c6 296 - rm -f $(DESTDIR)$(sbindir)/udevd
0d5be398 297 - rm -f $(DESTDIR)$(sbindir)/udevtrigger
7baada47 298 - rm -f $(DESTDIR)$(sbindir)/udevsettle
49fb51c6 299 - rm -f $(DESTDIR)$(sbindir)/udevcontrol
49fb51c6 300 - rm -f $(DESTDIR)$(usrsbindir)/udevmonitor
d8a57e7c
KS
301 - rm -f $(DESTDIR)$(usrbindir)/udevinfo
302 - rm -f $(DESTDIR)$(usrbindir)/udevtest
49fb51c6 303ifndef DESTDIR
0e47c219 304 - killall udevd
fc55cf68 305 - rm -rf /dev/.udev
49fb51c6 306endif
0e47c219 307 @extras="$(EXTRAS)"; for target in $$extras; do \
c699bc48 308 $(MAKE) -C $$target $@ || exit 1; \
0e47c219 309 done;
17d3cb12
KS
310.PHONY: uninstall-bin
311
312install: all install-bin install-config install-man
313.PHONY: install
314
315uninstall: uninstall-bin uninstall-man
316.PHONY: uninstall
0e47c219
KS
317
318test tests: all
e9f65389 319 @ cd test && ./udev-test.pl
05bd6efb 320 @ cd test && ./udevstart-test.pl
0e47c219 321.PHONY: test tests
0de3c3ed 322
17d3cb12 323buildtest:
ed0e3cbd 324 test/simple-build-check.sh
a8b38f1c
KS
325.PHONY: buildtest
326
ed0e3cbd
KS
327ChangeLog: Makefile
328 @ mv $@ $@.tmp
adc8e4b9 329 @ echo "Summary of changes from v$(shell echo $$(($(VERSION) - 1))) to v$(VERSION)" >> $@
ed0e3cbd 330 @ echo "============================================" >> $@
731a7d6d 331 @ echo >> $@
adc8e4b9 332 @ git log --pretty=short $(shell echo $$(($(VERSION) - 1)))..HEAD | git shortlog >> $@
ed0e3cbd
KS
333 @ echo >> $@
334 @ cat $@
335 @ cat $@.tmp >> $@
336 @ rm $@.tmp
337
a8b38f1c 338gcov-all:
15ff0ba3 339 $(MAKE) clean all USE_GCOV=true
1ef98545
KS
340 @ echo
341 @ echo "binaries built with gcov support."
342 @ echo "run the tests and analyze with 'make udev_gcov.txt'"
a8b38f1c
KS
343.PHONY: gcov-all
344
345# see docs/README-gcov_for_udev
346udev_gcov.txt: $(wildcard *.gcda) $(wildcard *.gcno)
347 for file in `find -maxdepth 1 -name "*.gcno"`; do \
348 name=`basename $$file .gcno`; \
349 echo "################" >> $@; \
350 echo "$$name.c" >> $@; \
351 echo "################" >> $@; \
352 if [ -e "$$name.gcda" ]; then \
353 gcov -l "$$name.c" >> $@ 2>&1; \
354 else \
355 echo "code for $$name.c was never executed" >> $@ 2>&1; \
356 fi; \
357 echo >> $@; \
358 done; \
359 echo "view $@ for the result"