git » nmdb » commit 2df81c3

Auto-detect TIPC and SCTP availability

author Alberto Bertogli
2010-04-17 21:30:45 UTC
committer Alberto Bertogli
2010-04-17 21:33:14 UTC
parent 8578ddfcd66783b6370c05d99ccfa4453ab9a393

Auto-detect TIPC and SCTP availability

This patch changes the Makefile to auto-detect TIPC and SCTP availability, by
attempting to use their corresponding headers.

It's not the most accurate way of testing, but it's really good enough, and on
weird cases it can always be overriden manually as it used to be.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

INSTALL +5 -5
libnmdb/Makefile +4 -2
nmdb/Makefile +4 -2

diff --git a/INSTALL b/INSTALL
index f1c9574..839a6b4 100644
--- a/INSTALL
+++ b/INSTALL
@@ -4,9 +4,9 @@ Quick guide for the patience-impaired
 
 At the top level directory, run:
 
- $ make ENABLE_TIPC=0 ENABLE_SCTP=0 install
+ $ make install
 
-to build and install the server without TIPC and SCTP support.
+to build and install the server, library and utilities.
 
 
 How to compile and install
@@ -36,8 +36,8 @@ The backend databases:
  * tdb (http://tdb.samba.org/)
  * A null backend (to use when you don't need a real one)
 
-By default, all network protocols are enabled, and backends are automatically
-detected according to the available libraries.
+By default, network protocols and backends are automatically detected
+according to the available libraries.
 
 You can change the defaults by passing parameters to make, like this:
 
@@ -46,7 +46,7 @@ You can change the defaults by passing parameters to make, like this:
 Where $PROTO can be TCP, UDP, TIPC or SCTP, and $BACKEND can be QDBM, BDB, TC,
 TDB or NULL.
 
-For instance, to build with bdb backend and without TIPC and UDP support, use:
+For instance, to build with bdb backend and without TIPC support, use:
 
  $ make BE_ENABLE_BDB=1 ENABLE_TIPC=0
 
diff --git a/libnmdb/Makefile b/libnmdb/Makefile
index 831cc3f..f0ff65f 100644
--- a/libnmdb/Makefile
+++ b/libnmdb/Makefile
@@ -1,8 +1,10 @@
 
-ENABLE_TIPC = 1
 ENABLE_TCP = 1
 ENABLE_UDP = 1
-ENABLE_SCTP = 1
+ENABLE_TIPC := $(shell if echo "\#include <linux/tipc.h>" | \
+		$(CPP) - > /dev/null 2>&1; then echo 1; else echo 0; fi)
+ENABLE_SCTP := $(shell if echo "\#include <netinet/sctp.h>" | \
+		$(CPP) - > /dev/null 2>&1; then echo 1; else echo 0; fi)
 
 CFLAGS += -std=c99 -pedantic -Wall -O3
 ALL_CFLAGS = -D_XOPEN_SOURCE=500 -fPIC $(CFLAGS)
diff --git a/nmdb/Makefile b/nmdb/Makefile
index ffdd658..7b784e7 100644
--- a/nmdb/Makefile
+++ b/nmdb/Makefile
@@ -1,9 +1,11 @@
 
 # Protocols to enable
-ENABLE_TIPC = 1
 ENABLE_TCP = 1
 ENABLE_UDP = 1
-ENABLE_SCTP = 1
+ENABLE_TIPC := $(shell if echo "\#include <linux/tipc.h>" | \
+		$(CPP) - > /dev/null 2>&1; then echo 1; else echo 0; fi)
+ENABLE_SCTP := $(shell if echo "\#include <netinet/sctp.h>" | \
+		$(CPP) - > /dev/null 2>&1; then echo 1; else echo 0; fi)
 
 # Backends to enable
 BE_ENABLE_QDBM := $(shell if `pkg-config --exists qdbm`; \