#!/bin/bash
# update-makefiles.sh
# (c) 2009 Krzysztof Kosiński
# Licensed under GNU GPL; see the file COPYING for details
#
# This script regenerates the makefiles for the subdirectories of hicolor.

OLD_IFS=$IFS
IFS=$'\0'

for dir_size in *; do
if test -d $dir_size; then

SUBDIRS=''

for dir in $dir_size/*; do
if test -d $dir; then
	ICONS_DATA=$(find $dir \( -name '*.svg' -o -name '*.png' \) -printf '\t%f \\\n' \
		| sort \
		| sed -e '$s|\\||')
#SIZE=$(echo $dir_size | sed -e 's|x.*||')
CONTEXT=$(echo $dir | sed -e 's|^.*/||')
echo \
'themedir = $(pkgdatadir)/icons/hicolor
size = '$dir_size'
context = '$CONTEXT'

iconsdir = $(themedir)/$(size)/$(context)

# Auto-generated by update-makefiles.sh
# Re-run the script to update.

icons_DATA = \
'$ICONS_DATA'

EXTRA_DIST = $(icons_DATA)' > $dir/Makefile.am
SUBDIRS="$SUBDIRS $CONTEXT"
fi
done

if test $dir_size = 'scalable'; then EXTENSION='svg'; else EXTENSION='png'; fi

echo \
'SUBDIRS = '$SUBDIRS'

size = '$dir_size'
hicolorthemedir = $(datadir)/icons/hicolor
inkscapeicondir = $(hicolorthemedir)/$(size)/apps

inkscapeicon_DATA = inkscape.'$EXTENSION'
EXTRA_DIST = $(inkscapeicon_DATA)' > $dir_size/Makefile.am

fi
done

IFS=$OLD_IFS
