# Copyright 2001,2002 (C) Free Software Foundation. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 1.
#
# 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 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

ifneq (,)
This makefile requires GNU Make.
endif

# This is the Makefile for the src/drivers directory of the GNU radio package.
# Each lower level directory Makefile must support the following targets:
#	all: 		The default. Builds everything, but doesn't install 
#			anything.
#
#	clean:		Cleans all binaries built from the "all" target.
#
#	install:	Builds (via the "all" target) and installs everything. 
#
#	uninstall:	Cleans all binaries installed from the 
#			"install" target. But does not do a 'make clean'
#
#	distclean:	Cleans all binaries (the "clean" target); and then 
#			reproduces a directory structure identical to an
#			original CVS tree checkout.

SUBDIRS = kernel user

ifeq (Makefile.conf,$(wildcard Makefile.conf))
include Makefile.conf
else
.PHONY: dummy1
dummy1:
	@echo
	@echo "Please, run the configure script as first..."
	@echo
endif


all:
	for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@; done

install: all
	for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@; done

clean:
	for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@; done

uninstall:
	echo "Not doing a make $@ yet for the driver" 

distclean: clean
	@rm Makefile.conf

devs:
	for dir in kernel; do $(MAKE) -C $$dir $@; done

DIST_FILES = 				\
	.cvsignore			\
	COPYING				\
	ChangeLog			\
	Makefile			\
	Makefile.conf.in		\
	README				\
	configure			\
	configure.in			\
	install-sh			\
	kernel				\
	kernel/.cvsignore		\
	kernel/Makefile			\
	kernel/adriver.h		\
	kernel/config.h.in		\
	kernel/driver.h			\
	kernel/mc4020.c			\
	kernel/mc4020.h			\
	kernel/mc4020_util.h		\
	kernel/plx9080.h		\
	kernel/version.h.in		\
	reconf				\
	user/.cvsignore			\
	user/Makefile			\
	user/mc4020-read-adc.c		\
	user/mc4020-set-dac.c		\
	user/test-adc.cc		\
	user/test-get-cal-data.c	\
	version.in

STAGING_DIR=mc4020-$(CONFIG_MC4020_VERSION)
TARBALL_NAME=$(STAGING_DIR).tar.gz

dist:	
	echo STAGING_DIR=$(STAGING_DIR)
	echo TARBALL_NAME=$(TARBALL_NAME)
	-rm -fr $(STAGING_DIR)
	for file in $(DIST_FILES); do echo $$file; done | cpio -p -d -m $(STAGING_DIR)
	tar czvf $(TARBALL_NAME) $(STAGING_DIR)
	rm -fr $(STAGING_DIR)
	echo $(TARBALL_NAME) is ready to go

distcheck: dist
	-rm -fr _distcheck
	mkdir _distcheck
	(cd _distcheck					\
		&& tar xzf ../$(TARBALL_NAME)		\
		&& cd $(STAGING_DIR)			\
		&& ./configure				\
		&& make)

