diff --git a/README.md b/README.md index d949b45..a91f474 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,16 @@ Toxic is a [Tox](https://tox.im)-based instant messenging client which formerly * [libconfig](http://www.hyperrealm.com/libconfig) (for Debian based systems, 'libconfig-dev') ##### Audio -* libtoxav (libtoxcore compiled with audio support) +* libtoxav ([libtoxcore](https://github.com/irungentoo/toxcore) compiled with audio support) * [openal](http://openal.org) (for Debian based systems, 'libopenal-dev') ##### Sound notifications -* [openal](http://openal.org) +* [openal](http://openal.org) (for Debian based systems, 'libopenal-dev') * [openalut](http://openal.org) (for Debian based systems, 'libalut-dev') +##### Desktop notifications +* [libnotify](https://developer.gnome.org/libnotify) (for Debian based systems, 'libnotify-dev') + ### Compiling 1. `cd build/` 2. `make PREFIX="/where/to/install"` @@ -27,10 +30,10 @@ Toxic is a [Tox](https://tox.im)-based instant messenging client which formerly ### Compilation Notes * You can add specific flags to the Makefile with `USER_CFLAGS=""` and/or `USER_LDFLAGS=""` * You can pass your own flags to the Makefile with `CFLAGS=""` and/or `LDFLAGS=""` (this will supersede the default ones) -* Audio call support is automatically enabled if all dependencies are found -* If you want to build toxic without audio call support, you can use `make DISABLE_AV=1` -* Sound notifications support is automatically enabled if all dependencies are found -* If you want to build toxic without sound notifications support, you can use `make DISABLE_NOTIFY=1` +* Additional features are automatically enabled if all dependencies are found, but you can disable them by using special variables: + * `DISABLE_AV=1` → build toxic without audio call support + * `DISABLE_SOUND_NOTIFY=1` → build toxic without sound notifications support + * `DISABLE_DESKTOP_NOTIFY=1` → build toxic without desktop notifications support ### Packaging * For packaging purpose, you can use `DESTDIR=""` to specify a directory where to store installed files diff --git a/build/Makefile b/build/Makefile index 99f0d22..5c4fcbb 100644 --- a/build/Makefile +++ b/build/Makefile @@ -4,18 +4,10 @@ VERSION = $(TOXIC_VERSION)_r$(REV) CFG_DIR = ../cfg SRC_DIR = ../src -MISC_DIR = ../misc -DOC_DIR = ../doc -SND_DIR = ../sounds PREFIX = /usr/local BINDIR = $(PREFIX)/bin DATADIR = $(PREFIX)/share/toxic MANDIR = $(PREFIX)/share/man -DATAFILES = DHTnodes toxic.conf.example -MANFILES = toxic.1 toxic.conf.5 -SNDFILES = ContactLogsIn.wav ContactLogsOut.wav Error.wav IncomingCall.wav -SNDFILES += LogIn.wav LogOut.wav NewMessage.wav OutgoingCall.wav -SNDFILES += TransferComplete.wav TransferPending.wav LIBS = libtoxcore ncursesw libconfig @@ -29,104 +21,35 @@ OBJ = chat.o chat_commands.o configdir.o dns.o execute.o file_senders.o notify.o OBJ += friendlist.o global_commands.o groupchat.o line_info.o input.o help.o autocomplete.o OBJ += log.o misc_tools.o prompt.o settings.o toxic.o toxic_strings.o windows.o -# Variables for audio call support -AUDIO_LIBS = libtoxav openal -AUDIO_CFLAGS = -D_AUDIO -AUDIO_OBJ = audio_call.o - -# Variables for sound notify support -SND_NOTIFY_LIBS = openal freealut -SND_NOTIFY_CFLAGS = -D_SOUND_NOTIFY - # Check on wich system we are running UNAME_S = $(shell uname -s) ifeq ($(UNAME_S), Linux) - -include $(CFG_DIR)/Linux.mk + -include $(CFG_DIR)/systems/Linux.mk endif ifeq ($(UNAME_S), FreeBSD) - -include $(CFG_DIR)/FreeBSD.mk + -include $(CFG_DIR)/systems/FreeBSD.mk endif ifeq ($(UNAME_S), Darwin) - -include $(CFG_DIR)/Darwin.mk + -include $(CFG_DIR)/systems/Darwin.mk endif ifeq ($(UNAME_S), Solaris) - -include $(CFG_DIR)/Solaris.mk + -include $(CFG_DIR)/systems/Solaris.mk endif # Check on which platform we are running UNAME_M = $(shell uname -m) ifeq ($(UNAME_M), x86_64) - -include $(CFG_DIR)/x86_64.mk + -include $(CFG_DIR)/platforms/x86_64.mk endif ifneq ($(filter %86, $(UNAME_M)),) - -include $(CFG_DIR)/x86.mk + -include $(CFG_DIR)/platforms/x86.mk endif ifneq ($(filter arm%, $(UNAME_M)),) - -include $(CFG_DIR)/arm.mk + -include $(CFG_DIR)/platforms/arm.mk endif -# Check if we can use X11 -CHECK_X11_LIBS = $(shell pkg-config x11 || echo -n "error") -ifneq ($(CHECK_X11_LIBS), error) - LIBS += x11 - CFLAGS += -D_X11 -endif - -# Check if we want/can build audio -ifneq ($(DISABLE_AV), 1) -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) - NEED_AV = 1 -else -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 -endif - -# Check if we want/can build sound notify support -ifneq ($(DISABLE_NOTIFY), 1) -CHECK_NOTIFY_LIBS = $(shell pkg-config $(SND_NOTIFY_LIBS) || echo -n "error") -ifneq ($(CHECK_NOTIFY_LIBS), error) - LIBS += $(SND_NOTIFY_LIBS) - CFLAGS += $(SND_NOTIFY_CFLAGS) - NEED_AV = 1 - -else -ifneq ($(MAKECMDGOALS), clean) -MISSING_NOTIFY_LIBS = $(shell for lib in $(SND_NOTIFY_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done) -$(warning WARNING -- Toxic will be compiled without sound notify support) -$(warning WARNING -- You need these libraries for sound notify support) -$(warning WARNING -- $(MISSING_NOTIFY_LIBS)) -endif -endif -endif - -# device.o is needed for both audio calls and notifications but should only be loaded once -ifeq ($(NEED_AV), 1) - OBJ += device.o -endif - -# Check if we can build Toxic -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 +# Include all needed checks +-include $(CFG_DIR)/check_features.mk # Targets all: toxic @@ -135,33 +58,6 @@ toxic: $(OBJ) @echo " LD $@" @$(CC) $(CFLAGS) -o toxic $(OBJ) $(LDFLAGS) -install: toxic - mkdir -p $(abspath $(DESTDIR)/$(BINDIR)) - mkdir -p $(abspath $(DESTDIR)/$(DATADIR)) - mkdir -p $(abspath $(DESTDIR)/$(DATADIR))/sounds - mkdir -p $(abspath $(DESTDIR)/$(MANDIR)) - @echo "Installing toxic executable" - @install -m 0755 toxic $(abspath $(DESTDIR)/$(BINDIR)) - @echo "Installing data files" - @for f in $(DATAFILES) ; do \ - install -m 0644 $(MISC_DIR)/$$f $(abspath $(DESTDIR)/$(DATADIR)) ;\ - file=$(abspath $(DESTDIR)/$(DATADIR))/$$f ;\ - sed -i'' -e 's:__DATADIR__:'$(abspath $(DATADIR))':g' $$file ;\ - done - @for f in $(SNDFILES) ; do \ - install -m 0644 $(SND_DIR)/$$f $(abspath $(DESTDIR)/$(DATADIR))/sounds ;\ - done - @echo "Installing man pages" - @for f in $(MANFILES) ; do \ - section=$(abspath $(DESTDIR)/$(MANDIR))/man`echo $$f | rev | cut -d "." -f 1` ;\ - file=$$section/$$f ;\ - mkdir -p $$section ;\ - install -m 0644 $(DOC_DIR)/$$f $$file ;\ - sed -i'' -e 's:__VERSION__:'$(VERSION)':g' $$file ;\ - sed -i'' -e 's:__DATADIR__:'$(abspath $(DATADIR))':g' $$file ;\ - gzip -f -9 $$file ;\ - done - %.o: $(SRC_DIR)/%.c @echo " CC $@" @$(CC) $(CFLAGS) -o $*.o -c $(SRC_DIR)/$*.c @@ -170,8 +66,9 @@ install: toxic clean: rm -rf *.d *.o toxic --include $(CFG_DIR)/help.mk - -include $(OBJ:.o=.d) -.PHONY: clean all install +-include $(CFG_DIR)/install.mk +-include $(CFG_DIR)/help.mk + +.PHONY: clean all diff --git a/cfg/av.mk b/cfg/av.mk new file mode 100644 index 0000000..be18bd2 --- /dev/null +++ b/cfg/av.mk @@ -0,0 +1,23 @@ +# Variables for audio call support +AUDIO_LIBS = libtoxav openal +AUDIO_CFLAGS = -D_AUDIO +ifneq (, $(findstring device.o, $(OBJ))) + AUDIO_OBJ = audio_call.o +else + AUDIO_OBJ = audio_call.o device.o +endif + +# Check if we can build audio support +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 +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 diff --git a/cfg/check_features.mk b/cfg/check_features.mk new file mode 100644 index 0000000..56d2210 --- /dev/null +++ b/cfg/check_features.mk @@ -0,0 +1,39 @@ +# Check if we can use X11 +CHECK_X11_LIBS = $(shell pkg-config x11 || echo -n "error") +ifneq ($(CHECK_X11_LIBS), error) + LIBS += x11 + CFLAGS += -D_X11 +endif + +# Check if we want build audio support +AUDIO = $(shell if [ -z "$(DISABLE_AV)" ] || [ "$(DISABLE_AV)" = "0" ] ; then echo enabled ; else echo disabled ; fi) +ifneq ($(AUDIO), disabled) + -include $(CFG_DIR)/av.mk +endif + +# Check if we want build sound notifications support +SND_NOTIFY = $(shell if [ -z "$(DISABLE_SOUND_NOTIFY)" ] || [ "$(DISABLE_SOUND_NOTIFY)" = "0" ] ; then echo enabled ; else echo disabled ; fi) +ifneq ($(SND_NOTIFY), disabled) + -include $(CFG_DIR)/sound_notifications.mk +endif + +# Check if we want build desktop notifications support +DESK_NOTIFY = $(shell if [ -z "$(DISABLE_DESKTOP_NOTIFY)" ] || [ "$(DISABLE_DESKTOP_NOTIFY)" = "0" ] ; then echo enabled ; else echo disabled ; fi) +ifneq ($(DESK_NOTIFY), disabled) + -include $(CFG_DIR)/desktop_notifications.mk +endif + +# Check if we can build Toxic +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 diff --git a/cfg/desktop_notifications.mk b/cfg/desktop_notifications.mk new file mode 100644 index 0000000..a3dd0b2 --- /dev/null +++ b/cfg/desktop_notifications.mk @@ -0,0 +1,17 @@ +# Variables for desktop notifications support +DESK_NOTIFY_LIBS = libnotify +DESK_NOTIFY_CFLAGS = -D_BOX_NOTIFY + +# Check if we can build desktop notifications support +CHECK_DESK_NOTIFY_LIBS = $(shell pkg-config $(DESK_NOTIFY_LIBS) || echo -n "error") +ifneq ($(CHECK_DESK_NOTIFY_LIBS), error) + LIBS += $(DESK_NOTIFY_LIBS) + CFLAGS += $(DESK_NOTIFY_CFLAGS) +else +ifneq ($(MAKECMDGOALS), clean) +MISSING_DESK_NOTIFY_LIBS = $(shell for lib in $(DESK_NOTIFY_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done) +$(warning WARNING -- Toxic will be compiled without desktop notifications support) +$(warning WARNING -- You need these libraries for desktop notifications support) +$(warning WARNING -- $(MISSING_DESK_NOTIFY_LIBS)) +endif +endif diff --git a/cfg/help.mk b/cfg/help.mk index 80a9bc4..6848df0 100644 --- a/cfg/help.mk +++ b/cfg/help.mk @@ -8,11 +8,12 @@ help: @echo " help: This help" @echo @echo "-- Variables --" - @echo " DISABLE_AV: Set to \"1\" to force building without audio call support" - @echo " DISABLE_NOTIFY: Set to \"1\" to force building without sound notify support" - @echo " USER_CFLAGS: Add custom flags to default CFLAGS" - @echo " USER_LDFLAGS: Add custom flags to default LDFLAGS" - @echo " PREFIX: Specify a prefix directory for binaries, data files,... (default is \"$(abspath $(PREFIX))\")" - @echo " DESTDIR: Specify a directory where to store installed files (mainly for packaging purpose)" + @echo " DISABLE_AV: Set to \"1\" to force building without audio call support" + @echo " DISABLE_SOUND_NOTIFY: Set to \"1\" to force building without sound notification support" + @echo " DISABLE_DESKTOP_NOTIFY: Set to \"1\" to force building without desktop notifications support" + @echo " USER_CFLAGS: Add custom flags to default CFLAGS" + @echo " USER_LDFLAGS: Add custom flags to default LDFLAGS" + @echo " PREFIX: Specify a prefix directory for binaries, data files,... (default is \"$(abspath $(PREFIX))\")" + @echo " DESTDIR: Specify a directory where to store installed files (mainly for packaging purpose)" .PHONY: help diff --git a/cfg/install.mk b/cfg/install.mk new file mode 100644 index 0000000..1d04404 --- /dev/null +++ b/cfg/install.mk @@ -0,0 +1,37 @@ +MISC_DIR = ../misc +DOC_DIR = ../doc +SND_DIR = ../sounds +DATAFILES = DHTnodes toxic.conf.example +MANFILES = toxic.1 toxic.conf.5 +SNDFILES = ContactLogsIn.wav ContactLogsOut.wav Error.wav IncomingCall.wav +SNDFILES += LogIn.wav LogOut.wav NewMessage.wav OutgoingCall.wav +SNDFILES += TransferComplete.wav TransferPending.wav + +install: toxic + mkdir -p $(abspath $(DESTDIR)/$(BINDIR)) + mkdir -p $(abspath $(DESTDIR)/$(DATADIR)) + mkdir -p $(abspath $(DESTDIR)/$(DATADIR))/sounds + mkdir -p $(abspath $(DESTDIR)/$(MANDIR)) + @echo "Installing toxic executable" + @install -m 0755 toxic $(abspath $(DESTDIR)/$(BINDIR)) + @echo "Installing data files" + @for f in $(DATAFILES) ; do \ + install -m 0644 $(MISC_DIR)/$$f $(abspath $(DESTDIR)/$(DATADIR)) ;\ + file=$(abspath $(DESTDIR)/$(DATADIR))/$$f ;\ + sed -i'' -e 's:__DATADIR__:'$(abspath $(DATADIR))':g' $$file ;\ + done + @for f in $(SNDFILES) ; do \ + install -m 0644 $(SND_DIR)/$$f $(abspath $(DESTDIR)/$(DATADIR))/sounds ;\ + done + @echo "Installing man pages" + @for f in $(MANFILES) ; do \ + section=$(abspath $(DESTDIR)/$(MANDIR))/man`echo $$f | rev | cut -d "." -f 1` ;\ + file=$$section/$$f ;\ + mkdir -p $$section ;\ + install -m 0644 $(DOC_DIR)/$$f $$file ;\ + sed -i'' -e 's:__VERSION__:'$(VERSION)':g' $$file ;\ + sed -i'' -e 's:__DATADIR__:'$(abspath $(DATADIR))':g' $$file ;\ + gzip -f -9 $$file ;\ + done + +.PHONY: install diff --git a/cfg/platforms/.gitignore b/cfg/platforms/.gitignore new file mode 100644 index 0000000..5e7d2734 --- /dev/null +++ b/cfg/platforms/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/cfg/sound_notifications.mk b/cfg/sound_notifications.mk new file mode 100644 index 0000000..bb39edd --- /dev/null +++ b/cfg/sound_notifications.mk @@ -0,0 +1,23 @@ +# Variables for sound notifications support +SND_NOTIFY_LIBS = openal freealut +SND_NOTIFY_CFLAGS = -D_SOUND_NOTIFY +ifneq (, $(findstring device.o, $(OBJ))) + SND_NOTIFY_OBJ = +else + SND_NOTIFY_OBJ = device.o +endif + +# Check if we can build sound notifications support +CHECK_SND_NOTIFY_LIBS = $(shell pkg-config $(SND_NOTIFY_LIBS) || echo -n "error") +ifneq ($(CHECK_SND_NOTIFY_LIBS), error) + LIBS += $(SND_NOTIFY_LIBS) + CFLAGS += $(SND_NOTIFY_CFLAGS) + OBJ += $(SND_NOTIFY_OBJ) +else +ifneq ($(MAKECMDGOALS), clean) +MISSING_SND_NOTIFY_LIBS = $(shell for lib in $(SND_NOTIFY_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done) +$(warning WARNING -- Toxic will be compiled without sound notifications support) +$(warning WARNING -- You need these libraries for sound notifications support) +$(warning WARNING -- $(MISSING_SND_NOTIFY_LIBS)) +endif +endif diff --git a/cfg/FreeBSD.mk b/cfg/systems/FreeBSD.mk similarity index 100% rename from cfg/FreeBSD.mk rename to cfg/systems/FreeBSD.mk diff --git a/cfg/Linux.mk b/cfg/systems/Linux.mk similarity index 100% rename from cfg/Linux.mk rename to cfg/systems/Linux.mk diff --git a/doc/toxic.conf.5 b/doc/toxic.conf.5 index 9956008..29299c8 100644 --- a/doc/toxic.conf.5 +++ b/doc/toxic.conf.5 @@ -11,9 +11,9 @@ client. .I
.B = { .PP -.IB : ; +.IB = ; .br -.IB = ; +.IB = ; .br ... .PP @@ -291,19 +291,19 @@ ui = { .RS // true to enable timestamps, false to disable .br - timestamps:true; + timestamps=true; .br // true to enable terminal alerts on messages, false to disable .br - alerts:true; + alerts=true; .br // true to use native terminal colours, false to use toxic default colour theme .br - native_colors:false; + native_colors=false; .br // true to enable autologging, false to disable .br - autolog:false; + autolog=false; .br // 24 or 12 hour time .br diff --git a/src/audio_call.c b/src/audio_call.c index aa57f9a..d8af93c 100644 --- a/src/audio_call.c +++ b/src/audio_call.c @@ -42,6 +42,10 @@ #else #include #include +/* compatibility with older versions of OpenAL */ +#ifndef ALC_ALL_DEVICES_SPECIFIER +#include +#endif #endif #define _cbend pthread_exit(NULL) diff --git a/src/device.c b/src/device.c index 5c6c705..16114de 100644 --- a/src/device.c +++ b/src/device.c @@ -35,6 +35,10 @@ #else #include #include +/* compatibility with older versions of OpenAL */ +#ifndef ALC_ALL_DEVICES_SPECIFIER +#include +#endif #endif #include diff --git a/src/notify.c b/src/notify.c index 6872d0b..612da36 100644 --- a/src/notify.c +++ b/src/notify.c @@ -43,6 +43,10 @@ #else #include #include + /* compatibility with older versions of OpenAL */ + #ifndef ALC_ALL_DEVICES_SPECIFIER + #include + #endif #ifdef _SOUND_NOTIFY #include /* freealut packet */ #endif @@ -475,4 +479,4 @@ int box_notify_append(ToxWindow* self, Notification notif, uint64_t flags, int i #else return notify(self, notif, flags); #endif -} \ No newline at end of file +}