Skip to content

Commit 3a756fa

Browse files
authored
Merge pull request #52 from landesfeind/master
Automatically detect availability of curl
2 parents 43bb4c4 + ff5ab54 commit 3a756fa

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,28 @@ CC ?= gcc
22
AR ?= ar
33
RANLIB ?= ranlib
44
CFLAGS ?= -g -Wall -O3 -Wsign-compare
5-
LIBS = -lcurl -lm -lz
5+
LIBS = -lm -lz
66
EXTRA_CFLAGS_PIC = -fpic
77
LDFLAGS =
88
LDLIBS =
99
INCLUDES =
1010

11+
# Create a simple test-program to check if gcc can compile with curl
12+
tmpfile:=$(shell mktemp --suffix=.c)
13+
$(file >$(tmpfile),#include <curl/curl.h>)
14+
$(file >>$(tmpfile),int main() { return 0; })
15+
HAVE_CURL:=$(shell $(CC) $(CFLAGS) $(EXTRA_CFLAGS_PIC) $(LIBS) -lcurl $(tmpfile) -o /dev/null >/dev/null 2>&1 && echo "YES")
16+
$(shell rm $(tmpfile))
17+
18+
ifeq ($(HAVE_CURL),YES)
19+
# If yes, add the library
20+
LIBS += -lcurl
21+
else
22+
# and if not, disable CURL specific code compilation
23+
CFLAGS += -DNOCURL
24+
endif
25+
26+
1127
prefix = /usr/local
1228
includedir = $(prefix)/include
1329
libdir = $(exec_prefix)/lib

0 commit comments

Comments
 (0)