From fba3044880aa2baea1b11ab5a003bfc41ec6007d Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Mon, 2 May 2016 08:26:39 +0200 Subject: Makefile: use dinamic linking by default --- Makefile | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 5e19d0a..5fbf82d 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,49 @@ SOURCES = $(wildcard *.c) -DEPS=libtoxcore -CC=gcc -CFLAGS=-g #-std=c99 -CFLAGS += $(shell pkg-config --cflags $(DEPS)) -LDFLAGS=-g -pthread -lm -static -lrt -LDFLAGS += $(shell pkg-config --libs $(DEPS)) -OBJECTS=$(SOURCES:.c=.o) -INCLUDES = $(wildcard *.h) +INCLUDES = $(wildcard *.h) gitversion.h +OBJECTS = $(SOURCES:.c=.o) +DEPS = libtoxcore -all: cscope.out tuntox +CFLAGS = $(shell pkg-config --cflags $(DEPS)) +LDFLAGS = $(shell pkg-config --libs $(DEPS)) +LDFLAGS_STATIC = -static -pthread -gitversion.h: .git/HEAD .git/index - echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > $@ -gitversion.c: gitversion.h +# Check on what platform we are running +UNAME_M = $(shell uname -m) +ifeq ($(UNAME_M), x86_64) + TOXCORE_STATIC_LIB = /usr/local/lib64/libtoxcore.a + SODIUM_STATIC_LIB = /usr/local/lib64/libsodium.a +endif +ifneq ($(filter %86, $(UNAME_M)),) + TOXCORE_STATIC_LIB = /usr/local/lib/libtoxcore.a + SODIUM_STATIC_LIB = /usr/local/lib/libsodium.a +endif + -.c.o: $(INCLUDES) - $(CC) $(CFLAGS) $< -c -o $@ +# Targets +all: tuntox + +gitversion.h: .git/HEAD .git/index + @echo " GEN $@" + @echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > $@ + +%.o: %.c $(INCLUDES) + @echo " CC $@" + @$(CC) -c $(CFLAGS) $< -o $@ tuntox: $(OBJECTS) $(INCLUDES) - $(CC) -o $@ $(OBJECTS) -ltoxcore -lpthread $(LDFLAGS) /usr/local/lib/libsodium.a /usr/local/lib/libtoxcore.a + @echo " LD $@" + @$(CC) $(LDFLAGS) $(OBJECTS) -o $@ + +tuntox_static: $(OBJECTS) $(INCLUDES) + @echo " LD tuntox" + @$(CC) $(LDFLAGS_STATIC) $(OBJECTS) -o tuntox $(TOXCORE_STATIC_LIB) $(SODIUM_STATIC_LIB) cscope.out: - cscope -bv ./*.[ch] + @echo " GEN $@" + @cscope -bv ./*.[ch] clean: - rm -rf *.o tuntox gitversion.h + rm -f *.o tuntox gitversion.h + +.PHONY: all clean tuntox_static -- cgit v1.2.3