include ../Hsml/CONFIG
include ../../CONFIG
MODS=BasicExec Hello noupdir unicode Mime LoadBalancing MyReq CleanLog
HSMLEXEC_MOD=HsmlExec.so
HSMLEXEC_OBJS=HsmlExec.o ../Hsml/Cache.o ../Hsml/Headers.o ../Hsml/SubLang.o
CFLAGS+=${DEFS}
CFLAGS+=-I/usr/pkg/include 
PICFLAGS?=-fPIC
#libscrews.a
LDFLAGS+=${COMPILER_RPATH_FLAG}${PREFIX}/lib -L${PREFIX}/lib -L. 
#-lscrews

all: hsmlexec
	@if [ "${DLOPEN}" = "1" ]; then \
	for A in $(MODS); do  \
		echo "[modules] $$A.so";  \
		$(CC) ${CFLAGS} ${PICFLAGS} -c $$A.c ; \
		$(CC) ${LDFLAGS} -o $$A.so -shared $$A.o ; done ; fi
	@echo "** BUILD MODULES ** OK"

hsmlexec:
	@rm -f HsmlExec.o
	@if [ "${INCORE_LUA}" = "1" ]; then \
           echo "[modules] HsmlExec.so << injecting lua into the core." ;\
	   ${CC} ${CFLAGS} ${PICFLAGS} -DINCORE_LUA=1 -c HsmlExec.c ;\
	   ${CC} ${LDFLAGS} -lm -llua ${HSMLEXEC_OBJS} -shared -o ${HSMLEXEC_MOD} ;\
	else \
	$(CC) ${CFLAGS} ${PICFLAGS} -c HsmlExec.c ;\
	$(CC) ${LDFLAGS} ${HSMLEXEC_OBJS} -shared -o ${HSMLEXEC_MOD} ;\
	fi
	
clean:
	@echo "** REMOVE MODULES **"
	@rm -f *.o
	@for A in $(MODS); do rm -f $$A.so $$A; done

todo:
	@grep -e TODO -e XXX *.c
