Skip to content

Commit

Permalink
Merge pull request #52 from landesfeind/master
Browse files Browse the repository at this point in the history
Automatically detect availability of curl
  • Loading branch information
dpryan79 authored Nov 9, 2020
2 parents 43bb4c4 + ff5ab54 commit 3a756fa
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@ CC ?= gcc
AR ?= ar
RANLIB ?= ranlib
CFLAGS ?= -g -Wall -O3 -Wsign-compare
LIBS = -lcurl -lm -lz
LIBS = -lm -lz
EXTRA_CFLAGS_PIC = -fpic
LDFLAGS =
LDLIBS =
INCLUDES =

# Create a simple test-program to check if gcc can compile with curl
tmpfile:=$(shell mktemp --suffix=.c)
$(file >$(tmpfile),#include <curl/curl.h>)
$(file >>$(tmpfile),int main() { return 0; })
HAVE_CURL:=$(shell $(CC) $(CFLAGS) $(EXTRA_CFLAGS_PIC) $(LIBS) -lcurl $(tmpfile) -o /dev/null >/dev/null 2>&1 && echo "YES")
$(shell rm $(tmpfile))

ifeq ($(HAVE_CURL),YES)
# If yes, add the library
LIBS += -lcurl
else
# and if not, disable CURL specific code compilation
CFLAGS += -DNOCURL
endif


prefix = /usr/local
includedir = $(prefix)/include
libdir = $(exec_prefix)/lib
Expand Down

0 comments on commit 3a756fa

Please sign in to comment.