kore/Makefile
Joris Vink 39a5f21986 Allow "kore build" to produce single binaries.
Producing single binaries can now be done with building with
"kore build". To get started edit your build.conf and add the
following directives:

single_binary = yes
kore_source = /path/to/kore

optionally you can add kore_flavor to instruct how kore should
be built:

kore_flavor = NOTLS=1

When doing this your build.conf must also include the correct
linking options as the linking is now done fully by kore build.

The binary produced will include your configuration and takes
over a few of kore its command line flags (such as -f, -n or -r).
2016-07-06 16:16:15 +02:00

103 lines
2.1 KiB
Makefile

# Kore Makefile
CC?=gcc
PREFIX?=/usr/local
OBJDIR?=obj
KORE=kore
INSTALL_DIR=$(PREFIX)/bin
INCLUDE_DIR=$(PREFIX)/include/kore
S_SRC= src/kore.c src/buf.c src/cli.c src/config.c src/connection.c \
src/domain.c src/mem.c src/msg.c src/module.c src/net.c \
src/pool.c src/timer.c src/utils.c src/worker.c src/keymgr.c
CFLAGS+=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
CFLAGS+=-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual
CFLAGS+=-Wsign-compare -Iincludes -std=c99 -pedantic
CFLAGS+=-DPREFIX='"$(PREFIX)"'
LDFLAGS=-rdynamic -lssl -lcrypto
ifneq ("$(DEBUG)", "")
CFLAGS+=-DKORE_DEBUG -g
NOOPT=1
endif
ifneq ("$(NOOPT)", "")
CFLAGS+=-O0
else
CFLAGS+=-O2
endif
ifneq ("$(NOHTTP)", "")
CFLAGS+=-DKORE_NO_HTTP
else
S_SRC+= src/auth.c src/accesslog.c src/http.c \
src/validator.c src/websocket.c
endif
ifneq ("$(NOTLS)", "")
CFLAGS+=-DKORE_NO_TLS
ifneq ("$(NOHTTP)", "")
LDFLAGS=-rdynamic
else
LDFLAGS=-rdynamic -lcrypto
endif
endif
ifneq ("$(PGSQL)", "")
S_SRC+=src/pgsql.c
LDFLAGS+=-L$(shell pg_config --libdir) -lpq
CFLAGS+=-I$(shell pg_config --includedir) -DKORE_USE_PGSQL \
-DPGSQL_INCLUDE_PATH="\"$(shell pg_config --includedir)\""
endif
ifneq ("$(TASKS)", "")
S_SRC+=src/tasks.c
LDFLAGS+=-lpthread
CFLAGS+=-DKORE_USE_TASKS
endif
OSNAME=$(shell uname -s | sed -e 's/[-_].*//g' | tr A-Z a-z)
ifeq ("$(OSNAME)", "darwin")
CFLAGS+=-I/opt/local/include/ -I/usr/local/opt/openssl/include
LDFLAGS+=-L/opt/local/lib -L/usr/local/opt/openssl/lib
S_SRC+=src/bsd.c
else ifeq ("$(OSNAME)", "linux")
CFLAGS+=-D_GNU_SOURCE=1
LDFLAGS+=-ldl
S_SRC+=src/linux.c
else
S_SRC+=src/bsd.c
endif
S_OBJS= $(S_SRC:src/%.c=$(OBJDIR)/%.o)
$(KORE): $(OBJDIR) $(S_OBJS)
$(CC) $(S_OBJS) $(LDFLAGS) -o $(KORE)
objects: $(OBJDIR) $(S_OBJS)
all: $(KORE)
$(OBJDIR):
@mkdir -p $(OBJDIR)
install:
mkdir -p $(INCLUDE_DIR)
mkdir -p $(INSTALL_DIR)
install -m 555 $(KORE) $(INSTALL_DIR)/$(KORE)
install -m 644 includes/*.h $(INCLUDE_DIR)
uninstall:
rm -f $(INSTALL_DIR)/$(KORE)
rm -rf $(INCLUDE_DIR)
$(OBJDIR)/%.o: src/%.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
find . -type f -name \*.o -exec rm {} \;
rm -rf $(KORE) $(OBJDIR)
.PHONY: all clean