From 1f0da0d2b0acb2aa04f75afb73b9d2bbb86a9949 Mon Sep 17 00:00:00 2001 From: Welp Wazowski Date: Mon, 8 Oct 2018 21:59:56 -0700 Subject: [PATCH] reworked the compilation process a bit, made cli work on Windows --- .gitignore | 4 ---- Makefile | 46 ++++++++++++++++++++++++------------ README.md | 18 ++++++++------ build/native/bin/.gitignore | 2 ++ build/native/obj/.gitignore | 2 ++ build/windows/bin/.gitignore | 2 ++ build/windows/obj/.gitignore | 2 ++ 7 files changed, 50 insertions(+), 26 deletions(-) create mode 100644 build/native/bin/.gitignore create mode 100644 build/native/obj/.gitignore create mode 100644 build/windows/bin/.gitignore create mode 100644 build/windows/obj/.gitignore diff --git a/.gitignore b/.gitignore index f111672..244ac0a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1 @@ -*.o -greeny-cli -greeny -test-greeny *kdev4* diff --git a/Makefile b/Makefile index 688e9af..926e694 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,44 @@ +ifneq ($(findstring mingw,$(CC)),) + windows := true + bin_dir := build/windows/bin + obj_dir := build/windows/obj +else + bin_dir := build/native/bin + obj_dir := build/native/obj +endif + CFLAGS := $(CFLAGS) -Icontrib -Wall --std=c99 -headers_common := contrib/bencode.h src/libannouncebulk.h src/err.h src/vector.h -sources_common := contrib/bencode.o src/libannouncebulk.o src/vector.o - -headers_cli := $(headers_common) -sources_cli := $(sources_common) src/cli.o -binary_cli := ./greeny-cli -LIBS_cli := - -headers_test := $(headers_common) -sources_test := $(sources_common) tests/test.o -binary_test := ./test-greeny LIBS_test := -lcmocka +ifdef windows + binary_suffix := .exe + + LIBS_cli := -l:libgnurx.dll.a +else + LIBS_cli := +endif + +objs_common := $(obj_dir)/bencode.o $(obj_dir)/libannouncebulk.o $(obj_dir)/vector.o + +objs_cli := $(objs_common) $(obj_dir)/cli.o +binary_cli := $(bin_dir)/greeny-cli$(binary_suffix) + +objs_test := $(objs_common) $(obj_dir)/test.o +binary_test := $(bin_dir)/test-greeny$(binary_suffix) all: $(binary_cli) test: $(binary_test) $(binary_test) -$(binary_cli) : $(sources_cli) $(headers_cli) - $(CC) -o $(binary_cli) $(LIBS_cli) $(sources_cli) +$(binary_cli) : $(objs_cli) + $(CC) -o $(binary_cli) $(objs_cli) $(LIBS_cli) -$(binary_test) : $(sources_test) $(headers_test) - $(CC) -o $(binary_test) $(LIBS_test) $(sources_test) +$(binary_test) : $(objs_test) + $(CC) -o $(binary_test) $(objs_test) $(LIBS_test) + +$(obj_dir)/%.o : */%.c + $(CC) $(CFLAGS) -c -o $@ $< clean: rm -f */*.o $(binary_cli) $(binary_test) diff --git a/README.md b/README.md index 305ba2d..7b42477 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ Greeny is the Graphical, Really Easy Editor for torreNts, Yup! -## Dependencies +## Linux & Mac Dependencies -* C compiler -* MinGW (if you want to build for Windows) -* GTK Development libraries (if you want to build for Linux or Mac) +* GCC (clang will probably work too, but praise Stallman!) +* Make +* GTK+ with development headers + +## Windows Cross-Compilation Dependencies + +* MinGW Cross-compiler +* MinGW Make +* MinGW libgnurx with development headers (this is because MinGW does not ship with the POSIX regular expression libraries). ## Compiling -Run `make` to build for your own system, assuming you're on Linux or Mac (Autotools? You almost fooled me). To build for Windows, install the mingw cross compiler (or, ya know, just install it normally on Windows) and run the mingw make tool (often `mingw64-make` for the cross-compiler). Be sure to `make clean` between runs, otherwise you might end up trying to link Linux objects into a Windows executable! - -On all platforms, dependencies are compiled statically, and no packaging or installers are needed. +`make` will build for your native Linux or Mac. Use the mingw cross compiler's built-in make tool (often `mingw64-make`) to build for Windows. Build artifacts and binaries will be put in a separate folder (build/windows), so you can switch between make and mingw64-make as often as you'd like. Binaries will be put in build/native/bin for Linux/Mac, and build/windows/bin for Windows. diff --git a/build/native/bin/.gitignore b/build/native/bin/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/build/native/bin/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/build/native/obj/.gitignore b/build/native/obj/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/build/native/obj/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/build/windows/bin/.gitignore b/build/windows/bin/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/build/windows/bin/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/build/windows/obj/.gitignore b/build/windows/obj/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/build/windows/obj/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore