diff --git a/INSTALL.md b/INSTALL.md index d45b738..fb3c3e3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -38,8 +38,8 @@ You can omit `libnotify` if you intend to build without desktop notifications en ## Compiling ``` -make PREFIX="/where/to/install" -sudo make install PREFIX="/where/to/install" +make +sudo env PREFIX="/where/to/install" make install ``` #### Documentation @@ -50,8 +50,8 @@ Run `make doc` in the build directory after editing the asciidoc files to regene ## Notes #### Compilation variables -* 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) +* You can add specific flags to the Makefile with `USER_CFLAGS=""` and `USER_LDFLAGS=""` passed as the arguments to make or as environment variables +* You can use CFLAGS and LDFLAGS environment variables to add specific flags to the Makefile * Additional features are automatically enabled if all dependencies are found, but you can disable them by using special variables: * `DISABLE_X11=1` → build toxic without X11 support (needed for focus tracking) * `DISABLE_AV=1` → build toxic without audio call support diff --git a/Makefile b/Makefile index 147e0e1..dacc76b 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,15 @@ CFG_DIR = $(BASE_DIR)/cfg -include $(CFG_DIR)/global_vars.mk -LIBS = toxcore ncursesw libconfig +LIBS = toxcore ncursesw libconfig libcurl -CFLAGS = -std=gnu99 -pthread -Wall -g -fstack-protector-all +CFLAGS ?= -g +CFLAGS += -std=gnu99 -pthread -Wall -fstack-protector-all CFLAGS += '-DTOXICVER="$(VERSION)"' -DHAVE_WIDECHAR -D_XOPEN_SOURCE_EXTENDED -D_FILE_OFFSET_BITS=64 CFLAGS += '-DPACKAGE_DATADIR="$(abspath $(DATADIR))"' -CFLAGS += $(USER_CFLAGS) -LDFLAGS = $(USER_LDFLAGS) +CFLAGS += ${USER_CFLAGS} +LDFLAGS ?= +LDFLAGS += ${USER_LDFLAGS} OBJ = autocomplete.o avatars.o bootstrap.o chat.o chat_commands.o configdir.o curl_util.o execute.o OBJ += file_transfers.o friendlist.o global_commands.o group_commands.o groupchat.o help.o input.o @@ -19,26 +21,19 @@ OBJ += term_mplex.o toxic.o toxic_strings.o windows.o # Check on wich system we are running UNAME_S = $(shell uname -s) ifeq ($(UNAME_S), Linux) - -include $(CFG_DIR)/systems/Linux.mk -endif -ifeq ($(UNAME_S), FreeBSD) - -include $(CFG_DIR)/systems/FreeBSD.mk -endif -ifeq ($(UNAME_S), DragonFly) - -include $(CFG_DIR)/systems/FreeBSD.mk +LDFLAGS += -ldl -lrt endif ifeq ($(UNAME_S), OpenBSD) - -include $(CFG_DIR)/systems/FreeBSD.mk +LIBS := $(filter-out ncursesw, $(LIBS)) +LDFLAGS += -lncursesw endif ifeq ($(UNAME_S), NetBSD) - -include $(CFG_DIR)/systems/FreeBSD.mk +LIBS := $(filter-out ncursesw, $(LIBS)) +LDFLAGS += -lncursesw endif ifeq ($(UNAME_S), Darwin) -include $(CFG_DIR)/systems/Darwin.mk endif -ifeq ($(UNAME_S), Solaris) - -include $(CFG_DIR)/systems/Solaris.mk -endif # Check on which platform we are running UNAME_M = $(shell uname -m) diff --git a/cfg/global_vars.mk b/cfg/global_vars.mk index c00dffe..d834d01 100644 --- a/cfg/global_vars.mk +++ b/cfg/global_vars.mk @@ -23,10 +23,10 @@ SNDFILES += ToxicRecvMessage.wav ToxicOutgoingCall.wav ToxicIncomingCall.wav SNDFILES += ToxicTransferComplete.wav ToxicTransferStart.wav # Install directories -PREFIX = /usr/local +PREFIX ?= /usr/local BINDIR = $(PREFIX)/bin DATADIR = $(PREFIX)/share/toxic -MANDIR = $(PREFIX)/share/man +MANDIR ?= $(PREFIX)/share/man APPDIR = $(PREFIX)/share/applications # Platform tools diff --git a/cfg/systems/FreeBSD.mk b/cfg/systems/FreeBSD.mk deleted file mode 100644 index bdccdba..0000000 --- a/cfg/systems/FreeBSD.mk +++ /dev/null @@ -1,4 +0,0 @@ -# Specials options for freebsd systems -LIBS := $(filter-out ncursesw, $(LIBS)) -LDFLAGS += -lncursesw -lcurl -MANDIR = $(PREFIX)/man diff --git a/cfg/systems/Linux.mk b/cfg/systems/Linux.mk deleted file mode 100644 index 6bd4075..0000000 --- a/cfg/systems/Linux.mk +++ /dev/null @@ -1,4 +0,0 @@ -# Specials options for linux systems -CFLAGS += -LDFLAGS += -ldl -lrt -lcurl -MANDIR = $(PREFIX)/share/man diff --git a/cfg/targets/help.mk b/cfg/targets/help.mk index da7cc3c..b7baf9a 100644 --- a/cfg/targets/help.mk +++ b/cfg/targets/help.mk @@ -21,5 +21,15 @@ help: @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 " MANDIR: Specify a directory where to store man pages (default is \"$(abspath $(PREFIX)/share/man)\")" + @echo + @echo "-- Environment Variables --" + @echo " CFLAGS: Add custom flags to default CFLAGS" + @echo " LDFLAGS: Add custom flags to default LDFLAGS" + @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 " MANDIR: Specify a directory where to store man pages (default is \"$(abspath $(PREFIX)/share/man)\")" .PHONY: help diff --git a/cfg/targets/install.mk b/cfg/targets/install.mk index 1c62ebe..76d860a 100644 --- a/cfg/targets/install.mk +++ b/cfg/targets/install.mk @@ -27,7 +27,7 @@ install: $(BUILD_DIR)/toxic if [ ! -e "$(DOC_DIR)/$$f" ]; then \ continue ;\ fi ;\ - section=$(abspath $(DESTDIR)/$(MANDIR))/man`echo $$f | rev | cut -d "." -f 1` ;\ + section=$(abspath $(DESTDIR)/$(MANDIR))/man`echo $${f##*.}` ;\ file=$$section/$$f ;\ mkdir -p $$section ;\ install -m 0644 $(DOC_DIR)/$$f $$file ;\ diff --git a/cfg/targets/uninstall.mk b/cfg/targets/uninstall.mk index bc60ef8..2382d01 100644 --- a/cfg/targets/uninstall.mk +++ b/cfg/targets/uninstall.mk @@ -16,7 +16,7 @@ uninstall: @echo "Removing man pages" @for f in $(MANFILES) ; do \ - section=$(abspath $(DESTDIR)/$(MANDIR))/man`echo $$f | rev | cut -d "." -f 1` ;\ + section=$(abspath $(DESTDIR)/$(MANDIR))/man`echo $${f##*.}` ;\ file=$$section/$$f ;\ rm -f $$file $$file.gz ;\ done diff --git a/src/video_device.c b/src/video_device.c index 2fc2b46..c1e2a6d 100644 --- a/src/video_device.c +++ b/src/video_device.c @@ -37,10 +37,10 @@ #include #include #include -#if defined(__linux__) -#include -#else +#if defined(__OpenBSD__) || defined(__NetBSD__) #include +#else +#include #endif #endif @@ -71,7 +71,7 @@ typedef struct VideoDevice { void *cb_data; /* Data to be passed to callback */ int32_t friend_number; /* ToxAV friend number */ -#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#if !defined(__OSX__) int fd; /* File descriptor of video device selected/opened */ struct v4l2_format fmt; struct VideoBuffer *buffers; @@ -136,7 +136,7 @@ static void yuv420tobgr(uint16_t width, uint16_t height, const uint8_t *y, } } -#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#if !defined(__OSX__) static void yuv422to420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v, uint8_t *input, uint16_t width, uint16_t height) { @@ -748,7 +748,7 @@ void *video_thread_poll(void *arg) // TODO: maybe use thread for every input so XFlush(device->x_display); free(img_data); -#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#if !defined(__OSX__) if (-1 == xioctl(device->fd, VIDIOC_QBUF, &buf)) { unlock; @@ -813,9 +813,9 @@ VideoDeviceError close_video_device(VideoDeviceType type, uint32_t device_idx) XCloseDisplay(device->x_display); pthread_mutex_destroy(device->mutex); -#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#if !defined(__OSX__) free(device->buffers); -#endif /* __linux__ / BSD */ +#endif /* not __OSX__ */ free(device); } else {