2015-03-21 18:33:51 +01:00
|
|
|
BASE_DIR = $(shell pwd -P)
|
2014-08-19 18:22:57 +02:00
|
|
|
CFG_DIR = $(BASE_DIR)/cfg
|
2014-06-25 09:13:57 +02:00
|
|
|
|
2014-08-25 12:54:44 +02:00
|
|
|
-include $(CFG_DIR)/global_vars.mk
|
2014-08-21 10:29:15 +02:00
|
|
|
|
2018-10-02 23:31:14 +02:00
|
|
|
LIBS = toxcore ncursesw libconfig libcurl
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2020-11-26 21:51:13 +01:00
|
|
|
CFLAGS ?= -std=c99 -pthread -Wall -Wpedantic -Wunused -fstack-protector-all -Wvla -Wno-missing-braces
|
2014-09-24 20:23:08 +02:00
|
|
|
CFLAGS += '-DTOXICVER="$(VERSION)"' -DHAVE_WIDECHAR -D_XOPEN_SOURCE_EXTENDED -D_FILE_OFFSET_BITS=64
|
2014-09-19 10:45:27 +02:00
|
|
|
CFLAGS += '-DPACKAGE_DATADIR="$(abspath $(DATADIR))"'
|
2018-10-02 23:31:14 +02:00
|
|
|
CFLAGS += ${USER_CFLAGS}
|
|
|
|
LDFLAGS ?=
|
|
|
|
LDFLAGS += ${USER_LDFLAGS}
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2016-09-20 06:00:09 +02:00
|
|
|
OBJ = autocomplete.o avatars.o bootstrap.o chat.o chat_commands.o configdir.o curl_util.o execute.o
|
2021-01-19 04:37:14 +01:00
|
|
|
OBJ += file_transfers.o friendlist.o global_commands.o conference_commands.o conference.o help.o input.o line_info.o
|
|
|
|
OBJ += log.o message_queue.o misc_tools.o name_lookup.o notify.o prompt.o qr_code.o settings.o
|
|
|
|
OBJ += term_mplex.o toxic.o toxic_strings.o windows.o
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2020-11-26 21:51:13 +01:00
|
|
|
# Check if debug build is enabled
|
2021-01-19 21:21:31 +01:00
|
|
|
RELEASE := $(shell if [ -z "$(ENABLE_RELEASE)" ] || [ "$(ENABLE_RELEASE)" = "0" ] ; then echo disabled ; else echo enabled ; fi)
|
2020-11-26 21:51:13 +01:00
|
|
|
ifneq ($(RELEASE), enabled)
|
|
|
|
CFLAGS += -O0 -g -DDEBUG
|
|
|
|
LDFLAGS += -O0
|
|
|
|
else
|
|
|
|
CFLAGS += -O2 -flto
|
|
|
|
LDFLAGS += -O2 -flto
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Check if LLVM Address Sanitizer is enabled
|
2021-01-20 02:12:34 +01:00
|
|
|
ASAN := $(shell if [ -z "$(ENABLE_ASAN)" ] || [ "$(ENABLE_ASAN)" = "0" ] ; then echo disabled ; else echo enabled ; fi)
|
|
|
|
ifneq ($(ASAN), disabled)
|
2020-11-30 05:26:51 +01:00
|
|
|
CFLAGS += -fsanitize=address -fno-omit-frame-pointer
|
2020-11-26 21:51:13 +01:00
|
|
|
endif
|
|
|
|
|
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)
|
2018-10-02 23:31:14 +02:00
|
|
|
LDFLAGS += -ldl -lrt
|
2015-09-09 13:23:48 +02:00
|
|
|
endif
|
2015-03-15 20:27:00 +01:00
|
|
|
ifeq ($(UNAME_S), OpenBSD)
|
2018-10-02 23:31:14 +02:00
|
|
|
LIBS := $(filter-out ncursesw, $(LIBS))
|
|
|
|
LDFLAGS += -lncursesw
|
2015-03-15 20:27:00 +01:00
|
|
|
endif
|
2017-11-15 04:24:19 +01:00
|
|
|
ifeq ($(UNAME_S), NetBSD)
|
2018-10-02 23:31:14 +02:00
|
|
|
LIBS := $(filter-out ncursesw, $(LIBS))
|
|
|
|
LDFLAGS += -lncursesw
|
2017-11-15 04:24:19 +01:00
|
|
|
endif
|
2014-06-24 09:02:06 +02:00
|
|
|
ifeq ($(UNAME_S), Darwin)
|
2015-03-16 13:16:03 +01:00
|
|
|
-include $(CFG_DIR)/systems/Darwin.mk
|
2014-06-24 09:02:06 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Check on which platform we are running
|
|
|
|
UNAME_M = $(shell uname -m)
|
|
|
|
ifeq ($(UNAME_M), x86_64)
|
2015-03-16 13:16:03 +01:00
|
|
|
-include $(CFG_DIR)/platforms/x86_64.mk
|
2014-06-24 09:02:06 +02:00
|
|
|
endif
|
|
|
|
ifneq ($(filter %86, $(UNAME_M)),)
|
2015-03-16 13:16:03 +01:00
|
|
|
-include $(CFG_DIR)/platforms/x86.mk
|
2014-06-24 09:02:06 +02:00
|
|
|
endif
|
|
|
|
ifneq ($(filter arm%, $(UNAME_M)),)
|
2015-03-16 13:16:03 +01:00
|
|
|
-include $(CFG_DIR)/platforms/arm.mk
|
2014-07-22 09:59:44 +02:00
|
|
|
endif
|
|
|
|
|
2014-07-30 14:14:13 +02:00
|
|
|
# Include all needed checks
|
2014-08-19 18:22:57 +02:00
|
|
|
-include $(CFG_DIR)/checks/check_features.mk
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2015-03-21 18:33:51 +01:00
|
|
|
# Fix path for object files
|
|
|
|
OBJ := $(addprefix $(BUILD_DIR)/, $(OBJ))
|
|
|
|
|
2014-06-24 00:17:14 +02:00
|
|
|
# Targets
|
2015-03-21 18:33:51 +01:00
|
|
|
all: $(BUILD_DIR)/toxic
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2015-03-21 18:33:51 +01:00
|
|
|
$(BUILD_DIR)/toxic: $(OBJ)
|
|
|
|
@echo " LD $(@:$(BUILD_DIR)/%=%)"
|
2016-10-06 11:50:21 +02:00
|
|
|
@$(CC) $(CFLAGS) -o $(BUILD_DIR)/toxic $(OBJ) $(LDFLAGS)
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2015-08-20 13:39:47 +02:00
|
|
|
$(BUILD_DIR)/osx_video.o: $(SRC_DIR)/$(OSX_VIDEO)
|
|
|
|
@echo " CC $(@:$(BUILD_DIR)/)osx_video.o"
|
|
|
|
@$(CC) $(CFLAGS) -o $(BUILD_DIR)/osx_video.o -c $(SRC_DIR)/$(OSX_VIDEO)
|
|
|
|
|
2015-03-21 18:33:51 +01:00
|
|
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
|
|
|
|
@if [ ! -e $(BUILD_DIR) ]; then \
|
|
|
|
mkdir -p $(BUILD_DIR) ;\
|
|
|
|
fi
|
|
|
|
@echo " CC $(@:$(BUILD_DIR)/%=%)"
|
|
|
|
@$(CC) $(CFLAGS) -o $(BUILD_DIR)/$*.o -c $(SRC_DIR)/$*.c
|
2020-10-24 12:52:25 +02:00
|
|
|
@$(CC) -MM $(CFLAGS) $(SRC_DIR)/$*.c >$(BUILD_DIR)/$*.d
|
2014-06-23 11:09:01 +02:00
|
|
|
|
|
|
|
clean:
|
2015-03-21 19:31:00 +01:00
|
|
|
rm -f $(BUILD_DIR)/*.d $(BUILD_DIR)/*.o $(BUILD_DIR)/toxic
|
2014-06-23 11:09:01 +02:00
|
|
|
|
2015-03-21 18:33:51 +01:00
|
|
|
-include $(BUILD_DIR)/$(OBJ:.o=.d)
|
2014-06-23 21:55:32 +02:00
|
|
|
|
2014-08-19 18:22:57 +02:00
|
|
|
-include $(CFG_DIR)/targets/*.mk
|
2014-07-30 14:14:13 +02:00
|
|
|
|
2014-08-25 12:54:44 +02:00
|
|
|
.PHONY: clean all
|