# [?]ARCHIVE : Optional forced archive (Defaults to latest)
# [?]CONFIGURE_LINE : Command to create makefile (defaults to autotools configure)
# [?]NOBDIR : Set to non-empty to disable use of a separate build dir
+# [?]AUTORECONF : Set to non-empty to regenerate ./configure
BTARGETS ?= all
$(DIR)/%: patches/%.patch
@echo [PATCH] $@
+ @tar -xf $(ARCHIVE) $@
@patch $@ $<
$(DIR)/%: patches/%
@echo [CP] $@
+ @mkdir -p $(dir $@)
@cp $< $@
-_patch: $(DIR) $(addprefix $(DIR)/,$(PATCHES))
+PATCHED_FILES := $(addprefix $(DIR)/,$(PATCHES))
+_patch: $(DIR) $(PATCHED_FILES)
-$(BDIR)/Makefile: _patch ../common.mk Makefile
+CONFIGSCRIPT := $(BDIR)/$(firstword $(CONFIGURE_LINE))
+PATCHED_ACFILES := $(filter %/configure.in %/config.sub, $(PATCHED_FILES))
+$(warning $(CONFIGSCRIPT): $(PATCHED_ACFILES))
+
+$(CONFIGSCRIPT): $(PATCHED_ACFILES)
+ifeq ($(AUTORECONF),)
+else
+ cd $(DIR) && autoreconf --force --install
+endif
+
+$(BDIR)/Makefile: _patch $(CONFIGSCRIPT) ../common.mk Makefile
mkdir -p $(BDIR)
cd $(BDIR) && $(CONFIGURE_LINE)