2014-06-24 09:02:06 +02:00
|
|
|
TOXIC_VERSION = 0.4.2
|
2014-06-23 22:32:10 +02:00
|
|
|
REV = $(shell git rev-list HEAD --count)
|
|
|
|
VERSION = $(TOXIC_VERSION)_r$(REV)
|
|
|
|
|
2014-06-23 15:34:32 +02:00
|
|
|
LIBS = libtoxcore ncurses
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2014-06-24 00:17:14 +02:00
|
|
|
CFLAGS ?= $(USER_CFLAGS) -DTOXICVER="\"$(VERSION)\"" -std=gnu99 -pthread
|
|
|
|
LDFLAGS ?= $(USER_LDFLAGS)
|
2014-06-24 11:53:02 +02:00
|
|
|
SRC_DIR = ../src
|
2014-06-23 21:55:32 +02:00
|
|
|
DESTDIR ?= /usr/local
|
2014-06-23 11:09:01 +02:00
|
|
|
|
|
|
|
OBJ = chat.o chat_commands.o configdir.o dns.o execute.o
|
|
|
|
OBJ += file_senders.o friendlist.o global_commands.o groupchat.o line_info.o
|
|
|
|
OBJ += log.o misc_tools.o prompt.o settings.o toxic.o toxic_strings.o windows.o
|
|
|
|
|
2014-06-24 00:17:14 +02:00
|
|
|
# Variables for audio support
|
2014-06-23 21:55:32 +02:00
|
|
|
AUDIO_LIBS = libtoxav openal
|
|
|
|
AUDIO_CFLAGS = -D_SUPPORT_AUDIO
|
|
|
|
AUDIO_OBJ = device.o audio_call.o
|
|
|
|
|
2014-06-24 00:17:14 +02:00
|
|
|
# Check on wich system we are running
|
2014-06-24 09:02:06 +02:00
|
|
|
UNAME_S = $(shell uname -s)
|
|
|
|
ifeq ($(UNAME_S), Linux)
|
|
|
|
CFLAGS +=
|
|
|
|
LDFLAGS += -ldl -lresolv
|
|
|
|
endif
|
|
|
|
ifeq ($(UNAME_S), Darwin)
|
|
|
|
CFLAGS +=
|
|
|
|
LDFLAGS +=
|
|
|
|
endif
|
|
|
|
ifeq ($(UNAME_S), Solaris)
|
|
|
|
CFLAGS +=
|
|
|
|
LDFLAGS +=
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Check on which platform we are running
|
|
|
|
UNAME_M = $(shell uname -m)
|
|
|
|
ifeq ($(UNAME_M), x86_64)
|
|
|
|
CFLAGS +=
|
|
|
|
LDFLAGS +=
|
|
|
|
endif
|
|
|
|
ifneq ($(filter %86, $(UNAME_M)),)
|
|
|
|
CFLAGS +=
|
|
|
|
LDFLAGS +=
|
|
|
|
endif
|
|
|
|
ifneq ($(filter arm%, $(UNAME_M)),)
|
2014-06-24 00:17:14 +02:00
|
|
|
CFLAGS +=
|
|
|
|
LDFLAGS +=
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Check if we can build audio
|
2014-06-23 21:55:32 +02:00
|
|
|
CHECK_AUDIO_LIBS = $(shell pkg-config $(AUDIO_LIBS) || echo -n "error")
|
|
|
|
ifneq ($(CHECK_AUDIO_LIBS), error)
|
2014-06-24 11:01:32 +02:00
|
|
|
LIBS += $(AUDIO_LIBS)
|
|
|
|
CFLAGS += $(AUDIO_CFLAGS)
|
|
|
|
OBJ += $(AUDIO_OBJ)
|
2014-06-23 15:34:32 +02:00
|
|
|
else
|
2014-06-23 21:55:32 +02:00
|
|
|
ifneq ($(MAKECMDGOALS), clean)
|
|
|
|
MISSING_AUDIO_LIBS = $(shell for lib in $(AUDIO_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done)
|
|
|
|
$(warning WARNING -- Toxic will be compiled without audio support)
|
|
|
|
$(warning WARNING -- You need these libraries for audio support)
|
|
|
|
$(warning WARNING -- $(MISSING_AUDIO_LIBS))
|
2014-06-23 15:34:32 +02:00
|
|
|
endif
|
2014-06-23 11:09:01 +02:00
|
|
|
endif
|
|
|
|
|
2014-06-24 00:17:14 +02:00
|
|
|
# Check if we can build Toxic
|
2014-06-23 21:55:32 +02:00
|
|
|
CHECK_LIBS = $(shell pkg-config $(LIBS) || echo -n "error")
|
|
|
|
ifneq ($(CHECK_LIBS), error)
|
2014-06-24 11:01:32 +02:00
|
|
|
CFLAGS += $(shell pkg-config --cflags $(LIBS))
|
|
|
|
LDFLAGS += $(shell pkg-config --libs $(LIBS))
|
2014-06-23 21:55:32 +02:00
|
|
|
else
|
|
|
|
ifneq ($(MAKECMDGOALS), clean)
|
|
|
|
MISSING_LIBS = $(shell for lib in $(LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done)
|
|
|
|
$(warning ERROR -- Cannot compile Toxic)
|
|
|
|
$(warning ERROR -- You need these libraries)
|
|
|
|
$(warning ERROR -- $(MISSING_LIBS))
|
|
|
|
$(error ERROR)
|
|
|
|
endif
|
2014-06-23 14:07:23 +02:00
|
|
|
endif
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2014-06-24 00:17:14 +02:00
|
|
|
# Targets
|
2014-06-23 11:09:01 +02:00
|
|
|
all: toxic
|
|
|
|
|
|
|
|
toxic: $(OBJ)
|
2014-06-24 11:01:32 +02:00
|
|
|
$(CC) $(CFLAGS) -o toxic $(OBJ) $(LDFLAGS)
|
2014-06-23 11:09:01 +02:00
|
|
|
|
|
|
|
install: toxic
|
2014-06-24 11:01:32 +02:00
|
|
|
mkdir -pv $(DESTDIR)/bin
|
|
|
|
install -m 0755 toxic $(DESTDIR)/bin
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2014-06-24 11:53:02 +02:00
|
|
|
%.o: $(SRC_DIR)/%.c
|
|
|
|
$(CC) $(CFLAGS) -o $*.o -c $(SRC_DIR)/$*.c
|
|
|
|
$(CC) -MM $(CFLAGS) $(SRC_DIR)/$*.c > $*.d
|
2014-06-23 11:09:01 +02:00
|
|
|
|
|
|
|
clean:
|
2014-06-24 11:01:32 +02:00
|
|
|
rm -rf *.d *.o toxic
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2014-06-23 21:55:32 +02:00
|
|
|
-include $(OBJ:.o=.d)
|
|
|
|
|
2014-06-23 11:09:01 +02:00
|
|
|
.PHONY: clean all install
|