# -*-makefile-*-
#
# Copyright (C) @YEAR@ by @AUTHOR@
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

#
# We provide this package
#
PACKAGES-$(PTXCONF_BAREBOX_@PACKAGE@) += barebox-@package@

#
# Paths and names
#
BAREBOX_@PACKAGE@_VERSION	:= @VERSION@
BAREBOX_@PACKAGE@_MD5		:=
BAREBOX_@PACKAGE@		:= barebox-@package@-$(BAREBOX_@PACKAGE@_VERSION)
BAREBOX_@PACKAGE@_SUFFIX	:= tar.bz2
BAREBOX_@PACKAGE@_URL		:= $(call barebox-url, BAREBOX_@PACKAGE@)
BAREBOX_@PACKAGE@_PATCHES	:= barebox-$(BAREBOX_@PACKAGE@_VERSION)
BAREBOX_@PACKAGE@_SOURCE	:= $(SRCDIR)/$(BAREBOX_@PACKAGE@_PATCHES).$(BAREBOX_@PACKAGE@_SUFFIX)
BAREBOX_@PACKAGE@_DIR		:= $(BUILDDIR)/$(BAREBOX_@PACKAGE@)
BAREBOX_@PACKAGE@_BUILD_DIR	:= $(BAREBOX_@PACKAGE@_DIR)-build
BAREBOX_@PACKAGE@_CONFIG	:= $(call ptx/in-platformconfigdir, barebox-@package@.config.$(BAREBOX_@PACKAGE@_VERSION))
BAREBOX_@PACKAGE@_LICENSE	:= GPL-2.0-only
BAREBOX_@PACKAGE@_LICENSE_FILES	:=
BAREBOX_@PACKAGE@_BUILD_OOT	:= KEEP

# ----------------------------------------------------------------------------
# Prepare
# ----------------------------------------------------------------------------

# use host pkg-config for host tools
BAREBOX_@PACKAGE@_PATH		:= PATH=$(HOST_PATH)

BAREBOX_@PACKAGE@_WRAPPER_BLACKLIST := \
	$(PTXDIST_LOWLEVEL_WRAPPER_BLACKLIST)

BAREBOX_@PACKAGE@_CONF_TOOL	:= kconfig
BAREBOX_@PACKAGE@_CONF_OPT	:= \
	-C $(BAREBOX_@PACKAGE@_DIR) \
	O=$(BAREBOX_@PACKAGE@_BUILD_DIR) \
	$(call barebox-opts, BAREBOX_@PACKAGE@)

BAREBOX_@PACKAGE@_MAKE_OPT	:= $(BAREBOX_@PACKAGE@_CONF_OPT)

BAREBOX_@PACKAGE@_IMAGES := @image@
BAREBOX_@PACKAGE@_IMAGES := $(addprefix $(BAREBOX_@PACKAGE@_BUILD_DIR)/,$(BAREBOX_@PACKAGE@_IMAGES))

ifdef PTXCONF_BAREBOX_@PACKAGE@
$(BAREBOX_@PACKAGE@_CONFIG):
	@echo
	@echo "****************************************************************************"
	@echo " Please generate a bareboxconfig with 'ptxdist menuconfig barebox-@package@'"
	@echo "****************************************************************************"
	@echo
	@echo
	@exit 1
endif

# ----------------------------------------------------------------------------
# Install
# ----------------------------------------------------------------------------

$(STATEDIR)/barebox-@package@.install:
	@$(call targetinfo)
	@$(call touch)

# ----------------------------------------------------------------------------
# Target-Install
# ----------------------------------------------------------------------------

$(STATEDIR)/barebox-@package@.targetinstall:
	@$(call targetinfo)
	@$(foreach image, $(BAREBOX_@PACKAGE@_IMAGES), \
		$(call ptx/image-install, BAREBOX_@PACKAGE@, $(image), \
			$(notdir $(image))-@package@)$(ptx/nl))
	@$(call touch)

# ----------------------------------------------------------------------------
# oldconfig / menuconfig
# ----------------------------------------------------------------------------

$(call ptx/kconfig-targets, barebox-@package@): $(STATEDIR)/barebox-@package@.extract
	@$(call world/kconfig, BAREBOX_@PACKAGE@, $(subst barebox-@package@_,,$@))

# vim: ft=make
