2013-04-17 22:34:27 +02:00
|
|
|
# Kore Makefile
|
|
|
|
|
2018-06-19 19:05:55 +02:00
|
|
|
CC?=cc
|
2014-12-11 23:58:15 +01:00
|
|
|
PREFIX?=/usr/local
|
2016-07-06 16:16:15 +02:00
|
|
|
OBJDIR?=obj
|
2014-08-01 10:46:50 +02:00
|
|
|
KORE=kore
|
2017-02-19 06:52:29 +01:00
|
|
|
KODEV=kodev/kodev
|
2018-10-17 11:31:36 +02:00
|
|
|
KORE_CRYPTO?=crypto
|
2014-12-11 23:58:15 +01:00
|
|
|
INSTALL_DIR=$(PREFIX)/bin
|
2018-06-19 22:40:55 +02:00
|
|
|
MAN_DIR=$(PREFIX)/share/man
|
2017-02-19 06:52:29 +01:00
|
|
|
SHARE_DIR=$(PREFIX)/share/kore
|
2014-12-11 23:58:15 +01:00
|
|
|
INCLUDE_DIR=$(PREFIX)/include/kore
|
2013-04-17 22:34:27 +02:00
|
|
|
|
2018-06-19 19:05:55 +02:00
|
|
|
VERSION=src/version.c
|
|
|
|
|
2017-02-09 11:30:44 +01:00
|
|
|
S_SRC= src/kore.c src/buf.c src/config.c src/connection.c \
|
2018-06-28 13:27:44 +02:00
|
|
|
src/domain.c src/filemap.c src/fileref.c src/mem.c src/msg.c \
|
|
|
|
src/module.c src/net.c src/pool.c src/runtime.c src/timer.c \
|
|
|
|
src/utils.c src/worker.c src/keymgr.c $(VERSION)
|
2013-04-17 22:34:27 +02:00
|
|
|
|
2017-02-09 11:30:44 +01:00
|
|
|
FEATURES=
|
2017-02-19 06:52:29 +01:00
|
|
|
FEATURES_INC=
|
2017-02-09 11:30:44 +01:00
|
|
|
|
2016-02-01 15:33:40 +01:00
|
|
|
CFLAGS+=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
|
2013-04-17 22:34:27 +02:00
|
|
|
CFLAGS+=-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual
|
2018-03-30 13:45:29 +02:00
|
|
|
CFLAGS+=-Wsign-compare -Iinclude/kore -std=c99 -pedantic
|
2018-02-14 13:48:49 +01:00
|
|
|
CFLAGS+=-DPREFIX='"$(PREFIX)"' -fstack-protector-all
|
2018-11-28 13:54:38 +01:00
|
|
|
|
|
|
|
ifneq ("$(OPENSSL_PATH)", "")
|
|
|
|
CFLAGS+=-I$(OPENSSL_PATH)/include
|
|
|
|
LDFLAGS=-rdynamic -L$(OPENSSL_PATH) -lssl -l$(KORE_CRYPTO)
|
|
|
|
else
|
2018-10-17 11:31:36 +02:00
|
|
|
LDFLAGS=-rdynamic -lssl -l$(KORE_CRYPTO)
|
2018-11-28 13:54:38 +01:00
|
|
|
endif
|
2013-06-17 23:39:17 +02:00
|
|
|
|
2017-02-19 06:52:29 +01:00
|
|
|
ifneq ("$(KORE_SINGLE_BINARY)", "")
|
2017-02-09 11:30:44 +01:00
|
|
|
CFLAGS+=-DKORE_SINGLE_BINARY
|
|
|
|
FEATURES+=-DKORE_SINGLE_BINARY
|
|
|
|
endif
|
|
|
|
|
2013-11-21 12:00:07 +01:00
|
|
|
ifneq ("$(DEBUG)", "")
|
2016-02-01 15:33:40 +01:00
|
|
|
CFLAGS+=-DKORE_DEBUG -g
|
2017-02-09 11:30:44 +01:00
|
|
|
FEATURES+=-DKORE_DEBUG
|
2016-02-13 14:21:09 +01:00
|
|
|
NOOPT=1
|
2016-02-01 15:33:40 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ("$(NOOPT)", "")
|
|
|
|
CFLAGS+=-O0
|
|
|
|
else
|
2018-07-09 09:45:10 +02:00
|
|
|
CFLAGS+=-O2
|
2013-11-16 13:30:47 +01:00
|
|
|
endif
|
|
|
|
|
2018-06-28 13:27:44 +02:00
|
|
|
ifneq ("$(NOSENDFILE)", "")
|
|
|
|
CFLAGS+=-DKORE_NO_SENDFILE
|
|
|
|
endif
|
|
|
|
|
2015-11-27 16:22:50 +01:00
|
|
|
ifneq ("$(NOHTTP)", "")
|
|
|
|
CFLAGS+=-DKORE_NO_HTTP
|
2017-02-09 11:30:44 +01:00
|
|
|
FEATURES+=-DKORE_NO_HTTP
|
2015-11-27 16:22:50 +01:00
|
|
|
else
|
|
|
|
S_SRC+= src/auth.c src/accesslog.c src/http.c \
|
2015-12-04 14:11:37 +01:00
|
|
|
src/validator.c src/websocket.c
|
2014-04-22 12:46:23 +02:00
|
|
|
endif
|
|
|
|
|
2015-05-25 15:42:34 +02:00
|
|
|
ifneq ("$(NOTLS)", "")
|
|
|
|
CFLAGS+=-DKORE_NO_TLS
|
2017-02-09 11:30:44 +01:00
|
|
|
FEATURES+=-DKORE_NO_TLS
|
2015-11-27 16:22:50 +01:00
|
|
|
ifneq ("$(NOHTTP)", "")
|
|
|
|
LDFLAGS=-rdynamic
|
|
|
|
else
|
2018-10-17 11:31:36 +02:00
|
|
|
LDFLAGS=-rdynamic -l$(KORE_CRYPTO)
|
2015-11-27 16:22:50 +01:00
|
|
|
endif
|
2014-08-01 10:22:32 +02:00
|
|
|
endif
|
|
|
|
|
2014-03-30 23:54:35 +02:00
|
|
|
ifneq ("$(PGSQL)", "")
|
2014-07-02 12:19:38 +02:00
|
|
|
S_SRC+=src/pgsql.c
|
2014-04-02 00:06:24 +02:00
|
|
|
LDFLAGS+=-L$(shell pg_config --libdir) -lpq
|
2014-08-03 17:33:40 +02:00
|
|
|
CFLAGS+=-I$(shell pg_config --includedir) -DKORE_USE_PGSQL \
|
|
|
|
-DPGSQL_INCLUDE_PATH="\"$(shell pg_config --includedir)\""
|
2017-02-19 06:52:29 +01:00
|
|
|
FEATURES+=-DKORE_USE_PGSQL
|
|
|
|
FEATURES_INC+=-I$(shell pg_config --includedir)
|
2014-03-30 23:54:35 +02:00
|
|
|
endif
|
|
|
|
|
2014-06-28 16:17:18 +02:00
|
|
|
ifneq ("$(TASKS)", "")
|
2014-07-02 12:19:38 +02:00
|
|
|
S_SRC+=src/tasks.c
|
2014-06-28 16:17:18 +02:00
|
|
|
LDFLAGS+=-lpthread
|
|
|
|
CFLAGS+=-DKORE_USE_TASKS
|
2017-02-09 11:30:44 +01:00
|
|
|
FEATURES+=-DKORE_USE_TASKS
|
2014-06-28 16:17:18 +02:00
|
|
|
endif
|
|
|
|
|
2016-07-12 13:33:21 +02:00
|
|
|
ifneq ("$(JSONRPC)", "")
|
|
|
|
S_SRC+=src/jsonrpc.c
|
|
|
|
LDFLAGS+=-lyajl
|
|
|
|
CFLAGS+=-DKORE_USE_JSONRPC
|
2017-02-09 11:30:44 +01:00
|
|
|
FEATURES+=-DKORE_USE_JSONRPC
|
2016-07-12 13:33:21 +02:00
|
|
|
endif
|
|
|
|
|
2017-01-12 23:38:51 +01:00
|
|
|
ifneq ("$(PYTHON)", "")
|
|
|
|
S_SRC+=src/python.c
|
2018-10-17 11:31:36 +02:00
|
|
|
KORE_PYTHON_LIB?=$(shell python3-config --ldflags)
|
|
|
|
KORE_PYTHON_INC?=$(shell python3-config --includes)
|
|
|
|
LDFLAGS+=$(KORE_PYTHON_LIB)
|
|
|
|
CFLAGS+=$(KORE_PYTHON_INC) -DKORE_USE_PYTHON
|
2017-02-19 06:52:29 +01:00
|
|
|
FEATURES+=-DKORE_USE_PYTHON
|
2018-10-17 11:31:36 +02:00
|
|
|
FEATURES_INC+=$(KORE_PYTHON_INC)
|
2017-01-12 23:38:51 +01:00
|
|
|
endif
|
|
|
|
|
2019-04-24 00:10:47 +02:00
|
|
|
ifneq ("$(CURL)", "")
|
|
|
|
S_SRC+=src/curl.c
|
|
|
|
KORE_CURL_LIB?=$(shell pkg-config --libs libcurl)
|
|
|
|
KORE_CURL_INC?=$(shell pkg-config --cflags libcurl)
|
|
|
|
LDFLAGS+=$(KORE_CURL_LIB)
|
|
|
|
CFLAGS+=$(KORE_CURL_INC) -DKORE_USE_CURL
|
|
|
|
FEATURES+=-DKORE_USE_CURL
|
|
|
|
FEATURES_INC+=$(KORE_CURL_INC)
|
|
|
|
endif
|
|
|
|
|
2018-06-12 19:43:10 +02:00
|
|
|
ifneq ("$(SANITIZE)", "")
|
|
|
|
CFLAGS+=-fsanitize=$(SANITIZE)
|
|
|
|
LDFLAGS+=-fsanitize=$(SANITIZE)
|
|
|
|
endif
|
|
|
|
|
2013-11-16 12:41:58 +01:00
|
|
|
OSNAME=$(shell uname -s | sed -e 's/[-_].*//g' | tr A-Z a-z)
|
|
|
|
ifeq ("$(OSNAME)", "darwin")
|
2014-10-13 11:53:56 +02:00
|
|
|
CFLAGS+=-I/opt/local/include/ -I/usr/local/opt/openssl/include
|
|
|
|
LDFLAGS+=-L/opt/local/lib -L/usr/local/opt/openssl/lib
|
2013-11-16 12:41:58 +01:00
|
|
|
S_SRC+=src/bsd.c
|
|
|
|
else ifeq ("$(OSNAME)", "linux")
|
2018-02-14 13:48:49 +01:00
|
|
|
CFLAGS+=-D_GNU_SOURCE=1 -D_FORTIFY_SOURCE=2
|
2013-11-16 12:41:58 +01:00
|
|
|
LDFLAGS+=-ldl
|
|
|
|
S_SRC+=src/linux.c
|
|
|
|
else
|
|
|
|
S_SRC+=src/bsd.c
|
2016-07-15 22:33:58 +02:00
|
|
|
ifneq ("$(JSONRPC)", "")
|
2016-07-15 22:34:21 +02:00
|
|
|
CFLAGS+=-I/usr/local/include
|
2016-07-15 22:33:58 +02:00
|
|
|
LDFLAGS+=-L/usr/local/lib
|
|
|
|
endif
|
2013-11-16 12:41:58 +01:00
|
|
|
endif
|
|
|
|
|
2016-07-06 16:16:15 +02:00
|
|
|
S_OBJS= $(S_SRC:src/%.c=$(OBJDIR)/%.o)
|
|
|
|
|
2018-06-19 19:05:55 +02:00
|
|
|
all: $(VERSION) $(KORE) $(KODEV)
|
|
|
|
|
|
|
|
$(VERSION): force
|
|
|
|
@if [ -d .git ]; then \
|
|
|
|
GIT_REVISION=`git rev-parse --short=8 HEAD`; \
|
|
|
|
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`; \
|
|
|
|
rm -f $(VERSION); \
|
|
|
|
printf "const char *kore_version = \"%s-%s\";\n" \
|
|
|
|
$$GIT_BRANCH $$GIT_REVISION > $(VERSION); \
|
|
|
|
elif [ -f RELEASE ]; then \
|
|
|
|
printf "const char *kore_version = \"%s\";\n" \
|
|
|
|
`cat RELEASE` > $(VERSION); \
|
|
|
|
else \
|
|
|
|
echo "No version information found (no .git or RELEASE)"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2017-02-19 06:52:29 +01:00
|
|
|
|
|
|
|
$(KODEV):
|
|
|
|
$(MAKE) -C kodev
|
|
|
|
|
2016-07-06 16:16:15 +02:00
|
|
|
$(KORE): $(OBJDIR) $(S_OBJS)
|
2014-08-02 13:01:58 +02:00
|
|
|
$(CC) $(S_OBJS) $(LDFLAGS) -o $(KORE)
|
2017-08-30 12:03:58 +02:00
|
|
|
@echo $(FEATURES) $(FEATURES_INC) > kore.features
|
2013-04-17 22:34:27 +02:00
|
|
|
|
2016-07-06 16:16:15 +02:00
|
|
|
objects: $(OBJDIR) $(S_OBJS)
|
2017-02-09 11:30:44 +01:00
|
|
|
@echo $(LDFLAGS) > $(OBJDIR)/ldflags
|
2017-02-19 06:52:29 +01:00
|
|
|
@echo "$(FEATURES) $(FEATURES_INC)" > $(OBJDIR)/features
|
2015-07-25 19:10:48 +02:00
|
|
|
|
2016-07-06 16:16:15 +02:00
|
|
|
$(OBJDIR):
|
|
|
|
@mkdir -p $(OBJDIR)
|
|
|
|
|
2018-06-28 13:27:44 +02:00
|
|
|
install:
|
2017-02-19 06:52:29 +01:00
|
|
|
mkdir -p $(SHARE_DIR)
|
2014-07-03 22:39:16 +02:00
|
|
|
mkdir -p $(INCLUDE_DIR)
|
2014-12-11 23:58:15 +01:00
|
|
|
mkdir -p $(INSTALL_DIR)
|
2018-06-19 22:40:55 +02:00
|
|
|
mkdir -p $(MAN_DIR)/man1
|
|
|
|
install -m 644 share/man/kodev.1 $(MAN_DIR)/man1/kodev.1
|
2014-08-01 10:46:50 +02:00
|
|
|
install -m 555 $(KORE) $(INSTALL_DIR)/$(KORE)
|
2017-02-19 06:52:29 +01:00
|
|
|
install -m 644 kore.features $(SHARE_DIR)/features
|
2018-03-30 13:47:12 +02:00
|
|
|
install -m 644 include/kore/*.h $(INCLUDE_DIR)
|
2017-02-19 06:52:29 +01:00
|
|
|
$(MAKE) -C kodev install
|
2014-07-03 21:38:16 +02:00
|
|
|
|
|
|
|
uninstall:
|
2014-08-01 10:46:50 +02:00
|
|
|
rm -f $(INSTALL_DIR)/$(KORE)
|
2014-07-03 22:39:16 +02:00
|
|
|
rm -rf $(INCLUDE_DIR)
|
2017-02-19 06:52:29 +01:00
|
|
|
rm -rf $(SHARE_DIR)
|
|
|
|
$(MAKE) -C kodev uninstall
|
2014-07-03 21:38:16 +02:00
|
|
|
|
2016-07-06 16:16:15 +02:00
|
|
|
$(OBJDIR)/%.o: src/%.c
|
2013-04-17 22:34:27 +02:00
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
clean:
|
2018-06-22 23:02:57 +02:00
|
|
|
rm -f $(VERSION)
|
2014-03-30 23:54:35 +02:00
|
|
|
find . -type f -name \*.o -exec rm {} \;
|
2017-02-19 06:52:29 +01:00
|
|
|
rm -rf $(KORE) $(OBJDIR) kore.features
|
|
|
|
$(MAKE) -C kodev clean
|
2018-11-29 21:13:34 +01:00
|
|
|
|
|
|
|
releng-build-examples:
|
|
|
|
rm -rf /tmp/kore_releng
|
|
|
|
$(MAKE) clean
|
|
|
|
$(MAKE) PYTHON=1 PGSQL=1 TASKS=1 PREFIX=/tmp/kore_releng
|
|
|
|
$(MAKE) install PREFIX=/tmp/kore_releng
|
|
|
|
$(MAKE) -C examples
|
2013-11-16 12:41:58 +01:00
|
|
|
|
2018-06-19 19:05:55 +02:00
|
|
|
.PHONY: all clean force
|