#
# Makefile  -  makefile for netboot package
#
# Copyright (C) 1996-2007 Gero Kuhlmann   <gero@gkminix.han.de>
#
#  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; either version 2 of the License, or
#  any later version.
#
#  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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# $Id: Makefile,v 1.11 2007/01/06 18:30:44 gkminix Exp $
#


# Include makefile configuration
include make.config
include make.rules


# Specify all subdirectories where we are going to make something
MISCSUBDIRS = include misc nblib dbtool FlashCard
ALLSUBDIRS  = $(MISCSUBDIRS) $(TOOLSUBDIRS) i386 bootrom
OPTSUBDIRS  = $(MISCSUBDIRS) $(CONFSUBDIRS)
INSTSUBDIRS = $(MISCSUBDIRS) $(CONFSUBDIRS) i386 bootrom
SUBDIRS     = $(ALLSUBDIRS)


.PHONY:	$(SUBDIRS)

all:	$(OPTSUBDIRS)


$(SUBDIRS):
	@echo making all in $@ ; \
	 (cd $@ && $(MAKE) all) || exit 1;


bootrom-image:
	@(cd makerom && $(MAKE) bootrom) || exit 1;
	@if test -r makerom/image.flash; then mv makerom/image.flash .; fi
	@if test -r makerom/image.flo; then mv makerom/image.flo .; fi
	@if test -r makerom/image.rom; then mv makerom/image.rom .; fi
	@if test -r makerom/image.bin; then mv makerom/image.bin .; fi
	@if test -r makerom/image.hex; then mv makerom/image.hex .; fi


tags:
	ctags -f tags -h ".h.h86.i86" -R --langmap="asm:+.S86.i86,c:+.c86.h86" \
		--exclude="mglparse.[ch]" --exclude="mgllex.[ch]" --exclude="*.asm"


libtool:	$(LIBTOOLDEPS)
	$(SHELL) ./config.status --recheck


make.config:	make.config.in config.status
	$(SHELL) ./config.status


config.status:	configure
	$(SHELL) ./config.status --recheck


install:
	@for subdir in $(sort $(INSTSUBDIRS)); do		\
	  echo making install in $$subdir;			\
	  (cd $$subdir && $(MAKE) install) || exit 1;		\
	 done


distrib:	distrib-recursive


clean:	clean-general clean-recursive
	rm -f image.rom image.flo image.flash image.bin image.hex
	rm -f tags

realclean: 	clean-general realclean-recursive
	rm -f make.config
	rm -f config.status config.cache config.log
	rm -f image.rom image.flo image.flash image.bin image.hex
	rm -f libtool tags

distclean:	clean-general distclean-recursive
	rm -f make.config
	rm -f config.status config.cache config.log
	rm -f image.rom image.flo image.flash image.bin image.hex
	rm -f libtool tags

