From: Lucas De Marchi Date: Sat, 21 Jan 2012 17:38:25 +0000 (-0200) Subject: build-sys: do not create symlinks by default X-Git-Tag: v5~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe8b0671a0e09650bb2694178257c5967e8bf86f;p=thirdparty%2Fkmod.git build-sys: do not create symlinks by default Distro packagers should create them instead. It's too much trouble to create them in the build system and every distro wants a different path for them. --- diff --git a/Makefile.am b/Makefile.am index 932d1ae3..0dd48ff1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -97,18 +97,6 @@ install-exec-hook: ln -sf $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/libkmod.so && \ mv $(DESTDIR)$(libdir)/libkmod.so.* $(DESTDIR)$(rootlibdir); \ fi -if BUILD_TOOLS - ln -sf kmod $(DESTDIR)$(bindir)/insmod - ln -sf kmod $(DESTDIR)$(bindir)/rmmod - ln -sf kmod $(DESTDIR)$(bindir)/lsmod - ln -sf kmod $(DESTDIR)$(bindir)/modprobe - ln -sf kmod $(DESTDIR)$(bindir)/modinfo - ln -sf kmod $(DESTDIR)$(bindir)/depmod - $(MKDIR_P) $(DESTDIR)$(sbindir) && \ - relpath=$$(tools/shortest-relpath $(DESTDIR)$(bindir)/kmod $(DESTDIR)$(sbindir)) && \ - cd $(DESTDIR)$(sbindir) && \ - ln -sf $$relpath modprobe -endif uninstall-hook: rm -f $(DESTDIR)$(rootlibdir)/libkmod.so* @@ -128,15 +116,13 @@ tools_kmod_CFLAGS = $(AM_CFLAGS) tools_kmod_LDADD = libkmod/libkmod-util.la \ libkmod/libkmod.la -noinst_PROGRAMS = tools/kmod-nolib tools/shortest-relpath +noinst_PROGRAMS = tools/kmod-nolib tools_kmod_nolib_SOURCES = $(tools_kmod_SOURCES) tools_kmod_nolib_CPPFLAGS = $(tools_kmod_CPPFLAGS) tools_kmod_nolib_CFLAGS = $(tools_kmod_CFLAGS) tools_kmod_nolib_LDADD = libkmod/libkmod-util.la \ libkmod/libkmod-private.la -tools_shortest_relpath_SOURCES = tools/shortest-relpath.c - ${noinst_SCRIPTS}: tools/kmod-nolib $(AM_V_GEN) ($(RM) $@; \ $(LN_S) $(notdir $<) $@) diff --git a/tools/.gitignore b/tools/.gitignore index a3a5795f..041d7b22 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -7,4 +7,3 @@ modinfo depmod kmod kmod-nolib -shortest-relpath diff --git a/tools/shortest-relpath.c b/tools/shortest-relpath.c deleted file mode 100644 index 5c960bbc..00000000 --- a/tools/shortest-relpath.c +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include -#include -#include - -static void usage(const char *progname) -{ - printf("%s \n", progname); -} - -/* - * path must be absolute path, as the result of calling realpath() - */ -static void split_path(const char *path, char d[PATH_MAX], size_t *dlen, - char n[NAME_MAX], size_t *nlen) -{ - size_t dirnamelen, namelen; - char *p; - - p = strrchr(path, '/'); /* p is never NULL since path is abs */ - dirnamelen = p - path; - if (dirnamelen > 0) - memcpy(d, path, dirnamelen); - d[dirnamelen] = '\0'; - - namelen = strlen(p + 1); - if (namelen > 0) - memcpy(n, p + 1, namelen + 1); - - if (dlen) - *dlen = dirnamelen; - if (nlen) - *nlen = namelen; -} - -int main(int argc, char *argv[]) -{ - size_t sympathlen, namelen, pathlen, i, j; - char name[NAME_MAX], path[PATH_MAX]; - char sympath[PATH_MAX]; - char buf[PATH_MAX]; - char *p; - - if (argc < 3) { - usage(basename(argv[0])); - return EXIT_FAILURE; - } - - p = realpath(argv[1], buf); - if (p == NULL) { - fprintf(stderr, "could not get realpath of %s: %m\n", argv[1]); - return EXIT_FAILURE; - } - split_path(buf, path, &pathlen, name, &namelen); - - p = realpath(argv[2], sympath); - if (p == NULL) { - fprintf(stderr, "could not get realpath of %s: %m\n", argv[2]); - return EXIT_FAILURE; - } - sympathlen = strlen(sympath); - - for (i = 1; i < sympathlen && i < pathlen; i++) { - if (sympath[i] == path[i]) - continue; - break; - } - - if (i < sympathlen) { - while (sympath[i - 1] != '/') - i--; - } - - p = &path[i]; - - j = 0; - if (i < sympathlen) { - memcpy(buf + j, "../", 3); - j += 3; - } - - for (; i < sympathlen; i++) { - if (sympath[i] != '/') - continue; - - memcpy(buf + j, "../", 3); - j += 3; - } - - if (p != path + pathlen) { - memcpy(buf + j, p, path + pathlen - p); - j += path + pathlen - p;; - buf[j++] = '/'; - } - memcpy(buf + j, name, namelen + 1); - - printf("%s\n", buf); - return 0; -}