#############################################################
#
# libnfnetlink
#
#############################################################
# Copyright (C) 2001-2003 by Erik Andersen <andersen@codepoet.org>
# Copyright (C) 2002 by Tim Riker <Tim@Rikers.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA

LIBNFNETINK_VER:=0.0.16
LIBNFNETINK_DIR:=$(BUILD_DIR)/libnfnetlink-$(LIBNFNETINK_VER)
LIBNFNETINK_SITE:=http://www.netfilter.org/projects/libnfnetlink/downloads.html
LIBNFNETINK_SOURCE:=libnfnetlink-$(LIBNFNETINK_VER).tar.bz2
LIBNFNETINK_CAT:=bzcat

$(DL_DIR)/$(LIBNFNETINK_SOURCE):
	 $(WGET) -P $(DL_DIR) $(LIBNFNETINK_SITE)\#$(LIBNFNETINK_SOURCE)

libnfnetlink-source: $(DL_DIR)/$(LIBNFNETINK_SOURCE)

$(LIBNFNETINK_DIR)/.unpacked: $(DL_DIR)/$(LIBNFNETINK_SOURCE)
	$(LIBNFNETINK_CAT) $(DL_DIR)/$(LIBNFNETINK_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
	touch $(LIBNFNETINK_DIR)/.unpacked

$(LIBNFNETINK_DIR)/.configured: $(LIBNFNETINK_DIR)/.unpacked
	( \
		cd $(LIBNFNETINK_DIR) ; \
		rm -rf config.cache; \
                $(TARGET_CONFIGURE_OPTS) \
                ./configure \
                --target=$(GNU_TARGET_NAME) \
                --host=$(GNU_TARGET_NAME) \
                --build=$(GNU_HOST_NAME) \
                --prefix=$(STAGING_DIR)/usr \
                --exec-prefix=$(STAGING_DIR)/usr \
                --bindir=$(STAGING_DIR)/bin \
                --sbindir=$(STAGING_DIR)/sbin \
                --libexecdir=$(STAGING_DIR)/lib \
                --sysconfdir=/etc \
                --datadir=/share \
                --localstatedir=/var \
                --mandir=/man \
                --infodir=/info \
	)
	touch $(LIBNFNETINK_DIR)/.configured

$(LIBNFNETINK_DIR)/.compiled: $(LIBNFNETINK_DIR)/.configured
	$(MAKE) -C $(LIBNFNETINK_DIR)
	touch $(LIBNFNETINK_DIR)/.compiled

$(STAGING_DIR)/usr/lib/libnfnetlink.so: $(LIBNFNETINK_DIR)/.compiled
	$(MAKE) \
		-C $(LIBNFNETINK_DIR) \
		prefix=$(STAGING_DIR) \
		exec_prefix=$(STAGING_DIR) \
		bindir=$(STAGING_DIR)/usr/bin \
		datadir=$(STAGING_DIR)/share \
		libdir=$(STAGING_DIR)/usr/lib \
		install
	touch -c $(STAGING_DIR)/usr/lib/libnfnetlink.so

$(TARGET_DIR)/lib/libnfnetlink.so: $(STAGING_DIR)/usr/lib/libnfnetlink.so
	cp -dpf $(STAGING_DIR)/usr/lib/libnfnetlink.so* $(TARGET_DIR)/lib/
	-$(STRIP) --strip-unneeded $(TARGET_DIR)/lib/libnfnetlink.so

libnfnetlink: uclibc $(TARGET_DIR)/lib/libnfnetlink.so

libnfnetlink-clean:
	-$(MAKE) -C $(LIBNFNETINK_DIR) clean
#############################################################
#
# Toplevel Makefile options
#
#############################################################
ifeq ($(strip $(BR2_PACKAGE_LIBNFNETLINK)),y)
TARGETS+=libnfnetlink
endif
