summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/af-to-name.awk5
-rw-r--r--src/basic/arphrd-to-name.awk5
-rw-r--r--src/basic/cap-to-name.awk5
-rw-r--r--src/basic/errno-to-name.awk4
-rw-r--r--src/basic/generate-af-list.sh5
-rw-r--r--src/basic/generate-arphrd-list.sh5
-rw-r--r--src/basic/generate-cap-list.sh5
-rw-r--r--src/basic/generate-errno-list.sh4
-rw-r--r--src/basic/generate-gperfs.py16
-rw-r--r--src/basic/meson.build283
10 files changed, 337 insertions, 0 deletions
diff --git a/src/basic/af-to-name.awk b/src/basic/af-to-name.awk
new file mode 100644
index 0000000000..e20830487f
--- /dev/null
+++ b/src/basic/af-to-name.awk
@@ -0,0 +1,5 @@
+BEGIN{ print "static const char* const af_names[] = { "}
+!/AF_FILE/ && !/AF_ROUTE/ && !/AF_LOCAL/ {
+ printf " [%s] = \"%s\",\n", $1, $1
+}
+END{print "};"}
diff --git a/src/basic/arphrd-to-name.awk b/src/basic/arphrd-to-name.awk
new file mode 100644
index 0000000000..57e4680f17
--- /dev/null
+++ b/src/basic/arphrd-to-name.awk
@@ -0,0 +1,5 @@
+BEGIN{ print "static const char* const arphrd_names[] = { "}
+!/CISCO/ {
+ printf " [ARPHRD_%s] = \"%s\",\n", $1, $1
+}
+END{print "};"}
diff --git a/src/basic/cap-to-name.awk b/src/basic/cap-to-name.awk
new file mode 100644
index 0000000000..d252291851
--- /dev/null
+++ b/src/basic/cap-to-name.awk
@@ -0,0 +1,5 @@
+BEGIN{ print "static const char* const capability_names[] = { "}
+{
+ printf " [%s] = \"%s\",\n", $1, tolower($1)
+}
+END{print "};"}
diff --git a/src/basic/errno-to-name.awk b/src/basic/errno-to-name.awk
new file mode 100644
index 0000000000..c48c8f93ab
--- /dev/null
+++ b/src/basic/errno-to-name.awk
@@ -0,0 +1,4 @@
+BEGIN{ print "static const char* const errno_names[] = { " }
+!/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ {
+ printf " [%s] = \"%s\",\n", $1, $1 }
+END{ print "};" }
diff --git a/src/basic/generate-af-list.sh b/src/basic/generate-af-list.sh
new file mode 100644
index 0000000000..e4f9f68312
--- /dev/null
+++ b/src/basic/generate-af-list.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+cpp -dM -include sys/socket.h - </dev/null | \
+ grep -Ev 'AF_UNSPEC|AF_MAX' | \
+ awk '/^#define[ \t]+AF_[^ \t]+[ \t]+PF_[^ \t]/ { print $2; }'
diff --git a/src/basic/generate-arphrd-list.sh b/src/basic/generate-arphrd-list.sh
new file mode 100644
index 0000000000..e4cd8ab6d2
--- /dev/null
+++ b/src/basic/generate-arphrd-list.sh
@@ -0,0 +1,5 @@
+#!/bin/sh -e
+
+cpp -dM -include net/if_arp.h - </dev/null | \
+ awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
+ sed -e 's/ARPHRD_//'
diff --git a/src/basic/generate-cap-list.sh b/src/basic/generate-cap-list.sh
new file mode 100644
index 0000000000..de4b44661e
--- /dev/null
+++ b/src/basic/generate-cap-list.sh
@@ -0,0 +1,5 @@
+#!/bin/sh -e
+
+cpp -dM -include linux/capability.h -include "$1" -include "$2" - </dev/null | \
+ awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \
+ grep -v CAP_LAST_CAP
diff --git a/src/basic/generate-errno-list.sh b/src/basic/generate-errno-list.sh
new file mode 100644
index 0000000000..291b118f36
--- /dev/null
+++ b/src/basic/generate-errno-list.sh
@@ -0,0 +1,4 @@
+#!/bin/sh -e
+
+cpp -dM -include errno.h - </dev/null | \
+ awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'
diff --git a/src/basic/generate-gperfs.py b/src/basic/generate-gperfs.py
new file mode 100644
index 0000000000..2e7d8931dd
--- /dev/null
+++ b/src/basic/generate-gperfs.py
@@ -0,0 +1,16 @@
+#!/usr/bin/python3
+
+"""Generate %-from-name.gperf from %-list.txt
+"""
+
+import sys
+
+name, prefix, input = sys.argv[1:]
+
+print("""\
+struct {}_name {{ const char* name; int id; }};
+%null-strings
+%%""".format(name))
+
+for line in open(input):
+ print("{0}, {1}{0}".format(line.rstrip(), prefix))
diff --git a/src/basic/meson.build b/src/basic/meson.build
new file mode 100644
index 0000000000..23caa1c7a5
--- /dev/null
+++ b/src/basic/meson.build
@@ -0,0 +1,283 @@
+# -*- mode: meson -*-
+
+basic_sources_plain = files('''
+ af-list.c
+ af-list.h
+ alloc-util.c
+ alloc-util.h
+ architecture.c
+ architecture.h
+ arphrd-list.c
+ arphrd-list.h
+ async.c
+ async.h
+ audit-util.c
+ audit-util.h
+ barrier.c
+ barrier.h
+ bitmap.c
+ bitmap.h
+ blkid-util.h
+ btrfs-ctree.h
+ btrfs-util.c
+ btrfs-util.h
+ build.h
+ bus-label.c
+ bus-label.h
+ calendarspec.c
+ calendarspec.h
+ capability-util.c
+ capability-util.h
+ cap-list.c
+ cap-list.h
+ cgroup-util.c
+ cgroup-util.h
+ chattr-util.c
+ chattr-util.h
+ clock-util.c
+ clock-util.h
+ conf-files.c
+ conf-files.h
+ copy.c
+ copy.h
+ cpu-set-util.c
+ cpu-set-util.h
+ def.h
+ device-nodes.c
+ device-nodes.h
+ dirent-util.c
+ dirent-util.h
+ env-util.c
+ env-util.h
+ errno-list.c
+ errno-list.h
+ escape.c
+ escape.h
+ ether-addr-util.c
+ ether-addr-util.h
+ exec-util.c
+ exec-util.h
+ exit-status.c
+ exit-status.h
+ extract-word.c
+ extract-word.h
+ fd-util.c
+ fd-util.h
+ fileio.c
+ fileio.h
+ fileio-label.c
+ fileio-label.h
+ format-util.h
+ fs-util.c
+ fs-util.h
+ glob-util.c
+ glob-util.h
+ gunicode.c
+ gunicode.h
+ hash-funcs.c
+ hash-funcs.h
+ hashmap.c
+ hashmap.h
+ hexdecoct.c
+ hexdecoct.h
+ hostname-util.c
+ hostname-util.h
+ in-addr-util.c
+ in-addr-util.h
+ ioprio.h
+ io-util.c
+ io-util.h
+ journal-importer.c
+ journal-importer.h
+ khash.c
+ khash.h
+ label.c
+ label.h
+ list.h
+ locale-util.c
+ locale-util.h
+ lockfile-util.c
+ lockfile-util.h
+ log.c
+ log.h
+ login-util.c
+ login-util.h
+ macro.h
+ memfd-util.c
+ memfd-util.h
+ mempool.c
+ mempool.h
+ missing_syscall.h
+ mkdir.c
+ mkdir.h
+ mkdir-label.c
+ mount-util.c
+ mount-util.h
+ MurmurHash2.c
+ MurmurHash2.h
+ nss-util.h
+ ordered-set.c
+ ordered-set.h
+ parse-util.c
+ parse-util.h
+ path-util.c
+ path-util.h
+ prioq.c
+ prioq.h
+ proc-cmdline.c
+ proc-cmdline.h
+ process-util.c
+ process-util.h
+ random-util.c
+ random-util.h
+ ratelimit.c
+ ratelimit.h
+ raw-clone.h
+ refcnt.h
+ replace-var.c
+ replace-var.h
+ rlimit-util.c
+ rlimit-util.h
+ rm-rf.c
+ rm-rf.h
+ securebits.h
+ selinux-util.c
+ selinux-util.h
+ set.h
+ sigbus.c
+ sigbus.h
+ signal-util.c
+ signal-util.h
+ siphash24.c
+ siphash24.h
+ smack-util.c
+ smack-util.h
+ socket-label.c
+ socket-util.c
+ socket-util.h
+ sparse-endian.h
+ special.h
+ stat-util.c
+ stat-util.h
+ stdio-util.h
+ strbuf.c
+ strbuf.h
+ string-table.c
+ string-table.h
+ string-util.c
+ string-util.h
+ strv.c
+ strv.h
+ strxcpyx.c
+ strxcpyx.h
+ syslog-util.c
+ syslog-util.h
+ terminal-util.c
+ terminal-util.h
+ time-util.c
+ time-util.h
+ umask-util.h
+ unaligned.h
+ unit-name.c
+ unit-name.h
+ user-util.c
+ user-util.h
+ utf8.c
+ utf8.h
+ util.c
+ util.h
+ verbs.c
+ verbs.h
+ virt.c
+ virt.h
+ web-util.c
+ web-util.h
+ xattr-util.c
+ xattr-util.h
+ xml.c
+ xml.h
+'''.split())
+
+missing_h = files('missing.h')
+
+generate_gperfs = find_program('generate-gperfs.py')
+
+generate_af_list = find_program('generate-af-list.sh')
+af_list_txt = custom_target(
+ 'af-list.txt',
+ output : 'af-list.txt',
+ command : [generate_af_list],
+ capture : true)
+
+generate_arphrd_list = find_program('generate-arphrd-list.sh')
+arphrd_list_txt = custom_target(
+ 'arphrd-list.txt',
+ output : 'arphrd-list.txt',
+ command : [generate_arphrd_list],
+ capture : true)
+
+generate_cap_list = find_program('generate-cap-list.sh')
+cap_list_txt = custom_target(
+ 'cap-list.txt',
+ output : 'cap-list.txt',
+ command : [generate_cap_list, config_h, missing_h],
+ capture : true)
+
+generate_errno_list = find_program('generate-errno-list.sh')
+errno_list_txt = custom_target(
+ 'errno-list.txt',
+ output : 'errno-list.txt',
+ command : [generate_errno_list],
+ capture : true)
+
+generated_gperf_headers = []
+foreach item : [['af', af_list_txt, 'af', ''],
+ ['arphrd', arphrd_list_txt, 'arphrd', 'ARPHRD_'],
+ ['cap', cap_list_txt, 'capability', ''],
+ ['errno', errno_list_txt, 'errno', '']]
+
+ fname = '@0@-from-name.gperf'.format(item[0])
+ gperf_file = custom_target(
+ fname,
+ input : item[1],
+ output : fname,
+ command : [generate_gperfs, item[2], item[3], '@INPUT@'],
+ capture : true)
+
+ fname = '@0@-from-name.h'.format(item[0])
+ target1 = custom_target(
+ fname,
+ input : gperf_file,
+ output : fname,
+ command : [gperf,
+ '-L', 'ANSI-C', '-t', '--ignore-case',
+ '-N', 'lookup_@0@'.format(item[2]),
+ '-H', 'hash_@0@_name'.format(item[2]),
+ '-p', '-C',
+ '@INPUT@'],
+ capture : true)
+
+ fname = '@0@-to-name.h'.format(item[0])
+ awkscript = '@0@-to-name.awk'.format(item[0])
+ target2 = custom_target(
+ fname,
+ input : [awkscript, item[1]],
+ output : fname,
+ command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
+ capture : true)
+
+ generated_gperf_headers += [target1, target2]
+endforeach
+
+basic_sources = basic_sources_plain + [missing_h] + generated_gperf_headers
+
+libbasic = static_library(
+ 'basic',
+ basic_sources,
+ include_directories : includes,
+ dependencies : [threads,
+ libcap,
+ libblkid,
+ libselinux,
+ ],
+ install : false)