chiark / gitweb /
udevd: fix udevd read() calls to leave room for null byte
[elogind.git] / Makefile
index 07f57519ab64c6b1d63f4af01231af7a98b393b5..7e3adb975b0a803b9908e865c40aef8d6e710b75 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-VERSION =      068
+VERSION =      069
 
 # 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
 
@@ -186,6 +190,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
@@ -194,6 +203,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)
@@ -227,6 +237,7 @@ all: $(KLCC) $(PROGRAMS) $(MAN_PAGES)
                        -C $$target $@; \
        done;
 .PHONY: all
+.DEFAULT: all
 
 # clear implicit rules
 .SUFFIXES:
@@ -288,8 +299,12 @@ ccdv: ccdv.c
 .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; \
@@ -318,6 +333,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:
@@ -329,6 +348,10 @@ 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:
@@ -340,9 +363,13 @@ uninstall-man:
        - rm $(mandir)/man8/udevmonitor.8
        - rm $(mandir)/man8/udevsend.8
        - rm $(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
@@ -361,13 +388,9 @@ endif
                echo $$target; \
                $(MAKE) prefix=$(prefix) -C $$target $@; \
        done;
-.PHONY: install
+.PHONY: install-bin
 
-uninstall: uninstall-man
-       - rm $(configdir)/rules.d/50-udev.rules
-       - rm $(configdir)/udev.conf
-       - rmdir $(configdir)/rules.d
-       - rmdir $(configdir)
+uninstall-bin:
        - rm $(sbindir)/udev
        - rm $(sbindir)/udevd
        - rm $(sbindir)/udevsend
@@ -379,16 +402,48 @@ uninstall: uninstall-man
        - rm $(usrbindir)/udevinfo
        - rm $(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"
+