Browse code

build system: avoid libraries re-compiling

- ignore module DEFS when deciding whether or not to recompile a
library: DEFS split into C_DEFS (for common DEFS which are taken
into account when deciding whether or not to recompile a lib)
and DEFS, which are now visible only inside the module or lib
that uses them. Same for INCLUDES and C_INCLUDES.

Andrei Pelinescu-Onciul authored on 19/03/2009 13:42:09
Showing 5 changed files
... ...
@@ -54,6 +54,8 @@
54 54
 #               the modules list can be changed without rebuilding the whole
55 55
 #               ser (andrei)
56 56
 #              added cfg-defs, new target that only rebuilds config.mak
57
+#  2009-03-10  replaced DEFS with C_DEFS (DEFS are now used only for
58
+#              "temporary" defines inside modules or libs) (andrei)
57 59
 #
58 60
 
59 61
 auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
... ...
@@ -203,7 +205,7 @@ ALLDEP=config.mak Makefile Makefile.sources Makefile.rules
203 205
 # hack to force makefile.defs re-inclusion (needed when make calls itself with
204 206
 # other options -- e.g. make bin)
205 207
 #makefile_defs=0
206
-#DEFS:=
208
+#C_DEFS:=
207 209
 
208 210
 
209 211
 # try saved cfg, unless we are in the process of building it
... ...
@@ -331,7 +333,7 @@ config.mak: Makefile.defs
331 333
 	@$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
332 334
 	@$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
333 335
 	@echo "override makefile_defs:=1" >>$@
334
-	@echo "DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(DEFS))" \
336
+	@echo "C_DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(C_DEFS))" \
335 337
 					"\$$(extra_defs)"  >>$@
336 338
 	@echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
337 339
 						"\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
... ...
@@ -66,6 +66,9 @@
66 66
 #  2008-06-26  support for make cfg / config.mak and hack to load 
67 67
 #               automatically config.mak when included from a module, lib 
68 68
 #               a.s.o (not from the main Makefile)  (andrei)
69
+#  2009-03-10  replaced DEFS with C_DEFS and INCLUDES with C_INCLUDES (DEFS
70
+#              and INCLUDES are now used only for "temporary" defines/includes
71
+#              inside modules or libs) (andrei)
69 72
 
70 73
 
71 74
 # check if already included/exported
... ...
@@ -460,7 +463,7 @@ endif
460 463
 #		adds support for Application Server interface
461 464
 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
462 465
 
463
-DEFS= $(extra_defs) \
466
+C_DEFS= $(extra_defs) \
464 467
 	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
465 468
 	 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
466 469
 	 -DSER_VER=$(SER_VER) \
... ...
@@ -507,14 +510,14 @@ DEFS= $(extra_defs) \
507 510
 # debugging symbols in all cases (-g). --andrei
508 511
 
509 512
 ifeq ($(CORE_TLS), 1)
510
-	DEFS+= -DUSE_TLS -DCORE_TLS
513
+	C_DEFS+= -DUSE_TLS -DCORE_TLS
511 514
 endif
512 515
 ifeq ($(TLS_HOOKS), 1)
513
-	DEFS+= -DUSE_TLS -DTLS_HOOKS
516
+	C_DEFS+= -DUSE_TLS -DTLS_HOOKS
514 517
 endif
515 518
 
516 519
 ifneq ($(STUN),)
517
-	DEFS+= -DUSE_STUN
520
+	C_DEFS+= -DUSE_STUN
518 521
 endif
519 522
 
520 523
 ifeq ($(mode),)
... ...
@@ -522,7 +525,7 @@ ifeq ($(mode),)
522 525
 endif
523 526
 
524 527
 ifeq ($(mode),debug)
525
-	DEFS+= -DEXTRA_DEBUG
528
+	C_DEFS+= -DEXTRA_DEBUG
526 529
 endif
527 530
 
528 531
 # platform dependent settings
... ...
@@ -598,7 +601,7 @@ endif
598 601
 
599 602
 ifeq ($(ARCH), arm)
600 603
 	use_fast_lock=yes
601
-	DEFS+=-DNOSMP # very unlikely to have an smp arm
604
+	C_DEFS+=-DNOSMP # very unlikely to have an smp arm
602 605
 endif
603 606
 
604 607
 ifeq ($(ARCH), arm6)
... ...
@@ -616,8 +619,8 @@ endif
616 619
 ifeq ($(ARCH), mips)
617 620
 # mips1 arch. (e.g. R3000) - no hardware locking support
618 621
 	use_fast_lock=no
619
-	DEFS+=-DMIPS_HAS_LLSC # likely
620
-	DEFS+=-DNOSMP # very likely
622
+	C_DEFS+=-DMIPS_HAS_LLSC # likely
623
+	C_DEFS+=-DNOSMP # very likely
621 624
 endif
622 625
 
623 626
 ifeq ($(ARCH), mips2)
... ...
@@ -632,24 +635,24 @@ endif
632 635
 
633 636
 ifeq ($(ARCH), alpha)
634 637
 	use_fast_lock=yes
635
-	DEFS+=-DNOSMP # very likely
638
+	C_DEFS+=-DNOSMP # very likely
636 639
 endif
637 640
 
638 641
 ifeq ($(use_fast_lock), yes)
639
-	DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
642
+	C_DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
640 643
 	found_lock_method=yes
641 644
 endif
642 645
 
643 646
 CFLAGS=
644 647
 LDFLAGS=
645
-INCLUDES=
648
+C_INCLUDES=
646 649
 # setting CFLAGS
647 650
 ifeq ($(mode), release)
648 651
 	#if i386
649 652
 ifeq	($(ARCH), i386)
650 653
 		# if gcc 
651 654
 ifeq		($(CC_NAME), gcc)
652
-				DEFS+=-DCC_GCC_LIKE_ASM
655
+				C_DEFS+=-DCC_GCC_LIKE_ASM
653 656
 				#common stuff
654 657
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
655 658
 			#if gcc 4.0+
... ...
@@ -692,7 +695,7 @@ endif			# CC_SHORTVER, 4.x
692 695
 
693 696
 else		# CC_NAME, gcc
694 697
 ifeq		($(CC_NAME), icc)
695
-			DEFS+=-DCC_GCC_LIKE_ASM
698
+			C_DEFS+=-DCC_GCC_LIKE_ASM
696 699
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
697 700
 					 -tpp6 -xK  #-openmp  #optimize for PIII 
698 701
 				# -prefetch doesn't seem to work
... ...
@@ -710,7 +713,7 @@ endif	#ARCH, i386
710 713
 ifeq	($(ARCH), x86_64)
711 714
 		# if gcc 
712 715
 ifeq		($(CC_NAME), gcc)
713
-				DEFS+=-DCC_GCC_LIKE_ASM
716
+				C_DEFS+=-DCC_GCC_LIKE_ASM
714 717
 				#common stuff
715 718
 				CFLAGS=-m64 -g -O9 -funroll-loops  -Wcast-align $(PROFILE)
716 719
 				LDFLAGS+=-m64
... ...
@@ -754,7 +757,7 @@ endif			# CC_SHORTVER, 4.x
754 757
 
755 758
 else		# CC_NAME, gcc
756 759
 ifeq		($(CC_NAME), icc)
757
-			DEFS+=-DCC_GCC_LIKE_ASM
760
+			C_DEFS+=-DCC_GCC_LIKE_ASM
758 761
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
759 762
 					 -tpp6 -xK  #-openmp  #optimize for PIII 
760 763
 				# -prefetch doesn't seem to work
... ...
@@ -772,7 +775,7 @@ endif	#ARCH, x86_64
772 775
 ifeq	($(ARCH), sparc64)
773 776
 			#if gcc
774 777
 ifeq		($(CC_NAME), gcc)
775
-				DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
778
+				C_DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
776 779
 				#common stuff
777 780
 				CFLAGS=-m64 -g -O9 -funroll-loops  $(PROFILE) \
778 781
 					#-Wcast-align \
... ...
@@ -834,7 +837,7 @@ endif			#CC_SHORTVER, 4.x
834 837
 	
835 838
 else		#CC_NAME, gcc
836 839
 ifeq		($(CC_NAME), suncc)
837
-			DEFS+=-DSPARC64_MODE
840
+			C_DEFS+=-DSPARC64_MODE
838 841
 			CFLAGS+= -m64 -g -xO5 -fast -native -xarch=v9 -xCC \
839 842
 					-xc99 # C99 support
840 843
 			# -Dinline="" # add this if cc < 5.3 (define inline as null)
... ...
@@ -849,7 +852,7 @@ endif	#ARCH, sparc64
849 852
 ifeq	($(ARCH), sparc)
850 853
 			#if gcc
851 854
 ifeq		($(CC_NAME), gcc)
852
-				DEFS+=-DCC_GCC_LIKE_ASM
855
+				C_DEFS+=-DCC_GCC_LIKE_ASM
853 856
 				#common stuff
854 857
 				CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
855 858
 					#-Wcast-align \
... ...
@@ -906,7 +909,7 @@ endif	#ARCH, sparc
906 909
 ifeq	($(ARCH), arm)
907 910
 		# if gcc 
908 911
 ifeq		($(CC_NAME), gcc)
909
-				DEFS+=-DCC_GCC_LIKE_ASM
912
+				C_DEFS+=-DCC_GCC_LIKE_ASM
910 913
 				#common stuff
911 914
 				CFLAGS=-O9 -funroll-loops $(PROFILE)
912 915
 			#if gcc 4.x+
... ...
@@ -948,7 +951,7 @@ endif	#ARCH, arm
948 951
 ifeq	($(ARCH), arm6)
949 952
 		# if gcc 
950 953
 ifeq		($(CC_NAME), gcc)
951
-				DEFS+=-DCC_GCC_LIKE_ASM
954
+				C_DEFS+=-DCC_GCC_LIKE_ASM
952 955
 				#common stuff
953 956
 				CFLAGS=-march=armv6 -O9 -funroll-loops \
954 957
 						$(PROFILE)
... ...
@@ -990,7 +993,7 @@ endif	#ARCH, arm6
990 993
 ifeq	($(ARCH), mips)
991 994
 		# if gcc 
992 995
 ifeq		($(CC_NAME), gcc)
993
-				DEFS+=-DCC_GCC_LIKE_ASM
996
+				C_DEFS+=-DCC_GCC_LIKE_ASM
994 997
 				#common stuff
995 998
 				CFLAGS=-O9 -funroll-loops  $(PROFILE)
996 999
 			#if gcc 4.0+
... ...
@@ -1031,7 +1034,7 @@ endif	#ARCH, mips
1031 1034
 ifeq	($(ARCH), mips2)
1032 1035
 		# if gcc 
1033 1036
 ifeq		($(CC_NAME), gcc)
1034
-				DEFS+=-DCC_GCC_LIKE_ASM
1037
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1035 1038
 				#common stuff
1036 1039
 				CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
1037 1040
 			#if gcc 4.0+
... ...
@@ -1070,7 +1073,7 @@ endif	#ARCH, mips2
1070 1073
 ifeq	($(ARCH), mips64)
1071 1074
 		# if gcc 
1072 1075
 ifeq		($(CC_NAME), gcc)
1073
-				DEFS+=-DCC_GCC_LIKE_ASM
1076
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1074 1077
 				#common stuff
1075 1078
 				CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
1076 1079
 			#if gcc 4.0+
... ...
@@ -1109,7 +1112,7 @@ endif	#ARCH, mips64
1109 1112
 ifeq	($(ARCH), alpha)
1110 1113
 		# if gcc 
1111 1114
 ifeq		($(CC_NAME), gcc)
1112
-				DEFS+=-DCC_GCC_LIKE_ASM
1115
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1113 1116
 				#common stuff
1114 1117
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
1115 1118
 			#if gcc 4.0+
... ...
@@ -1149,7 +1152,7 @@ endif	#ARCH, alpha
1149 1152
 ifeq	($(ARCH), ppc)
1150 1153
 		# if gcc 
1151 1154
 ifeq		($(CC_NAME), gcc)
1152
-				DEFS+=-DCC_GCC_LIKE_ASM
1155
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1153 1156
 				#common stuff
1154 1157
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
1155 1158
 			#if gcc 4.0+
... ...
@@ -1190,7 +1193,7 @@ endif	#ARCH, ppc
1190 1193
 ifeq	($(ARCH), ppc64)
1191 1194
 		# if gcc 
1192 1195
 ifeq		($(CC_NAME), gcc)
1193
-				DEFS+=-DCC_GCC_LIKE_ASM
1196
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1194 1197
 				#common stuff
1195 1198
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
1196 1199
 ifeq			($(CC_SHORTVER), 4.x)
... ...
@@ -1269,9 +1272,9 @@ endif
1269 1272
 else	#mode,release
1270 1273
 ifeq	($(CC_NAME), gcc)
1271 1274
 		CFLAGS=-g -Wcast-align $(PROFILE)
1272
-		DEFS+=-DCC_GCC_LIKE_ASM
1275
+		C_DEFS+=-DCC_GCC_LIKE_ASM
1273 1276
 ifeq		($(ARCH), sparc64)
1274
-			DEFS+=SPARC64_MODE
1277
+			C_DEFS+=SPARC64_MODE
1275 1278
 			CFLAGS+= -mcpu=ultrasparc -m64
1276 1279
 			LDFLAGS+=-m64
1277 1280
 endif
... ...
@@ -1292,7 +1295,7 @@ else
1292 1295
 endif
1293 1296
 endif
1294 1297
 ifeq	($(CC_NAME), icc)
1295
-		DEFS+=-DCC_GCC_LIKE_ASM
1298
+		C_DEFS+=-DCC_GCC_LIKE_ASM
1296 1299
 		CFLAGS=-g  $(PROFILE)
1297 1300
 		LDFLAGS+=-g -Wl,-E $(PROFILE)
1298 1301
 		MOD_LDFLAGS:=-shared $(LDFLAGS)
... ...
@@ -1357,27 +1360,27 @@ LIB_SUFFIX:=.so
1357 1360
 ifeq ($(OS), linux)
1358 1361
 # by default use futexes if available
1359 1362
 	use_futex= yes
1360
-	DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1363
+	C_DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1361 1364
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1362 1365
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1363 1366
 	ifneq ($(found_lock_method), yes)
1364
-		#DEFS+= -DUSE_POSIX_SEM
1365
-		DEFS+=-DUSE_PTHREAD_MUTEX
1367
+		#C_DEFS+= -DUSE_POSIX_SEM
1368
+		C_DEFS+=-DUSE_PTHREAD_MUTEX
1366 1369
 		LIBS+= -lpthread
1367
-		#DEFS+= -DUSE_SYSV_SEM  # try posix sems
1370
+		#C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
1368 1371
 		found_lock_method=yes
1369 1372
 	else
1370
-		ifneq (,$(findstring -DUSE_POSIX_SEM, $(DEFS)))
1373
+		ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1371 1374
 			LIBS+=-lpthread
1372 1375
 		endif
1373
-		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(DEFS)))
1376
+		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1374 1377
 			LIBS+=-lpthread
1375 1378
 		endif
1376 1379
 	endif
1377 1380
 	# check for >= 2.5.44
1378 1381
 	ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
1379 1382
 		ifeq ($(NO_EPOLL),)
1380
-			DEFS+=-DHAVE_EPOLL
1383
+			C_DEFS+=-DHAVE_EPOLL
1381 1384
 			# linux + gcc >= 3.0 + -malign-double + epoll => problems
1382 1385
 			CFLAGS_RM+=-malign-double
1383 1386
 			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
... ...
@@ -1386,17 +1389,17 @@ ifeq ($(OS), linux)
1386 1389
 	# check for >= 2.2.0
1387 1390
 	ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
1388 1391
 		ifeq ($(NO_SIGIO),)
1389
-			DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1392
+			C_DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1390 1393
 		endif
1391 1394
 	endif
1392 1395
 	# check for >= 2.5.70
1393 1396
 	ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
1394 1397
 		ifeq ($(use_futex), yes)
1395
-			DEFS+=-DUSE_FUTEX
1398
+			C_DEFS+=-DUSE_FUTEX
1396 1399
 		endif
1397 1400
 	endif
1398 1401
 	ifeq ($(NO_SELECT),)
1399
-		DEFS+=-DHAVE_SELECT
1402
+		C_DEFS+=-DHAVE_SELECT
1400 1403
 	endif
1401 1404
 	# sctp support
1402 1405
 	ifeq ($(SCTP),1)
... ...
@@ -1418,27 +1421,27 @@ $(info "sctp libraries not installed -- sctp disabled")
1418 1421
 		
1419 1422
 		ifeq ($(SCTP),1)
1420 1423
 			# use lksctp
1421
-			DEFS+=-DUSE_SCTP
1424
+			C_DEFS+=-DUSE_SCTP
1422 1425
 			LIBS+=-lsctp
1423 1426
 		endif
1424 1427
 	endif # SCTP
1425 1428
 endif
1426 1429
 
1427 1430
 ifeq  ($(OS), solaris)
1428
-	DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1431
+	C_DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1429 1432
 			-DHAVE_ALLOCA_H -DUSE_SIGACTION
1430 1433
 	ifneq ($(found_lock_method), yes)
1431
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1434
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1432 1435
 		found_lock_method=yes
1433 1436
 	endif
1434 1437
 	# check for ver >= 5.7
1435 1438
 	ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
1436 1439
 		ifeq ($(NO_DEVPOLL),)
1437
-			DEFS+=-DHAVE_DEVPOLL
1440
+			C_DEFS+=-DHAVE_DEVPOLL
1438 1441
 		endif
1439 1442
 	endif
1440 1443
 	ifeq ($(NO_SELECT),)
1441
-		DEFS+=-DHAVE_SELECT
1444
+		C_DEFS+=-DHAVE_SELECT
1442 1445
 	endif
1443 1446
 	# check for filio.h
1444 1447
 	filio_h_locations= /usr/include/sys/filio.h \
... ...
@@ -1448,7 +1451,7 @@ ifeq  ($(OS), solaris)
1448 1451
 						done;\
1449 1452
 				)
1450 1453
 	ifeq ($(has_filio_h), yes)
1451
-		DEFS+=-DHAVE_FILIO_H
1454
+		C_DEFS+=-DHAVE_FILIO_H
1452 1455
 	endif
1453 1456
 	ifeq ($(mode), release)
1454 1457
 		#use these only if you're using gcc with Solaris ld
... ...
@@ -1475,12 +1478,12 @@ endif
1475 1478
 endif
1476 1479
 
1477 1480
 ifeq ($(OS), freebsd)
1478
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1481
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1479 1482
 		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1480 1483
 		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1481 1484
 		-DHAVE_NETINET_IN_SYSTM
1482 1485
 	ifneq ($(found_lock_method), yes)
1483
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1486
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1484 1487
 		found_lock_method=yes
1485 1488
 		LIBS+= -pthread   #dlopen is in libc
1486 1489
 	else
... ...
@@ -1489,11 +1492,11 @@ ifeq ($(OS), freebsd)
1489 1492
 	# check for ver >= 4.1
1490 1493
 	ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
1491 1494
 		ifeq ($(NO_KQUEUE),)
1492
-			DEFS+=-DHAVE_KQUEUE
1495
+			C_DEFS+=-DHAVE_KQUEUE
1493 1496
 		endif
1494 1497
 	endif
1495 1498
 	ifeq ($(NO_SELECT),)
1496
-		DEFS+=-DHAVE_SELECT
1499
+		C_DEFS+=-DHAVE_SELECT
1497 1500
 	endif
1498 1501
 	YACC=yacc
1499 1502
 	# sctp support
... ...
@@ -1512,29 +1515,29 @@ $(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
1512 1515
 		endif
1513 1516
 		
1514 1517
 		ifeq ($(SCTP),1)
1515
-			DEFS+=-DUSE_SCTP
1518
+			C_DEFS+=-DUSE_SCTP
1516 1519
 			LIBS+=  # no extra libs needed on freebsd
1517 1520
 		endif
1518 1521
 	endif # SCTP
1519 1522
 endif
1520 1523
 
1521 1524
 ifeq ($(OS), openbsd)
1522
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
1525
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
1523 1526
 		-DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
1524 1527
 		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1525 1528
 		-DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT
1526 1529
 	ifneq ($(found_lock_method), yes)
1527
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1530
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1528 1531
 		found_lock_method=yes
1529 1532
 	endif
1530 1533
 	# check for ver >=2 9
1531 1534
 	ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
1532 1535
 		ifeq ($(NO_KQUEUE),)
1533
-			DEFS+=-DHAVE_KQUEUE
1536
+			C_DEFS+=-DHAVE_KQUEUE
1534 1537
 		endif
1535 1538
 	endif
1536 1539
 	ifeq ($(NO_SELECT),)
1537
-		DEFS+=-DHAVE_SELECT
1540
+		C_DEFS+=-DHAVE_SELECT
1538 1541
 	endif
1539 1542
 	# (symbols on openbsd are prefixed by "_")
1540 1543
 	YACC=yacc
... ...
@@ -1554,29 +1557,29 @@ endif
1554 1557
 endif
1555 1558
 	
1556 1559
 ifeq ($(OPENBSD_IS_AOUT), yes)
1557
-		DEFS+=-DDLSYM_PREFIX='"_"'
1560
+		C_DEFS+=-DDLSYM_PREFIX='"_"'
1558 1561
 		LDFLAGS=        # openbsd ld doesn't like -O2 or -E
1559 1562
 endif
1560 1563
 endif   # if opensd
1561 1564
 	
1562 1565
 ifeq ($(OS), netbsd)
1563
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1566
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1564 1567
 		-DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
1565 1568
 	ifneq ($(found_lock_method), yes)
1566
-		DEFS+= -DUSE_SYSV_SEM  # try pthread sems
1569
+		C_DEFS+= -DUSE_SYSV_SEM  # try pthread sems
1567 1570
 		found_lock_method=yes
1568 1571
 	endif
1569 1572
 	# check for ver >= 2.0.0
1570 1573
 	ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
1571 1574
 		ifeq ($(NO_KQUEUE),)
1572
-			DEFS+=-DHAVE_KQUEUE
1575
+			C_DEFS+=-DHAVE_KQUEUE
1573 1576
 			# netbsd + kqueue and -malign-double don't work
1574 1577
 			CFLAGS_RM+=-malign-double
1575 1578
 			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1576 1579
 		endif
1577 1580
 	endif
1578 1581
 	ifeq ($(NO_SELECT),)
1579
-		DEFS+=-DHAVE_SELECT
1582
+		C_DEFS+=-DHAVE_SELECT
1580 1583
 	endif
1581 1584
 	YACC=yacc
1582 1585
 	LIBS=  
... ...
@@ -1584,7 +1587,7 @@ endif
1584 1587
 
1585 1588
 # OS X support, same as freebsd
1586 1589
 ifeq ($(OS), darwin)
1587
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1590
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1588 1591
 		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1589 1592
 		-DUSE_ANON_MMAP \
1590 1593
 		-DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
... ...
@@ -1592,18 +1595,18 @@ ifeq ($(OS), darwin)
1592 1595
 	# -DNDEBUG used to turn off assert (assert wants to call
1593 1596
 	# eprintf which doesn't seem to be defined in any shared lib
1594 1597
 	ifneq ($(found_lock_method), yes)
1595
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1598
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1596 1599
 		found_lock_method=yes
1597
-		DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
1600
+		C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
1598 1601
 		                       # processes and unnamed posix sems are not
1599 1602
 		                       # supported)
1600 1603
 	endif
1601 1604
 	LIBS= -lresolv  #dlopen is in libc
1602 1605
 	ifeq ($(NO_KQUEUE),)
1603
-		DEFS+=-DHAVE_KQUEUE
1606
+		C_DEFS+=-DHAVE_KQUEUE
1604 1607
 	endif
1605 1608
 	ifeq ($(NO_SELECT),)
1606
-		DEFS+=-DHAVE_SELECT
1609
+		C_DEFS+=-DHAVE_SELECT
1607 1610
 	endif
1608 1611
 	LDFLAGS=        # darwin doesn't like -O2 or -E
1609 1612
 	# the modules uses symbols from ser => either 
... ...
@@ -1621,34 +1624,34 @@ endif
1621 1624
 
1622 1625
 ifneq (,$(findstring cygwin, $(OS)))
1623 1626
 	# cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
1624
-	#DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS))
1627
+	#C_DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(C_DEFS))
1625 1628
 	DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
1626
-	DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1629
+	C_DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1627 1630
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1628 1631
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1629 1632
 	ifneq ($(found_lock_method), yes)
1630
-		DEFS+= -DUSE_POSIX_SEM
1631
-		#DEFS+= -DUSE_SYSV_SEM  # try posix sems
1633
+		C_DEFS+= -DUSE_POSIX_SEM
1634
+		#C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
1632 1635
 		# PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
1633 1636
 		#LIBS+= -lpthread
1634 1637
 		found_lock_method=yes
1635 1638
 	else
1636
-		ifneq (,$(findstring -DUSE_POSIX_SEM, $(DEFS)))
1639
+		ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1637 1640
 			#LIBS+=-lpthread
1638 1641
 		endif
1639
-		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(DEFS)))
1642
+		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1640 1643
 $(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
1641 1644
 		endif
1642 1645
 	endif
1643 1646
 	# check for >= 2.5.70
1644 1647
 	ifeq ($(NO_SELECT),)
1645
-		DEFS+=-DHAVE_SELECT
1648
+		C_DEFS+=-DHAVE_SELECT
1646 1649
 	endif
1647 1650
 endif
1648 1651
 
1649 1652
 #add libssl if needed
1650 1653
 ifeq ($(CORE_TLS), 1)
1651
-DEFS+= -I$(LOCALBASE)/ssl/include
1654
+C_DEFS+= -I$(LOCALBASE)/ssl/include
1652 1655
 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
1653 1656
 		$(TLS_EXTRA_LIBS)
1654 1657
 # NOTE: depending on the way in which libssl was compiled you might
... ...
@@ -1657,13 +1660,13 @@ LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
1657 1660
 endif
1658 1661
 
1659 1662
 ifneq ($(STUN),)
1660
-DEFS+= -I$(LOCALBASE)/ssl/include
1663
+C_DEFS+= -I$(LOCALBASE)/ssl/include
1661 1664
 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lcrypto
1662 1665
 endif
1663 1666
 
1664 1667
 ifneq ($(found_lock_method), yes)
1665 1668
 $(warning	No locking method found so far, trying SYS V sems)
1666
-		DEFS+= -DUSE_SYSV_SEM  # try sys v sems
1669
+		C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems
1667 1670
 		found_lock_method=yes
1668 1671
 endif
1669 1672
 
... ...
@@ -1685,7 +1688,7 @@ export exported_vars
1685 1688
 #  is run)
1686 1689
 saved_fixed_vars:=	MAIN_NAME \
1687 1690
 		RELEASE OS ARCH \
1688
-		DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS INCLUDES \
1691
+		C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
1689 1692
 		MOD_LDFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \
1690 1693
 		LIB_SUFFIX LIB_PREFIX \
1691 1694
 		LIBS \
... ...
@@ -11,6 +11,9 @@
11 11
 #               installed if needed (andrei)
12 12
 #  2008-06-23  added the README & man targets (andrei)
13 13
 #  2008-06-27  make cfg / config.mak support (andrei)
14
+#  2009-03-10  replaced DEFS with C_DEFS and INCLUDES with C_INCLUDES (DEFS
15
+#              and INCLUDES are now used only for "temporary" defines/includes
16
+#              inside modules or libs) (andrei)
14 17
 #
15 18
 
16 19
 MOD_NAME=$(NAME:.so=)
... ...
@@ -26,9 +29,10 @@ override modules=
26 29
 override static_modules=
27 30
 override static_modules_path=
28 31
 
29
-# should be set in Makefile of apart module
32
+# should be set in the Makefile of each module
30 33
 # INCLUDES += -I$(COREPATH)
31 34
 
35
+# temporary def (visible only in the module, not exported)
32 36
 DEFS += -DMOD_NAME='"$(MOD_NAME)"'
33 37
 
34 38
 ifneq ($(makefile_defs_included),1)
... ...
@@ -19,7 +19,7 @@
19 19
 # Radiusclient-ng is often installed from tarballs so we
20 20
 # need to look int /usr/local/lib as well
21 21
 #
22
-DEFS+=-I$(LOCALBASE)/include
22
+INCLUDES+=-I$(LOCALBASE)/include
23 23
 
24 24
 ifneq ($(radiusclient_ng), 4)
25 25
 
... ...
@@ -6,7 +6,8 @@
6 6
 #
7 7
 
8 8
 #
9
-# Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, INCLUDES, LIBS, MKDEP, auto_gen, 
9
+# Uses: NAME, ALLDEP, CC, CFLAGS, C_DEFS, DEFS, C_INCLUDES, INCLUDES, LIBS, 
10
+#       MKDEP, auto_gen, 
10 11
 # auto_gen_others, depends, objs, extra_objs, static_modules, 
11 12
 # static_modules_path, LD_RPATH
12 13
 # (all this must  be defined previously!,  see Makefile.defs & Makefile)
... ...
@@ -20,19 +21,22 @@
20 21
 #              automatically build listed SER_LIBS if needed (andrei)
21 22
 #  2008-06-23  automatically rebuild if make time defines or includes
22 23
 #              changed (via makecfg.lst)
23
-#
24
+#  2009-03-10  support for C_DEFS and C_INCLUDES (DEFS and INCLUDES are now
25
+#              used only for "temporary" defines/includes inside modules or
26
+#              libs, C_DEFS and C_INCLUDES are used for the common stuff)
27
+#              (andrei)
24 28
 
25 29
 
26 30
 # check if the saved cfg corresponds with the current one
27 31
 # (if not rebuild everything)
28 32
 ifeq (,$(filter $(nodep_targets),$(MAKECMDGOALS)))
29 33
 -include makecfg.lst
30
-ifneq ($(strip $(DEFS)), $(strip $(CFG_DEFS)))
31
-#$(warning different defs: <$(strip $(DEFS))> != )
34
+ifneq ($(strip $(C_DEFS) $(DEFS)), $(strip $(CFG_DEFS)))
35
+#$(warning different defs: <$(strip $(C_DEFS) $(DEFS))> != )
32 36
 #$(warning               : <$(strip $(CFG_DEFS))>)
33 37
 $(shell rm -f makecfg.lst)
34 38
 endif
35
-ifneq ($(strip $(INCLUDES)), $(strip $(CFG_INCLUDES)))
39
+ifneq ($(strip $(C_INCLUDES) $(INCLUDES)), $(strip $(CFG_INCLUDES)))
36 40
 $(shell rm -f makecfg.lst)
37 41
 endif
38 42
 endif
... ...
@@ -41,10 +45,10 @@ ALLDEP+=makecfg.lst
41 45
 
42 46
 #implicit rules
43 47
 %.o:%.c  $(ALLDEP)
44
-	$(CC) $(CFLAGS) $(INCLUDES) $(DEFS) -c $< -o $@
48
+	$(CC) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) -c $< -o $@
45 49
 
46 50
 %.d: %.c $(ALLDEP)
47
-	@set -e; $(MKDEP) $(CFLAGS) $(INCLUDES) $(DEFS) $< \
51
+	@set -e; $(MKDEP) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) $<\
48 52
 	    |  sed 's#\(\($(*D)/\)\{0,1\}$(*F)\)\.o[ :]*#$*.o $@ : #g' > $@; \
49 53
 	    test -s $@ || ( rm -f $@; false )
50 54
 
... ...
@@ -134,8 +138,10 @@ librpath.lst: $(ALLDEP)
134 138
 	@echo LIB_RPATH_LST:=$(SER_RPATH_LST) >librpath.lst
135 139
 
136 140
 makecfg.lst:
137
-	@echo CFG_DEFS:=$(subst ',\', $(subst ",\", $(strip $(DEFS)))) >>$@
138
-	@echo CFG_INCLUDES:=$(subst ',\', $(subst ",\", $(strip $(INCLUDES)))) >>$@
141
+	@echo CFG_DEFS:=\
142
+		$(subst ',\', $(subst ",\", $(strip $(C_DEFS) $(DEFS)))) >>$@
143
+	@echo CFG_INCLUDES:=\
144
+		$(subst ',\', $(subst ",\", $(strip $(C_INCLUDES) $(INCLUDES)))) >>$@
139 145
 .PHONY: all
140 146
 all: $(NAME) modules
141 147