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