include ../../$(CONFIG)

GARNAME = libtool
GARVERSION = 1.5.6
CATEGORIES = autotools

DISTFILES = $(GARNAME)_$(GARVERSION).orig.tar.gz

DESCRIPTION = libtool

DEBIAN_PACKAGES = libltdl3-dev libtool libtool1.4

define BLURB
 # FIXME: blurb goes here
endef

CONFIGURE_ENV = CC="$(CC)" CXX="$(CXX)"
CONFIGURE_ARGS = --prefix="$(COMPILER_DIR)/arch_tools" --host=`$(CURDIR)/$(WORKSRC)/config.guess` -C
BUILD_ENV = CC="$(CC)" CXX="$(CXX)"
BUILD_ARGS =

CONFIGURE_SCRIPTS = $(WORKSRC)/configure
BUILD_SCRIPTS = $(WORKSRC)/Makefile
INSTALL_SCRIPTS = $(WORKSRC)/Makefile

include ../category.mk

pre-configure:
	@echo "lt_cv_dlopen_self=$${lt_cv_dlopen_self='yes'}" >> $(CURDIR)/$(WORKSRC)/config.cache
	@echo "lt_cv_dlopen_self_static=$${lt_cv_dlopen_self_static='yes'}" >> $(CURDIR)/$(WORKSRC)/config.cache

post-configure:
	# Sed some to fix CC and CXX in libtool (scratchbox specific hack)
	sed 's/CC=".*gcc"/CC="gcc"/g' < work/$(GARNAME)-$(GARVERSION)/libtool > work/$(GARNAME)-$(GARVERSION)/libtool.cc
	sed 's/CC=".*g++"/CC="g++"/g' < work/$(GARNAME)-$(GARVERSION)/libtool.cc > work/$(GARNAME)-$(GARVERSION)/libtool.cxx
	mv work/$(GARNAME)-$(GARVERSION)/libtool.cxx work/$(GARNAME)-$(GARVERSION)/libtool
	rm work/$(GARNAME)-$(GARVERSION)/libtool.cc	

	# The system libtool script in Debian must be able to support
	# invoking gcc as cc (Debian specific)
	echo '# ### BEGIN LIBTOOL TAG CONFIG: BINCC' >> work/$(GARNAME)-$(GARVERSION)/libtool
	sed -n -e '/^# ### BEGIN LIBTOOL CONFIG/,/^# ### END LIBTOOL CONFIG/p' < work/$(GARNAME)-$(GARVERSION)/libtool \
		| grep -B 2 -A 1 -e '^LTCC=' -e '^CC=' \
		| sed -e 's/gcc/cc/g' >> work/$(GARNAME)-$(GARVERSION)/libtool
	echo '# ### END LIBTOOL TAG CONFIG: BINCC' >> work/$(GARNAME)-$(GARVERSION)/libtool
	echo >> work/$(GARNAME)-$(GARVERSION)/libtool

	# The system libtool script in Debian must be able to support
	# invoking g++ both by the g++ and c++ names. (Debian specific)
	sed -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: CXX$$/,/^# ### END LIBTOOL TAG CONFIG: CXX$$/p' < work/$(GARNAME)-$(GARVERSION)/libtool \
		| sed -e 's/CONFIG: CXX/CONFIG: BINCXX/g' \
			-e 's/g++/c++/g' >> work/$(GARNAME)-$(GARVERSION)/libtool
	echo >> work/$(GARNAME)-$(GARVERSION)/libtool

	# Add our BINCC and BINCXX tags (Debian specific)
	sed -e 's/^\(available_tags\)=\"\(.*\)\"/\1=\"\2 BINCC BINCXX\"/' \
		< work/$(GARNAME)-$(GARVERSION)/libtool > work/$(GARNAME)-$(GARVERSION)/libtool.tags
	mv work/$(GARNAME)-$(GARVERSION)/libtool.tags work/$(GARNAME)-$(GARVERSION)/libtool

	# Make libtool executable again
	chmod 755 work/$(GARNAME)-$(GARVERSION)/libtool

