Now you can choose sstring/hook/event engines by setting a line in settings.mk instead of messing around with defines.
@sinclude@ @includel@$(INCPATH)defaults.mk@includel@
@sinclude@ @includel@$(INCPATH)settings.mk@includel@
+@ifeq@${HOOKS_NEW}@ifeqsep@1@ifeqend@
+HOOK_ENGINE=old
+@else@
+HOOK_ENGINE=new
+@endif@
+
+# if USE_VALGRIND == 1
+@ifeq@${USE_VALGRIND}@ifeqsep@1@ifeqend@
+ CFLAGS+=-DUSE_VALGRIND
+ SSTRING_ENGINE=valgrind
+
+ # if SSTRING_NEW == 1
+ @ifeq@${SSTRING_NEW}@ifeqsep@1@ifeqend@
+ IMPOSSIBLE="USE_VALGRIND and SSTRING_NEW"
+ @endif@
+
+ # if SSTRING_MMAP == 1
+ @ifeq@${SSTRING_MMAP}@ifeqsep@1@ifeqend@
+ IMPOSSIBLE="USE_VALGRIND and SSTRING_MMAP"
+ @endif@
+@else@
+
+ # if SSTRING_NEW == 1
+ @ifeq@${SSTRING_NEW}@ifeqsep@1@ifeqend@
+ SSTRING_ENGINE=new
+ @else@
+ SSTRING_ENGINE=old
+
+ # if SSTRING_MMAP == 1
+ @ifeq@${SSTRING_MMAP}@ifeqsep@1@ifeqend@
+ IMPOSSIBLE="SSTRING_MMAP without SSTRING_NEW"
+ @endif@
+ @endif@
+@endif@
+
+@ifeq@${SSTRING_NEW}@ifeqsep@1@ifeqend@
+HOOK_ENGINE=old
+@else@
+HOOK_ENGINE=new
+@endif@
+
+@ifdef@ IMPOSSIBLE
+@error@ impossible combination of settings: ${IMPOSSIBLE}@errorend@
+@endif@
+
@ifndef@ BUILDID
BUILDID @shell@ (hg id || echo "unknown") | sed -e "s/+ /-/;s/ /-/" @shellend@
@endif@
@include@ @includel@../build.mk@includel@
-default: all
-
-.PHONY: kqueue epoll poll hooks-new hooks-old
-
-events.c:
- rm -f events.c
- ln -s events-poll.c events.c
-
-kqueue:
- rm -f events.c events.o
- ln -s events-kqueue.c events.c
-
-epoll:
- rm -f events.c events.o
- ln -s events-epoll.c events.c
-
-poll:
- rm -f events.c events.o
- ln -s events-poll.c events.c
-
-hooks.c:
- rm -f hooks.c
- ln -s hooks-old.c hooks.c
-
-hooks-new:
- rm -f hooks.c hooks.o ../newserv
- ln -s hooks-new.c hooks.c
-
-hooks-old:
- rm -f hooks.c hooks.o ../newserv
- ln -s hooks-old.c hooks.c
-
.PHONY: all
-all: events.c main.o events.o schedule.o hooks.o error.o modules.o config.o schedulealloc.o nsmalloc.o
+default: all
+
+all: events-${EVENT_ENGINE}.o main.o schedule.o hooks-${HOOK_ENGINE}.o error.o modules.o config.o schedulealloc.o nsmalloc.o
+# copy these into settings.mk, do NOT alter here
+EVENT_ENGINE=poll
NEWSEARCH_NEWPARSER=0
+USE_VALGRIND=0
+SSTRING_NEW=0
+SSTRING_MMAP=0
+HOOKS_NEW=0
@include@ @includel@../build.mk@includel@
-.PHONY: sstring-new sstring-old
+.PHONY: all
default: all
-sstring.c:
- rm -f sstring.c sstring.h
- ln -s sstring-old.h sstring.h
- ln -s sstring-old.c sstring.c
-
-sstring-new:
- rm -f sstring.c sstring.h
- ln -s sstring-new.h sstring.h
- ln -s sstring-new.c sstring.c
- @echo "WARNING: you must recompile newserv from scratch to use a different string library (make clean)"
-
-sstring-old:
- rm -f sstring.c sstring.h
- ln -s sstring-old.h sstring.h
- ln -s sstring-old.c sstring.c
- @echo "WARNING: you must recompile newserv from scratch to use a different string library (make clean)"
-
-.PHONY: all
-all: sstring.o array.o splitline.o base64.o flags.o irc_string.o strlfunc.o sha1.o irc_ipv6.o rijndael.o sha2.o hmac.o prng.o md5.o stringbuf.o
+all: sstring-${SSTRING_ENGINE}.o array.o splitline.o base64.o flags.o irc_string.o strlfunc.o sha1.o irc_ipv6.o rijndael.o sha2.o hmac.o prng.o md5.o stringbuf.o sstring-lib.o
+++ /dev/null
-/* sstring.h - Declaration of "static strings" functions */
-
-#ifndef __SSTRING_H
-#define __SSTRING_H
-
-/* Externally visibly max string length */
-#define SSTRING_MAX 512
-
-/* you can actually change USE_VALGRIND here without recompiling! */
-typedef struct sstring {
- short length;
- short alloc;
- struct sstring *next;
-#ifdef USE_VALGRIND
- void *block;
-#endif
- unsigned long refcount;
- char content[];
-} sstring;
-
-#ifdef COMPILING_SSTRING
-
-/* Internal defines */
-
-/* SSTRING_MAXLEN is the internal version of SSTRING_MAX which includes
- * space for the trailing NUL */
-#define SSTRING_MAXLEN (SSTRING_MAX + 1)
-#define SSTRING_SLACK 8
-#define SSTRING_ALLOC 16384
-
-#define SSTRING_HASHSIZE 85243
-
-#endif /* COMPILING_SSTRING */
-
-sstring *getsstring(const char *, int);
-void freesstring(sstring *);
-int sstringcompare(sstring *ss1, sstring *ss2);
-void initsstring();
-void finisstring();
-
-#endif /* __SSTRING_H */
+++ /dev/null
-/* sstring.h - Declaration of "static strings" functions */
-
-#ifndef __SSTRING_H
-#define __SSTRING_H
-
-/* Externally visibly max string length */
-#define SSTRING_MAX 512
-
-#ifdef COMPILING_SSTRING
-/* Internal version of structure */
-typedef struct {
- char *content;
- union {
- struct {
- short length;
- short alloc;
- } l;
- void *next;
- } u;
-} sstring;
-
-/* Internal defines */
-
-/* SSTRING_MAXLEN is the internal version of SSTRING_MAX which includes
- * space for the trailing NUL */
-#define SSTRING_MAXLEN (SSTRING_MAX + 1)
-#define SSTRING_SLACK 8
-#define SSTRING_STRUCTALLOC 4096
-#define SSTRING_DATAALLOC 4096
-
-#else
-/* External (simpler) version */
-
-typedef struct {
- char *content;
- short length;
-} sstring;
-
-#endif /* COMPILING_SSTRING */
-
-sstring *getsstring(const char *, int);
-void freesstring(sstring *);
-int sstringcompare(sstring *ss1, sstring *ss2);
-void initsstring();
-void finisstring();
-
-#endif /* __SSTRING_H */
CFLAGS+=$(INCPCRE)
LDFLAGS+=$(LIBPCRE)
-@if@ ${NEWSEARCH_NEWPARSER} == 1
-CFLAGS+=-DNEWSEARCH_NEWPARSER=1
-@endif@
-
-NSCOMMANDS=ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.o ns-modes.o ns-nick.o ns-ident.o ns-regex.o ns-host.o ns-channel.o ns-lt.o ns-gt.o ns-timestamp.o ns-country.o ns-authname.o ns-ip.o ns-kill.o ns-gline.o ns-exists.o ns-services.o ns-size.o ns-name.o ns-topic.o ns-oppct.o ns-cumodecount.o ns-cumodepct.o ns-hostpct.o ns-authedpct.o ns-length.o ns-kick.o ns-authts.o ns-channels.o ns-server.o ns-authid.o ns-notice.o newsearch_ast.o ns-any.o ns-channeliter.o ns-var.o ns-all.o ns-cumodes.o ns-cidr.o ns-nickiter.o
-
.PHONY: all clean distclean
all: newsearch.so
-@if@ ${NEWSEARCH_NEWPARSER} == 1
+NSCOMMANDS=ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.o ns-modes.o ns-nick.o ns-ident.o ns-regex.o ns-host.o ns-channel.o ns-lt.o ns-gt.o ns-timestamp.o ns-country.o ns-authname.o ns-ip.o ns-kill.o ns-gline.o ns-exists.o ns-services.o ns-size.o ns-name.o ns-topic.o ns-oppct.o ns-cumodecount.o ns-cumodepct.o ns-hostpct.o ns-authedpct.o ns-length.o ns-kick.o ns-authts.o ns-channels.o ns-server.o ns-authid.o ns-notice.o newsearch_ast.o ns-any.o ns-channeliter.o ns-var.o ns-all.o ns-cumodes.o ns-cidr.o ns-nickiter.o
+
+@ifeq@${NEWSEARCH_NEWPARSER}@ifeqsep@1@ifeqend@
+CFLAGS+=-DNEWSEARCH_NEWPARSER=1
newsearch.so: newsearch.o formats.o y.tab.o lex.yy.o parser.o ${NSCOMMANDS}
@else@
newsearch.so: newsearch.o formats.o ${NSCOMMANDS}