X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=Makefile;h=ed5a87c4276f56ba4a19118fb03040424f037883;hb=5bd4c5d72aa69c8d0b722630fd88e29c4a42662a;hp=80364c2a7a001b55c13e2df0148645e348b5c87b;hpb=7b86ada7d4a6b2597299912964d1b8da3d059691;p=elogind.git diff --git a/Makefile b/Makefile index 80364c2a7..ed5a87c42 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -VERSION = 068 +VERSION = 070 # set this to make use of syslog USE_LOG = true @@ -27,6 +27,10 @@ USE_LOG = true # to print the debug messages to syslog) DEBUG = false +# compile with gcc's code coverage option +# (use it with DEBUG, works only with glibc) +USE_GCOV = false + # include Security-Enhanced Linux support USE_SELINUX = false @@ -60,7 +64,6 @@ HEADERS = \ udev.h \ udev_utils.h \ udev_rules.h \ - udev_version.h \ udev_db.h \ udev_sysfs.h \ logging.h \ @@ -144,8 +147,6 @@ STRIP = $(CROSS)strip RANLIB = $(CROSS)ranlib HOSTCC = gcc -export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS - # code taken from uClibc to determine the current arch ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \ -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/powerpc/ppc/g'} @@ -187,6 +188,11 @@ else STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment endif +ifeq ($(strip $(USE_GCOV)),true) + CFLAGS += -fprofile-arcs -ftest-coverage + LDFLAGS = -fprofile-arcs +endif + # if our own version of klibc is used, we need to build it ifeq ($(strip $(USE_KLIBC)),true) KLIBC_INSTALL = $(PWD)/klibc/.install @@ -195,6 +201,7 @@ ifeq ($(strip $(USE_KLIBC)),true) LD = $(KLCC) else CFLAGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations + LDFLAGS += -Wl,-warn-common endif ifeq ($(strip $(USE_SELINUX)),true) @@ -220,7 +227,12 @@ all: $(KLCC) $(PROGRAMS) $(MAN_PAGES) @extras="$(EXTRAS)"; for target in $$extras; do \ echo $$target; \ $(MAKE) prefix=$(prefix) \ + CC="$(CC)" \ + CFLAGS="$(CFLAGS)" \ LD="$(LD)" \ + LDFLAGS="$(LDFLAGS)" \ + STRIPCMD="$(STRIPCMD)" \ + LIB_OBJS="$(LIB_OBJS)" \ LIBUDEV="$(PWD)/$(LIBUDEV)" \ LIBSYSFS="$(PWD)/$(LIBSYSFS)" \ KERNEL_DIR="$(KERNEL_DIR)" \ @@ -228,20 +240,29 @@ all: $(KLCC) $(PROGRAMS) $(MAN_PAGES) -C $$target $@; \ done; .PHONY: all +.DEFAULT: all + +# clear implicit rules +.SUFFIXES: -$(PROGRAMS): $(HOST_PROGS) $(KLCC) $(HEADERS) $(GEN_HEADERS) $(LIBSYSFS) $(LIBUDEV) - $(QUIET) $(CC) $(CFLAGS) -c -o $@.o $@.c - $(QUIET) $(LD) $(LDFLAGS) -o $@ $@.o $(LIBUDEV) $(LIBSYSFS) $(LIB_OBJS) +# build the objects +%.o: %.c $(GEN_HEADERS) + $(QUIET) $(CC) -c $(CFLAGS) $< -o $@ + +# "Static Pattern Rule" to build all programs +$(PROGRAMS): %: $(HOST_PROGS) $(KLCC) $(HEADERS) $(GEN_HEADERS) $(LIBSYSFS) $(LIBUDEV) %.o + $(QUIET) $(LD) $(LDFLAGS) $@.o -o $@ $(LIBUDEV) $(LIBSYSFS) $(LIB_OBJS) $(QUIET) $(STRIPCMD) $@ -# our own copy of klibc if KLCC is specified it will not be used +# our own copy of klibc, it is not used if KLCC is given $(KLCC): - $(MAKE) -j1 -C klibc KRNLSRC=$(KERNEL_DIR) SUBDIRS=klibc TESTS= \ + $(MAKE) -C klibc KRNLSRC=$(KERNEL_DIR) SUBDIRS=klibc TESTS= \ SHLIBDIR=$(KLIBC_INSTALL)/lib \ INSTALLDIR=$(KLIBC_INSTALL) \ bindir=$(KLIBC_INSTALL)/bin \ mandir=$(KLIBC_INSTALL)/man all install -find $(KLIBC_INSTALL)/include -name SCCS -print| xargs rm -rf +.NOTPARALLEL: $(KLCC) $(UDEV_OBJS): $(KLCC) $(LIBUDEV): $(HOST_PROGS) $(HEADERS) $(GEN_HEADERS) $(UDEV_OBJS) @@ -276,16 +297,17 @@ udev_version.h: xmlto man $? .PRECIOUS: %.8 -.c.o: - $(QUIET) $(CC) $(CFLAGS) -c -o $@ $< - ccdv: ccdv.c @$(HOSTCC) -O1 ccdv.c -o ccdv .SILENT: ccdv clean: - -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print | xargs rm -f - -rm -f core $(PROGRAMS) $(GEN_HEADERS) $(GEN_CONFIGS) + - find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print0 | xargs -0rt rm -f + - find -name "*.gcno" -print0 | xargs -0rt rm -f + - find -name "*.gcda" -print0 | xargs -0rt rm -f + - find -name "*.gcov" -print0 | xargs -0rt rm -f + - rm -f udev_gcov.txt + - rm -f core $(PROGRAMS) $(GEN_HEADERS) $(GEN_CONFIGS) $(MAKE) -C klibc SUBDIRS=klibc clean @extras="$(EXTRAS)"; for target in $$extras; do \ echo $$target; \ @@ -314,6 +336,10 @@ install-config: $(GEN_CONFIGS) echo "pick a udev rules file from the etc/udev directory that matches your distribution"; \ echo; \ fi + @extras="$(EXTRAS)"; for target in $$extras; do \ + echo $$target; \ + $(MAKE) prefix=$(prefix) -C $$target $@; \ + done; .PHONY: install-config install-man: @@ -325,20 +351,28 @@ install-man: $(INSTALL_DATA) -D udevsend.8 $(DESTDIR)$(mandir)/man8/udevsend.8 $(INSTALL_DATA) -D udevmonitor.8 $(DESTDIR)$(mandir)/man8/udevmonitor.8 - ln -f -s udevd.8 $(DESTDIR)$(mandir)/man8/udevcontrol.8 + @extras="$(EXTRAS)"; for target in $$extras; do \ + echo $$target; \ + $(MAKE) prefix=$(prefix) -C $$target $@; \ + done; .PHONY: install-man uninstall-man: - - rm $(mandir)/man8/udev.8 - - rm $(mandir)/man8/udevinfo.8 - - rm $(mandir)/man8/udevtest.8 - - rm $(mandir)/man8/udevstart.8 - - rm $(mandir)/man8/udevd.8 - - rm $(mandir)/man8/udevmonitor.8 - - rm $(mandir)/man8/udevsend.8 - - rm $(mandir)/man8/udevcontrol.8 + - rm -f $(mandir)/man8/udev.8 + - rm -f $(mandir)/man8/udevinfo.8 + - rm -f $(mandir)/man8/udevtest.8 + - rm -f $(mandir)/man8/udevstart.8 + - rm -f $(mandir)/man8/udevd.8 + - rm -f $(mandir)/man8/udevmonitor.8 + - rm -f $(mandir)/man8/udevsend.8 + - rm -f $(mandir)/man8/udevcontrol.8 + @extras="$(EXTRAS)"; for target in $$extras; do \ + echo $$target; \ + $(MAKE) prefix=$(prefix) -C $$target $@; \ + done; .PHONY: uninstall-man -install: install-config install-man all +install-bin: $(INSTALL) -d $(DESTDIR)$(udevdir) $(INSTALL_PROGRAM) -D udev $(DESTDIR)$(sbindir)/udev $(INSTALL_PROGRAM) -D udevd $(DESTDIR)$(sbindir)/udevd @@ -348,43 +382,71 @@ install: install-config install-man all $(INSTALL_PROGRAM) -D udevinfo $(DESTDIR)$(usrbindir)/udevinfo $(INSTALL_PROGRAM) -D udevtest $(DESTDIR)$(usrbindir)/udevtest $(INSTALL_PROGRAM) -D udevstart $(DESTDIR)$(sbindir)/udevstart + @extras="$(EXTRAS)"; for target in $$extras; do \ + echo $$target; \ + $(MAKE) prefix=$(prefix) -C $$target $@; \ + done; ifndef DESTDIR - killall udevd - rm -rf $(udevdb) - $(sbindir)/udevd --daemon endif - @extras="$(EXTRAS)"; for target in $$extras; do \ - echo $$target; \ - $(MAKE) prefix=$(prefix) -C $$target $@; \ - done; -.PHONY: install - -uninstall: uninstall-man - - rm $(configdir)/rules.d/50-udev.rules - - rm $(configdir)/udev.conf - - rmdir $(configdir)/rules.d - - rmdir $(configdir) - - rm $(sbindir)/udev - - rm $(sbindir)/udevd - - rm $(sbindir)/udevsend - - rm $(sbindir)/udevinitsend - - rm $(sbindir)/udeveventrecoreder - - rm $(sbindir)/udevcontrol - - rm $(sbindir)/udevstart - - rm $(usrsbindir)/udevmonitor - - rm $(usrbindir)/udevinfo - - rm $(usrbindir)/udevtest +.PHONY: install-bin + +uninstall-bin: + - rm -f $(sbindir)/udev + - rm -f $(sbindir)/udevd + - rm -f $(sbindir)/udevsend + - rm -f $(sbindir)/udevinitsend + - rm -f $(sbindir)/udeveventrecoreder + - rm -f $(sbindir)/udevcontrol + - rm -f $(sbindir)/udevstart + - rm -f $(usrsbindir)/udevmonitor + - rm -f $(usrbindir)/udevinfo + - rm -f $(usrbindir)/udevtest - rm -rf $(udevdb) - - rmdir $(udevdir) - killall udevd @extras="$(EXTRAS)"; for target in $$extras; do \ echo $$target; \ $(MAKE) prefix=$(prefix) -C $$target $@; \ done; -.PHONY: uninstall-man +.PHONY: uninstall-bin + +install: all install-bin install-config install-man +.PHONY: install + +uninstall: uninstall-bin uninstall-man +.PHONY: uninstall test tests: all @ cd test && ./udev-test.pl @ cd test && ./udevstart-test.pl .PHONY: test tests +buildtest: + ./test/simple-build-check.sh +.PHONY: buildtest + +gcov-all: + $(MAKE) clean all DEBUG=true USE_GCOV=true + @echo + @echo "binaries built with gcov support." + @echo "run the tests and analyze with 'make udev_gcov.txt'" +.PHONY: gcov-all + +# see docs/README-gcov_for_udev +udev_gcov.txt: $(wildcard *.gcda) $(wildcard *.gcno) + for file in `find -maxdepth 1 -name "*.gcno"`; do \ + name=`basename $$file .gcno`; \ + echo "################" >> $@; \ + echo "$$name.c" >> $@; \ + echo "################" >> $@; \ + if [ -e "$$name.gcda" ]; then \ + gcov -l "$$name.c" >> $@ 2>&1; \ + else \ + echo "code for $$name.c was never executed" >> $@ 2>&1; \ + fi; \ + echo >> $@; \ + done; \ + echo "view $@ for the result" +