aboutsummaryrefslogtreecommitdiffstats
path: root/move-asn1-header-files.sh
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2016-01-04 15:23:09 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2016-01-04 18:09:37 +0100
commit5aabad1380bee7b1454aae8bca7db735fd41a2f3 (patch)
treeefebc95c00b24a97ba16566d87591c8e46e8d696 /move-asn1-header-files.sh
parent216ac210bfb0e540545ae22faa3da7ee44ccdd28 (diff)
move asn1 headers to include/ dir (1/5)
Add move-asn1-header-files.sh to do header file moving and sed'ding the include statements. The file moving part is disabled until a later commit, to make reading the diffs easier. Call shell script from src/{hnbap,ranap,rua}/Makefile.am regen targets. Add convenience regen target to src/Makefile.am, calling regen in the three subdirs. This change is split over several commits to ease diff reading. Subsequent commits show, in steps: - the "unmoved" effect of sed, - header moves, - adjust build system and include statements.
Diffstat (limited to 'move-asn1-header-files.sh')
-rwxr-xr-xmove-asn1-header-files.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/move-asn1-header-files.sh b/move-asn1-header-files.sh
new file mode 100755
index 0000000..5355230
--- /dev/null
+++ b/move-asn1-header-files.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Usage:
+# ../../move-asn1-headers.sh osmocom/foo/bar File1.h File2.h ...
+
+set -e
+
+base_dir="$(dirname "$0")"
+
+include_subdir="$1"
+shift
+
+include_dir="$base_dir/include/$include_subdir"
+mkdir -p "$include_dir"
+echo "$PWD/*.h --> $include_dir"
+
+sed_includes() {
+ while [ -n "$1" ]; do
+ fname="$1"
+ shift
+
+ echo 'sed -i "s,^#include \"'$fname'\"$,#include <'$include_subdir/$fname'>," *.[hc]'
+ sed -i "s,^#include \"$fname\"$,#include <$include_subdir/$fname>," *.[hc]
+ done
+}
+
+move_headers() {
+ echo mv $@ "$include_dir/"
+ mv $@ "$include_dir/"
+}
+
+# first replace all `#include "foo.h"' with `#include <dir/foo.h>' locally
+sed_includes $@
+
+# move sed'ed *.h files to the proper include/dir
+#move_headers $@ TEMPORARILY DISABLED to simplify the diff