diff options
-rw-r--r-- | Makefile | 55 |
1 files changed, 38 insertions, 17 deletions
@@ -1,28 +1,49 @@ | |||
1 | SOURCES = $(wildcard *.c) | 1 | SOURCES = $(wildcard *.c) |
2 | DEPS=libtoxcore | 2 | INCLUDES = $(wildcard *.h) gitversion.h |
3 | CC=gcc | 3 | OBJECTS = $(SOURCES:.c=.o) |
4 | CFLAGS=-g #-std=c99 | 4 | DEPS = libtoxcore |
5 | CFLAGS += $(shell pkg-config --cflags $(DEPS)) | ||
6 | LDFLAGS=-g -pthread -lm -static -lrt | ||
7 | LDFLAGS += $(shell pkg-config --libs $(DEPS)) | ||
8 | OBJECTS=$(SOURCES:.c=.o) | ||
9 | INCLUDES = $(wildcard *.h) | ||
10 | 5 | ||
11 | all: cscope.out tuntox | 6 | CFLAGS = $(shell pkg-config --cflags $(DEPS)) |
7 | LDFLAGS = $(shell pkg-config --libs $(DEPS)) | ||
8 | LDFLAGS_STATIC = -static -pthread | ||
12 | 9 | ||
13 | gitversion.h: .git/HEAD .git/index | ||
14 | echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > $@ | ||
15 | 10 | ||
16 | gitversion.c: gitversion.h | 11 | # Check on what platform we are running |
12 | UNAME_M = $(shell uname -m) | ||
13 | ifeq ($(UNAME_M), x86_64) | ||
14 | TOXCORE_STATIC_LIB = /usr/local/lib64/libtoxcore.a | ||
15 | SODIUM_STATIC_LIB = /usr/local/lib64/libsodium.a | ||
16 | endif | ||
17 | ifneq ($(filter %86, $(UNAME_M)),) | ||
18 | TOXCORE_STATIC_LIB = /usr/local/lib/libtoxcore.a | ||
19 | SODIUM_STATIC_LIB = /usr/local/lib/libsodium.a | ||
20 | endif | ||
21 | |||
17 | 22 | ||
18 | .c.o: $(INCLUDES) | 23 | # Targets |
19 | $(CC) $(CFLAGS) $< -c -o $@ | 24 | all: tuntox |
25 | |||
26 | gitversion.h: .git/HEAD .git/index | ||
27 | @echo " GEN $@" | ||
28 | @echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > $@ | ||
29 | |||
30 | %.o: %.c $(INCLUDES) | ||
31 | @echo " CC $@" | ||
32 | @$(CC) -c $(CFLAGS) $< -o $@ | ||
20 | 33 | ||
21 | tuntox: $(OBJECTS) $(INCLUDES) | 34 | tuntox: $(OBJECTS) $(INCLUDES) |
22 | $(CC) -o $@ $(OBJECTS) -ltoxcore -lpthread $(LDFLAGS) /usr/local/lib/libsodium.a /usr/local/lib/libtoxcore.a | 35 | @echo " LD $@" |
36 | @$(CC) $(LDFLAGS) $(OBJECTS) -o $@ | ||
37 | |||
38 | tuntox_static: $(OBJECTS) $(INCLUDES) | ||
39 | @echo " LD tuntox" | ||
40 | @$(CC) $(LDFLAGS_STATIC) $(OBJECTS) -o tuntox $(TOXCORE_STATIC_LIB) $(SODIUM_STATIC_LIB) | ||
23 | 41 | ||
24 | cscope.out: | 42 | cscope.out: |
25 | cscope -bv ./*.[ch] | 43 | @echo " GEN $@" |
44 | @cscope -bv ./*.[ch] | ||
26 | 45 | ||
27 | clean: | 46 | clean: |
28 | rm -rf *.o tuntox gitversion.h | 47 | rm -f *.o tuntox gitversion.h |
48 | |||
49 | .PHONY: all clean tuntox_static | ||