• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2set -ueo pipefail
3
4# Linux's ioctl codes using function-style macros in their definition which
5# bindgen is unable to evaluate. To extract the ioctl code values, we have
6# a small C program, main.c, which prints the values of the ioctls on the
7# platform it's compiled for. This script compiles it for several platforms
8# and generates an ioctl.h header file, which bindgen can fully process,
9# producing an ioctl module in the Rust bindings.
10#
11# This is a very simplistic and not yet portable script; if you need it run,
12# to add new ioctl codes or a new architecture, and are unable to run it,
13# please file an issue in the issue tracker.
14
15cflags="-Wall"
16out="../modules/ioctl.h"
17
18echo "// This file is generated from the ioctl/generate.sh script." > "$out"
19
20i686-linux-gnu-gcc -Iinclude -c list.c $cflags
21i686-linux-gnu-gcc main.c list.o -o main.exe $cflags
22./main.exe >> "$out"
23x86_64-linux-gnu-gcc -Iinclude -c list.c $cflags
24x86_64-linux-gnu-gcc main.c list.o -o main.exe $cflags
25./main.exe >> "$out"
26aarch64-linux-gnu-gcc -Iinclude -c list.c $cflags
27aarch64-linux-gnu-gcc main.c list.o -o main.exe $cflags
28qemu-aarch64 -L /usr/aarch64-linux-gnu ./main.exe >> "$out"
29arm-linux-gnueabihf-gcc -Iinclude -c list.c $cflags
30arm-linux-gnueabihf-gcc main.c list.o -o main.exe $cflags
31qemu-arm -L /usr/arm-linux-gnueabihf ./main.exe >> "$out"
32powerpc64le-linux-gnu-gcc -Iinclude -c list.c $cflags
33powerpc64le-linux-gnu-gcc main.c list.o -o main.exe $cflags
34qemu-ppc64le -L /usr/powerpc64le-linux-gnu ./main.exe >> "$out"
35mips64el-linux-gnuabi64-gcc -Iinclude -c list.c $cflags
36mips64el-linux-gnuabi64-gcc main.c list.o -o main.exe $cflags
37qemu-mips64el -L /usr/mips64el-linux-gnuabi64 ./main.exe >> "$out"
38mipsel-linux-gnu-gcc -Iinclude -c list.c $cflags
39mipsel-linux-gnu-gcc main.c list.o -o main.exe $cflags
40qemu-mipsel -L /usr/mipsel-linux-gnu ./main.exe >> "$out"
41riscv64-linux-gnu-gcc -Iinclude -c list.c $cflags
42riscv64-linux-gnu-gcc main.c list.o -o main.exe $cflags
43qemu-riscv64 -L /usr/riscv64-linux-gnu ./main.exe >> "$out"
44
45rm list.o main.exe
46