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
 DEFS=-DNOCR -DMACROEATER -DSTATS #-DNO_DEBUG #-DNO_LOG
726efa25
 
f8734075
 # platform dependent settings
 
 ARCH = $(shell uname -s)
 
96001c50
 #common
e60a9728
 CC=gcc
96001c50
 LD=gcc
1fb7b1aa
 CFLAGS=-O3 -Wcast-align #-Wmissing-prototypes 
96001c50
 LDFLAGS=-Wl,-O2 -Wl,-E
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
66fe760d
 LDFLAGS=-O2
 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
 
96001c50
 MKDEP=gcc -M 
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)