2017-07-29 22:00:34 +02:00
|
|
|
USE_DB=TRUE
|
2018-02-10 11:22:41 +01:00
|
|
|
USE_SSL = TRUE
|
2015-10-22 11:39:11 +02:00
|
|
|
CC=gcc
|
|
|
|
EXT=dylib
|
2018-03-19 11:32:10 +01:00
|
|
|
BUILDIRD=build
|
2015-12-02 11:44:17 +01:00
|
|
|
UNAME_S := $(shell uname -s)
|
2015-12-02 11:42:40 +01:00
|
|
|
ifeq ($(UNAME_S),Linux)
|
2016-12-12 20:17:05 +01:00
|
|
|
BUILDIRD=/opt/www
|
2016-11-01 18:30:45 +01:00
|
|
|
PF_FLAG=-D_GNU_SOURCE -DLINUX
|
2015-12-02 11:42:40 +01:00
|
|
|
endif
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
2018-09-05 23:26:21 +02:00
|
|
|
BUILDIRD=/Users/mrsang/Documents/build/www
|
2016-11-01 18:30:45 +01:00
|
|
|
PF_FLAG= -DMACOS
|
2018-02-10 11:22:41 +01:00
|
|
|
SSL_HEADER_PATH = -I/usr/local/opt/openssl/include
|
|
|
|
SSL_LIB_PATH = -L/usr/local/opt/openssl/lib
|
2015-12-02 11:42:40 +01:00
|
|
|
endif
|
2017-07-29 22:00:34 +02:00
|
|
|
|
|
|
|
ifeq ($(USE_DB),TRUE)
|
2018-02-09 13:13:11 +01:00
|
|
|
DB_OBJ=libs/dbhelper.o
|
2017-07-29 22:00:34 +02:00
|
|
|
DB_LIB=-lsqlite3
|
|
|
|
DB_FLAG=-D USE_DB
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(USE_DB),FALSE)
|
|
|
|
DB_OBJ=
|
|
|
|
DB_LIB=
|
|
|
|
DB_FLAG=
|
|
|
|
endif
|
|
|
|
|
2018-02-10 11:22:41 +01:00
|
|
|
ifeq ($(USE_SSL),TRUE)
|
|
|
|
SSL_LIB= $(SSL_LIB_PATH) -lssl -lcrypto
|
|
|
|
SSL_FLAG=-D USE_OPENSSL
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(USE_SSL),FALSE)
|
|
|
|
SSL_LIB=
|
|
|
|
SSL_FLAG=
|
|
|
|
SSL_HEADER_PATH =
|
|
|
|
SSL_LIB_PATH =
|
|
|
|
endif
|
|
|
|
|
2017-07-29 22:00:34 +02:00
|
|
|
|
2018-02-10 11:22:41 +01:00
|
|
|
CFLAGS= -W -Wall -g -std=c99 -D DEBUG $(DB_FLAG) $(PF_FLAG) $(SSL_FLAG) $(SSL_HEADER_PATH)
|
2017-07-29 22:00:34 +02:00
|
|
|
|
|
|
|
LIB_PATH=$(BUILDIRD)/plugins
|
|
|
|
LIB_NAME=libantd
|
2017-06-11 16:33:48 +02:00
|
|
|
LIB_FLAG= $(LIB_NAME).$(EXT)
|
2018-02-10 17:02:17 +01:00
|
|
|
SERVERLIB= -ldl $(LIB_FLAG) $(DB_LIB) $(SSL_LIB) -lpthread
|
2017-07-29 22:00:34 +02:00
|
|
|
|
|
|
|
SERVER_O=plugin_manager.o \
|
2017-07-30 01:00:36 +02:00
|
|
|
http_server.o
|
2015-10-22 11:39:11 +02:00
|
|
|
#-lsocket
|
2018-03-02 23:28:43 +01:00
|
|
|
PLUGINS= pluginsman.$(EXT) wterm.$(EXT) nodedaemon.$(EXT) wsimg.$(EXT)
|
2015-10-22 11:39:11 +02:00
|
|
|
|
2018-02-09 13:13:11 +01:00
|
|
|
LIBOBJS = libs/ini.o \
|
|
|
|
libs/handle.o \
|
2017-07-29 22:00:34 +02:00
|
|
|
$(DB_OBJ) \
|
2018-02-09 13:13:11 +01:00
|
|
|
libs/dictionary.o \
|
|
|
|
libs/base64.o \
|
|
|
|
libs/utils.o \
|
|
|
|
libs/ws.o \
|
|
|
|
libs/sha1.o \
|
|
|
|
libs/list.o
|
2017-07-29 22:00:34 +02:00
|
|
|
|
2018-02-09 13:13:11 +01:00
|
|
|
PLUGINSDEP = libs/plugin.o
|
2017-07-29 22:00:34 +02:00
|
|
|
|
2015-10-22 11:39:11 +02:00
|
|
|
|
2016-02-26 14:32:13 +01:00
|
|
|
main: httpd plugins
|
2015-10-22 11:39:11 +02:00
|
|
|
|
2018-03-19 11:32:10 +01:00
|
|
|
initd:
|
2018-03-19 11:35:56 +01:00
|
|
|
-mkdir -p $(LIB_PATH)
|
2015-10-22 11:39:11 +02:00
|
|
|
|
2017-07-29 22:00:34 +02:00
|
|
|
httpd: lib $(SERVER_O)
|
2018-02-10 17:07:19 +01:00
|
|
|
$(CC) $(CFLAGS) $(SERVER_O) -o $(BUILDIRD)/httpd httpd.c $(SERVERLIB)
|
2016-10-31 20:59:27 +01:00
|
|
|
cp antd $(BUILDIRD)
|
2015-10-22 11:39:11 +02:00
|
|
|
|
2017-07-29 22:00:34 +02:00
|
|
|
lib: $(LIBOBJS)
|
2018-02-10 11:22:41 +01:00
|
|
|
$(CC) $(CFLAGS) $(DB_LIB) $(SSL_LIB) -shared -o $(LIB_NAME).$(EXT) $(LIBOBJS)
|
2017-06-11 16:33:48 +02:00
|
|
|
cp $(LIB_NAME).$(EXT) $(LIB_PATH$)/
|
2015-10-22 11:39:11 +02:00
|
|
|
%.o: %.c
|
2016-11-23 23:33:49 +01:00
|
|
|
$(CC) -fPIC $(CFLAGS) -c $< -o $@
|
2017-07-29 22:00:34 +02:00
|
|
|
|
2015-10-22 11:39:11 +02:00
|
|
|
plugins: $(PLUGINS)
|
|
|
|
|
|
|
|
%.$(EXT): $(PLUGINSDEP)
|
2018-02-09 13:13:11 +01:00
|
|
|
for file in $(wildcard libs/$(basename $@)/*.c) ; do\
|
2016-11-01 12:33:18 +01:00
|
|
|
$(CC) -fPIC $(CFLAGS) -c $$file -o $$file.o; \
|
2015-10-22 11:39:11 +02:00
|
|
|
done
|
2017-07-29 22:00:34 +02:00
|
|
|
$(CC) $(CFLAGS) $(PLUGINLIBS) $(LIB_FLAG) -shared -o $(BUILDIRD)/plugins/$(basename $@).$(EXT) \
|
2018-02-09 13:13:11 +01:00
|
|
|
$(PLUGINSDEP) libs/$(basename $@)/*.c.o
|
2015-10-22 11:39:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
clean: sclean pclean
|
|
|
|
|
|
|
|
sclean:
|
2017-07-29 22:00:34 +02:00
|
|
|
-rm -f *.o $(BUILDIRD)/httpd
|
|
|
|
-rm *.$(EXT)
|
2015-10-22 11:39:11 +02:00
|
|
|
pclean:
|
2018-02-10 11:22:41 +01:00
|
|
|
-rm -rf $(BUILDIRD)/plugins/* libs/*.o
|
|
|
|
-for file in libs/* ;do \
|
2015-10-22 11:39:11 +02:00
|
|
|
if [ -d "$$file" ]; then \
|
|
|
|
rm "$$file"/*.o; \
|
|
|
|
fi \
|
|
|
|
done
|
2016-12-12 20:17:05 +01:00
|
|
|
.PRECIOUS: %.o
|