reworked the compilation process a bit, made cli work on Windows

This commit is contained in:
Welp Wazowski
2018-10-08 21:59:56 -07:00
parent 17780f129f
commit 1f0da0d2b0
7 changed files with 50 additions and 26 deletions

4
.gitignore vendored
View File

@@ -1,5 +1 @@
*.o
greeny-cli
greeny
test-greeny
*kdev4*

View File

@@ -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)

View File

@@ -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.

2
build/native/bin/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

2
build/native/obj/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

2
build/windows/bin/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

2
build/windows/obj/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore