chiark / gitweb /
[PATCH] automatically install correct initscript
[elogind.git] / Makefile
index 3b44b23359c78157a7bbe8d895780a29f5cadd39..c3b33a7be10c20cc25e4440de84847050432c6cb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -35,7 +35,8 @@ DAEMON =      udevd
 SENDER =       udevsend
 HELPER =       udevinfo
 TESTER =       udevtest
-VERSION =      018_bk
+STARTER =      udevstart
+VERSION =      019_bk
 INSTALL_DIR =  /usr/local/bin
 RELEASE_NAME = $(ROOT)-$(VERSION)
 LOCAL_CFG_DIR =        etc/udev
@@ -73,6 +74,9 @@ udevdir = ${prefix}/udev
 # than the local version of klibc
 #USE_KLIBC = true
 
+# set up PWD so that older versions of make will work with our build.
+PWD = $(shell pwd)
+
 # If you are running a cross compiler, you may want to set this
 # to something more interesting, like "arm-linux-".  If you want
 # to compile vs uClibc, that can be done here as well.
@@ -169,7 +173,7 @@ endif
 
 CFLAGS += -I$(PWD)/libsysfs
 
-all: $(ROOT) $(SENDER) $(DAEMON) $(HELPER) $(TESTER)
+all: $(ROOT) $(SENDER) $(DAEMON) $(HELPER) $(TESTER) $(STARTER)
        @extras="$(EXTRAS)" ; for target in $$extras ; do \
                echo $$target ; \
                $(MAKE) prefix=$(prefix) \
@@ -224,6 +228,14 @@ ifeq ($(USE_DBUS), true)
        OBJS += udev_dbus.o
 endif
 
+# if USE_SELINUX is enabled, then we do not strip or optimize
+ifeq ($(strip $(USE_SELINUX)),true)
+       CFLAGS  += -DUSE_SELINUX
+       OBJS += udev_selinux.o
+       LIB_OBJS += -lselinux
+endif
+
+
 # header files automatically generated
 GEN_HEADERS =  udev_version.h
 
@@ -254,6 +266,7 @@ $(TESTER).o: $(GEN_HEADERS)
 $(HELPER).o: $(GEN_HEADERS)
 $(DAEMON).o: $(GEN_HEADERS)
 $(SENDER).o: $(GEN_HEADERS)
+$(STARTER).o: $(GEN_HEADERS)
 
 $(ROOT): $(ROOT).o $(OBJS) $(HEADERS) $(LIBC)
        $(LD) $(LDFLAGS) -o $@ $(CRT0) udev.o $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
@@ -275,10 +288,14 @@ $(SENDER): $(SENDER).o udevd.h $(LIBC)
        $(LD) $(LDFLAGS) -o $@ $(CRT0) udevsend.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
        $(STRIPCMD) $@
 
+$(STARTER): $(STARTER).o $(HEADERS) $(LIBC)
+       $(LD) $(LDFLAGS) -o $@ $(CRT0) udevstart.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
+       $(STRIPCMD) $@
+
 clean:
        -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
         | xargs rm -f 
-       -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(HELPER) $(DAEMON) $(SENDER) $(TESTER)
+       -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(HELPER) $(DAEMON) $(SENDER) $(TESTER) $(STARTER)
        $(MAKE) -C klibc clean
        @extras="$(EXTRAS)" ; for target in $$extras ; do \
                echo $$target ; \
@@ -330,6 +347,15 @@ uninstall-dbus-policy:
        -
 endif
 
+install-initscript: etc/init.d/udev etc/init.d/udev.debian etc/init.d/udev.init.LSB
+       @if [ -f /etc/redhat-release ]; then \
+               $(INSTALL_DATA) etc/init.d/udev $(etcdir)/init.d/udev; \
+       elif [ -f /etc/SuSE-release ]; then \
+               $(INSTALL_DATA) etc/init.d/udev.init.LSB $(etcdir)/init.d/udev; \
+       elif [ -f /etc/debian_version ]; then \
+               $(INSTALL_DATA) etc/init.d/udev.debian $(etcdir)/init.d/udev; \
+       fi
+
 install-config: $(GEN_CONFIGS)
        $(INSTALL) -d $(DESTDIR)$(configdir)
        @if [ ! -r $(DESTDIR)$(configdir)udev.conf ]; then \
@@ -345,7 +371,7 @@ install-config: $(GEN_CONFIGS)
                $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
        fi
 
-install: install-config install-dbus-policy all
+install: install-initscript install-config install-dbus-policy all
        $(INSTALL) -d $(DESTDIR)$(udevdir)
        $(INSTALL) -d $(DESTDIR)$(hotplugdir)
        $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
@@ -353,19 +379,15 @@ install: install-config install-dbus-policy all
        $(INSTALL_PROGRAM) -D $(SENDER) $(DESTDIR)$(sbindir)/$(SENDER)
        $(INSTALL_PROGRAM) -D $(HELPER) $(DESTDIR)$(sbindir)/$(HELPER)
        $(INSTALL_PROGRAM) -D $(TESTER) $(DESTDIR)$(sbindir)/$(TESTER)
-       @if [ "x$(USE_LSB)" = "xtrue" ]; then \
-               $(INSTALL_PROGRAM) -D etc/init.d/udev.init.LSB $(DESTDIR)$(initdir)/udev; \
-               ln -s $(DESTDIR)$(initdir)/udev $(sbindir)/rcudev; \
-       else \
-               $(INSTALL_PROGRAM) -D etc/init.d/udev $(DESTDIR)$(initdir)/udev; \
-       fi
        $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
        $(INSTALL_DATA) -D udevinfo.8 $(DESTDIR)$(mandir)/man8/udevinfo.8
        $(INSTALL_DATA) -D udevd.8 $(DESTDIR)$(mandir)/man8/udevd.8
-       - ln -f -s ./udevd.8 $(DESTDIR)$(mandir)/man8/udevsend.8
-       - rm -f $(DESTDIR)$(hotplugdir)/$(ROOT).hotplug
-       - rm -f $(udevdir)/.udev.tdb
+       - ln -f -s udevd.8 $(DESTDIR)$(mandir)/man8/udevsend.8
        - ln -f -s $(sbindir)/$(SENDER) $(DESTDIR)$(hotplugdir)/$(ROOT).hotplug
+ifndef DESTDIR
+       - killall udevd
+       - rm -f $(udevdir)/.udev.tdb
+endif
        @extras="$(EXTRAS)" ; for target in $$extras ; do \
                echo $$target ; \
                $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \