1fa020dd7SArnaldo Carvalho de Melo#!/bin/sh 2fa020dd7SArnaldo Carvalho de Melo# SPDX-License-Identifier: LGPL-2.1 3fa020dd7SArnaldo Carvalho de Melo 4fa020dd7SArnaldo Carvalho de Melo# This one uses a copy from the kernel sources headers that is in a 5fa020dd7SArnaldo Carvalho de Melo# place used just for these tools/perf/beauty/ usage, we shouldn't not 6fa020dd7SArnaldo Carvalho de Melo# put it in tools/include/linux otherwise they would be used in the 7fa020dd7SArnaldo Carvalho de Melo# normal compiler building process and would drag needless stuff from the 8fa020dd7SArnaldo Carvalho de Melo# kernel. 9fa020dd7SArnaldo Carvalho de Melo 10fa020dd7SArnaldo Carvalho de Melo# When what these scripts need is already in tools/include/ then use it, 11fa020dd7SArnaldo Carvalho de Melo# otherwise grab and check the copy from the kernel sources just for these 12fa020dd7SArnaldo Carvalho de Melo# string table building scripts. 13fa020dd7SArnaldo Carvalho de Melo 14fa020dd7SArnaldo Carvalho de Melo[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/perf/trace/beauty/include/linux/ 15fa020dd7SArnaldo Carvalho de Melo 16fa020dd7SArnaldo Carvalho de Meloprintf "static const char *socket_families[] = {\n" 17fa020dd7SArnaldo Carvalho de Melo# #define AF_LOCAL 1 /* POSIX name for AF_UNIX */ 18fa020dd7SArnaldo Carvalho de Meloregex='^#define[[:space:]]+AF_(\w+)[[:space:]]+([[:digit:]]+).*' 19fa020dd7SArnaldo Carvalho de Melo 20*818448e9STiezhu Yanggrep -E $regex ${header_dir}/socket.h | \ 21fa020dd7SArnaldo Carvalho de Melo sed -r "s/$regex/\2 \1/g" | \ 22fa020dd7SArnaldo Carvalho de Melo xargs printf "\t[%s] = \"%s\",\n" | \ 23*818448e9STiezhu Yang grep -E -v "\"(UNIX|MAX)\"" 24fa020dd7SArnaldo Carvalho de Meloprintf "};\n" 25