PRODUCT=libpng
DL_VERSION=1.4.0

ifeq ($(BUILD_STATIC),yes)
    CONFIGURE_OPTS += --disable-shared
endif

include $(MAKELIB)/default.rules

.PRECIOUS: $(CONFIGDIR)/$(PRODUCT)/downloaded

$(CONFIGDIR)/$(PRODUCT)/downloaded: $(DOWNLOADDIR)/$(PRODUCT)-$(DL_VERSION).tar.gz
	(cd $(SRCDIR); \
		rm -Rf $(PRODUCT); \
		tar xzf $(DOWNLOADDIR)/$(PRODUCT)-$(DL_VERSION).tar.gz; \
		mv $(PRODUCT)-$(DL_VERSION) $(PRODUCT))
	@mkdir -p $(CONFIGDIR)/$(PRODUCT)
	@mkdir -p $(CONFIGDIR)/$(PRODUCT)/patches
	@rm -f $(CONFIGDIR)/$(PRODUCT)/patches/*.applied
	@touch $(CONFIGDIR)/$(PRODUCT)/downloaded

prepare: $(DOWNLOADDIR)/$(PRODUCT)-$(DL_VERSION).tar.gz

$(DOWNLOADDIR)/$(PRODUCT)-$(DL_VERSION).tar.gz:
	[ -d $(DOWNLOADDIR) ] || mkdir -p $(DOWNLOADDIR)
	wget -c -O $@.tmp http://downloads.sourceforge.net/libpng/$(PRODUCT)-$(DL_VERSION).tar.gz
	mv $@.tmp $@

.PRECIOUS: $(DOWNLOADDIR)/$(PRODUCT)-$(DL_VERSION).tar.gz

include $(MAKELIB)/autoconf.rules
include $(MAKELIB)/patch.rules
