Makefile
e60a9728
 # $Id$
 #
 # sip_router makefile
 #
1b1b19d8
 # WARNING: requires gmake (GNU Make)
96001c50
 #  Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 6), WinNT
e60a9728
 
96001c50
 auto_gen=lex.yy.c cfg.tab.c   #lexx, yacc etc
34fd2612
 exclude_modules=CVS
96001c50
 sources=$(filter-out $(auto_gen), $(wildcard *.c)) $(auto_gen) 
 objs=$(sources:.c=.o)
 depends=$(sources:.c=.d)
34fd2612
 modules=$(filter-out $(addprefix modules/, $(exclude_modules)), \
 						$(wildcard modules/*))
e60a9728
 
f20a56a2
 NAME=ser
e60a9728
 
726efa25
 # compile-time options
 # NOCR disables seeking for CRs -- breaks standard but is fast
 # recommended: on (speed-up, no implementation really sends CR)
 # MACROEATER replaces frequently called parser helper functions
 # with macros
 # recommanded: on (speed-up)
1fb7b1aa
 # STATS allows to print out number of packets processed on CTRL-C; 
 # implementation still nasty and reports per-process
f8d46776
 # NO_DEBUG turns off some of the debug messages (DBG(...)).
 # NO_LOG completely turns of all the logging (and DBG(...))
 # DEBUG compiles in some extra debugging code
 # OLD_PARSER uses the old and stable parser (from ser 8.3.2)
104316b6
 # DNS_IP_HACK faster ip address resolver for ip strings (e.g "127.0.0.1")
628e3a5a
 # SHM_MEM    compiles in shared mem. support, needed by some modules and
 #            by USE_SHM_MEM
 # PKG_MALLOC uses a faster malloc (exclusive w/ USE_SHM_MEM)
 # USE_SHM_MEM all pkg_malloc => sh_malloc (most mallocs use a common sh. mem.
 #           segment); don't define PKG_MALLOC!
ec0e1fd4
 DEFS=-DNOCR -DMACROEATER -DDNS_IP_HACK  -DSHM_MEM -DUSE_SHM_MEM #-DNO_DEBUG 
628e3a5a
 #-DPKG_MALLOC
 #-DNO_DEBUG#-DSTATS -DNO_DEBUG 
104316b6
 #-DNO_LOG
f8d46776
 
 PROFILE=  # -pg #set this if you want profiling
9ed077fa
 mode = debug
 #mode = release
726efa25
 
f8734075
 # platform dependent settings
 
 ARCH = $(shell uname -s)
 
96001c50
 #common
e60a9728
 CC=gcc
96001c50
 LD=gcc
f571aa35
 
60e130f9
 ifeq ($(mode), release)
f571aa35
 	CFLAGS=-O2 -Wcast-align $(PROFILE) -Winline#-Wmissing-prototypes 
 	LDFLAGS=-Wl,-O2 -Wl,-E $(PROFILE)
 else
e72b5b50
 	CFLAGS=-g -Wcast-align -Winline
 	LDFLAGS=-g -Wl,-E
f571aa35
 endif
 
f8734075
 LEX=flex
 YACC=bison
71b44bf0
 YACC_FLAGS=-d -b cfg
1b1b19d8
 # on linux and freebsd keep it empty (e.g. LIBS= )
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
3bf76e49
 LIBS=-lfl -ldl
f8734075
 
96001c50
 
 ifeq ($(ARCH), Linux)
 
 endif
f8734075
 ifeq  ($(ARCH), SunOS)
 
 MAKE=gmake
 YACC=yacc
f8d46776
 LDFLAGS=-O2 $(PROFILE)
66fe760d
 LIBS+=-L/usr/local/lib -lxnet # or -lnsl -lsocket or -lglibc ?
f8734075
 
 endif
 ifeq ($(ARCH), FreeBSD)
 
 MAKE=gmake
 YACC=yacc
58996a65
 LIBS= -lfl  #dlopen is in libc
f8734075
 
 endif
96001c50
 ifneq (,$(findstring CYGWIN, $(ARCH)))
f8734075
 
96001c50
 #cygwin is the same as common
0ae4dfdc
 
 endif
 
e60a9728
 
628e3a5a
 MKDEP=gcc -M $(DEFS)
e60a9728
 
f8734075
 ALLDEP=Makefile
e60a9728
 
96001c50
 export #export all variables for the sub-makes
e60a9728
 
a15c363f
 
96001c50
 #implicit rules
e60a9728
 %.o:%.c $(ALLDEP)
726efa25
 	$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
e60a9728
 
 %.d: %.c
 	$(MKDEP) $< >$@
 
96001c50
 
a15c363f
 # normal rules
3e429f5c
 $(NAME): $(objs)
96001c50
 	$(LD) $(LDFLAGS) $(objs) $(LIBS) -o $(NAME) 
3e429f5c
 
a15c363f
 lex.yy.c: cfg.lex $(ALLDEP)
 	$(LEX) $<
 
f8734075
 cfg.tab.c: cfg.y $(ALLDEP)
a15c363f
 	$(YACC) $(YACC_FLAGS) $<
 
e60a9728
 
96001c50
 
e60a9728
 .PHONY: all
96001c50
 all: $(NAME) modules
e60a9728
 
 .PHONY: dep
 dep: $(depends)
 
 .PHONY: clean
 clean:
 	-rm $(objs) $(NAME)
96001c50
 	-for r in $(modules); do $(MAKE) -C $$r clean ; done
 
 .PHONY: modules
 modules:
 	-for r in $(modules); do \
 		$(MAKE) -C $$r ; \
 	done
 
e60a9728
 
 .PHONY: proper
96001c50
 proper: clean 
e60a9728
 	-rm $(depends)
96001c50
 	-for r in $(modules); do $(MAKE) -C $$r proper ; done
e60a9728
 
 include $(depends)
 
f571aa35
 dbg: ser
 	gdb -command debug.gdb