--- /dev/null
+#!/bin/sh
+
+ARRAY_NAME=ul_log_domains_array
+
+DIRS=""
+
+while [ $# -gt 0 ] ; do
+ case "x${1}x" in
+ "x--helpx" | "x-hx" )
+ echo -e Usage: `basename ${0}`" [options] <srcdir> .."
+ echo -e " -h --help help"
+ echo -e " -a --array identifier of log domain array variable"
+ exit 0
+ ;;
+ "x--arrayx" | "x-ax" )
+ shift 1
+ ARRAY_NAME="${1}"
+ ;;
+ "x--"* )
+ echo "Unknown option"
+ exit 2
+ ;;
+ * )
+ DIRS="$DIRS ${1}"
+ ;;
+ esac
+ shift 1
+done
+
+DOMAINS=$( for d in $DIRS ; do find -L $d '(' -name '*.c' -o -name '*.cc' ')' -exec grep UL_LOG_CUST '{}' ';' | \
+ sed -n -e 's/^.*UL_LOG_CUST(\([^)]*\)).*$/\1/p' ; done | sort -u )
+
+#echo $DOMAINS
+
+#echo -e "#define UL_LOGL_DEF UL_LOGL_DEB\n"
+
+echo "/*"
+echo " * This is generated file, do not edit it directly."
+echo " * Take it from standard output of \"ul_log_domains\""
+echo " * script called in the top level project directory"
+echo " */"
+
+for i in $DOMAINS ; do
+ echo "ul_log_domain_t $i = {UL_LOGL_DEF, \"$(echo -n $i | sed -n -e 's/ulogd_\(.*\)/\1/pg' )\"};"
+done
+
+echo
+echo "ul_log_domain_t *$ARRAY_NAME[] = {"
+
+for i in $DOMAINS ; do
+ echo " &$i,"
+done
+
+echo "};"