From 35a201cc8ef0c3f5b2df88d2e528aabee1048348 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Fri, 30 Apr 2021 18:47:09 +0200 Subject: Initial/Final commit --- Makefile | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Makefile (limited to 'Makefile') 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 -- cgit v1.2.3