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 36
 make modules 
37 37
 or make modules exclude_modules="CVS print" etc.
38 38
 
39
+Make tags:
40
+
41
+make TAGS
42
+
43
+Create a tar.gz with the sources:
44
+
45
+make tar
46
+
47
+
48
+
39 49
 Install(not done yet):
40 50
 
41 51
 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 126
 cfg.tab.c: cfg.y $(ALLDEP)
127 127
 	$(YACC) $(YACC_FLAGS) $<
128 128
 
129
-
130
-
131 129
 .PHONY: all
132 130
 all: $(NAME) modules
133 131
 
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 132
 
142 133
 .PHONY: modules
143 134
 modules:
144
-	-for r in $(modules); do \
135
+	-@for r in $(modules); do \
145 136
 		echo  "" ; \
146 137
 		echo  "" ; \
147 138
 		$(MAKE) -C $$r ; \
148 139
 	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
-
140
+	
158 141
 dbg: ser
159 142
 	gdb -command debug.gdb
143
+
144
+
145
+tar: mantainer-clean 
146
+	tar -C .. -zcf ../$(NAME)-$(RELEASE)_src.tar.gz  $(notdir $(CURDIR)) 
160 147
new file mode 100644
... ...
@@ -0,0 +1,114 @@
0
+#
1
+# $Id$
2
+#
3
+# makefile defs (CC, LD,a.s.o)
4
+#
5
+
6
+
7
+#version number
8
+VERSION = 0
9
+PATCHLEVEL = 8
10
+SUBLEVEL = 4
11
+EXTRAVERSION =
12
+
13
+RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
14
+ARCH = $(shell uname -s)
15
+
16
+# compile-time options
17
+# 
18
+# -DSTATS	
19
+#		allows to print out number of packets processed on CTRL-C; 
20
+# 		implementation still nasty and reports per-process
21
+# -DNO_DEBUG 	
22
+#		turns off some of the debug messages (DBG(...)).
23
+# -DNO_LOG 	
24
+#		completely turns of all the logging (and DBG(...))
25
+# -DEXTRA_DEBUG	
26
+#		compiles in some extra debugging code
27
+# -DDNS_IP_HACK	
28
+#		faster ip address resolver for ip strings (e.g "127.0.0.1")
29
+# -DSHM_MEM	
30
+#		compiles in shared mem. support, needed by some modules and
31
+#		by USE_SHM_MEM
32
+# -DPKG_MALLOC	
33
+#		uses a faster malloc (exclusive w/ USE_SHM_MEM)
34
+# -DUSE_SHM_MEM	
35
+#		all pkg_malloc => shm_malloc (most mallocs use a common sh. 
36
+#		mem. segment); don't define PKG_MALLOC if you want this!
37
+# -DDBG_QM_MALLOC
38
+#		qm_malloc debug code, will cause pkg_malloc and shm_malloc
39
+#		to keep and display lot of debuging information: file name,
40
+#		function, line number of malloc/free call for each block,
41
+#		extra error checking (trying to free the same pointer
42
+#		twice, trying to free a pointer alloc'ed with a different
43
+#		malloc etc.)
44
+DEFS= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
45
+	 -DDNS_IP_HACK  -DSHM_MEM \
46
+	 -DPKG_MALLOC -DDBG_QM_MALLOC -DNODEBUG
47
+#-DEXTRA_DEBUG
48
+# -DUSE_SHM_MEM
49
+#-DNO_DEBUG 
50
+#-DPKG_MALLOC
51
+#-DNO_DEBUG#-DSTATS -DNO_DEBUG 
52
+#-DNO_LOG
53
+
54
+PROFILE=  #-pg #set this if you want profiling
55
+#mode = debug
56
+mode = release
57
+
58
+# platform dependent settings
59
+
60
+
61
+#common
62
+CC=gcc
63
+LD=gcc
64
+MKDEP=gcc -MM $(DEFS)
65
+MKTAGS=ctags-exuberant -R .
66
+
67
+ifeq ($(mode), release)
68
+	CFLAGS=-O2 -Wcast-align $(PROFILE) -Winline#-Wmissing-prototypes 
69
+	LDFLAGS=-Wl,-O2 -Wl,-E $(PROFILE)
70
+	# we need -fPIC -DPIC only for shared objects, we don't need them for
71
+	# the executable file, because it's always loaded at a fixed address
72
+	# -andrei
73
+else
74
+	CFLAGS=-g -Wcast-align -Winline $(PROFILE)
75
+	LDFLAGS=-g -Wl,-E $(PROFILE)
76
+endif
77
+
78
+#*FLAGS used for compiling the modules
79
+MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
80
+MOD_LDFLAGS=-O2 -shared
81
+
82
+LEX=flex
83
+YACC=bison
84
+YACC_FLAGS=-d -b cfg
85
+# on linux and freebsd keep it empty (e.g. LIBS= )
86
+# on solaris add -lxnet (e.g. LIBS= -lxnet)
87
+LIBS=-lfl -ldl
88
+
89
+
90
+#arch specific stuff
91
+ifeq ($(ARCH), Linux)
92
+
93
+endif
94
+ifeq  ($(ARCH), SunOS)
95
+
96
+YACC=yacc
97
+LDFLAGS=-O2 $(PROFILE)
98
+MOD_LDFLAGS=-O2 -G
99
+LIBS+=-L/usr/local/lib -lxnet # or -lnsl -lsocket or -lglibc ?
100
+
101
+endif
102
+ifeq ($(ARCH), FreeBSD)
103
+
104
+YACC=yacc
105
+LIBS= -lfl  #dlopen is in libc
106
+
107
+endif
108
+ifneq (,$(findstring CYGWIN, $(ARCH)))
109
+
110
+#cygwin is the same as common
111
+
112
+endif
113
+
0 114
new file mode 100644
... ...
@@ -0,0 +1,31 @@
0
+#
1
+# $Id$
2
+#
3
+# module Makefile
4
+#(to be included from each module)
5
+#
6
+
7
+
8
+ALLDEP=Makefile ../../Makefile.sources ../../Makefile.rules \
9
+ ../../Makefile.modules
10
+
11
+ifeq ($(MAKELEVEL), 0)
12
+# make called directly in the module dir!
13
+
14
+$(warning "you should run make from the main ser directory")
15
+include ../../Makefile.defs
16
+ALLDEP+=../../Makefile.defs
17
+
18
+else
19
+# called by the main Makefile
20
+
21
+ALLDEP+=../../Makefile
22
+
23
+endif
24
+
25
+include ../../Makefile.sources
26
+
27
+CFLAGS:=$(MOD_CFLAGS)
28
+LDFLAGS:=$(MOD_LDFLAGS)
29
+
30
+include ../../Makefile.rules
0 31
new file mode 100644
... ...
@@ -0,0 +1,63 @@
0
+#
1
+# $Id$
2
+#
3
+#
4
+# common Makefile rules, included by main Makefile & the  modules
5
+#
6
+
7
+#
8
+# Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, LIBS, MKDEP, auto_gen, depends, objs
9
+# (all this must  be defined previously!,  see Makefile.defs & Makefile)
10
+#
11
+
12
+
13
+
14
+#implicit rules
15
+%.o:%.c $(ALLDEP)
16
+	$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
17
+
18
+%.d: %.c $(ALLDEP)
19
+	@set -e; $(MKDEP) $< \
20
+	|  sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
21
+	[ -s $@ ] || rm -f $@
22
+
23
+
24
+# normal rules
25
+$(NAME): $(objs)
26
+	$(LD) $(LDFLAGS) $(objs) $(LIBS) -o $(NAME) 
27
+
28
+
29
+.PHONY: all
30
+all: $(NAME) modules
31
+
32
+.PHONY: dep
33
+dep: $(depends)
34
+
35
+.PHONY: clean
36
+clean:
37
+	-@rm $(objs) $(NAME) 2>/dev/null
38
+	-@for r in $(modules); do $(MAKE) -C $$r clean ; done
39
+
40
+
41
+
42
+.PHONY: proper
43
+.PHONY: distclean
44
+.PHONY: realclean
45
+proper realclean distclean: clean 
46
+	-@rm $(depends) 2>/dev/null
47
+	-@for r in $(modules); do $(MAKE) -C $$r proper ; done
48
+
49
+.PHONY: mantainer-cleaan
50
+mantainer-clean: distclean
51
+	-rm $(auto_gen) TAGS tags *.dbg .*.swp
52
+	-@for r in $(modules); do $(MAKE) -C $$r mantainer-clean ; done
53
+
54
+.PHONY: TAGS
55
+TAGS:
56
+	$(MKTAGS) 
57
+	
58
+
59
+ifneq (,$(filter-out clean proper distclean realclean mantainer-clean TAGS \
60
+		tar, $(MAKECMDGOALS)))
61
+include $(depends)
62
+endif
0 63
new file mode 100644
... ...
@@ -0,0 +1,17 @@
0
+#
1
+# $Id$
2
+#
3
+# common Makefile variables 
4
+# (source files, objs, etc)
5
+
6
+
7
+#
8
+# expects: auto_gen defined
9
+#
10
+# defines: sources, objs, depends
11
+#
12
+
13
+sources=$(filter-out $(auto_gen), $(wildcard *.c)) $(auto_gen)
14
+objs=$(sources:.c=.o)
15
+depends=$(sources:.c=.d)
16
+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