# Wand Makefile
# 
# Copyright (C) 2006  Nathan (Acorn) Pooley
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
# 
# 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 General Public License (gpl.txt) for more details. 
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
# 
# You can contact the author, Nathan (Acorn) Pooley, by writing
# to Nathan (Acorn) Pooley, 949 Buckeye Drive, Sunnyvale, CA  94086, USA
# or through the form at http://www.rawbw.com/~acorn/wand/feedback.html
#
VERSION=1.2
DIST=wand-$(VERSION)

-include Makefile.cfg

default:
	$(MAKE) -C server
	$(MAKE) -C sw


dist:
	echo "Creating $(DIST).tgz"
	rm -f $(DIST).tgz $(DIST) $(DIST)_filelist $(DIST)_datalist
	ln -s `pwd` $(DIST)
	$(MAKE) --no-print-directory -s dist_files > $(DIST)_filelist
	$(MAKE) --no-print-directory -s dist_data_files > $(DIST)_datalist
	tar -c -z -f $(DIST).tgz -T $(DIST)_filelist
	tar -c -z -f $(DIST)-data.tgz -T $(DIST)_datalist
	rm $(DIST) $(DIST)_filelist $(DIST)_datalist

dist_files:
	\ls *.txt configure Makefile LICENSE INSTALL README | \
		sed -e 's|^|$(DIST)/|'
	$(MAKE) --no-print-directory -s -C server $@ | \
		sed -e 's|^|$(DIST)/server/|'
	$(MAKE) --no-print-directory -s -C sw $@ | \
		sed -e 's|^|$(DIST)/sw/|'
	$(MAKE) --no-print-directory -s -C hw $@ | \
		sed -e 's|^|$(DIST)/hw/|'

dist_data_files:
	$(MAKE) --no-print-directory -s -C server $@ | \
		sed -e 's|^|$(DIST)/server/|'
	$(MAKE) --no-print-directory -s -C instructions $@ | \
		sed -e 's|^|$(DIST)/instructions/|'

help:
	@echo "Available targets:"
	@echo "  default   - build all software for the wand"
	@echo "  dist      - create ../wand-$(VERSION).tgz for distribution"
	@echo "  help      - show this help"

.PHONY: default dist help dist_files dist_data_files
