-@ifndef@ INCPATH
+ifndef INCPATH
INCPATH=../
-@endif@
+endif
+CONFIGURED=1
CFLAGS=
+LEX=flex
+MFLAGS=
-@sinclude@ @includel@$(INCPATH)settings.mk@includel@
+ifeq (${HOOKS_NEW},1)
+HOOK_ENGINE=new
+else
+HOOK_ENGINE=old
+endif
-@ifndef@ BUILDID
-BUILDID @shell@ (hg id || echo "unknown") | sed -e "s/+ /-/" @shellend@
-@endif@
+# if USE_VALGRIND == 1
+ifeq (${USE_VALGRIND},1)
+ CFLAGS+=-DUSE_VALGRIND
+ SSTRING_ENGINE=valgrind
-.SUFFIXES: .so
+## if SSTRING_NEW == 1
+ifeq (${SSTRING_NEW},1)
+ IMPOSSIBLE="USE_VALGRIND and SSTRING_NEW"
+endif # SSTRING_NEW == 1
+
+## if SSTRING_MMAP == 1
+ifeq (${SSTRING_MMAP},1)
+ IMPOSSIBLE="USE_VALGRIND and SSTRING_MMAP"
+endif ## SSTRING_MMAP == 1
+else # USE_VALGRIND == 1
+
+## if SSTRING_NEW == 1
+ifeq (${SSTRING_NEW},1)
+ SSTRING_ENGINE=new
+else ## SSTRING_NEW == 1
+ SSTRING_ENGINE=old
+
+### if SSTRING_MMAP == 1
+ifeq (${SSTRING_MMAP},1)
+ IMPOSSIBLE="SSTRING_MMAP without SSTRING_NEW"
+endif ### SSTRING_MMAP == 1
+endif ## SSTRING_NEW == 1
+endif # USE_VALGRIND == 1
+
+ifdef IMPOSSIBLE
+$(error impossible combination of settings: ${IMPOSSIBLE})
+endif
+
+ifndef BUILDID
+BUILDID = $(shell (hg id || echo "unknown") | sed -e "s/[()]//g;s/+ /+/g;s/ /-/g" )
+endif
+MFLAGS+=BUILDID=$(BUILDID)
+
+.SUFFIXES: .so .y .l
.o.so:
- ld -shared -Bdynamic $(LDFLAGS) -o $@ @srcs@
+ $(CC) -nostartfiles -shared -o $@ $^ $(LDFLAGS)
+
+.y.c: ;
+
+.l.c: ;
+
+default: all
+
+CFLAGS+=-I./ -DBUILDID=$(BUILDID) -fPIC
+CFLAGS+=-Wall -g -finline-functions -funroll-loops -Werror=format-security
-CC=gcc
-CFLAGS+=-Wall -g -finline-functions -funroll-loops -std=c99 -I./ -DBUILDID=$(BUILDID)
-CFLAGS+=-fPIC -export-dynamic
+ifndef CLANG
+ifndef NOC99
+CFLAGS+=-std=c99
+endif
+CFLAGS+=-export-dynamic
+endif