
include $(COMMON_BASE_MK)

NAME=libcurl
SRC_DIR=curl-7.54.1
INSTALL_DIR=$(LIB_DIR)/$(NAME)/install
BUILD_DIR=build
GEN_MAKEFILE=$(BUILD_DIR)/Makefile

CONFIG_OPTS = --target=arm-linux --host=arm-linux
CONFIG_OPTS += --enable-static
ifeq ($(CONFIG_LIBCURL_SHARE_LIB), y)
CONFIG_OPTS += --enable-shared
else
CONFIG_OPTS += --disable-shared
endif
CONFIG_OPTS += --enable-threaded-resolver
CONFIG_OPTS += --without-libidn --without-ssl --without-librtmp --without-gnutls --without-nss --without-libssh2 \
               --without-zlib --without-winidn --disable-telnet --disable-tftp --disable-smtp \
               --disable-imap --disable-pop3 --disable-rtsp --disable-ldap --disable-ldaps --disable-ipv6

all: $(GEN_MAKEFILE)
	make -C build all
	make -C build install
	cp -v $(SRC_DIR)/lib/curl_md5.h  $(INSTALL_DIR)/include/curl/
	cp -v $(SRC_DIR)/lib/curl_hmac.h $(INSTALL_DIR)/include/curl/

$(GEN_MAKEFILE):
	mkdir -p $(BUILD_DIR)
	cd $(BUILD_DIR); ../$(SRC_DIR)/configure --prefix=$(INSTALL_DIR) $(CONFIG_OPTS)

clean:
	-rm -fr $(BUILD_DIR) $(INSTALL_DIR)

romfs:
	cd $(INSTALL_DIR)/lib; \
	for i in *.so*; do \
		if [ -L $$i ]; then \
			$(ROMFSINST) -s `find $$i -printf %l` /lib/$$i; \
		elif [ -f $$i ]; then \
			$(ROMFSINST) /lib/$$i; \
		fi; \
	done

populate_sdk:
	cp -afvp $(INSTALL_DIR)/include/*  $(CROSS_COMPILE_SYSROOT)/usr/include/
	cp -afvp $(INSTALL_DIR)/lib/*  $(CROSS_COMPILE_SYSROOT)/usr/lib/
	cp -afvp $(INSTALL_DIR)/bin/*  $(CROSS_COMPILE_SYSROOT)/usr/bin/
