#############################################################
#
# http-lib
#
#############################################################
HTTP_LIB_VER:=1.2
HTTP_LIB_SOURCE:=http-tiny-$(HTTP_LIB_VER).tar.gz
HTTP_LIB_SITE:=http://www.demailly.com/~dl
HTTP_LIB_CAT:=zcat
HTTP_LIB_DIR:=$(BUILD_DIR)/http-tiny-$(HTTP_LIB_VER)
HTTP_LIB_BINARY:=libhttp.a

$(DL_DIR)/$(HTTP_LIB_SOURCE):
	 $(WGET) -P $(DL_DIR) $(HTTP_LIB_SITE)/$(HTTP_LIB_SOURCE)

http-lib-source: $(DL_DIR)/$(HTTP_LIB_SOURCE)

$(HTTP_LIB_DIR)/.unpacked: $(DL_DIR)/$(HTTP_LIB_SOURCE)
	$(HTTP_LIB_CAT) $(DL_DIR)/$(HTTP_LIB_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
	toolchain/patch-kernel.sh $(HTTP_LIB_DIR) local/http-lib/patches/ '*'
	touch $(HTTP_LIB_DIR)/.unpacked

$(HTTP_LIB_DIR)/src/.libs/$(HTTP_LIB_BINARY): $(HTTP_LIB_DIR)/.unpacked
	$(MAKE) CC=$(TARGET_CC) CC_FOR_BUILD=$(HOSTCC) -C $(HTTP_LIB_DIR)
	cp -dpf $(HTTP_LIB_DIR)/http_lib.h $(STAGING_DIR)/usr/include

$(STAGING_DIR)/usr/lib/$(HTTP_LIB_BINARY): \
	$(HTTP_LIB_DIR)/src/.libs/$(HTTP_LIB_BINARY)
	cp -dpf $(HTTP_LIB_DIR)/libhttp.a $(STAGING_DIR)/usr/lib
	#$(TARGET_CC) -shared -o $(STAGING_DIR)/usr/lib/libhttp.so $(STAGING_DIR)/usr/lib/libhttp.a

$(TARGET_DIR)/usr/lib/$(HTTP_LIB_BINARY): \
	$(STAGING_DIR)/usr/lib/$(HTTP_LIB_BINARY)
	#cp -dpf $(STAGING_DIR)/usr/lib/libhttp.so $(TARGET_DIR)/usr/lib/
	#-$(STRIP) --strip-unneeded $(TARGET_DIR)/usr/lib/libhttp.so

http-lib: $(TARGET_DIR)/usr/lib/$(HTTP_LIB_BINARY)

http-lib-clean:
	-make -C $(HTTP_LIB_DIR) clean

http-lib-dirclean:
	rm -rf $(HTTP_LIB_DIR)

#############################################################
#
# Toplevel Makefile options
#
#############################################################
ifeq ($(strip $(BR2_PACKAGE_HTTP_LIB)),y)
TARGETS+=http-lib
endif

