aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile62
1 files changed, 62 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9dccbd2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,62 @@
+include Makefile.config
+
+MARIADB_SRC = mariadb-connector-c-v_2.3.7/
+LIBMARIADB = $(MARIADB_SRC)/build/libmariadb/libmariadbclient.a
+
+XML2_SRC = libxml2-2.9.10/
+LIBXML2 = $(XML2_SRC)/.libs/libxml2.a
+
+CC = $(TARGET)-gcc
+OBJECTS = string_buf.o restore.o hashtable.o
+
+all : __executable
+
+$(OBJECTS) : Makefile.config Makefile
+
+ifeq ($(TARGET),x86_64-linux-gnu)
+SUFFIX =
+STATIC_LIBS =
+LINKFLAGS = -shared -lxml2 -lmariadbclient
+CFLAGS = -fPIC -I /usr/include/libxml2/
+else
+SUFFIX = .exe
+STATIC_LIBS = $(LIBMARIADB) $(LIBXML2)
+LINKFLAGS = -static -L $(dir $(LIBMARIADB)) -L $(dir $(LIBXML2)) \
+ -lxml2 -lmariadbclient -lkernel32 -lws2_32
+CFLAGS = -I $(XML2_SRC)/include/ -I $(MARIADB_SRC)/include/
+
+$(OBJECTS) : $(LIBMARIADB) $(LIBXML2)
+endif
+
+EXECUTABLE = restore$(SUFFIX)
+
+__executable : $(EXECUTABLE)
+$(EXECUTABLE) : $(OBJECTS)
+ $(TARGET)-gcc $^ $(LINKFLAGS) -o $@
+
+$(LIBXML2) : Makefile.config
+ -cd $(XML2_SRC) && make distclean 2> /dev/null
+ cd $(XML2_SRC) && ./configure \
+ --host=$(TARGET) \
+ --without-iconv \
+ --with-zlib \
+ --without-python \
+ --without-http \
+ --without-ftp \
+ --without-lzma
+ cd $(XML2_SRC) && make -j$$((`nproc` + 1))
+
+$(LIBMARIADB) : Makefile.config
+ rm -rf $(MARIADB_SRC)/build/
+ cd $(MARIADB_SRC) && cmake -B build/ \
+ -D CMAKE_TOOLCHAIN_FILE=./mingw_cross_toolchain.cmake \
+ -D WITH_EXTERNAL_ZLIB=ON \
+ -D GNU_HOST=$(TARGET)
+ cd $(MARIADB_SRC)build/ && make -j$$((`nproc` + 1)) mariadbclient
+
+clean :
+ -cd $(XML2_SRC) && make distclean 2> /dev/null
+ rm -rf $(MARIADB_SRC)/build/
+ rm -rf *.o restore restore.exe
+
+.PHONY : clean all __executable