Browse code

- converted to autoconf compatible format (replaced some os specific ifdefs with HAVE_xxx a.s.o)

Andrei Pelinescu-Onciul authored on 04/11/2002 17:05:32
Showing 8 changed files
... ...
@@ -4,7 +4,7 @@ $Id$
4 4
 Installation Notes
5 5
 
6 6
 Supported arhitectures: Linux/i386, Linux/armv4l, FreeBSD/i386,
7
-Solaris/sparc64, Win*/i386 (CYGWIN) - only the core
7
+Solaris/sparc64 
8 8
 (for other arhitectures the Makefile must be edited)
9 9
 
10 10
 There are various configuration options defined in the Makefile.
... ...
@@ -12,7 +12,8 @@ EXTRAVERSION =
12 12
 
13 13
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
14 14
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
15
-ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
15
+ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc/  \
16
+			-e s/armv4l/arm/)
16 17
 
17 18
  # install location
18 19
 PREFIX = /usr/local
... ...
@@ -126,7 +127,7 @@ YACC := $(shell echo "$${YACC}")
126 126
 #  		forking (done at the top of main_loop). Needed if you want
127 127
 #  		to use the snmp module.
128 128
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
129
-	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"' \
129
+	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH)\
130 130
 	 -DCFG_DIR='"$(cfg-target)"'\
131 131
 	 -DPKG_MALLOC \
132 132
 	 -DSHM_MEM  -DSHM_MMAP \
... ...
@@ -214,7 +215,7 @@ $(warning	Unknown compiler $(CC)\; supported compilers: \
214 214
 endif
215 215
 
216 216
 # find ldname (gnu or solaris)
217
-ifeq ($(ARCH), sparc64)
217
+ifeq ($(ARCH), sparc)
218 218
 ifeq ($(CC_NAME), gcc)
219 219
 		LDGCC=$(shell $(CC) -v 2>&1 | grep with-ld| \
220 220
 				   sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
... ...
@@ -245,13 +246,13 @@ ifeq ($(ARCH), i386)
245 245
 	DEFS+= -DFAST_LOCK
246 246
 endif
247 247
 
248
-ifeq ($(ARCH), sparc64)
248
+ifeq ($(ARCH), sparc)
249 249
 ifeq 	($(CC_NAME), gcc)
250 250
 		DEFS+= -DFAST_LOCK
251 251
 endif
252 252
 endif
253 253
 
254
-ifeq ($(ARCH), armv4l)
254
+ifeq ($(ARCH), arm)
255 255
 	DEFS+= -DFAST_LOCK
256 256
 endif
257 257
 
... ...
@@ -302,8 +303,8 @@ endif		#CC_NAME, gcc
302 302
 endif	#ARCH, i386
303 303
 
304 304
 
305
-	#if sparc64
306
-ifeq	($(ARCH), sparc64)
305
+	#if sparc
306
+ifeq	($(ARCH), sparc)
307 307
 			#if gcc
308 308
 ifeq		($(CC_NAME), gcc)
309 309
 				#common stuff
... ...
@@ -344,10 +345,10 @@ else
344 344
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
345 345
 endif		#CC_NAME, suncc
346 346
 endif		#CC_NAME, gcc
347
-endif	#ARCH, sparc64
347
+endif	#ARCH, sparc
348 348
 
349 349
 	#if ipaq/netwinder
350
-ifeq	($(ARCH), armv4l)
350
+ifeq	($(ARCH), arm)
351 351
 		# if gcc 
352 352
 ifeq		($(CC_NAME), gcc)
353 353
 				#common stuff
... ...
@@ -383,7 +384,7 @@ endif	#ARCH, i386
383 383
 LDFLAGS=
384 384
 # setting LDFLAGS
385 385
 ifeq	($(CC_NAME), gcc)
386
-ifeq		($(ARCH), sparc64)
386
+ifeq		($(ARCH), sparc)
387 387
 ifeq			($(LDTYPE), solaris)
388 388
 					# solaris ld
389 389
 					LDFLAGS+=-O2 $(PROFILE)
... ...
@@ -414,7 +415,7 @@ endif
414 414
 else	#mode,release
415 415
 ifeq	($(CC_NAME), gcc)
416 416
 		CFLAGS=-g -Wcast-align -Winline $(PROFILE)
417
-ifeq		($(ARCH), sparc64)
417
+ifeq		($(ARCH), sparc)
418 418
 			CFLAGS+= -mcpu=ultrasparc 
419 419
 endif
420 420
 ifeq		($(LDTYPE), solaris)
... ...
@@ -462,6 +463,10 @@ YACC_FLAGS=-d -b cfg
462 462
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
463 463
 LIBS= -lfl -ldl -lresolv
464 464
 
465
+ifneq ($(OS), solaris)
466
+	DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN
467
+endif
468
+
465 469
 
466 470
 #os specific stuff
467 471
 ifeq ($(OS), Linux)
... ...
@@ -469,6 +474,7 @@ ifeq ($(OS), Linux)
469 469
 endif
470 470
 
471 471
 ifeq  ($(OS), solaris)
472
+	DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H
472 473
 	ifeq ($(mode), release)
473 474
 		#use these only if you're using gcc with Solaris ld
474 475
 		#LDFLAGS=-O2 $(PROFILE)
... ...
@@ -488,11 +494,17 @@ endif
488 488
 endif
489 489
 
490 490
 ifeq ($(OS), freebsd)
491
-
491
+	DEFS+=-DHAVE_SOCKADDR_SA_LEN
492 492
 	YACC=yacc
493 493
 	LIBS= -lfl  #dlopen is in libc
494
+endif
494 495
 
496
+ifeq ($(OS), openbsd)
497
+	DEFS+=-DHAVE_SOCKADDR_SA_LEN
498
+	YACC=yacc
499
+	LIBS= -lfl  -lc_r
495 500
 endif
501
+	
496 502
 
497 503
 ifneq (,$(findstring CYGWIN, $(OS)))
498 504
 	#cygwin is the same as common
... ...
@@ -54,7 +54,7 @@ inline static int tsl(fl_lock_t* lock)
54 54
 {
55 55
 	int val;
56 56
 
57
-#ifdef __i386
57
+#ifdef __CPU_i386
58 58
 
59 59
 #ifdef NOSMP
60 60
 	val=0;
... ...
@@ -69,7 +69,7 @@ inline static int tsl(fl_lock_t* lock)
69 69
 		" xchg %b1, %0" : "=q" (val), "=m" (*lock) : "0" (val) : "memory"
70 70
 	);
71 71
 #endif /*NOSMP*/
72
-#elif defined __sparc
72
+#elif defined __CPU_sparc
73 73
 	asm volatile(
74 74
 			"ldstub [%1], %0 \n\t"
75 75
 #ifndef NOSMP
... ...
@@ -78,7 +78,7 @@ inline static int tsl(fl_lock_t* lock)
78 78
 			: "=r"(val) : "r"(lock):"memory"
79 79
 	);
80 80
 	
81
-#elif defined __arm__
81
+#elif defined __CPU_arm
82 82
 	asm volatile(
83 83
 			"# here \n\t"
84 84
 			"swpb %0, %1, [%2] \n\t"
... ...
@@ -115,14 +115,14 @@ inline static void get_lock(fl_lock_t* lock)
115 115
 
116 116
 inline static void release_lock(fl_lock_t* lock)
117 117
 {
118
-#ifdef __i386
118
+#ifdef __CPU_i386
119 119
 	char val;
120 120
 	val=0;
121 121
 	asm volatile(
122 122
 		" movb $0, (%0)" : /*no output*/ : "r"(lock): "memory"
123 123
 		/*" xchg %b0, %1" : "=q" (val), "=m" (*lock) : "0" (val) : "memory"*/
124 124
 	); 
125
-#elif defined __sparc
125
+#elif defined __CPU_sparc
126 126
 	asm volatile(
127 127
 #ifndef NOSMP
128 128
 			"membar #LoadStore | #StoreStore \n\t" /*is this really needed?*/
... ...
@@ -132,7 +132,7 @@ inline static void release_lock(fl_lock_t* lock)
132 132
 			: "r" (lock)
133 133
 			: "memory"
134 134
 	);
135
-#elif defined __arm__
135
+#elif defined __CPU_arm
136 136
 	asm volatile(
137 137
 		" str %0, [%1] \n\r" 
138 138
 		: /*no outputs*/ 
... ...
@@ -84,7 +84,7 @@ struct socket_info{
84 84
 
85 85
 
86 86
 /* len of the sockaddr */
87
-#ifdef __FreeBSD__
87
+#ifdef HAVE_SOCKADDR_SA_LEN
88 88
 #define sockaddru_len(su)	((su).s.sa_len)
89 89
 #else
90 90
 #ifdef USE_IPV6
... ...
@@ -94,7 +94,7 @@ struct socket_info{
94 94
 #else
95 95
 #define sockaddru_len(su)	sizeof(struct sockaddr_in)
96 96
 #endif /*USE_IPV6*/
97
-#endif /*__FreeBSD__*/
97
+#endif /* HAVE_SOCKADDR_SA_LEN*/
98 98
 	
99 99
 /* inits an ip_addr with the addr. info from a hostent structure
100 100
  * ip = struct ip_addr*
... ...
@@ -217,7 +217,7 @@ static inline int init_su( union sockaddr_union* su,
217 217
 #ifdef USE_IPV6
218 218
 	case	AF_INET6:
219 219
 		memcpy(&su->sin6.sin6_addr, ip->u.addr, ip->len); 
220
-		#ifdef __FreeBSD__
220
+		#ifdef HAVE_SOCKADDR_SA_LEN
221 221
 			su->sin6.sin6_len=sizeof(struct sockaddr_in6);
222 222
 		#endif
223 223
 		su->sin6.sin6_port=port;
... ...
@@ -225,7 +225,7 @@ static inline int init_su( union sockaddr_union* su,
225 225
 #endif
226 226
 	case AF_INET:
227 227
 		memcpy(&su->sin.sin_addr, ip->u.addr, ip->len);
228
-		#ifdef __FreeBSD__
228
+		#ifdef HAVE_SOCKADDR_SA_LEN
229 229
 			su->sin.sin_len=sizeof(struct sockaddr_in);
230 230
 		#endif
231 231
 		su->sin.sin_port=port;
... ...
@@ -254,7 +254,7 @@ static inline int hostent2su( union sockaddr_union* su,
254 254
 #ifdef USE_IPV6
255 255
 	case	AF_INET6:
256 256
 		memcpy(&su->sin6.sin6_addr, he->h_addr_list[idx], he->h_length);
257
-		#ifdef __FreeBSD__
257
+		#ifdef HAVE_SOCKADDR_SA_LEN
258 258
 			su->sin6.sin6_len=sizeof(struct sockaddr_in6);
259 259
 		#endif
260 260
 		su->sin6.sin6_port=port;
... ...
@@ -262,7 +262,7 @@ static inline int hostent2su( union sockaddr_union* su,
262 262
 #endif
263 263
 	case AF_INET:
264 264
 		memcpy(&su->sin.sin_addr, he->h_addr_list[idx], he->h_length);
265
-		#ifdef __FreeBSD__
265
+		#ifdef HAVE_SOCKADDR_SA_LEN
266 266
 			su->sin.sin_len=sizeof(struct sockaddr_in);
267 267
 		#endif
268 268
 		su->sin.sin_port=port;
... ...
@@ -48,7 +48,7 @@
48 48
 
49 49
 #include <sys/ioctl.h>
50 50
 #include <net/if.h>
51
-#ifdef __sun
51
+#ifdef HAVE_SYS_SOCKIO_H
52 52
 #include <sys/sockio.h>
53 53
 #endif
54 54
 
... ...
@@ -82,7 +82,7 @@
82 82
 
83 83
 static char id[]="@(#) $Id$";
84 84
 static char version[]=  NAME " " VERSION " (" ARCH "/" OS ")" ;
85
-static char compiled[]= __TIME__ " " __DATE__ ;
85
+static char compiled[]= __TIME__ __DATE__ ;
86 86
 static char flags[]=
87 87
 "STATS:"
88 88
 #ifdef STATS
... ...
@@ -389,7 +389,7 @@ int daemonize(char*  name)
389 389
 	}
390 390
 	
391 391
 	if (log_stderr==0)
392
-		openlog(name, LOG_PID|LOG_CONS, LOG_LOCAL1 /*LOG_DAEMON*/);
392
+		openlog(name, LOG_PID|LOG_CONS, LOG_DAEMON);
393 393
 		/* LOG_CONS, LOG_PERRROR ? */
394 394
 	return  0;
395 395
 
... ...
@@ -757,7 +757,7 @@ int add_interfaces(char* if_name, int family, unsigned short port)
757 757
 	struct ip_addr addr;
758 758
 	int ret;
759 759
 
760
-#ifdef __FreeBSD__
760
+#ifdef HAVE_SOCKADDR_SA_LEN
761 761
 	#define MAX(a,b) ( ((a)>(b))?(a):(b))
762 762
 #endif
763 763
 	/* ipv4 or ipv6 only*/
... ...
@@ -787,7 +787,7 @@ int add_interfaces(char* if_name, int family, unsigned short port)
787 787
 	last=(char*)ifc.ifc_req+ifc.ifc_len;
788 788
 	for(ifr=ifc.ifc_req; (char*)ifr<last;
789 789
 			ifr=(struct ifreq*)((char*)ifr+sizeof(ifr->ifr_name)+
790
-			#ifdef  __FreeBSD__
790
+			#ifdef  HAVE_SOCKADDR_SA_LEN
791 791
 				MAX(ifr->ifr_addr.sa_len, sizeof(struct sockaddr))
792 792
 			#else
793 793
 				( (ifr->ifr_addr.sa_family==AF_INET)?
... ...
@@ -53,10 +53,9 @@
53 53
 
54 54
 
55 55
 /* define semun */
56
-#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
56
+#if defined(HAVE_UNION_SEMUN) && !defined(_SEM_SEMUN_UNDEFINED)
57 57
 	/* union semun is defined by including <sys/sem.h> */
58 58
 #else
59
-#ifndef __FreeBSD__
60 59
 	/* according to X/OPEN we have to define it ourselves */
61 60
 	union semun {
62 61
 		int val;                    /* value for SETVAL */
... ...
@@ -65,7 +64,6 @@
65 65
 		struct seminfo *__buf;      /* buffer for IPC_INFO */
66 66
 	};
67 67
 #endif
68
-#endif
69 68
 
70 69
 
71 70
 
... ...
@@ -250,7 +250,7 @@ struct hostent* sip_resolvehost(char* name, unsigned short* port);
250 250
 static inline struct hostent* resolvehost(const char* name)
251 251
 {
252 252
 	static struct hostent* he=0;
253
-#ifdef __sun
253
+#ifdef HAVE_GETIPNODEBYNAME 
254 254
 	int err;
255 255
 	static struct hostent* he2=0;
256 256
 #endif
... ...
@@ -275,14 +275,16 @@ static inline struct hostent* resolvehost(const char* name)
275 275
 #ifdef USE_IPV6
276 276
 	if(he==0){
277 277
 		/*try ipv6*/
278
-	#ifdef __sun
278
+	#ifdef HAVE_GETHOSTBYNAME2
279
+		he=gethostbyname2(name, AF_INET6);
280
+	#elif defined HAVE_GETIPNODEBYNAME
279 281
 		/* on solaris 8 getipnodebyname has a memory leak,
280 282
 		 * after some time calls to it will fail with err=3
281 283
 		 * solution: patch your solaris 8 installation */
282 284
 		if (he2) freehostent(he2);
283 285
 		he=he2=getipnodebyname(name, AF_INET6, 0, &err);
284 286
 	#else
285
-		he=gethostbyname2(name, AF_INET6);
287
+		#error neither gethostbyname2 or getipnodebyname present
286 288
 	#endif
287 289
 	}
288 290
 #endif
... ...
@@ -166,6 +166,9 @@ int load_module(char* path)
166 166
 	struct module_exports* exp;
167 167
 	struct sr_module* t;
168 168
 	
169
+#ifndef RTLD_NOW
170
+#define RTLD_NOW DL_LAZY
171
+#endif
169 172
 	handle=dlopen(path, RTLD_NOW); /* resolve all symbols now */
170 173
 	if (handle==0){
171 174
 		LOG(L_ERR, "ERROR: load_module: could not open module <%s>: %s\n",