Browse Source

json, jsonrpc-c: use pkg-config to locate the libs

- if available, use pkg-config tool to locate json and event libs
Daniel-Constantin Mierla 14 years ago
parent
commit
d8a3d9d919
2 changed files with 19 additions and 6 deletions
  1. 8 3
      modules/json/Makefile
  2. 11 3
      modules/jsonrpc-c/Makefile

+ 8 - 3
modules/json/Makefile

@@ -9,10 +9,15 @@ auto_gen=
 NAME=json.so
 LIBS=
 
-DEFS+=-I/usr/include/json -I$(LOCALBASE)/include/json \
+BUILDER = $(shell which pkg-config)
+ifeq ($(BUILDER),)
+	DEFS+=-I/usr/include/json -I$(LOCALBASE)/include/json \
        -I$(LOCALBASE)/include
-LIBS+=-L$(SYSBASE)/include/lib -L$(LOCALBASE)/lib -ljson
- 
+	LIBS+=-L$(SYSBASE)/include/lib -L$(LOCALBASE)/lib -ljson
+else
+	DEFS+= $(shell pkg-config --cflags json)
+	LIBS+= $(shell pkg-config --libs json)
+endif
 DEFS+=-DOPENSER_MOD_INTERFACE
 
 SERLIBPATH=../../lib

+ 11 - 3
modules/jsonrpc-c/Makefile

@@ -7,11 +7,19 @@
 include ../../Makefile.defs
 auto_gen=
 NAME=jsonrpc-c.so
-LIBS=-lm -levent
+LIBS=-lm
 
-DEFS+=-I/usr/include/json -I$(LOCALBASE)/include/json \
+BUILDER = $(shell which pkg-config)
+ifeq ($(BUILDER),)
+	DEFS+=-I/usr/include/json -I$(LOCALBASE)/include/json \
        -I$(LOCALBASE)/include
-LIBS+=-L$(SYSBASE)/include/lib -L$(LOCALBASE)/lib -ljson
+	LIBS+=-L$(SYSBASE)/include/lib -L$(LOCALBASE)/lib -levent -ljson
+else
+	DEFS+= $(shell pkg-config --cflags json)
+	LIBS+= $(shell pkg-config --libs json)
+	DEFS+= $(shell pkg-config --cflags libevent)
+	LIBS+= $(shell pkg-config --libs libevent)
+endif
  
 DEFS+=-DOPENSER_MOD_INTERFACE