1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-13 01:13:02 +01:00

Makefile: checks for libs

This commit is contained in:
Ansa89 2014-06-23 21:55:32 +02:00
parent 9f8a6a8b6b
commit 717f8986cd

View File

@ -1,30 +1,43 @@
SUPPORT_AUDIO ?= 0
LIBS = libtoxcore ncurses
CFLAGS = -std=gnu99 -pthread
LDFLAGS = -ldl -lresolv
DESTDIR=/usr/local
DESTDIR ?= /usr/local
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
ifeq ($(SUPPORT_AUDIO), 1)
CHECK_OPENAL = $(shell pkg-config openal || echo -n "no_audio")
CHECK_TOXAV = $(shell pkg-config libtoxav || echo -n "no_audio")
ifeq (no_audio, $(filter no_audio, $(CHECK_OPENAL) $(CHECK_TOXAV)))
SUPPORT_AUDIO = 0
AUDIO_LIBS = libtoxav openal
AUDIO_CFLAGS = -D_SUPPORT_AUDIO
AUDIO_OBJ = device.o audio_call.o
CHECK_AUDIO_LIBS = $(shell pkg-config $(AUDIO_LIBS) || echo -n "error")
ifneq ($(CHECK_AUDIO_LIBS), error)
LIBS += $(AUDIO_LIBS)
CFLAGS += $(AUDIO_CFLAGS)
OBJ += $(AUDIO_OBJ)
else
CFLAGS += -D_SUPPORT_AUDIO
OBJ += device.o audio_call.o
LIBS += openal libtoxav
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))
endif
endif
ifneq ($(LIBS),)
CFLAGS += $(shell pkg-config --cflags $(LIBS))
LDFLAGS += $(shell pkg-config --libs $(LIBS))
CHECK_LIBS = $(shell pkg-config $(LIBS) || echo -n "error")
ifneq ($(CHECK_LIBS), error)
CFLAGS += $(shell pkg-config --cflags $(LIBS))
LDFLAGS += $(shell pkg-config --libs $(LIBS))
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
endif
all: toxic
@ -36,8 +49,6 @@ install: toxic
mkdir -pv $(DESTDIR)/bin
install -m 0755 toxic $(DESTDIR)/bin
-include $(OBJ:.o=.d)
%.o: %.c
$(CC) $(CFLAGS) -o $*.o -c $*.c
$(CC) -MM $(CFLAGS) $*.c > $*.d
@ -45,4 +56,6 @@ install: toxic
clean:
rm -rf *.d *.o toxic
-include $(OBJ:.o=.d)
.PHONY: clean all install