add osmo-hlr-db-tool, program to migrate from osmo-nitb db

Move macro copy_sqlite3_text_to_buf() to db.h, so it can be used in
hlr_db_tool.c.

Add _dbd_decode_binary() from libdbi to avoid depending on the entire libdbi
just for KI BLOB decoding. Add it in a separate file, copying its own license,
the lGPL.

Offer commandline option "import-nitb-db" to read in an old osmo-nitb database
and copy subscriber IMSIs and 2G auth data to OsmoHLR db format.

Anticipate future command line options like "import-csv", so keep the code
generalized.

Change-Id: I0dfa6ec033dd93161c1adc2ce1637195fe5b7a63
diff --git a/src/Makefile.am b/src/Makefile.am
index 3b09b7b..9fbb062 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,6 +35,7 @@
 
 bin_PROGRAMS = \
 	osmo-hlr \
+	osmo-hlr-db-tool \
 	$(NULL)
 
 noinst_PROGRAMS = \
@@ -66,6 +67,21 @@
 	$(SQLITE3_LIBS) \
 	$(NULL)
 
+osmo_hlr_db_tool_SOURCES = \
+	hlr_db_tool.c \
+	db.c \
+	db_hlr.c \
+	logging.c \
+	rand_urandom.c \
+	dbd_decode_binary.c \
+	$(NULL)
+
+osmo_hlr_db_tool_LDADD = \
+	$(LIBOSMOCORE_LIBS) \
+	$(LIBOSMOGSM_LIBS) \
+	$(SQLITE3_LIBS) \
+	$(NULL)
+
 db_test_SOURCES = \
 	auc.c \
 	db.c \