1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 16:03:03 +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 LIBS = libtoxcore ncurses
CFLAGS = -std=gnu99 -pthread CFLAGS = -std=gnu99 -pthread
LDFLAGS = -ldl -lresolv LDFLAGS = -ldl -lresolv
DESTDIR=/usr/local DESTDIR ?= /usr/local
OBJ = chat.o chat_commands.o configdir.o dns.o execute.o 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 += 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 OBJ += log.o misc_tools.o prompt.o settings.o toxic.o toxic_strings.o windows.o
ifeq ($(SUPPORT_AUDIO), 1) AUDIO_LIBS = libtoxav openal
CHECK_OPENAL = $(shell pkg-config openal || echo -n "no_audio") AUDIO_CFLAGS = -D_SUPPORT_AUDIO
CHECK_TOXAV = $(shell pkg-config libtoxav || echo -n "no_audio") AUDIO_OBJ = device.o audio_call.o
ifeq (no_audio, $(filter no_audio, $(CHECK_OPENAL) $(CHECK_TOXAV)))
SUPPORT_AUDIO = 0 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 else
CFLAGS += -D_SUPPORT_AUDIO ifneq ($(MAKECMDGOALS), clean)
OBJ += device.o audio_call.o MISSING_AUDIO_LIBS = $(shell for lib in $(AUDIO_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done)
LIBS += openal libtoxav $(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
endif endif
ifneq ($(LIBS),) CHECK_LIBS = $(shell pkg-config $(LIBS) || echo -n "error")
CFLAGS += $(shell pkg-config --cflags $(LIBS)) ifneq ($(CHECK_LIBS), error)
LDFLAGS += $(shell pkg-config --libs $(LIBS)) 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 endif
all: toxic all: toxic
@ -36,8 +49,6 @@ install: toxic
mkdir -pv $(DESTDIR)/bin mkdir -pv $(DESTDIR)/bin
install -m 0755 toxic $(DESTDIR)/bin install -m 0755 toxic $(DESTDIR)/bin
-include $(OBJ:.o=.d)
%.o: %.c %.o: %.c
$(CC) $(CFLAGS) -o $*.o -c $*.c $(CC) $(CFLAGS) -o $*.o -c $*.c
$(CC) -MM $(CFLAGS) $*.c > $*.d $(CC) -MM $(CFLAGS) $*.c > $*.d
@ -45,4 +56,6 @@ install: toxic
clean: clean:
rm -rf *.d *.o toxic rm -rf *.d *.o toxic
-include $(OBJ:.o=.d)
.PHONY: clean all install .PHONY: clean all install