summaryrefslogtreecommitdiffstats
path: root/debian/rules.d/scripts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--debian/rules.d/scripts/Makefile48
-rw-r--r--debian/rules.d/scripts/basic/Makefile4
-rw-r--r--debian/rules.d/scripts/genksyms/Makefile16
-rw-r--r--debian/rules.d/scripts/kconfig/Makefile16
-rw-r--r--debian/rules.d/scripts/mod/Makefile22
-rw-r--r--debian/rules.d/scripts/mod/Makefile.real23
-rw-r--r--debian/rules.d/scripts/mod/elfconfig.h7
-rwxr-xr-xdebian/rules.d/scripts/mod/gendef.py20
-rw-r--r--debian/rules.d/scripts/mod/modpost.c136
-rw-r--r--debian/rules.d/scripts/mod/real-lsb-32/elfconfig.h4
-rw-r--r--debian/rules.d/scripts/mod/real-lsb-32/types.h3
-rw-r--r--debian/rules.d/scripts/mod/real-lsb-64/elfconfig.h4
-rw-r--r--debian/rules.d/scripts/mod/real-lsb-64/types.h3
-rw-r--r--debian/rules.d/scripts/mod/real-msb-32/elfconfig.h4
-rw-r--r--debian/rules.d/scripts/mod/real-msb-32/types.h3
-rw-r--r--debian/rules.d/scripts/mod/real-msb-64/elfconfig.h4
-rw-r--r--debian/rules.d/scripts/mod/real-msb-64/types.h3
-rw-r--r--debian/rules.d/scripts/mod/types.h12
18 files changed, 332 insertions, 0 deletions
diff --git a/debian/rules.d/scripts/Makefile b/debian/rules.d/scripts/Makefile
new file mode 100644
index 000000000..bbfe9c0d1
--- /dev/null
+++ b/debian/rules.d/scripts/Makefile
@@ -0,0 +1,48 @@
+PROGS = \
+ bin2c \
+ kallsyms \
+ recordmcount \
+ sign-file \
+ unifdef
+
+DATA = \
+ Kbuild.include \
+ Makefile.* \
+ mkversion \
+ module-common.lds \
+ subarch.include
+
+SCRIPTS = \
+ checkincludes.pl \
+ check-local-export \
+ checkstack.pl \
+ checkversion.pl \
+ depmod.sh \
+ gcc-*.sh \
+ gen_initramfs_list.sh \
+ headers_install.sh \
+ kernel-doc \
+ ld-version.sh \
+ Lindent \
+ makelst \
+ mksysmap \
+ mkuboot.sh \
+ modules-check.sh \
+ namespace.pl \
+ pahole-flags.sh \
+ pahole-version.sh \
+ patch-kernel \
+ recordmcount.pl \
+ setlocalversion \
+ ver_linux
+
+SUBDIRS = \
+ basic \
+ genksyms \
+ kconfig \
+ mod
+
+include $(top_rulesdir)/Makefile.inc
+
+CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+sign-file: LDLIBS += -lcrypto
diff --git a/debian/rules.d/scripts/basic/Makefile b/debian/rules.d/scripts/basic/Makefile
new file mode 100644
index 000000000..127f53fa8
--- /dev/null
+++ b/debian/rules.d/scripts/basic/Makefile
@@ -0,0 +1,4 @@
+PROGS = \
+ fixdep
+
+include $(top_rulesdir)/Makefile.inc
diff --git a/debian/rules.d/scripts/genksyms/Makefile b/debian/rules.d/scripts/genksyms/Makefile
new file mode 100644
index 000000000..88524563f
--- /dev/null
+++ b/debian/rules.d/scripts/genksyms/Makefile
@@ -0,0 +1,16 @@
+PROGS = genksyms
+
+include $(top_rulesdir)/Makefile.inc
+
+genksyms: genksyms.o parse.tab.o lex.lex.o
+
+lex.lex.o: keywords.c parse.tab.h
+
+parse.tab.c: parse.y
+ $(YACC) -o$@ -t -l $<
+
+parse.tab.h: parse.y
+ $(YACC) -o/dev/null --defines=$@ -t -l $<
+
+lex.lex.c: lex.l
+ $(LEX) -o$@ -L $<
diff --git a/debian/rules.d/scripts/kconfig/Makefile b/debian/rules.d/scripts/kconfig/Makefile
new file mode 100644
index 000000000..c9ad2aaf9
--- /dev/null
+++ b/debian/rules.d/scripts/kconfig/Makefile
@@ -0,0 +1,16 @@
+PROGS = conf
+
+include $(top_rulesdir)/Makefile.inc
+
+conf: conf.o confdata.o expr.o lexer.lex.o menu.o parser.tab.o preprocess.o symbol.o util.o
+
+lexer.lex.o: parser.tab.h
+
+%.lex.c: %.l
+ flex -o$@ -L $<
+
+%.tab.c: %.y
+ bison -o$@ -t -l $<
+
+%.tab.h: %.y
+ bison -o/dev/null --defines=$@ -t -l $<
diff --git a/debian/rules.d/scripts/mod/Makefile b/debian/rules.d/scripts/mod/Makefile
new file mode 100644
index 000000000..6ebade2bc
--- /dev/null
+++ b/debian/rules.d/scripts/mod/Makefile
@@ -0,0 +1,22 @@
+PROGS = \
+ modpost \
+ modpost.real-lsb-32 \
+ modpost.real-lsb-64 \
+ modpost.real-msb-32 \
+ modpost.real-msb-64
+
+include $(top_rulesdir)/Makefile.inc
+
+wrapperdir = $(top_rulesdir)/$(OUTDIR)
+
+modpost.real-%:
+ $(MAKE) -f $(wrapperdir)/Makefile.real TYPE=$* SOURCEDIR=$(top_srcdir)/scripts/mod
+
+%: %.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+
+modpost-opts.h: $(top_srcdir)/scripts/mod/modpost.c
+ $(wrapperdir)/gendef.py $< > $@
+
+modpost.o: modpost.c modpost-opts.h
+ $(CC) $(CFLAGS) $(CPPFLAGS) -I $(CURDIR) -c -o $@ $<
diff --git a/debian/rules.d/scripts/mod/Makefile.real b/debian/rules.d/scripts/mod/Makefile.real
new file mode 100644
index 000000000..6d56ff6ae
--- /dev/null
+++ b/debian/rules.d/scripts/mod/Makefile.real
@@ -0,0 +1,23 @@
+PROGS = modpost.real-$(TYPE)
+
+include $(top_rulesdir)/Makefile.inc
+
+wrapperdir = $(top_rulesdir)/$(OUTDIR)
+CFLAGS += -I $(CURDIR)/real-$(TYPE) -I $(wrapperdir)/real-$(TYPE)
+
+modpost.real-$(TYPE): file2alias.real-$(TYPE).o modpost.real-$(TYPE).o sumversion.real-$(TYPE).o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+
+%.real-$(TYPE).o: $(SOURCEDIR)/%.c real-$(TYPE)/devicetable-offsets.h
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
+real-$(TYPE)/devicetable-offsets.s: $(SOURCEDIR)/devicetable-offsets.c
+ mkdir -p real-$(TYPE)
+ $(CC) -include $(wrapperdir)/real-$(TYPE)/types.h $(CFLAGS) $(CPPFLAGS) -nostdinc -I$(top_srcdir)/include -S -o $@ $<
+
+real-$(TYPE)/devicetable-offsets.h: real-$(TYPE)/devicetable-offsets.s
+ echo >$@ "#define __DEVICEVTABLE_OFFSETS_H__"
+ sed -ne "s:^[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\".*:\1:; \
+ /^->/{s:->#\(.*\):/* \1 */:; \
+ s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+ s:->::; p;}" $< >>$@
diff --git a/debian/rules.d/scripts/mod/elfconfig.h b/debian/rules.d/scripts/mod/elfconfig.h
new file mode 100644
index 000000000..8c90ea600
--- /dev/null
+++ b/debian/rules.d/scripts/mod/elfconfig.h
@@ -0,0 +1,7 @@
+#include <endian.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define HOST_ELFDATA ELFDATA2LSB
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#define HOST_ELFDATA ELFDATA2MSB
+#endif
diff --git a/debian/rules.d/scripts/mod/gendef.py b/debian/rules.d/scripts/mod/gendef.py
new file mode 100755
index 000000000..55d3fc60e
--- /dev/null
+++ b/debian/rules.d/scripts/mod/gendef.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python3
+import re
+import sys
+
+for line in open(sys.argv[1]):
+ match = re.search(r'getopt\(argc, argv, "([\w:]*?)"\)', line)
+ if match:
+ options = match.group(1)
+ break
+else:
+ raise RuntimeError
+
+print('#define GETOPT_OPTIONS "%s"' % options)
+
+print('#define GETOPT_CASE', end=' ')
+for c in options:
+ if c == ':' or c == 'T':
+ continue
+ print("case '%c':" % c, end=' ')
+print()
diff --git a/debian/rules.d/scripts/mod/modpost.c b/debian/rules.d/scripts/mod/modpost.c
new file mode 100644
index 000000000..d574957ae
--- /dev/null
+++ b/debian/rules.d/scripts/mod/modpost.c
@@ -0,0 +1,136 @@
+#include <elf.h>
+#include <errno.h>
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "modpost-opts.h"
+
+int main (int argc, char *argv[])
+{
+ char const *data, *class;
+ char *list_name = NULL;
+ char *name = NULL;
+ char prog[1024];
+ unsigned char ei[EI_NIDENT];
+ int opt;
+ FILE *file;
+
+ while ((opt = getopt (argc, argv, GETOPT_OPTIONS)) != -1)
+ {
+ switch(opt)
+ {
+ GETOPT_CASE
+ break;
+ case 'T':
+ list_name = optarg;
+ break;
+ default:
+ return EXIT_FAILURE;
+ }
+ }
+
+ if (optind != argc)
+ {
+ name = argv[optind];
+ }
+ else if (list_name)
+ {
+ size_t name_len;
+ int is_stdin = strcmp (list_name, "-") == 0;
+
+ /* Read first line of list file */
+ if (is_stdin)
+ {
+ file = stdin;
+ setvbuf(stdin, NULL, _IONBF, 0); /* don't over-read */
+ }
+ else
+ {
+ file = fopen (list_name, "r");
+ if (!file)
+ {
+ fprintf (stderr, "Can't open \"%s\"\n", list_name);
+ return EXIT_FAILURE;
+ }
+ }
+ if (getline (&name, &name_len, file) < 0)
+ {
+ if (errno)
+ {
+ fprintf (stderr, "Can't read \"%s\"\n", list_name);
+ return EXIT_FAILURE;
+ }
+ else
+ {
+ /* Empty list */
+ return EXIT_SUCCESS;
+ }
+ }
+ if (!is_stdin)
+ fclose(file);
+
+ /* Remove new-line */
+ name [strcspn (name, "\n")] = 0;
+
+ /* If this came from stdin, we need to add the first name to the
+ * arguments, because the upstream modpost can't read it again.
+ */
+ if (is_stdin)
+ {
+ char **new_argv = malloc (sizeof(*argv) * (argc + 2));
+ memcpy(new_argv, argv, sizeof(*argv) * argc);
+ new_argv [argc] = name;
+ new_argv [argc + 1] = NULL;
+ argv = new_argv;
+ }
+ }
+ else
+ {
+ /* Empty list */
+ return EXIT_SUCCESS;
+ }
+
+ if (!(file = fopen (name, "r")))
+ {
+ fprintf (stderr, "Can't open \"%s\"\n", name);
+ return EXIT_FAILURE;
+ }
+
+ if (fread (ei, 1, EI_NIDENT, file) != EI_NIDENT)
+ {
+ fprintf (stderr, "Error: input truncated\n");
+ return EXIT_FAILURE;
+ }
+
+ if (memcmp (ei, ELFMAG, SELFMAG) != 0)
+ {
+ fprintf (stderr, "Error: not ELF\n");
+ return EXIT_FAILURE;
+ }
+ switch (ei[EI_DATA]) {
+ case ELFDATA2LSB:
+ data = "lsb";
+ break;
+ case ELFDATA2MSB:
+ data = "msb";
+ break;
+ default:
+ return EXIT_FAILURE;
+ }
+ switch (ei[EI_CLASS]) {
+ case ELFCLASS32:
+ class = "32";
+ break;
+ case ELFCLASS64:
+ class = "64";
+ break;
+ default:
+ return EXIT_FAILURE;
+ }
+ snprintf (prog, sizeof prog, "%s.real-%s-%s", argv[0], data, class);
+
+ return execv (prog, argv);
+}
diff --git a/debian/rules.d/scripts/mod/real-lsb-32/elfconfig.h b/debian/rules.d/scripts/mod/real-lsb-32/elfconfig.h
new file mode 100644
index 000000000..1f7a7321a
--- /dev/null
+++ b/debian/rules.d/scripts/mod/real-lsb-32/elfconfig.h
@@ -0,0 +1,4 @@
+#define KERNEL_ELFCLASS ELFCLASS32
+#define KERNEL_ELFDATA ELFDATA2LSB
+#define MODULE_SYMBOL_PREFIX ""
+#include "../elfconfig.h"
diff --git a/debian/rules.d/scripts/mod/real-lsb-32/types.h b/debian/rules.d/scripts/mod/real-lsb-32/types.h
new file mode 100644
index 000000000..bad6dcccd
--- /dev/null
+++ b/debian/rules.d/scripts/mod/real-lsb-32/types.h
@@ -0,0 +1,3 @@
+#include "../types.h"
+typedef __u32 kernel_ulong_t;
+#define BITS_PER_LONG 32
diff --git a/debian/rules.d/scripts/mod/real-lsb-64/elfconfig.h b/debian/rules.d/scripts/mod/real-lsb-64/elfconfig.h
new file mode 100644
index 000000000..e6f519fcc
--- /dev/null
+++ b/debian/rules.d/scripts/mod/real-lsb-64/elfconfig.h
@@ -0,0 +1,4 @@
+#define KERNEL_ELFCLASS ELFCLASS64
+#define KERNEL_ELFDATA ELFDATA2LSB
+#define MODULE_SYMBOL_PREFIX ""
+#include "../elfconfig.h"
diff --git a/debian/rules.d/scripts/mod/real-lsb-64/types.h b/debian/rules.d/scripts/mod/real-lsb-64/types.h
new file mode 100644
index 000000000..8d7b87591
--- /dev/null
+++ b/debian/rules.d/scripts/mod/real-lsb-64/types.h
@@ -0,0 +1,3 @@
+#include "../types.h"
+typedef __u64 __attribute__((aligned(8))) kernel_ulong_t;
+#define BITS_PER_LONG 64
diff --git a/debian/rules.d/scripts/mod/real-msb-32/elfconfig.h b/debian/rules.d/scripts/mod/real-msb-32/elfconfig.h
new file mode 100644
index 000000000..a9ae561ab
--- /dev/null
+++ b/debian/rules.d/scripts/mod/real-msb-32/elfconfig.h
@@ -0,0 +1,4 @@
+#define KERNEL_ELFCLASS ELFCLASS32
+#define KERNEL_ELFDATA ELFDATA2MSB
+#define MODULE_SYMBOL_PREFIX ""
+#include "../elfconfig.h"
diff --git a/debian/rules.d/scripts/mod/real-msb-32/types.h b/debian/rules.d/scripts/mod/real-msb-32/types.h
new file mode 100644
index 000000000..bad6dcccd
--- /dev/null
+++ b/debian/rules.d/scripts/mod/real-msb-32/types.h
@@ -0,0 +1,3 @@
+#include "../types.h"
+typedef __u32 kernel_ulong_t;
+#define BITS_PER_LONG 32
diff --git a/debian/rules.d/scripts/mod/real-msb-64/elfconfig.h b/debian/rules.d/scripts/mod/real-msb-64/elfconfig.h
new file mode 100644
index 000000000..844d22f5c
--- /dev/null
+++ b/debian/rules.d/scripts/mod/real-msb-64/elfconfig.h
@@ -0,0 +1,4 @@
+#define KERNEL_ELFCLASS ELFCLASS64
+#define KERNEL_ELFDATA ELFDATA2MSB
+#define MODULE_SYMBOL_PREFIX ""
+#include "../elfconfig.h"
diff --git a/debian/rules.d/scripts/mod/real-msb-64/types.h b/debian/rules.d/scripts/mod/real-msb-64/types.h
new file mode 100644
index 000000000..8d7b87591
--- /dev/null
+++ b/debian/rules.d/scripts/mod/real-msb-64/types.h
@@ -0,0 +1,3 @@
+#include "../types.h"
+typedef __u64 __attribute__((aligned(8))) kernel_ulong_t;
+#define BITS_PER_LONG 64
diff --git a/debian/rules.d/scripts/mod/types.h b/debian/rules.d/scripts/mod/types.h
new file mode 100644
index 000000000..bba382183
--- /dev/null
+++ b/debian/rules.d/scripts/mod/types.h
@@ -0,0 +1,12 @@
+/* Minimal definitions for mod_devicetable.h and devicetable-offsets.c */
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+typedef unsigned int __u32;
+typedef unsigned long long __u64;
+typedef struct {
+ __u8 b[16];
+} guid_t;
+typedef guid_t uuid_le;
+typedef unsigned char uuid_t[16];
+#define UUID_STRING_LEN 36
+#define offsetof(a,b) __builtin_offsetof(a,b)