ioctlsort: rewrite build rules using noinst_PROGRAMS
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 4 Nov 2014 01:40:42 +0000 (01:40 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 11 Nov 2014 15:30:00 +0000 (15:30 +0000)
* linux/ioctlsort.c: Rename to ioctlsort.c
* Makefile.am (EXTRA_DIST): Rename linux/ioctlsort.c to ioctlsort.c.
[MAINTAINER_MODE] (noinst_PROGRAMS): Add ioctlsort.
(ioctlsort_SOURCES): Add ioctlsort.c.
(nodist_ioctlsort_SOURCES): Add ioctls.h and ioctldefs.h.
(CLEANFILES): Add $(nodist_ioctlsort_SOURCES).
(ioctlsort.$(OBJEXT)): Likewise.
(ioctlsort): Remove.

Makefile.am
ioctlsort.c [new file with mode: 0644]
linux/ioctlsort.c [deleted file]

index 5f98cd6398c89ae198d1fbd0316b74caa9f8f091..f046e0c562c11a394652ffcba87f01fcc1617edf 100644 (file)
@@ -96,6 +96,7 @@ EXTRA_DIST =                          \
        debian/strace64.manpages        \
        debian/watch                    \
        errnoent.sh                     \
+       ioctlsort.c                     \
        linux/aarch64/errnoent1.h       \
        linux/aarch64/ioctlent.h.in     \
        linux/aarch64/ioctlent1.h       \
@@ -130,7 +131,6 @@ EXTRA_DIST =                                \
        linux/inotify.h                 \
        linux/ioctlent.h.in             \
        linux/ioctlent.sh               \
-       linux/ioctlsort.c               \
        linux/kexec.h                   \
        linux/keyctl.h                  \
        linux/m68k/ioctlent.h.in        \
@@ -260,6 +260,17 @@ news-check: NEWS
                exit 1;                                         \
        fi
 
+ioctlent_h = $(builddir)/$(OS)/ioctlent.h
+BUILT_SOURCES += $(ioctlent_h)
+CLEANFILES = $(ioctlent_h)
+ioctlent_h_deps = $(srcdir)/$(OS)/ioctlent.h.in $(srcdir)/$(OS)/$(ARCH)/ioctlent.h.in
+$(ioctlent_h): $(top_builddir)/config.status $(ioctlent_h_deps)
+       $(MKDIR_P) $(builddir)/$(OS)
+       cat $(ioctlent_h_deps) | \
+               $(COMPILE) -E -P - | \
+               sed 's/^\([[:space:]]*{\)"[^"]\+",[[:space:]]*/\1/' | \
+               LC_ALL=C sort -u -k2,2 -k1,1 > $@
+
 if MAINTAINER_MODE
 
 gen_changelog_start_date = 2009-07-08 20:00
@@ -297,31 +308,19 @@ KERNEL_INCLUDE = \
        $(INCLUDEDIR)
 IOCTLDIR = $(shell find $(KERNEL_INCLUDE) -maxdepth 0 -type d -print -quit 2>/dev/null)
 IOCTLASM = $(INCLUDEDIR)/asm
-IOCTLSORT_INCLUDEDIR = $(INCLUDEDIR)
 
-ioctlent_h_in = linux/ioctlent.h.in
+noinst_PROGRAMS = ioctlsort
+ioctlsort_SOURCES = ioctlsort.c
+nodist_ioctlsort_SOURCES = ioctls.h ioctldefs.h
+CLEANFILES += $(nodist_ioctlsort_SOURCES)
+ioctlsort.$(OBJEXT): $(nodist_ioctlsort_SOURCES)
+ioctls.h: $(srcdir)/linux/ioctlent.sh
+       $(SHELL) $< $(IOCTLDIR) $(IOCTLASM)
+ioctldefs.h: ioctls.h ;
 
+ioctlent_h_in = linux/ioctlent.h.in
 BUILT_SOURCES += $(ioctlent_h_in)
-
 $(srcdir)/$(ioctlent_h_in): ioctlsort
        $(<D)/$(<F) > $@
-ioctlsort: $(srcdir)/linux/ioctlsort.c ioctls.h ioctldefs.h
-       $(filter-out -I%,$(LINK.c)) -I. -I$(IOCTLSORT_INCLUDEDIR) \
-       $(filter -I%,$(LINK.c)) \
-         -o $@ $<
-ioctls.h: $(srcdir)/linux/ioctlent.sh
-       $(SHELL) $< $(IOCTLDIR) $(IOCTLASM)
-ioctldefs.h: ioctls.h ;
 
 endif
-
-ioctlent_h = $(builddir)/$(OS)/ioctlent.h
-BUILT_SOURCES += $(ioctlent_h)
-CLEANFILES = $(ioctlent_h)
-ioctlent_h_deps = $(srcdir)/$(OS)/ioctlent.h.in $(srcdir)/$(OS)/$(ARCH)/ioctlent.h.in
-$(ioctlent_h): $(top_builddir)/config.status $(ioctlent_h_deps)
-       $(MKDIR_P) $(builddir)/$(OS)
-       cat $(ioctlent_h_deps) | \
-               $(COMPILE) -E -P - | \
-               sed 's/^\([[:space:]]*{\)"[^"]\+",[[:space:]]*/\1/' | \
-               LC_ALL=C sort -u -k2,2 -k1,1 > $@
diff --git a/ioctlsort.c b/ioctlsort.c
new file mode 100644 (file)
index 0000000..393b534
--- /dev/null
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <stdint.h>
+
+#include <asm/ioctl.h>
+#include <linux/types.h>
+
+#include "ioctldefs.h"
+#include <linux/atmioc.h>
+
+struct ioctlent {
+       const char*     header;
+       const char*     name;
+       unsigned long   code;
+};
+
+struct ioctlent ioctls[] = {
+#include "ioctls.h"
+};
+
+int nioctls = sizeof(ioctls) / sizeof(ioctls[0]);
+
+int compare(const void* a, const void* b) {
+       unsigned long code1 = ((struct ioctlent *) a)->code;
+       unsigned long code2 = ((struct ioctlent *) b)->code;
+       const char *name1 = ((struct ioctlent *) a)->name;
+       const char *name2 = ((struct ioctlent *) b)->name;
+       return (code1 > code2) ? 1 : (code1 < code2) ? -1 : strcmp(name1, name2);
+}
+
+static int is_not_prefix(const char *s1, const char *s2) {
+       size_t len = strlen(s1);
+
+       if (len > strlen(s2))
+               return 1;
+       return memcmp(s1, s2, len);
+}
+
+int main(int argc, char** argv) {
+       int i;
+
+       /* ioctl_lookup() only looks at the NR and TYPE bits atm. */
+       for (i = 0; i < nioctls; i++)
+               ioctls[i].code &= (_IOC_NRMASK << _IOC_NRSHIFT) |
+                                 (_IOC_TYPEMASK << _IOC_TYPESHIFT);
+
+       qsort(ioctls, nioctls, sizeof(ioctls[0]), compare);
+       puts("\t/* Generated by ioctlsort */");
+       for (i = 0; i < nioctls; i++)
+               if (i == 0 || ioctls[i-1].code != ioctls[i].code ||
+                   is_not_prefix(ioctls[i-1].name, ioctls[i].name))
+                       printf("\t{\"%s\",\t\"%s\",\t%#06lx},\n",
+                               ioctls[i].header, ioctls[i].name, ioctls[i].code);
+
+       return 0;
+}
diff --git a/linux/ioctlsort.c b/linux/ioctlsort.c
deleted file mode 100644 (file)
index 393b534..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <stdint.h>
-
-#include <asm/ioctl.h>
-#include <linux/types.h>
-
-#include "ioctldefs.h"
-#include <linux/atmioc.h>
-
-struct ioctlent {
-       const char*     header;
-       const char*     name;
-       unsigned long   code;
-};
-
-struct ioctlent ioctls[] = {
-#include "ioctls.h"
-};
-
-int nioctls = sizeof(ioctls) / sizeof(ioctls[0]);
-
-int compare(const void* a, const void* b) {
-       unsigned long code1 = ((struct ioctlent *) a)->code;
-       unsigned long code2 = ((struct ioctlent *) b)->code;
-       const char *name1 = ((struct ioctlent *) a)->name;
-       const char *name2 = ((struct ioctlent *) b)->name;
-       return (code1 > code2) ? 1 : (code1 < code2) ? -1 : strcmp(name1, name2);
-}
-
-static int is_not_prefix(const char *s1, const char *s2) {
-       size_t len = strlen(s1);
-
-       if (len > strlen(s2))
-               return 1;
-       return memcmp(s1, s2, len);
-}
-
-int main(int argc, char** argv) {
-       int i;
-
-       /* ioctl_lookup() only looks at the NR and TYPE bits atm. */
-       for (i = 0; i < nioctls; i++)
-               ioctls[i].code &= (_IOC_NRMASK << _IOC_NRSHIFT) |
-                                 (_IOC_TYPEMASK << _IOC_TYPESHIFT);
-
-       qsort(ioctls, nioctls, sizeof(ioctls[0]), compare);
-       puts("\t/* Generated by ioctlsort */");
-       for (i = 0; i < nioctls; i++)
-               if (i == 0 || ioctls[i-1].code != ioctls[i].code ||
-                   is_not_prefix(ioctls[i-1].name, ioctls[i].name))
-                       printf("\t{\"%s\",\t\"%s\",\t%#06lx},\n",
-                               ioctls[i].header, ioctls[i].name, ioctls[i].code);
-
-       return 0;
-}