File: Makefile.defs

package info (click to toggle)
kamailio 5.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 63,604 kB
  • sloc: ansic: 666,678; xml: 177,688; cpp: 14,250; sh: 8,506; makefile: 7,910; sql: 7,758; yacc: 3,582; perl: 2,954; python: 1,763; java: 449; php: 258; cs: 40; awk: 27
file content (2101 lines) | stat: -rw-r--r-- 57,831 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
# Kamailio build system

#
# makefile defs (CC, LD,a.s.o)
#
# Environment variables:
#   PREFIX, LOCALBASE, BASEDIR
#   INSTALL, TAR , CC, LEX, YACC,
#   CPUTYPE, CC_EXTRA_OPTS, LD_EXTRA_OPTS
#   exclude_modules, skip_modules, include_modules
#   extra_defs
#

# default silent, unless Q= 0|no|off|verbose|noisy
quiet?=$(if $(filter 0 no off verbose noisy,$(Q)),verbose,silent)

# check if already included/exported

# used for sanity checks for Makefile.defs inclusion (!= makefile_defs which
# specifies if we have a set of valid defs)
override makefile_defs_included:=1
ifeq ($(makefile_defs),1)
ifeq ($(quiet),verbose)
$(info Makefile.defs defs skipped)
endif # verbose

else

ifeq (,$(main_makefile))
# hack to automatically use config.mak in all the modules, without
# changing the current module makefiles (which all include Makefile.defs):
# if not called from the main makefile (module, lib or ut):
# include config.mak, but if not present or incomplete (makefile_defs!=1)
# don't export the vars)
DEFCOREPATH = ../../src
ifneq ("$(wildcard $(DEFCOREPATH))","")
COREPATH?= ../../src
else
COREPATH?= ../..
endif
include $(COREPATH)/config.mak
ifeq ($(quiet),verbose)
$(info config.mak included)
endif # verbose
# config.mak should set makefile_defs if complete
export makefile_defs

else
override makefile_defs=1
export makefile_defs


ifeq ($(quiet),verbose)
$(info normal Makefile.defs exec)
endif # verbose

-include Makefile.vars

# usage: $(call set_if_empty,VAR,value)
set_if_empty=$(if $($(1)),,$(eval override $(1)=$(2)))

# flavour: sip-router, ser or kamailio
$(call	set_if_empty,FLAVOUR,kamailio)

#prefix for various configs and scripts
#config name/name-prefix for distributed configs
CFG_NAME?=sip-router
#config name/name-prefix for distributed scripts
SCR_NAME=sip-router
#name in source tree
SRC_NAME=sip-router

ifeq ($(FLAVOUR),sip-router)
# main binary name
MAIN_NAME=ser
else ifeq ($(FLAVOUR),ser)
# main binary name
MAIN_NAME=ser
else ifeq ($(FLAVOUR),kamailio)
# main binary name
MAIN_NAME=kamailio
# use kamailio config
CFG_NAME=kamailio
# kamailio statistics on
KMSTATS ?= 1
# fast malloc statistics on
FMSTATS ?= 1
else # unknown:
# main binary name
MAIN_NAME=kamailio
endif

# application server support on
WITHAS ?= 1
# enable core hooks for SCTP
SCTP ?= 1
# enable raw sockets
RAW_SOCKS ?= yes
ifeq ($(RAW_SOCKS),1)
	RAW_SOCKS = yes
endif

# what to install
INSTALL_FLAVOUR=$(FLAVOUR)

# version number
VERSION = 5
PATCHLEVEL = 2
SUBLEVEL = 1
EXTRAVERSION = 

# memory manager switcher
# 0 - f_malloc (fast malloc)
# 1 - q_malloc (quick malloc)
# 2 - tlsf_malloc (O(1) malloc and free)
MEMMNG ?= 0
# memory debugger switcher
# 0 - off (no-debug mode)
# 1 - on (debug mode)
MEMDBG ?= 1

VERSIONVAL = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
			$(SUBLEVEL) )
RELEASE:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
OS := $(shell uname -s | sed -e s/SunOS/solaris/ -e s/CYGWIN.*/cygwin/ \
		 | tr "[A-Z]" "[a-z]" | tr "/" "_")

ifeq ($(OS),solaris)
	GETARCH=isainfo -n
ifeq ($(GETARCH),)
	GETARCH=uname -p
endif
else
	GETARCH=uname -m
endif

HOST_ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4[uv]/sparc64/  \
			-e s/armv[3-5].*/arm/  -e s/armv6.*/arm6/ \
			-e "s/Power Macintosh/ppc/" \
			-e "s/cobalt/mips2/" \
			-e s/amd64/x86_64/ -e s/sparcv9/sparc64/ )
# fix sparc -> sparc64
ifeq ($(HOST_ARCH),sparc)
	ifeq ($(shell uname -m),sun4u)
		HOST_ARCH := sparc64
	endif
	ifeq ($(shell uname -m),sun4v)
		HOST_ARCH := sparc64
	endif
endif

OSREL := $(shell uname -r)
# numerical version (good for comparisons: A.B.C => A*1000000+B*1000+C)
OSREL_N:= $(shell echo $(OSREL) | sed -e 's/^[^0-9]*//' \
		-e 's/^\([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*$$/\1/g' | \
		(IFS=. read A B C D; R=0; \
		[ -n "$$A" ] && R=`expr $$R \* 1000 + $$A` && \
		[ -n "$$B" ] && R=`expr $$R \* 1000 + $$B` && \
		[ -n "$$C" ] && R=`expr $$R \* 1000 + $$C`; echo $$R ) )


# TLS support
CORE_TLS ?=
# by default compile with tls hooks support (so that no ser recompile is
#  needed before the tls module can be used)
TLS_HOOKS=1
ifeq ($(CORE_TLS), 1)
	RELEASE:=$(RELEASE)-tls
	TLS_HOOKS:=0
endif
ifeq ($(TLS_HOOKS), 1)
#	RELEASE:=$(RELEASE)-tls
endif

# extra CC command line options (e.g  -march=athlon-mp)
CC_EXTRA_OPTS ?=

# extra LD command line options
LD_EXTRA_OPTS ?=

ifeq ($(OS), solaris)
#use GNU versions
INSTALL ?= ginstall
TAR ?= gtar
else
INSTALL ?= install
TAR ?= tar
endif

INSTALL_TOUCH = touch          # used to create the file first (good to
                               #  make solaris install work)
INSTALL_CFG = $(INSTALL) -m 644
INSTALL_BIN = $(INSTALL) -m 755
INSTALL_SCRIPT = $(INSTALL) -m 755
INSTALL_MODULES = $(INSTALL) -m 755
INSTALL_LIB = $(INSTALL) -m 755
INSTALL_DOC = $(INSTALL) -m 644
INSTALL_MAN = $(INSTALL) -m 644
INSTALL_SHARE = $(INSTALL) -m 644

#set some vars from the environment (and not make builtins)
CC   := $(shell echo "$${CC}")
LEX  := $(shell echo "$${LEX}")
YACC := $(shell echo "$${YACC}")




# find compiler name & version
ifeq ($(CC),)
	CC=gcc
endif
LD= $(CC)
CC_LONGVER:=$(shell if  $(CC) -v 2>/dev/null; then \
						$(CC) -v 2>&1 ;\
					else \
						$(CC) -V 2>&1 ; \
					fi )
CC_OPT ?= -O9
MKTAGS=ctags

#find-out the compiler's name

ifneq (,$(findstring gcc, $(CC_LONGVER)))
	CC_NAME=gcc
	RPAREN=)
	CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|\
				sed  -e 's/([^$(RPAREN)]*)//g' \
					 -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
					 -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
#	CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|cut -d" " -f 3\
#				|sed -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
#				 	 -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
	# sed with POSIX.1 regex doesn't support |, + or ?
	# (darwin, solaris ...) => this complicated expression
	MKDEP=$(CC) -MM -MG
	#transform gcc version into 2.9x or 3.0
	CC_SHORTVER:=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
				 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
				 sed -e 's/2\.9.*/2.9x/' \
					-e 's/3\.[0-3]\..*/3.0/' \
					-e 's/3\.[0-3]/3.0/' \
					-e 's/3\.[4-9]\..*/3.4/' \
					-e 's/3\.[4-9]/3.4/' \
					-e 's/4\.[0-1]\..*/4.x/' \
					-e 's/4\.[0-1]/4.x/' \
					-e 's/4\.[2-4]\..*/4.2+/' \
					-e 's/4\.[2-4]$$/4.2+/' \
					-e 's/4\.[5-9]\..*/4.5+/' \
					-e 's/4\.[5-9]$$/4.5+/' \
					-e 's/5\.[0-9]\..*/5.0+/' \
					-e 's/5\.[0-9]$$/5.0+/' \
					-e 's/6\.[0-9]\..*/6.0+/' \
					-e 's/6\.[0-9]$$/6.0+/' \
					-e 's/7\.[0-9]\..*/7.0+/' \
					-e 's/7\.[0-9]$$/7.0+/' \
					-e 's/8\.[0-9]\..*/8.0+/' \
					-e 's/8\.[0-9]$$/8.0+/')
ifeq (,$(strip $(filter-out 3.0 3.4 4.x 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
	# dependencies can be generated on-the-fly while compiling *.c
	CC_MKDEP_OPTS=-MMD -MP
endif # 3.0 <= $(CC_SHORTVER) <= 4.x
endif # gcc

ifneq (, $(findstring Sun, $(CC_LONGVER)))
	CC_NAME=suncc
	CC_SHORTVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
					sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
	CC_VER=$(CC) $(CC_SHORTVER)
	MKDEP=$(CC) -xM1
	CC_MKDEP_OPTS=-xMMD
endif

ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
	# very nice: gcc compatible
	CC_NAME=icc
	CC_FULLVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
					sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
	CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
	CC_VER=$(CC) $(CC_FULLVER)
	MKDEP=$(CC) -MM
endif

ifneq (, $(findstring clang, $(CC_LONGVER)))
	#clang should be gcc compatible
	CC_NAME=clang
	CC_FULLVER:=$(shell echo "$(CC_LONGVER)" | head -n 1 |  sed -e 's/.*version \([0-9]\.[0-9]\).*/\1/g' )
	CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
	CC_VER=$(CC) $(CC_FULLVER)
	CC_OPT=-O3
	MKDEP=$(CC) -MM
endif

ifeq (,$(CC_NAME))
#not found
	CC_NAME=$(CC)
	CC_SHORTVER=unknown
	CC_VER=unknown
	MKDEP=gcc -MM
$(warning	Unknown compiler $(CC)\; supported compilers: \
			gcc, sun cc, intel icc )
endif

# ARCH detection
# predefined compiler macros for different architectures
# (see http://predef.sourceforge.net/prearch.html for a more complete list)
i386_macros= i386 __i386__ __i486__ __i586__ __i686__ \
			__i386 _M_IX86 __X86__ _X86_
x86_64_macros= __amd64__ __amd64 __x86_64__ __x86_64 _M_X64

sparc_macros= __sparc__ __sparc __sparcv8
sparc64_macros= __sparcv9 __sparc_v9__

arm_macros= __arm__ __thumb__
arm6_macros= __ARM_ARCH_6__

aarch64_macros= __aarch64__

ppc_macros= __powerpc __powerpc__ __POWERPC__ __ppc__ _ARCH_PPC
ppc64_macros= __ppc64__ _ARCH_PPC64

mips_macros= __mips__ __mips _MIPS_ARCH_MIPS1
mips2_macros= _MIPS_ISA_MIPS2 _MIPS_ISA_MIPS3 _MIPS_ISA_MIPS4 \
			_MIPS_ARCH_MIPS2 _MIPS_ARCH_MIPS3 _MIPS_ARCH_MIPS4
mips64_macros= _MIPS_ISA_MIPS64 _MIPS_ARCH_MIPS64

alpha_macros= __alpha__ __alpha _M_ALPHA_

ifeq ($(CC_NAME),gcc)
#if gcc use gcc arch
predef_macros:=$(shell $(CC) -dM -E -x c $(CC_EXTRA_OPTS) $(extra_defs) \
					$(CFLAGS) /dev/null)

ifneq ($(strip $(filter $(i386_macros), $(predef_macros))),)
CC_ARCH=i386
else ifneq ($(strip $(filter $(x86_64_macros), $(predef_macros))),)
CC_ARCH=x86_64
else ifneq ($(strip $(filter $(sparc_macros), $(predef_macros))),)

ifneq ($(strip $(filter $(sparc64_macros), $(predef_macros))),)
CC_ARCH=sparc64
else # sparc64_macros
CC_ARCH=sparc
endif # sparc64_macros

else ifneq ($(strip $(filter $(arm_macros), $(predef_macros))),)

ifneq ($(strip $(filter $(arm6_macros), $(predef_macros))),)
CC_ARCH=arm6
else # arm6_macros
CC_ARCH=arm
endif # arm6_macros

else ifneq ($(strip $(filter $(ppc64_macros), $(predef_macros))),)
CC_ARCH=ppc64
else ifneq ($(strip $(filter $(ppc_macros), $(predef_macros))),)
CC_ARCH=ppc
else ifneq ($(strip $(filter $(mips_macros), $(predef_macros))),)

ifneq ($(strip $(filter $(mips64_macros), $(predef_macros))),)
CC_ARCH=mips64
else ifneq ($(strip $(filter $(mips2_macros), $(predef_macros))),)
CC_ARCH=mips2
else # mips2_macros
CC_ARCH=mips
endif # mips64_macros

else ifneq ($(strip $(filter $(alpha_macros), $(predef_macros))),)
CC_ARCH=alpha
else

$(warn "Unknown target compiler architecture")

endif # predefined macros tests (x86_macros, ...)

endif # gcc

ifdef CC_ARCH
ARCH:=$(CC_ARCH)
else
ARCH:=$(HOST_ARCH)
endif

# retarget amd64 to x86_64
ifeq ($(ARCH), amd64)
	override ARCH=x86_64
endif

$(info target architecture <$(ARCH)>, host architecture <$(HOST_ARCH)>)

LIBDIR ?= lib

# dirs
cfg_dir = etc/$(MAIN_NAME)/
bin_dir = sbin/
share_dir = share/$(MAIN_NAME)/
# lib/$(MAIN_NAME)/modules , lib/$(MAIN_NAME)/modules-s, lib/$(MAIN_NAME)/modules-k
modules_dir = $(LIBDIR)/$(MAIN_NAME)/
lib_dir = $(LIBDIR)/$(MAIN_NAME)/
run_dir = var/run/$(MAIN_NAME)/
doc_dir = doc/$(MAIN_NAME)/
man_dir = man/
data_dir = $(MAIN_NAME)/

ifeq ($(OS), linux)
	doc_dir = share/doc/$(MAIN_NAME)/
	man_dir = share/man/
	data_dir = share/$(MAIN_NAME)/
	LOCALBASE ?= /usr/local
endif

ifeq ($(OS), gnu_kfreebsd)
	doc_dir = share/doc/$(MAIN_NAME)/
	man_dir = share/man/
	data_dir = share/$(MAIN_NAME)/
	LOCALBASE ?= /usr/local
endif

ifeq ($(OS), freebsd)
	doc_dir = share/doc/$(MAIN_NAME)/
	man_dir = man/
	data_dir = share/$(MAIN_NAME)/
	LOCALBASE ?= /usr/local
endif

ifeq ($(OS), openbsd)
	doc_dir = share/doc/$(MAIN_NAME)/
	man_dir = man/
	data_dir = share/$(MAIN_NAME)/
	LOCALBASE ?= /usr/local
endif

ifeq ($(OS), netbsd)
	doc_dir = share/doc/$(MAIN_NAME)/
	man_dir = man/
	data_dir = share/$(MAIN_NAME)/
	LOCALBASE ?= /usr/pkg
endif

ifeq ($(OS), dragonfly)
	doc_dir = share/doc/$(MAIN_NAME)/
	man_dir = man/
	data_dir = share/$(MAIN_NAME)/
	LOCALBASE ?= /usr/pkg
endif

ifeq ($(OS), darwin)
	doc_dir = share/doc/$(MAIN_NAME)/
	man_dir = man/
	data_dir = share/$(MAIN_NAME)/
	LOCALBASE ?= /usr/local
endif

LOCALBASE ?= /usr/local

# Doxygen directory
doxygen_dir=doc/doxygen

BASEDIR ?= $(DESTDIR)
basedir = $(BASEDIR)
RUNBASEDIR ?= $(DESTDIR)
runbasedir = $(RUNBASEDIR)

# install location
PREFIX ?= $(LOCALBASE)
prefix = $(PREFIX)
# install path is $(basedir) $(prefix)
# example:
#  creating a bin. archive in /tmp, which unpacks in /usr/local
#  basedir=/tmp
#  prefix=/usr/local

# install prefixes for various stuff
cfg_prefix = $(basedir)$(prefix)
bin_prefix = $(basedir)$(prefix)
modules_prefix = $(basedir)$(prefix)
lib_prefix = $(basedir)$(prefix)
run_prefix = $(runbasedir)
doc_prefix = $(basedir)$(prefix)
man_prefix = $(basedir)$(prefix)
ut_prefix = $(basedir)$(prefix)
share_prefix = $(basedir)$(prefix)
data_prefix = $(basedir)$(prefix)


# target dirs for various stuff
cfg_target = $(prefix)/$(cfg_dir)
bin_target = $(prefix)/$(bin_dir)
#modules_target = $(prefix)/$(modules_dir)
lib_target = $(prefix)/$(lib_dir)
run_target = $(run_prefix)/$(run_dir)
share_target = $(prefix)/$(share_dir)
doc_target = $(prefix)/$(doc_dir)
data_target = $(prefix)/$(data_dir)


# compile-time options
#
# -DSTATS
#		allows to print out number of packets processed on CTRL-C;
# 		implementation still nasty and reports per-process
# -DNO_DEBUG
#		turns off some of the debug messages (DBG(...)).
# -DNO_LOG
#		completely turns of all the logging (and DBG(...))
# -DEXTRA_DEBUG
#		compiles in some extra debugging code
# -DDNS_IP_HACK
#		faster ip address resolver for ip strings (e.g "127.0.0.1")
# -DSHM_MEM
#		compiles in shared mem. support, needed by some modules and
#		by USE_SHM_MEM
# -DSHM_MMAP
#		use mmap instead of SYSV shared memory
# -DPKG_MALLOC
#		uses a faster malloc (exclusive w/ USE_SHM_MEM)
# -DUSE_SHM_MEM
#		all pkg_malloc => shm_malloc (most mallocs use a common sh.
#		mem. segment); don't define PKG_MALLOC if you want this!
# -DDBG_QM_MALLOC
#		qm_malloc debug code, will cause pkg_malloc and shm_malloc
#		to keep and display lot of debuging information: file name,
#		function, line number of malloc/free call for each block,
#		extra error checking (trying to free the same pointer
#		twice, trying to free a pointer alloc'ed with a different
#		malloc etc.)
# -DVQ_MALLOC
#		additional option to PKG_MALLOC which utilizes a fater then
#		qm version
#		(not true anymore, q_malloc performs approx. the same)
# -DQ_MALLOC
#		custom quick malloc, recommended for debugging
# -DF_MALLOC
#		an even faster malloc, not recommended for debugging
# -DTLSF_MALLOC
#       an implemetation of the "two levels segregated fit" malloc algorithm
# -DDL_MALLOC
#		a malloc implementation based on Doug Lea's dl_malloc
# -DSF_MALLOC
#		an experimental multi-CPU, pool based, multi-process safe version of
#		F_MALLOC. Should give better performance on machines with lots of CPUs
#		after some tunning.
# -DLL_MALLOC
#		an experimental multi-CPU, pool based, multi-process safe, mostly
#		lockless version of SF_MALLOC/F_MALLOC. Not for production use for
#		now.
# -DDBG_MALLOC
#		issues additional debugging information if lock/unlock is called
# -DMEM_JOIN_FREE
#		enable the join of free memory chunks (see also mem_join cfg param)
# -DFAST_LOCK
#		uses fast arhitecture specific locking (see the arh. specific section)
# -DUSE_SYSV_SEM
#		uses sys v sems for locking (slower & limited number)
# -DUSE_PTHREAD_MUTEX
#		uses pthread mutexes, faster than sys v or posix sems, but do not
#		work on all systems inter-processes (e.g. linux)
# -DUSE_POSIX_SEM
#		uses posix semaphores for locking (faster than sys v)
# -DUSE_FUTEX
#		uses futexes for locking (linux 2.6+)
# -DBUSY_WAIT
#		uses busy waiting on the lock (FAST_LOCK)
# -DADAPTIVE_WAIT
#		try busy waiting for a while and if the lock is still held go to
#		force reschedule (FAST_LOCK)
# -DADAPTIVE_WAIT_LOOPS=number
#		number of loops we busy wait, after "number" loops have elapsed we
#		force a reschedule (FAST_LOCK)
# -DNOSMP
#		don't use smp compliant locking (faster but won't work on SMP machines)
#		(not yet enabled) (FAST_LOCK)
# -DNO_PINGTEL_TAG_HACK
#		if enabled, To-header-field will be less liberal and will not accept
#		'tag=' (tag parameter with equal sign and without value); it is called
#		this way because such message was sighted from a Pingtel phone
# -DUSE_TCP
#		compiles in tcp support
# -DDISABLE_NAGLE
#		disable the tcp Nagle algorithm (lower delay)
# -DUSE_TLS
#		compiles in tls support, requires -DUSE_TCP. Note: this is only
#		generic support (parsing a.s.o.), it does not include the actual
#		"tls engine". If you really want tls you need also either
#		-DCORE_TLS and a tls/ subdir with the tls code or -DTLS_HOOKS and
#		the tls module loaded.
# -DCORE_TLS
#		compiles tls in-core support. Requires -DUSE_TLS, conflicts
#		-DTLS_HOOKS. Please use make CORE_TLS=1 instead  (it will set all the
#		needed defines automatically and extra libraries needed for linking).
# -DTLS_HOOKS
#		compile tls module support (support for having the "tls engine" in a
#		module). Requires -DUSE_TLS, conflicts -DCORE_TLS.
#		Please use make TLS_HOOKS=1 (or TLS_HOOKS=0 to for disabling) instead
#		of setting -DTLS_HOOKS (it will set all the needed defines
#		automatically)
# -DHAVE_RESOLV_RES
#		support for changing some of the resolver parameters present
#		 (_res structure in <resolv.h>)
# -DUSE_COMP
#		compiles in comp=[sergz|sigcomp] support (parsing uri & via,
#		adding it to via, lumps a.s.o). WARNING: right now this option
#		is useless since the compression code doesn't exist yet.
# -DHONOR_MADDR
#		compiles in checks and use for maddr parameter in uri.
#		Required to support Windows Messenger 5.x over TCP connection
#		which (mis)uses this parameter.
# -DUSE_DNS_CACHE
#		use an internal dns cache instead of making dns requests each time
# -DUSE_DNS_CACHE_STATS
#		turns on DNS cache measurements
# -DUSE_DNS_FAILOVER
#		if the destination resolves to multiple ips, on send error fall back
#		to the others
# -DUSE_DST_BLACKLIST
#		blacklist bad destination (timeout, failed to connect, error sending
#        a.s.o)
# -DUSE_DST_BLACKLIST_STATS
#		turns on blacklist bad destination measurements
# -DPROFILING
#		if enabled profiling will be enabled for child processes
#		Don't forget to set PROFILE (see below)
# -DNO_SIG_DEBUG
#        turns off debugging messages in signal handlers (which might be
#         unsafe)
# -DUSE_NAPTR
#		 turns on naptr support (but must be also enabled from the config)
# -DDNS_WATCHDOG_SUPPORT
#		turns on DNS watchdog support which can be used to inform the
#		core that the DNS servers are down. No DNS query is performed
#		when the servers are unreachable, and even expired resource
#		records are used from the cache. (requires external watchdog)
# -DWITH_AS_SUPPORT
#		adds support for Application Server interface
# Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore

ifeq ($(OS), dragonfly)
	# Tell it that dragonflybsd is equivalent to compiling for freebsd, but
	# define also __OS_dragonfly (for fine-tunning like kqueue support).
	os_defs := -D__OS_freebsd -D__OS_dragonfly
	EQUIV_OS = freebsd
else
	os_defs := -D__OS_$(OS)
	EQUIV_OS = $(OS)
endif

C_DEFS= $(extra_defs) \
	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
	 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
	 -D__CPU_$(ARCH) $(os_defs) \
	 -DVERSIONVAL=$(VERSIONVAL) \
	 -DCFG_DIR='"$(cfg_target)"'\
	 -DSHARE_DIR='"$(share_target)"'\
	 -DRUN_DIR='"$(run_target)"'

ifneq ($(MEMPKG), sys)
C_DEFS+= -DPKG_MALLOC
endif

C_DEFS+= -DSHM_MEM  -DSHM_MMAP \
	 -DDNS_IP_HACK \
	 -DUSE_MCAST \
	 -DUSE_TCP \
	 -DDISABLE_NAGLE \
	 -DHAVE_RESOLV_RES \
	 -DUSE_DNS_CACHE \
	 -DUSE_DNS_FAILOVER \
	 -DUSE_DST_BLACKLIST \
	 -DUSE_NAPTR \
	 -DWITH_XAVP \
	 #-DUSE_DNS_CACHE_STATS \
	 #-DUSE_DST_BLACKLIST_STATS \
	 #-DDNS_WATCHDOG_SUPPORT \
	 #-DLL_MALLOC \
	 #-DSF_MALLOC \
	 #-DDL_MALLOC \
	 #-DDBG_F_MALLOC \
	 #-DNO_DEBUG \
	 #-DEXTRA_DEBUG \
	 #-DVQ_MALLOC  \
	 #-DDBG_LOCK \
	 #-DNOSMP \
	 #-DUSE_SHM_MEM \
	 #-DSTATS \
	 #-DNO_LOG \
	 #-DPROFILING \
	 #-DNO_SIG_DEBUG

#PROFILE=  -pg	# set this if you want profiling
				# you may also want to set -DPROFILING

# WARNING: do not add mode=debug or mode=release anymore in the Makefile,
# use make mode=debug all instead. By default Kamailio is compiled with
# debugging symbols in all cases (-g) and without optimization (-O0).

# memory managers and related debug mode
C_DEFS+= -DMEM_JOIN_FREE
# enable f_malloc
C_DEFS+= -DF_MALLOC
# enable q_malloc
C_DEFS+= -DQ_MALLOC
# enable TLSF malloc
C_DEFS+= -DTLSF_MALLOC

ifeq ($(MEMDBG), 1)
	C_DEFS+= -DDBG_SR_MEMORY

ifeq ($(MEMPKG), sys)
ifeq ($(MEMDBGSYS), 1)
	C_DEFS+= -DDBG_SYS_MEMORY
endif
endif

endif

ifneq ($(PKG_MEM_SIZE),)
	C_DEFS+= -DPKG_MEM_SIZE=$(PKG_MEM_SIZE)
endif
ifeq ($(CORE_TLS), 1)
	C_DEFS+= -DUSE_TLS -DCORE_TLS
endif
ifeq ($(TLS_HOOKS), 1)
	C_DEFS+= -DUSE_TLS -DTLS_HOOKS
endif
ifeq ($(KMSTATS), 1)
	C_DEFS+= -DUSE_CORE_STATS -DSTATISTICS
endif
ifeq ($(FMSTATS), 1)
	C_DEFS+= -DMALLOC_STATS
endif
ifeq ($(WITHAS), 1)
	C_DEFS+= -DWITH_AS_SUPPORT
endif

ifeq ($(SCTP), 1)
	C_DEFS+= -DUSE_SCTP
endif

ifeq ($(mode),)
	mode = release
endif

ifeq ($(mode),debug)
	C_DEFS+= -DEXTRA_DEBUG
endif

# platform dependent settings

# find ld & as name (gnu or solaris)
ifeq ($(OS), solaris)
ifeq ($(CC_NAME), gcc)
		LDGCC:=$(shell $(CC) -v 2>&1 | grep with-ld| \
				   sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
		ASGCC:=$(shell $(CC) -v 2>&1 | grep with-as| \
				   sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
		LDPATH:=$(shell  if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
						else \
						if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
							echo $(LDGCC); \
						else echo "ld" ; \
						fi\
						fi)
		ASPATH:=$(shell  if [ -z "$(ASGCC)" ] ; then echo "as" ;\
						else \
						if $(ASGCC) -V 2>/dev/null 1>/dev/null </dev/null; \
						then \
							echo $(ASGCC); \
						else echo "as" ; \
						fi\
						fi)

		LDTYPE:=$(shell if $(LDPATH) -V 1>/dev/null  2>/dev/null; then \
							if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
							then echo gnu; \
							else \
							if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
							then echo solaris; \
							else \
								echo unknown ; \
							fi \
							fi \
						fi)
		ASTYPE:=$(shell if $(ASPATH) -V 1>/dev/null  2>/dev/null </dev/null; \
						then \
							if $(ASPATH) -V 2>&1 </dev/null | \
								grep GNU >/dev/null; then echo gnu; \
							else \
							if $(ASPATH) -V 2>&1 </dev/null | \
								grep Sun >/dev/null; then echo solaris; \
							else \
								echo unknown ; \
							fi \
							fi \
						fi)
#$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")

endif
endif

# arch. specific definitions
ifeq ($(ARCH), i386)
	use_fast_lock=yes
endif

ifeq ($(ARCH), x86_64)
	use_fast_lock=yes
endif

ifeq ($(ARCH), sparc64)
ifeq 	($(CC_NAME), gcc)
	use_fast_lock=yes
endif
endif

ifeq ($(ARCH), sparc)
	use_fast_lock=yes
endif

ifeq ($(ARCH), arm)
	use_fast_lock=yes
	C_DEFS+=-DNOSMP # very unlikely to have an smp arm
endif

ifeq ($(ARCH), arm6)
	use_fast_lock=yes
	C_DEFS+=-DNOSMP # very unlikely to have an smp arm
endif

ifeq ($(ARCH), aarch64)
	use_fast_lock=yes
	C_DEFS+=-DNOSMP
endif

ifeq ($(ARCH), ppc)
	use_fast_lock=yes
endif

ifeq ($(ARCH), ppc64)
	use_fast_lock=yes
endif

ifeq ($(ARCH), mips)
# mips1 arch. (e.g. R3000) - no hardware locking support
	use_fast_lock=no
	C_DEFS+=-DMIPS_HAS_LLSC # likely
	C_DEFS+=-DNOSMP # very likely
endif

ifeq ($(ARCH), mips2)
# mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
	use_fast_lock=yes
endif

ifeq ($(ARCH), mips64)
# mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
	use_fast_lock=yes
endif

ifeq ($(ARCH), alpha)
	use_fast_lock=yes
	C_DEFS+=-DNOSMP # very likely
endif

ifeq ($(use_fast_lock), yes)
	C_DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024
	found_lock_method=yes
endif

CFLAGS=
LDFLAGS=
C_INCLUDES=
# setting CFLAGS
ifeq ($(mode), release)
	#if i386
ifeq	($(ARCH), i386)
		# if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS=-g $(CC_OPT) -funroll-loops  -Wcast-align $(PROFILE)
			#if gcc 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
$(call				set_if_empty,CPUTYPE,generic)
					CFLAGS+=-m32 -minline-all-stringops \
							-falign-loops \
							-ftree-vectorize \
							-fno-strict-overflow \
							-mtune=$(CPUTYPE)
					LDFLAGS+=-m32
else
			#if gcc 4.0+
ifeq			($(CC_SHORTVER), 4.x)
$(call				set_if_empty,CPUTYPE,athlon64)
					CFLAGS+=-m32 -minline-all-stringops \
							-falign-loops \
							-ftree-vectorize \
							-mtune=$(CPUTYPE)
					LDFLAGS+=-m32
else
			#if gcc 3.4+
ifeq			($(CC_SHORTVER), 3.4)
$(call				set_if_empty,CPUTYPE,athlon)
					CFLAGS+=-m32 -minline-all-stringops \
							-falign-loops \
							-mtune=$(CPUTYPE)
					LDFLAGS+=-m32
else
			#if gcc 3.0+
ifeq			($(CC_SHORTVER), 3.0)
$(call				set_if_empty,CPUTYPE,athlon)
					CFLAGS+=-minline-all-stringops \
							-falign-loops \
							-mcpu=$(CPUTYPE)
					# -m32 supported since gcc 3.2
else
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
					for better results)

					CFLAGS+=-m486 \
							-malign-loops=4
else
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version  ($(CC_SHORTVER)), compile at your own risk!)

endif			# CC_SHORTVER, 2.9x
endif			# CC_SHORTVER, 3.0
endif			# CC_SHORTVER, 3.4
endif			# CC_SHORTVER, 4.x
endif			# CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		# CC_NAME, gcc
ifeq		($(CC_NAME), clang)
$(call                          set_if_empty,CPUTYPE,athlon64)
					C_DEFS+=-DCC_GCC_LIKE_ASM
					CFLAGS+=-g -m32 $(CC_OPT) -mtune=$(CPUTYPE)
					LDFLAGS+=-m32
else			# CC_NAME, clang
ifeq		($(CC_NAME), icc)
			C_DEFS+=-DCC_GCC_LIKE_ASM
			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
					 -tpp6 -xK  #-openmp  #optimize for PIII
				# -prefetch doesn't seem to work
				#( ty to inline acroos files, unroll loops,prefetch,
				# optimize for PIII, use PIII instructions & vect.,
				# mutlithread loops)
else
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, icc
endif		#CC_NAME, clang
endif		#CC_NAME, gcc
endif	#ARCH, i386

#x86_64
ifeq	($(ARCH), x86_64)
		# if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS=-g $(CC_OPT) -funroll-loops  -Wcast-align $(PROFILE)
			#if gcc 4.5+
ifeq			($(CC_SHORTVER),$(filter $(CC_SHORTVER),4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+))
$(call				set_if_empty,CPUTYPE,generic)
					CFLAGS+=-m64 -minline-all-stringops \
							-falign-loops \
							-ftree-vectorize \
							-fno-strict-overflow \
							-mtune=$(CPUTYPE)
					LDFLAGS+=-m64
else
			#if gcc 4.0+
ifeq			($(CC_SHORTVER), 4.x)
$(call				set_if_empty,CPUTYPE,athlon64)
					CFLAGS+=-m64 -minline-all-stringops \
							-falign-loops \
							-ftree-vectorize \
							-mtune=$(CPUTYPE)
					LDFLAGS+=-m64
else
			#if gcc 3.4
ifeq			($(CC_SHORTVER), 3.4)
$(call				set_if_empty,CPUTYPE,athlon64)
					CFLAGS+=-m64 -minline-all-stringops \
							-falign-loops
					LDFLAGS+=-m64
else
			#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
$(call				set_if_empty,CPUTYPE,athlon64)
					CFLAGS+=-minline-all-stringops \
							-falign-loops
							#-mcpu=$(CPUTYPE) \ # not working on all x86_64 gccs
							#-mcpu=athlon
					#-m64 on x86_64/x86 works starting with gcc 3.2
else
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
					for better results)

					CFLAGS+=-m486 \
							-malign-loops=4
else
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version  ($(CC_SHORTVER)), compile at your own risk!)

endif			# CC_SHORTVER, 2.9x
endif			# CC_SHORTVER, 3.0
endif			# CC_SHORTVER, 3.4
endif			# CC_SHORTVER, 4.x
endif			# CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+

else		# CC_NAME, gcc
ifeq            ($(CC_NAME), clang)
$(call                          set_if_empty,CPUTYPE,opteron)
					C_DEFS+=-DCC_GCC_LIKE_ASM
                                        CFLAGS+=-g -m64 \
                                                $(CC_OPT)
                                        LDFLAGS+=-m64
else      	# CC_NAME, clang
ifeq		($(CC_NAME), icc)
			C_DEFS+=-DCC_GCC_LIKE_ASM
			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
					 -tpp6 -xK  #-openmp  #optimize for PIII
				# -prefetch doesn't seem to work
				#( ty to inline acroos files, unroll loops,prefetch,
				# optimize for PIII, use PIII instructions & vect.,
				# mutlithread loops)
else
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, icc
endif		#CC_NAME, clang
endif		#CC_NAME, gcc
endif	#ARCH, x86_64

	#if sparc64
ifeq	($(ARCH), sparc64)
			#if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
				#common stuff
				CFLAGS=-g $(CC_OPT) -funroll-loops  $(PROFILE) \
					#-Wcast-align \
					#-Wmissing-prototypes
				#if gcc 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
$(call				set_if_empty,CPUTYPE,ultrasparc)
					#use 32bit for now
					CFLAGS+=-m64 -mcpu=ultrasparc  \
							-mtune=$(CPUTYPE) \
							-fno-strict-overflow \
							-ftree-vectorize
					# use -m64 to force 64 bit (but add it also to LDFLAGS and
					#  don't forget to define SPARC64_MODE)
					# -m32 for 32 bit (default on solaris),
					# nothing for arch. default
					LDFLAGS+=-m64
else
				#if gcc 4.x
ifeq			($(CC_SHORTVER), 4.x)
$(call				set_if_empty,CPUTYPE,ultrasparc)
					#use 32bit for now
					CFLAGS+=-m64 -mcpu=ultrasparc  \
							-mtune=$(CPUTYPE) \
							-ftree-vectorize
					LDFLAGS+=-m64
else
				#if gcc 3.4
ifeq			($(CC_SHORTVER), 3.4)
$(call				set_if_empty,CPUTYPE,ultrasparc)
					#use 32bit for now
					CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPUTYPE)
					LDFLAGS+=-m64
else
				#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
$(call				set_if_empty,CPUTYPE,ultrasparc)
					#use 32bit for now
					CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPUTYPE)   \
					# -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
					#-mno-epilogue #try to inline function exit code
					#-mflat # omit save/restore
					#-,faster-structs #faster non Sparc ABI structure copy ops
					LDFLAGS+=-m64
else			# CC_SHORTVER, 3.0
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
					for better results)
ifneq				($(OS), netbsd)
						# on netbsd/sparc64,  gcc 2.95.3 does not compile
						# ser with -mv8
						CFLAGS+= -mv9
						# -m64/-m32 on sparc works starting with gcc 3.0
endif
ifeq					($(ASTYPE), solaris)
							CFLAGS+= -Wa,-xarch=v8plus
endif
else			#CC_SHORTVER, 2.9x
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version ($(CC_SHORTVER)), compile at your own risk!)

					CFLAGS+= -mv9
ifeq					($(ASTYPE), solaris)
							CFLAGS+= -Wa,-xarch=v8plus
endif

endif			#CC_SHORTVER, 2.9x
endif			#CC_SHORTVER, 3.0
endif			#CC_SHORTVER, 3.4
endif			#CC_SHORTVER, 4.x
endif			#CC_SHORTVER, 8.0+ 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		#CC_NAME, gcc
ifeq		($(CC_NAME), suncc)
			C_DEFS+=-DCC_GCC_LIKE_ASM
			C_DEFS+=-DSPARC64_MODE
			CFLAGS+= -m64 -g -xO3 -xtarget=native -xmemalign=8i \
					-fma=fused -fns=yes \
					-xc99 # C99 support
			LDFLAGS+=-m64
			# -Dinline="" # add this if cc < 5.3 (define inline as null)
else
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, suncc
endif		#CC_NAME, gcc
endif	#ARCH, sparc64

	#if sparc
ifeq	($(ARCH), sparc)
			#if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS=-g $(CC_OPT) -funroll-loops  $(PROFILE) \
					#-Wcast-align \
					#-Wmissing-prototypes
				#if gcc 5.0+, 4.5+ or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
$(call				set_if_empty,CPUTYPE,v8)
					#use 32bit for now
					CFLAGS+= -mtune=$(CPUTYPE) \
							-fno-strict-overflow \
							-ftree-vectorize
else
				#if gcc 4.x
ifeq			($(CC_SHORTVER), 4.x)
$(call				set_if_empty,CPUTYPE,v8)
					#use 32bit for now
					CFLAGS+= -mtune=$(CPUTYPE) \
							-ftree-vectorize
else
				#if gcc 3.4
ifeq			($(CC_SHORTVER), 3.4)
$(call				set_if_empty,CPUTYPE,v8)
					#use 32bit for now
					CFLAGS+= -mtune=$(CPUTYPE)
else
				#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
$(call				set_if_empty,CPUTYPE,v8)
					#use 32bit for now
					CFLAGS+= -mtune=$(CPUTYPE)   \
					#-mno-epilogue #try to inline function exit code
					#-mflat # omit save/restore
					#-,faster-structs #faster non Sparc ABI structure copy ops
else			# CC_SHORTVER, 3.0
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
					for better results)
else			#CC_SHORTVER, 2.9x
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version ($(CC_SHORTVER)), compile at your own risk!)

endif			#CC_SHORTVER, 2.9x
endif			#CC_SHORTVER, 3.0
endif			#CC_SHORTVER, 3.4
endif			#CC_SHORTVER, 4.x
endif			#CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		#CC_NAME, gcc
ifeq		($(CC_NAME), suncc)
			C_DEFS+=-DCC_GCC_LIKE_ASM
			CFLAGS+= -g -xO3 -xtarget=native -xmemalign=4i \
					-fma=fused -fns=yes \
					-xc99 # C99 support
			# -Dinline="" # add this if cc < 5.3 (define inline as null)
else
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, suncc
endif		#CC_NAME, gcc
endif	#ARCH, sparc

	#if ipaq/netwinder
ifeq	($(ARCH), arm)
		# if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS=-marm -march=armv5t $(CC_OPT) -funroll-loops -fsigned-char $(PROFILE)
			#if gcc 4.5+ or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
					CFLAGS+= -ftree-vectorize -fno-strict-overflow
					# not supported on arm: -minline-all-stringops
else
			#if gcc 4.x+
ifeq			($(CC_SHORTVER), 4.x)
					CFLAGS+= -ftree-vectorize
					# not supported on arm: -minline-all-stringops
else
			#if gcc 3.4+
ifeq			($(CC_SHORTVER), 3.4)
					CFLAGS+=
else
			#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
					CFLAGS+=
							#-mcpu=athlon
else
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
					for better results)

					CFLAGS+=
else
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version ($(CC_SHORTVER)), compile at your own risk!)

endif			# CC_SHORTVER, 2.9x
endif			# CC_SHORTVER, 3.0
endif			# CC_SHORTVER, 3.4
endif			# CC_SHORTVER, 4.x
endif			# CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		# CC_NAME, gcc
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, gcc
endif	#ARCH, arm

	#if armv6 cpu
ifeq	($(ARCH), arm6)
		# if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS=-march=armv6 $(CC_OPT) -funroll-loops -fsigned-char \
						$(PROFILE)
			#if gcc 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
					CFLAGS+= -ftree-vectorize -fno-strict-overflow
else
			#if gcc 4.x+
ifeq			($(CC_SHORTVER), 4.x)
					CFLAGS+= -ftree-vectorize
else
			#if gcc 3.4+
ifeq			($(CC_SHORTVER), 3.4)
					CFLAGS+=
else
			#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
					CFLAGS+=
							#-mcpu=athlon
else
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
					for better results)

					CFLAGS+=
else
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version ($(CC_SHORTVER)), compile at your own risk!)

endif			# CC_SHORTVER, 2.9x
endif			# CC_SHORTVER, 3.0
endif			# CC_SHORTVER, 3.4
endif			# CC_SHORTVER, 4.x
endif			# CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		# CC_NAME, gcc
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, gcc
endif	#ARCH, arm6

	#if  mips (R3000)
ifeq	($(ARCH), mips)
		# if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS=$(CC_OPT) -funroll-loops  $(PROFILE)
			#if gcc 8.0+, 7.0+, 6.0, 5.0+, 4.5+ or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
					CFLAGS+=-mfp32 -march=r3000 \
							-ftree-vectorize -fno-strict-overflow
			# not supported on mips: -minline-all-stringops
else
			#if gcc 4.0+
ifeq			($(CC_SHORTVER), 4.x)
					CFLAGS+=-march=r3000 \
							-ftree-vectorize
			# not supported on mips: -minline-all-stringops
else
			#if gcc 3.4+
ifeq			($(CC_SHORTVER), 3.4)
					CFLAGS+= -march=r3000
else
			#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
					CFLAGS+= -march=r3000
else
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
					for better results)

					CFLAGS+=-march=r3000
else
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version ($(CC_SHORTVER)), compile at your own risk!)

endif			# CC_SHORTVER, 2.9x
endif			# CC_SHORTVER, 3.0
endif			# CC_SHORTVER, 3.4
endif			# CC_SHORTVER, 4.x
endif			# CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		# CC_NAME, gcc
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, gcc
endif	#ARCH, mips

	#if  >=mips2 (R4000, R5000, R6000 ....)
ifeq	($(ARCH), mips2)
		# if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS= -mips2 $(CC_OPT) -funroll-loops $(PROFILE)
			#if gcc 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
					CFLAGS+=-ftree-vectorize -fno-strict-overflow
			# not supported on mips: -minline-all-stringops
else
			#if gcc 4.0+
ifeq			($(CC_SHORTVER), 4.x)
					CFLAGS+=-ftree-vectorize
			# not supported on mips: -minline-all-stringops
else
			#if gcc 3.4+
ifeq			($(CC_SHORTVER), 3.4)
					CFLAGS+=
else
			#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
					CFLAGS+=
else
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
					for better results)
					CFLAGS+=
else
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version ($(CC_SHORTVER)), compile at your own risk!)

endif			# CC_SHORTVER, 2.9x
endif			# CC_SHORTVER, 3.0
endif			# CC_SHORTVER, 3.4
endif			# CC_SHORTVER, 4.x
endif			# CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		# CC_NAME, gcc
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, gcc
endif	#ARCH, mips2

#if  >=mips64
ifeq	($(ARCH), mips64)
		# if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS= -mips64 $(CC_OPT) -funroll-loops $(PROFILE)
			#if gcc 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
					CFLAGS+=-ftree-vectorize -fno-strict-overflow
			# not supported on mips: -minline-all-stringops

else
			#if gcc 4.0+
ifeq			($(CC_SHORTVER), 4.x)
					CFLAGS+=-ftree-vectorize
			# not supported on mips: -minline-all-stringops
else
			#if gcc 3.4+
ifeq			($(CC_SHORTVER), 3.4)
					CFLAGS+=
else
			#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
					CFLAGS+=
else
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
					for better results)
					CFLAGS+=
else
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version ($(CC_SHORTVER)), compile at your own risk!)

endif			# CC_SHORTVER, 2.9x
endif			# CC_SHORTVER, 3.0
endif			# CC_SHORTVER, 3.4
endif			# CC_SHORTVER, 4.x
endif			# CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		# CC_NAME, gcc
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, gcc
endif	#ARCH, mips64

#if  alpha
ifeq	($(ARCH), alpha)
		# if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS= $(CC_OPT) -funroll-loops $(PROFILE)
			#if gcc 5.0+, 4.5 or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
					CFLAGS+= -fno-strict-overflow
					# not supported: -minline-all-stringops
else
			#if gcc 4.0+
ifeq			($(CC_SHORTVER), 4.x)
					CFLAGS+=
					# not supported: -minline-all-stringops
else
			#if gcc 3.4+
ifeq			($(CC_SHORTVER), 3.4)
					CFLAGS+=
else
			#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
					CFLAGS+=
else
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
					for better results)
					CFLAGS+=
else
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version ($(CC_SHORTVER)), compile at your own risk!)

endif			# CC_SHORTVER, 2.9x
endif			# CC_SHORTVER, 3.0
endif			# CC_SHORTVER, 3.4
endif			# CC_SHORTVER, 4.x
endif			# CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		# CC_NAME, gcc
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, gcc
endif	#ARCH, alpha

#if  ppc
ifeq	($(ARCH), ppc)
		# if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS=
			#if gcc 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
$(call				set_if_empty,CPUTYPE,powerpc)
ifeq 				($(NOALTIVEC),)
						CFLAGS += $(CC_OPT) -funroll-loops -fsigned-char $(PROFILE)
						CFLAGS += -ftree-vectorize
						CFLAGS += -maltivec
						CFLAGS += -fno-strict-overflow
						CFLAGS += -mtune=$(CPUTYPE)
endif
else
			#if gcc 4.0+
ifeq			($(CC_SHORTVER), 4.x)
$(call				set_if_empty,CPUTYPE,powerpc)
ifeq 				($(NOALTIVEC),)
						CFLAGS += $(CC_OPT) -funroll-loops -fsigned-char $(PROFILE)
						CFLAGS += -ftree-vectorize
						CFLAGS += -maltivec
						CFLAGS += -mtune=$(CPUTYPE)
endif
else
			#if gcc 3.4+
ifeq			($(CC_SHORTVER), 3.4)
					CFLAGS+=
else
			#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
					CFLAGS+=
else
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
					for better results)
					CFLAGS+=
else
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version ($(CC_SHORTVER)), compile at your own risk!)

endif			# CC_SHORTVER, 2.9x
endif			# CC_SHORTVER, 3.0
endif			# CC_SHORTVER, 3.4
endif			# CC_SHORTVER, 4.x
endif			# CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		# CC_NAME, gcc
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, gcc
endif	#ARCH, ppc

#if  ppc64
ifeq	($(ARCH), ppc64)
		# if gcc
ifeq		($(CC_NAME), gcc)
				C_DEFS+=-DCC_GCC_LIKE_ASM
				#common stuff
				CFLAGS= $(CC_OPT) -funroll-loops -fsigned-char $(PROFILE)
			#if gcc 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+
ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+ 7.0+ 8.0+,$(CC_SHORTVER))))
$(call				set_if_empty,CPUTYPE,powerpc64)
					CFLAGS+=-ftree-vectorize \
							-fno-strict-overflow \
							-mtune=$(CPUTYPE) -maltivec
else
			#if gcc 4.0+
ifeq			($(CC_SHORTVER), 4.x)
$(call				set_if_empty,CPUTYPE,powerpc64)
					CFLAGS+=-ftree-vectorize \
							-mtune=$(CPUTYPE) -maltivec
else
			#if gcc 3.4+
ifeq			($(CC_SHORTVER), 3.4)
					CFLAGS+=
else
			#if gcc 3.0
ifeq			($(CC_SHORTVER), 3.0)
					CFLAGS+=
else
ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
					for better results)
					CFLAGS+=
else
				#really old version
$(warning			You are using an old and unsupported gcc \
					 version ($(CC_SHORTVER)), compile at your own risk!)

endif			# CC_SHORTVER, 2.9x
endif			# CC_SHORTVER, 3.0
endif			# CC_SHORTVER, 3.4
endif			# CC_SHORTVER, 4.x
endif			# CC_SHORTVER, 8.0+, 7.0+, 6.0+, 5.0+, 4.5+ or 4.2+

else		# CC_NAME, gcc
				#other compilers
$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
endif		#CC_NAME, gcc
endif	#ARCH, ppc

CFLAGS+= $(CC_EXTRA_OPTS)


# setting LDFLAGS
ifeq	($(CC_NAME), gcc)
ifeq		($(LDTYPE), solaris)
		# solaris ld
		LDFLAGS+=-O2 $(PROFILE)
		MOD_LDFLAGS:=-G $(LDFLAGS)
		LIB_LDFLAGS:=-G $(LDFLAGS)
		LIB_SONAME=-Wl,-h,
		LD_RPATH=-Wl,-R,
else
		#gcc and maybe others, => gnu ld
		LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
		MOD_LDFLAGS:=-shared $(LDFLAGS)
		LIB_LDFLAGS:=-shared $(LDFLAGS)
		LIB_SONAME=-Wl,-soname,
		LD_RPATH=-Wl,-rpath,
endif
endif
ifeq	($(CC_NAME), icc)
	#gcc and maybe others
	LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
	MOD_LDFLAGS:=-shared $(LDFLAGS)
	LIB_LDFLAGS:=-shared $(LDFLAGS)
	LIB_SONAME=-Wl,-soname,
	LD_RPATH=-Wl,-rpath,
endif
ifeq	($(CC_NAME), suncc)
	# -dy?
	LDFLAGS+=-xO3 $(PROFILE)
	MOD_LDFLAGS:=-G $(LDFLAGS)
	LIB_LDFLAGS:=-G $(LDFLAGS)
	LIB_SONAME=-Wl,-h,
	LD_RPATH=-Wl,-R,
endif
	# we need -fPIC -DPIC only for shared objects, we don't need them for
	# the executable file, because it's always loaded at a fixed address
	# -andrei

ifeq ($(CC_NAME), clang)
	LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
	MOD_LDFLAGS:=-shared $(LDFLAGS)
	LIB_LDFLAGS:=-shared $(LDFLAGS)
	LIB_SONAME=-Wl,-soname,
	LD_RPATH=-Wl,-rpath,
endif

LDFLAGS+= $(LD_EXTRA_OPTS)
MOD_LDFLAGS+= $(LD_EXTRA_OPTS)
LIB_LDFLAGS+= $(LD_EXTRA_OPTS)

else	#mode,release
ifeq	($(CC_NAME), gcc)
		CFLAGS=-g -Wcast-align $(PROFILE)
		C_DEFS+=-DCC_GCC_LIKE_ASM
ifeq		($(ARCH), sparc64)
			C_DEFS+=SPARC64_MODE
			CFLAGS+= -mcpu=ultrasparc -m64
			LDFLAGS+=-m64
endif
ifeq		($(LDTYPE), solaris)
			#solaris ld
			LDFLAGS+=-g $(PROFILE)
			MOD_LDFLAGS:=-G $(LDFLAGS)
			LIB_LDFLAGS:=-G $(LDFLAGS)
			LIB_SONAME=-Wl,-h,
			LD_RPATH=-Wl,-R,
else
			#gnu or other ld type
			LDFLAGS+=-g -Wl,-E $(PROFILE)
			MOD_LDFLAGS:=-shared $(LDFLAGS)
			LIB_LDFLAGS:=-shared $(LDFLAGS)
			LIB_SONAME=-Wl,-soname,
			LD_RPATH=-Wl,-rpath,
endif
endif
ifeq	($(CC_NAME), icc)
		C_DEFS+=-DCC_GCC_LIKE_ASM
		CFLAGS=-g  $(PROFILE)
		LDFLAGS+=-g -Wl,-E $(PROFILE)
		MOD_LDFLAGS:=-shared $(LDFLAGS)
		LIB_LDFLAGS:=-shared $(LDFLAGS)
		LIB_SONAME=-Wl,-soname,
		LD_RPATH=-Wl,-rpath,
endif
ifeq	($(CC_NAME), suncc)
		CFLAGS= -g $(PROFILE)
		LDFLAGS+=-g $(PROFILE)
		MOD_LDFLAGS:=-G $(LDFLAGS)
		LIB_LDFLAGS:=-G $(LDFLAGS)
		LIB_SONAME=-Wl,-h,
		LD_RPATH=-Wl,-R,
endif

endif #mode=release


# set pedantic compiler options
ifeq ($(CC_NAME), gcc)
		CFLAGS+= -Wall
else # no gcc
ifeq ($(CC_NAME), icc)
		CFLAGS+= -Wall
else # no icc
ifeq ($(CC_NAME), clang)
		CFLAGS+= -Wunused-variable -Wuninitialized
endif # CC_NAME=clang
endif # CC_NAME=icc
endif # CC_NAME=gcc

#CFLAGS used for compiling the modules, libraries and utils
ifeq	($(CC_NAME), gcc)
MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
endif
ifeq	($(CC_NAME), icc)
MOD_CFLAGS=-Kpic $(CFLAGS)
LIB_CFLAGS=-Kpic $(CFLAGS)
endif
ifeq	($(CC_NAME), suncc)
MOD_CFLAGS=-xcode=pic32 $(CFLAGS)
LIB_CFLAGS=-xcode=pic32 $(CFLAGS)
endif
ifeq    ($(CC_NAME), clang)
MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
endif

UTILS_CFLAGS=$(CFLAGS)
# LDFLAGS uses for compiling the utils
UTILS_LDFLAGS=$(LDFLAGS)

ifeq ($(LEX),)
	LEX=flex
endif
ifeq ($(YACC),)
	YACC=bison
endif
YACC_FLAGS=-d -b core/cfg
# on solaris add -lxnet (e.g. LIBS= -lxnet)
LIBS= -ldl -lresolv
LIB_PREFIX:=lib
LIB_SUFFIX:=.so


#os specific stuff
ifeq ($(OS), linux)
# by default use futexes if available
	use_futex= yes
	C_DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DHAVE_IP_MREQN
	ifeq ($(RAW_SOCKS), yes)
		C_DEFS+= -DUSE_RAW_SOCKS
	endif
	ifneq ($(found_lock_method), yes)
		#C_DEFS+= -DUSE_POSIX_SEM
		C_DEFS+=-DUSE_PTHREAD_MUTEX
		LIBS+= -lpthread
		#C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
		found_lock_method=yes
	else
		ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
			LIBS+=-lpthread
		endif
		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
			LIBS+=-lpthread
		endif
	endif

	# check for >= 2.5.44
	ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
		ifeq ($(NO_EPOLL),)
			C_DEFS+=-DHAVE_EPOLL
			# linux + gcc >= 3.0 + -malign-double + epoll => problems
			CFLAGS_RM+=-malign-double
			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
		endif
	endif
	# check for >= 2.2.0
	ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
		ifeq ($(NO_SIGIO),)
			C_DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
		endif
	endif
	# check for >= 2.5.70
	ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
		ifeq ($(use_futex), yes)
			C_DEFS+=-DUSE_FUTEX
		endif
	endif
	ifeq ($(NO_SELECT),)
		C_DEFS+=-DHAVE_SELECT
	endif
endif

ifeq ($(OS), gnu_kfreebsd)
# by default use futexes if available
	use_futex= yes
	C_DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
	ifeq ($(RAW_SOCKS), yes)
		C_DEFS+= -DUSE_RAW_SOCKS
	endif
	ifneq ($(found_lock_method), yes)
		#C_DEFS+= -DUSE_POSIX_SEM
		C_DEFS+=-DUSE_PTHREAD_MUTEX
		LIBS+= -lpthread
		#C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
		found_lock_method=yes
	else
		ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
			LIBS+=-lpthread
		endif
		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
			LIBS+=-lpthread
		endif
	endif

	# check for ver >= 4.1
	ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
		ifeq ($(NO_KQUEUE),)
			C_DEFS+=-DHAVE_KQUEUE
		endif
	endif
	ifeq ($(NO_SELECT),)
		C_DEFS+=-DHAVE_SELECT
	endif
endif

ifeq  ($(OS), solaris)
	C_DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
			-DHAVE_ALLOCA_H -DUSE_SIGACTION
	ifneq ($(found_lock_method), yes)
		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
		found_lock_method=yes
	endif
	# check for ver >= 5.7
	ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
		ifeq ($(NO_DEVPOLL),)
			C_DEFS+=-DHAVE_DEVPOLL
		endif
	endif
	ifeq ($(NO_SELECT),)
		C_DEFS+=-DHAVE_SELECT
	endif
	# check for filio.h
	filio_h_locations= /usr/include/sys/filio.h \
						$(LOCALBASE)/include/sys/filio.h
	has_filio_h=$(shell for r in $(filio_h_locations); do \
						if  [ -r "$$r" ] ; then echo yes; exit; fi \
						done;\
				)
	ifeq ($(has_filio_h), yes)
		C_DEFS+=-DHAVE_FILIO_H
	endif
	ifeq ($(mode), release)
		#use these only if you're using gcc with Solaris ld
		#LDFLAGS=-O2 $(PROFILE)
		#MOD_LDFLAGS=-O2 -G
	else
		#LDFLAGS=-g $(PROFILE)
		#MOD_LDFLAGS=-g -G
	endif
	#YACC=yacc

ifeq ($(CC_NAME), suncc)
	LIBS= -ldl -lresolv
endif
	OLD_SOLARIS= $(shell echo "$(OSREL)" | \
				sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
	LIBS+= -L$(LOCALBASE)/lib -lxnet -lsocket -lnsl -lmd5
ifeq	($(OLD_SOLARIS), yes)
		LIBS+=-lposix4
else
		LIBS+=-lrt
endif
	# -lrt needed for sched_yield
endif

ifeq ($(OS), freebsd)
	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
		-DHAVE_NETINET_IN_SYSTM -DHAVE_IP_MREQN
	ifeq ($(RAW_SOCKS), yes)
		C_DEFS+= -DUSE_RAW_SOCKS
	endif
	ifneq ($(found_lock_method), yes)
		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
		found_lock_method=yes
		LIBS+= -pthread   #dlopen is in libc
	else
		LIBS=   #dlopen is in libc
	endif
	# check for ver >= 4.1
	ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
		ifeq ($(NO_KQUEUE),)
			C_DEFS+=-DHAVE_KQUEUE
		endif
	endif
	ifeq ($(NO_SELECT),)
		C_DEFS+=-DHAVE_SELECT
	endif
	YACC=yacc
endif

ifeq ($(OS), dragonfly)
	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
		-DHAVE_NETINET_IN_SYSTM
	ifneq ($(found_lock_method), yes)
		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
		found_lock_method=yes
		LIBS+= -pthread   #dlopen is in libc
	else
		LIBS=   #dlopen is in libc
	endif
	# dragonfly was forked from freebsd 4.8 => all version have kqueue
	ifeq ($(NO_KQUEUE),)
		C_DEFS+=-DHAVE_KQUEUE
	endif
	ifeq ($(NO_SELECT),)
		C_DEFS+=-DHAVE_SELECT
	endif
	YACC=yacc
endif

ifeq ($(OS), openbsd)
	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
		-DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
		-DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT \
		-DHAVE_SCHED_YIELD
	ifneq ($(found_lock_method), yes)
		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
		found_lock_method=yes
	endif
	# check for ver >=2 9
	ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
		ifeq ($(NO_KQUEUE),)
			C_DEFS+=-DHAVE_KQUEUE
		endif
	endif
	ifeq ($(NO_SELECT),)
		C_DEFS+=-DHAVE_SELECT
	endif
	# (symbols on openbsd are prefixed by "_")
	YACC=yacc
	# unfortunately pthread is needed for sigwait
	LIBS= -lpthread
endif   # if opensd

ifeq ($(OS), netbsd)
	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
		-DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
	ifneq ($(found_lock_method), yes)
		C_DEFS+= -DUSE_SYSV_SEM  # try pthread sems
		found_lock_method=yes
	endif
	# check for ver >= 2.0.0
	ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
		ifeq ($(NO_KQUEUE),)
			C_DEFS+=-DHAVE_KQUEUE
			# netbsd + kqueue and -malign-double don't work
			CFLAGS_RM+=-malign-double
			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
		endif
	endif
	ifeq ($(NO_SELECT),)
		C_DEFS+=-DHAVE_SELECT
	endif
	YACC=yacc
	LIBS=
endif

# OS X support, same as freebsd
ifeq ($(OS), darwin)
	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
		-DUSE_ANON_MMAP \
		-DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
		-DUSE_SIGWAIT -DHAVE_IP_MREQN
	# -DNDEBUG used to turn off assert (assert wants to call
	# eprintf which doesn't seem to be defined in any shared lib
	ifneq ($(found_lock_method), yes)
		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
		found_lock_method=yes
		C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
		                       # processes and unnamed posix sems are not
		                       # supported)
	endif
	LIBS= -lresolv  #dlopen is in libc
	ifeq ($(NO_KQUEUE),)
		C_DEFS+=-DHAVE_KQUEUE
	endif
	ifeq ($(NO_SELECT),)
		C_DEFS+=-DHAVE_SELECT
	endif
	LDFLAGS=        # darwin doesn't like -O2 or -E
	# the modules uses symbols from ser => either
	# -flat_namespace -undefined_suppress or -bundle_loader ../../$(MAIN_NAME)
	MOD_LDFLAGS:= -bundle -flat_namespace -undefined suppress
	# for libs using symbols from ser (e.g srdb2, a.s.o) we
	# need -flat_namespace -undefined suppress
	LIB_LDFLAGS:= -dynamiclib -flat_namespace -undefined suppress
	LIB_SUFFIX:=.dylib
	# on darwin soname should include the full path
	# (it kind of combines rpath & soname)
	LIB_SONAME=
	# no equiv. for rpath on darwin
	LD_RPATH=
	YACC=yacc
endif

ifneq (,$(findstring cygwin, $(OS)))
	# cygwin does support IPV6 starting from version 1.7, but (still?) doesn't support fd passing so no TCP
	#C_DEFS:=$(filter-out -DUSE_TCP, $(C_DEFS))
	DEFS_RM+=-DUSE_TCP
	C_DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
	ifneq ($(found_lock_method), yes)
		C_DEFS+= -DUSE_POSIX_SEM
		#C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
		# PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
		#LIBS+= -lpthread
		found_lock_method=yes
	else
		ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
			#LIBS+=-lpthread
		endif
		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
$(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
		endif
	endif
	# check for >= 2.5.70
	ifeq ($(NO_SELECT),)
		C_DEFS+=-DHAVE_SELECT
	endif
endif

#add libssl if needed
ifeq ($(CORE_TLS), 1)
C_INCLUDES+= -I$(LOCALBASE)/ssl/include
LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
		$(TLS_EXTRA_LIBS)
# NOTE: depending on the way in which libssl was compiled you might
#       have to add -lz -lkrb5   (zlib and kerberos5).
#       E.g.: make CORE_TLS=1 EXTRA_TLS_LIBS="-lz -lkrb5"
endif

ifneq ($(found_lock_method), yes)
$(warning	No locking method found so far, trying SYS V sems)
		C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems
		found_lock_method=yes
endif


endif # ifeq (,$(main_makefile))
endif  # ifeq ($(makefile_defs), 1)

# if incomplete or missing config.mak, or already exported vars, don't
# try to export/re-export
ifeq ($(makefile_defs),1)
ifneq ($(exported_vars),1)


override exported_vars:=1
export exported_vars

# variable changeable only at configure time (once saved in config.mak they
#  cannot be overwritten from environment or command line, unless make cfg
#  is run)
saved_fixed_vars:=	MAIN_NAME  CFG_NAME SCR_NAME FLAVOUR INSTALL_FLAVOUR \
		SRC_NAME RELEASE OS ARCH \
		C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
		CC_MKDEP_OPTS \
		MOD_LDFLAGS LIB_LDFLAGS UTILS_LDFLAGS LIB_SONAME LD_RPATH \
		LIB_SUFFIX LIB_PREFIX \
		LIBS \
		LEX YACC YACC_FLAGS \
		PREFIX LOCALBASE \
		TAR \
		INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
		INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE \
		Q

# variable changeable at compile time
# extra: prefix DESTDIR BASEDIR basedirt
saved_chg_vars:=\
		CC_EXTRA_OPTS CPUTYPE CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS UTILS_CFLAGS \
		BASEDIR basedir DESTDIR LIBDIR RUNBASEDIR runbasedir \
		PREFIX prefix \
		cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
		doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \
		share_prefix share_dir lib_prefix lib_dir data_prefix data_dir \
		cfg_target lib_target data_target run_prefix run_dir run_target \
		share_target


#export relevant variables to the sub-makes
export $(saved_fixed_vars)
export $(saved_chg_vars)


endif # ifneq ($(exported_vars),1)
endif # ifeq ($(makefile_defs),1)