Browse code

- updated INSTALL w/ more info on building ser - splited Makefile in Makefile, Makefile.sources, Makefile.defs, Makefile.rules, - added Makefile.modules (included by each an every module) - fixed a warning in textops - updated all module Makefile to use Makefile.modules

Andrei Pelinescu-Onciul authored on 08/12/2001 22:06:27
Showing 8 changed files
... ...
@@ -24,9 +24,49 @@ Arhitecture Notes:
24 24
 	(>=0.12). 
25 25
 	
26 26
 
27
+
28
+
29
+Howto:
30
+(NOTE: if make doesn't work try gmake  instead)
31
+
32
+- compile with default options:
33
+
34
+make   #builds only ser core, equivalent to make ser
35
+make modules
36
+
37
+or make all #builds everything
38
+
39
+- compile with profiling
40
+
41
+make PROFILE=-pg all
42
+
43
+-compile debug mode version
44
+
45
+make mode=debug all
46
+
47
+-compile debug version with profiling
48
+
49
+make mode=debug PROFILE=-pg all
50
+
51
+-compile only the print module
52
+
53
+make modules=modules/print modules
54
+
55
+-compile all the modules except textops
56
+
57
+make exclude_modules="CVS textops" modules
58
+
59
+
60
+
61
+Make targets:
62
+
27 63
 Clean:
64
+
28 65
 make clean   (clean the modules too)
29 66
 make proper  (clean also the dependencies)
67
+make distclean (the same as proper)
68
+make mantainer-clean (clean everything, including auto generated files,
69
+ tags, *.dbg a.s.o)
30 70
 
31 71
 Compile:
32 72
 
... ...
@@ -36,6 +76,16 @@ make
36 76
 make modules 
37 77
 or make modules exclude_modules="CVS print" etc.
38 78
 
79
+Make tags:
80
+
81
+make TAGS
82
+
83
+Create a tar.gz with the sources:
84
+
85
+make tar
86
+
87
+
88
+
39 89
 Install(not done yet):
40 90
 
41 91
 make prefix=/usr/local  install
... ...
@@ -6,119 +6,29 @@
6 6
 #  Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 6), WinNT (cygwin)
7 7
 
8 8
 auto_gen=lex.yy.c cfg.tab.c   #lexx, yacc etc
9
+
10
+#include  source related defs
11
+include Makefile.sources
12
+
9 13
 exclude_modules=CVS usrloc
10
-sources=$(filter-out $(auto_gen), $(wildcard *.c)) $(auto_gen)
11
-objs=$(sources:.c=.o)
12
-depends=$(sources:.c=.d)
13 14
 modules=$(filter-out $(addprefix modules/, $(exclude_modules)), \
14 15
 						$(wildcard modules/*))
15 16
 
16 17
 NAME=ser
17 18
 
18
-# compile-time options
19
-# 
20
-# STATS allows to print out number of packets processed on CTRL-C; 
21
-# implementation still nasty and reports per-process
22
-# NO_DEBUG turns off some of the debug messages (DBG(...)).
23
-# NO_LOG completely turns of all the logging (and DBG(...))
24
-# EXTRA_DEBUG compiles in some extra debugging code
25
-# DNS_IP_HACK faster ip address resolver for ip strings (e.g "127.0.0.1")
26
-# SHM_MEM    compiles in shared mem. support, needed by some modules and
27
-#            by USE_SHM_MEM
28
-# PKG_MALLOC uses a faster malloc (exclusive w/ USE_SHM_MEM)
29
-# USE_SHM_MEM all pkg_malloc => shm_malloc (most mallocs use a common sh. mem.
30
-#           segment); don't define PKG_MALLOC if you want this!
31
-# DBG_QM_MALLOC - qm_malloc debug code, will cause pkg_malloc and shm_malloc
32
-#                  to keep and display lot of debuging information: file name,
33
-#                  function, line number of malloc/free call for each block,
34
-#                  extra error checking (trying to free the same pointer
35
-#                  twice, trying to free a pointer alloc'ed with a different
36
-#                  malloc etc.)
37
-DEFS=-DDNS_IP_HACK  -DSHM_MEM \
38
-	 -DPKG_MALLOC #-DDBG_QM_MALLOC 
39
-#-DEXTRA_DEBUG
40
-# -DUSE_SHM_MEM
41
-#-DNO_DEBUG 
42
-#-DPKG_MALLOC
43
-#-DNO_DEBUG#-DSTATS -DNO_DEBUG 
44
-#-DNO_LOG
45
-
46
-PROFILE=  -pg #set this if you want profiling
47
-mode = debug
48
-#mode = release
49
-
50
-# platform dependent settings
51
-
52
-ARCH = $(shell uname -s)
53
-
54
-#common
55
-CC=gcc
56
-LD=gcc
57
-
58
-ifeq ($(mode), release)
59
-	CFLAGS=-O2 -Wcast-align $(PROFILE) -Winline#-Wmissing-prototypes 
60
-	LDFLAGS=-Wl,-O2 -Wl,-E $(PROFILE)
61
-	# we need -fPIC -DPIC only for shared objects, we don't need them for the 
62
-	# executable file, because it's always loaded at a fixed address
63
-	# -andrei
64
-else
65
-	CFLAGS=-g -fPIC -DPIC -Wcast-align -Winline $(PROFILE)
66
-	LDFLAGS=-g -Wl,-E $(PROFILE)
67
-endif
68
-
69
-LEX=flex
70
-YACC=bison
71
-YACC_FLAGS=-d -b cfg
72
-# on linux and freebsd keep it empty (e.g. LIBS= )
73
-# on solaris add -lxnet (e.g. LIBS= -lxnet)
74
-LIBS=-lfl -ldl
75
-
76
-
77
-ifeq ($(ARCH), Linux)
78
-
79
-endif
80
-ifeq  ($(ARCH), SunOS)
81
-
82
-MAKE=gmake
83
-YACC=yacc
84
-LDFLAGS=-O2 $(PROFILE)
85
-LIBS+=-L/usr/local/lib -lxnet # or -lnsl -lsocket or -lglibc ?
86
-
87
-endif
88
-ifeq ($(ARCH), FreeBSD)
89
-
90
-MAKE=gmake
91
-YACC=yacc
92
-LIBS= -lfl  #dlopen is in libc
93
-
94
-endif
95
-ifneq (,$(findstring CYGWIN, $(ARCH)))
19
+ALLDEP=Makefile Makefile.sources Makefile.defs Makefile.rules
96 20
 
97
-#cygwin is the same as common
21
+#include general defs (like CC, CFLAGS  a.s.o)
22
+include Makefile.defs
98 23
 
99
-endif
24
+#export relevant variables to the sub-makes
25
+export DEFS PROFILE CC  LD MKDEP MKTAGS CFLAGS LDFLAGS MOD_CFLAGS MOD_LDFLAGS
26
+export LEX YACC YACC_FLAGS
100 27
 
28
+# include the common rules
29
+include Makefile.rules
101 30
 
102
-MKDEP=gcc -MM $(DEFS)
103
-
104
-ALLDEP=Makefile
105
-
106
-export #export all variables for the sub-makes
107
-
108
-
109
-#implicit rules
110
-%.o:%.c $(ALLDEP)
111
-	$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
112
-
113
-%.d: %.c $(ALLDEP)
114
-	set -e; $(MKDEP) $< \
115
-	|  sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
116
-	[ -s $@ ] || rm -f $@
117
-
118
-
119
-# normal rules
120
-$(NAME): $(objs)
121
-	$(LD) $(LDFLAGS) $(objs) $(LIBS) -o $(NAME) 
31
+#extra targets 
122 32
 
123 33
 lex.yy.c: cfg.lex $(ALLDEP)
124 34
 	$(LEX) $<
... ...
@@ -126,34 +36,21 @@ lex.yy.c: cfg.lex $(ALLDEP)
126 36
 cfg.tab.c: cfg.y $(ALLDEP)
127 37
 	$(YACC) $(YACC_FLAGS) $<
128 38
 
129
-
130
-
131 39
 .PHONY: all
132 40
 all: $(NAME) modules
133 41
 
134
-.PHONY: dep
135
-dep: $(depends)
136
-
137
-.PHONY: clean
138
-clean:
139
-	-rm $(objs) $(NAME) 2>/dev/null
140
-	-for r in $(modules); do $(MAKE) -C $$r clean ; done
141 42
 
142 43
 .PHONY: modules
143 44
 modules:
144
-	-for r in $(modules); do \
45
+	-@for r in $(modules); do \
145 46
 		echo  "" ; \
146 47
 		echo  "" ; \
147 48
 		$(MAKE) -C $$r ; \
148 49
 	done
149
-
150
-
151
-.PHONY: proper
152
-proper: clean 
153
-	-rm $(depends) 2>/dev/null
154
-	-for r in $(modules); do $(MAKE) -C $$r proper ; done
155
-
156
-include $(depends)
157
-
50
+	
158 51
 dbg: ser
159 52
 	gdb -command debug.gdb
53
+
54
+
55
+tar: mantainer-clean 
56
+	tar -C .. -zcf ../$(NAME)-$(RELEASE)_src.tar.gz  $(notdir $(CURDIR)) 
160 57
new file mode 100644
... ...
@@ -0,0 +1,114 @@
1
+#
2
+# $Id$
3
+#
4
+# makefile defs (CC, LD,a.s.o)
5
+#
6
+
7
+
8
+#version number
9
+VERSION = 0
10
+PATCHLEVEL = 8
11
+SUBLEVEL = 4
12
+EXTRAVERSION =
13
+
14
+RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
15
+ARCH = $(shell uname -s)
16
+
17
+# compile-time options
18
+# 
19
+# -DSTATS	
20
+#		allows to print out number of packets processed on CTRL-C; 
21
+# 		implementation still nasty and reports per-process
22
+# -DNO_DEBUG 	
23
+#		turns off some of the debug messages (DBG(...)).
24
+# -DNO_LOG 	
25
+#		completely turns of all the logging (and DBG(...))
26
+# -DEXTRA_DEBUG	
27
+#		compiles in some extra debugging code
28
+# -DDNS_IP_HACK	
29
+#		faster ip address resolver for ip strings (e.g "127.0.0.1")
30
+# -DSHM_MEM	
31
+#		compiles in shared mem. support, needed by some modules and
32
+#		by USE_SHM_MEM
33
+# -DPKG_MALLOC	
34
+#		uses a faster malloc (exclusive w/ USE_SHM_MEM)
35
+# -DUSE_SHM_MEM	
36
+#		all pkg_malloc => shm_malloc (most mallocs use a common sh. 
37
+#		mem. segment); don't define PKG_MALLOC if you want this!
38
+# -DDBG_QM_MALLOC
39
+#		qm_malloc debug code, will cause pkg_malloc and shm_malloc
40
+#		to keep and display lot of debuging information: file name,
41
+#		function, line number of malloc/free call for each block,
42
+#		extra error checking (trying to free the same pointer
43
+#		twice, trying to free a pointer alloc'ed with a different
44
+#		malloc etc.)
45
+DEFS= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
46
+	 -DDNS_IP_HACK  -DSHM_MEM \
47
+	 -DPKG_MALLOC -DDBG_QM_MALLOC -DNODEBUG
48
+#-DEXTRA_DEBUG
49
+# -DUSE_SHM_MEM
50
+#-DNO_DEBUG 
51
+#-DPKG_MALLOC
52
+#-DNO_DEBUG#-DSTATS -DNO_DEBUG 
53
+#-DNO_LOG
54
+
55
+PROFILE=  #-pg #set this if you want profiling
56
+#mode = debug
57
+mode = release
58
+
59
+# platform dependent settings
60
+
61
+
62
+#common
63
+CC=gcc
64
+LD=gcc
65
+MKDEP=gcc -MM $(DEFS)
66
+MKTAGS=ctags-exuberant -R .
67
+
68
+ifeq ($(mode), release)
69
+	CFLAGS=-O2 -Wcast-align $(PROFILE) -Winline#-Wmissing-prototypes 
70
+	LDFLAGS=-Wl,-O2 -Wl,-E $(PROFILE)
71
+	# we need -fPIC -DPIC only for shared objects, we don't need them for
72
+	# the executable file, because it's always loaded at a fixed address
73
+	# -andrei
74
+else
75
+	CFLAGS=-g -Wcast-align -Winline $(PROFILE)
76
+	LDFLAGS=-g -Wl,-E $(PROFILE)
77
+endif
78
+
79
+#*FLAGS used for compiling the modules
80
+MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
81
+MOD_LDFLAGS=-O2 -shared
82
+
83
+LEX=flex
84
+YACC=bison
85
+YACC_FLAGS=-d -b cfg
86
+# on linux and freebsd keep it empty (e.g. LIBS= )
87
+# on solaris add -lxnet (e.g. LIBS= -lxnet)
88
+LIBS=-lfl -ldl
89
+
90
+
91
+#arch specific stuff
92
+ifeq ($(ARCH), Linux)
93
+
94
+endif
95
+ifeq  ($(ARCH), SunOS)
96
+
97
+YACC=yacc
98
+LDFLAGS=-O2 $(PROFILE)
99
+MOD_LDFLAGS=-O2 -G
100
+LIBS+=-L/usr/local/lib -lxnet # or -lnsl -lsocket or -lglibc ?
101
+
102
+endif
103
+ifeq ($(ARCH), FreeBSD)
104
+
105
+YACC=yacc
106
+LIBS= -lfl  #dlopen is in libc
107
+
108
+endif
109
+ifneq (,$(findstring CYGWIN, $(ARCH)))
110
+
111
+#cygwin is the same as common
112
+
113
+endif
114
+
0 115
new file mode 100644
... ...
@@ -0,0 +1,31 @@
1
+#
2
+# $Id$
3
+#
4
+# module Makefile
5
+#(to be included from each module)
6
+#
7
+
8
+
9
+ALLDEP=Makefile ../../Makefile.sources ../../Makefile.rules \
10
+ ../../Makefile.modules
11
+
12
+ifeq ($(MAKELEVEL), 0)
13
+# make called directly in the module dir!
14
+
15
+$(warning "you should run make from the main ser directory")
16
+include ../../Makefile.defs
17
+ALLDEP+=../../Makefile.defs
18
+
19
+else
20
+# called by the main Makefile
21
+
22
+ALLDEP+=../../Makefile
23
+
24
+endif
25
+
26
+include ../../Makefile.sources
27
+
28
+CFLAGS:=$(MOD_CFLAGS)
29
+LDFLAGS:=$(MOD_LDFLAGS)
30
+
31
+include ../../Makefile.rules
0 32
new file mode 100644
... ...
@@ -0,0 +1,63 @@
1
+#
2
+# $Id$
3
+#
4
+#
5
+# common Makefile rules, included by main Makefile & the  modules
6
+#
7
+
8
+#
9
+# Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, LIBS, MKDEP, auto_gen, depends, objs
10
+# (all this must  be defined previously!,  see Makefile.defs & Makefile)
11
+#
12
+
13
+
14
+
15
+#implicit rules
16
+%.o:%.c $(ALLDEP)
17
+	$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
18
+
19
+%.d: %.c $(ALLDEP)
20
+	@set -e; $(MKDEP) $< \
21
+	|  sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
22
+	[ -s $@ ] || rm -f $@
23
+
24
+
25
+# normal rules
26
+$(NAME): $(objs)
27
+	$(LD) $(LDFLAGS) $(objs) $(LIBS) -o $(NAME) 
28
+
29
+
30
+.PHONY: all
31
+all: $(NAME) modules
32
+
33
+.PHONY: dep
34
+dep: $(depends)
35
+
36
+.PHONY: clean
37
+clean:
38
+	-@rm $(objs) $(NAME) 2>/dev/null
39
+	-@for r in $(modules); do $(MAKE) -C $$r clean ; done
40
+
41
+
42
+
43
+.PHONY: proper
44
+.PHONY: distclean
45
+.PHONY: realclean
46
+proper realclean distclean: clean 
47
+	-@rm $(depends) 2>/dev/null
48
+	-@for r in $(modules); do $(MAKE) -C $$r proper ; done
49
+
50
+.PHONY: mantainer-cleaan
51
+mantainer-clean: distclean
52
+	-rm $(auto_gen) TAGS tags *.dbg .*.swp
53
+	-@for r in $(modules); do $(MAKE) -C $$r mantainer-clean ; done
54
+
55
+.PHONY: TAGS
56
+TAGS:
57
+	$(MKTAGS) 
58
+	
59
+
60
+ifneq (,$(filter-out clean proper distclean realclean mantainer-clean TAGS \
61
+		tar, $(MAKECMDGOALS)))
62
+include $(depends)
63
+endif
0 64
new file mode 100644
... ...
@@ -0,0 +1,17 @@
1
+#
2
+# $Id$
3
+#
4
+# common Makefile variables 
5
+# (source files, objs, etc)
6
+
7
+
8
+#
9
+# expects: auto_gen defined
10
+#
11
+# defines: sources, objs, depends
12
+#
13
+
14
+sources=$(filter-out $(auto_gen), $(wildcard *.c)) $(auto_gen)
15
+objs=$(sources:.c=.o)
16
+depends=$(sources:.c=.d)
17
+modules=
... ...
@@ -41,9 +41,9 @@
41 41
 #include <dmalloc.h>
42 42
 #endif
43 43
 
44
-
45 44
 static char id[]="@(#) $Id$";
46
-static char version[]="ser 0.8.3.9";
45
+static char version[]=  NAME " " VERSION " (" ARCH ")" ;
46
+static char compiled[]= __TIME__ __DATE__ ;
47 47
 static char flags[]=
48 48
 "STATS:"
49 49
 #ifdef STATS
... ...
@@ -81,7 +81,7 @@ static char flags[]=
81 81
 ;
82 82
 
83 83
 static char help_msg[]= "\
84
-Usage: ser -l address [-l address] [options]\n\
84
+Usage: " NAME " -l address [-l address] [options]\n\
85 85
 Options:\n\
86 86
     -c		 Perform loop checks and compute branches\n\
87 87
     -f file      Configuration file (default " CFG_FILE ")\n\
... ...
@@ -357,7 +357,7 @@ static void sig_usr(int signo)
357 357
 #endif
358 358
 	}
359 359
 bye:
360
-	DPrint("Thank you for flying ser\n");
360
+	DPrint("Thank you for flying " NAME "\n");
361 361
 	exit(0);
362 362
 }
363 363
 
... ...
@@ -1,51 +1,12 @@
1 1
 # $Id$
2 2
 #
3
-# print example module makefile
3
+# example module makefile
4 4
 #
5 5
 # 
6 6
 # WARNING: do not run this directly, it should be run by the master Makefile
7 7
 
8 8
 auto_gen=
9
-sources= $(filter-out $(auto_gen), $(wildcard *.c)) $(auto_gen) 
10
-objs= $(sources:.c=.o)
11
-depends= $(sources:.c=.d)
12
-
13 9
 NAME=tm.so
14
-
15
-SHLIB_LD_FLAGS= -shared
16 10
 LIBS= #-lpthread
17
-CFLAGS+= -fPIC -DPIC
18
-
19
-ALLDEP=Makefile ../../Makefile
20
-
21
-ifeq ($(ARCH), SunOS)
22
-LDFLAGS=-O2 -G 
23
-endif
24
-
25
-#implicit rules
26
-%.o:%.c $(ALLDEP)
27
-	$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
28
-
29
-%.d: %.c
30
-	$(MKDEP) $< >$@
31
-
32
-
33
-$(NAME): $(objs)
34
-	$(LD) $(LDFLAGS) $(SHLIB_LD_FLAGS) $(objs) $(LIBS) -o $(NAME)
35
-
36
-
37
-.PHONY: all
38
-all: $(NAME)
39
-
40
-.PHONY: dep
41
-dep: $(depends)
42
-
43
-.PHONY: clean
44
-clean:
45
-	-rm -f $(objs) $(NAME)
46
-
47
-.PHONY: proper
48
-proper: clean
49
-	-rm $(depends)
50 11
 
51
-include $(depends)
12
+include ../../Makefile.modules