]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
Fixed installation when changing DESTDIR
authorRafael Almeida <rafaelc@dcc.ufmg.br>
Mon, 2 Jun 2008 00:33:44 +0000 (21:33 -0300)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Fri, 25 Jul 2008 20:40:19 +0000 (13:40 -0700)
After changing the DESTDIR the installated binaries have some issues
due to hard coded paths. For example, using distributions on NetEm
would segfault.

I've changed iplink.c and tc_util.c so they are now aware of DESTDIR.
Along with that change I needed to change the main Makefile so it
defines the DESTDIR macro when calling gcc.

I also changed the paths so that during the installation sbin, etc,
share and lib directories are created directly inside of the DESTDIR,
instead of creating a usr directory inside that. That's the behaviour
of most packages out there, so I think most users will be expecting
that to happen.

Makefile
ip/iplink.c
netem/Makefile
tc/Makefile
tc/tc_util.c

index 723eb5d328e910550d5d0bfd32185aa3f6c705f0..cfb27f42278acee1beb267196382ae0d4e320090 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,13 @@
-DESTDIR=
-SBINDIR=/usr/sbin
+DESTDIR=/usr/
+SBINDIR=/sbin
 CONFDIR=/etc/iproute2
-DOCDIR=/usr/share/doc/iproute2
-MANDIR=/usr/share/man
+DOCDIR=/share/doc/iproute2
+MANDIR=/share/man
 
 # Path to db_185.h include
 DBM_INCLUDE:=/usr/include
 
-DEFINES= -DRESOLVE_HOSTNAMES
+DEFINES= -DRESOLVE_HOSTNAMES -DDESTDIR=\"$(DESTDIR)\"
 
 #options if you have a bind>=4.9.4 libresolv (or, maybe, glibc)
 LDLIBS=-lresolv
index c70c84ad479ab4f3c49928c0f1cef001791ce08a..9a092630e97bb923c7c42869d962c0ba6c87319e 100644 (file)
@@ -33,6 +33,9 @@
 #include "ip_common.h"
 
 #define IPLINK_IOCTL_COMPAT    1
+#ifndef DESTDIR
+#define DESTDIR "/usr/"
+#endif
 
 static void usage(void) __attribute__((noreturn));
 
@@ -78,7 +81,7 @@ struct link_util *get_link_kind(const char *id)
                if (strcmp(l->id, id) == 0)
                        return l;
 
-       snprintf(buf, sizeof(buf), "/usr/lib/ip/link_%s.so", id);
+       snprintf(buf, sizeof(buf), DESTDIR "/lib/ip/link_%s.so", id);
        dlh = dlopen(buf, RTLD_LAZY);
        if (dlh == NULL) {
                /* look in current binary, only open once */
index 2d7d68bb150be7704033995a7746a29df2582e97..b6ccfc6a4d0c29dcc8f433acf55a252c869086fc 100644 (file)
@@ -20,9 +20,9 @@ stats: stats.c
        $(HOSTCC) $(CCOPTS) -I../include -o $@ $@.c -lm
 
 install: all
-       mkdir -p $(DESTDIR)/usr/lib/tc
+       mkdir -p $(DESTDIR)/lib/tc
        for i in $(DISTDATA); \
-       do install -m 755 $$i $(DESTDIR)/usr/lib/tc; \
+       do install -m 755 $$i $(DESTDIR)/lib/tc; \
        done
 
 clean:
index bf2df0077c4b79484a46c7b1d4e289fca6392865..4116983e7267304db8efe3696d7197968b5bef83 100644 (file)
@@ -72,10 +72,10 @@ libtc.a: $(TCLIB)
        $(AR) rcs $@ $(TCLIB)
 
 install: all
-       mkdir -p $(DESTDIR)/usr/lib/tc
+       mkdir -p $(DESTDIR)/lib/tc
        install -m 0755 tc $(DESTDIR)$(SBINDIR)
        for i in $(TCSO); \
-       do install -m 755 $$i $(DESTDIR)/usr/lib/tc; \
+       do install -m 755 $$i $(DESTDIR)/lib/tc; \
        done
 
 clean:
index cd9dd59423d586af591ccc761d7c6a786588a109..ba7c0c9dad4db33a735fa98728a10927edc686ce 100644 (file)
 #include "utils.h"
 #include "tc_util.h"
 
+#ifndef DESTDIR
+#define DESTDIR "/usr/"
+#endif
+
 const char *get_tc_lib(void)
 {
        const char *lib_dir;
 
        lib_dir = getenv("TC_LIB_DIR");
        if (!lib_dir)
-               lib_dir = "/usr/lib/tc";
+               lib_dir = DESTDIR "/lib/tc";
 
        return lib_dir;
 }