default: all

SQUASHFS_VERSION=@SQUASHFS_VERSION@

# Include mkimage config file with default definitions
include @MKI_PREFIX@/usr/share/mkimage/config.mk

# Include autogenerated settings for specific product flavor
# Not neccessary for clean family targets.
-include stage-autocfg.mk

# packagelist stuff
include ../functions.mk

ifeq "$(USE_CLAMAV)" "1"
	CLAMDB=.work/.cache/clam/etc/skel/.klamav/database/main.cvd
	CLAMCOPY=copy-tree
	COPY_TREE=.work/.cache/clam
	# FIXME: klamav only?
	GLOBAL_PLC_PACKAGES+=klamav
endif

# FIXME: hardwired l10n, see also #16863
GLOBAL_HSH_LANGS=en_US:ru_RU:uk_UA

# Make build log look pretty
ifeq (@KERNEL@,rt-up)
PACK_SQUASHFS_OPTS=-no-progress -comp gzip 
else 
ifeq (@KERNEL@,rt-smp)  
PACK_SQUASHFS_OPTS=-no-progress -comp gzip 
else 
ifeq (@COMPRESSION@,gzip)
PACK_SQUASHFS_OPTS=-no-progress -comp gzip
else
PACK_SQUASHFS_OPTS=-comp xz -Xbcj x86
endif
endif
endif

IMAGE_INIT_LIST = +branding-@BRANDING@-release

LOCAL_PLC_PACKAGE_LISTS = kernel plc
IMAGE_PACKAGES = \
		 branding-@BRANDING@-release \
		 apt-conf-@APTCONF_PACKAGE@ \
		 $(GLOBAL_PLC_PACKAGES) \
		 $(call list,kernel) \
		 $(call list,plc) \
		 $(call list,$(GLOBAL_PLC_PACKAGE_LISTS)) \
		 $(call list,$(GLOBAL_PLC_PKG_GROUPS))

#		 branding-@BRANDING@-bootsplash \
#		 branding-@BRANDING@-graphics \
#		 branding-@BRANDING@-notes \
#		 branding-@BRANDING@-indexhtml \
#		 branding-@BRANDING@-bootloader \

MKI_PACK_RESULTS = squash:live

# Include mkimage targets definitions
include @MKI_PREFIX@/usr/share/mkimage/targets.mk

all: build-image $(CLAMDB) $(CLAMCOPY) run-scripts run-image-scripts pack-image
	# FIXME: this kludge should be fixed along with main/'s one
	# by moving .base generation where it belongs, to software/
	@mkdir -p `dirname $(call list,.base)`
	@touch $(call list,.base)

.work/.cache/clam/etc/skel/.klamav/database/main.cvd:
	mkdir -p .work/.cache/clam/etc/skel/.klamav/database
	wget -P .work/.cache/clam/etc/skel/.klamav/database @CLAMAV_DB@/main.cvd
	wget -P .work/.cache/clam/etc/skel/.klamav/database @CLAMAV_DB@/daily.cvd
