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