#
# Makefile  -  main makefile for bootrom
#
# Copyright (C) 1996-2003 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.
#


include make.config
include make.defs


# The headers directory has to come first!
SUBDIRS	= headers loader kernel netdrvr
TARGETS	= headers-$(DEV86) loader-$(DEV86) kernel-$(DEV86) netdrvr-$(DEV86)


#
# Rules to generate targets
#
.PHONY:	all distrib
.PHONY:	headers-i86 kernel-i86 loader-i86 netdrvr-i86
.PHONY:	headers-no86 kernel-no86 loader-no86 netdrvr-no86

all distrib:	$(TARGETS)
	@(! grep "undefined symbol" `find -name '*.map'` || exit 1)


headers-i86 kernel-i86 loader-i86 netdrvr-i86:
	@echo making all in $(@:-i86=)
	@(cd $(@:-i86=); $(MAKE) all || exit 1)

headers-no86 kernel-no86 loader-no86 netdrvr-no86:
	@echo nothing to make in $(@:-no86=)


#
# Maintenance rules
#
.PHONY:	dep install clean realclean distclean
.PHONY:	clean-recursive realclean-recursive distclean-recursive

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


instbin:
	$(INSTALL) -o bin -g bin -d $(nblibdir)
	$(INSTALL) -o bin -g bin -d $(nblibdir)/binaries
	$(INSTALL) -o bin -g bin -d $(nblibdir)/utils
	@for i in $(bindestdir)/*.bin; do \
	  $(INSTALL) -m 644 -o bin -g bin $$i $(nblibdir)/binaries; \
	done
	@for i in $(bindestdir)/*.com; do \
	  $(INSTALL) -m 644 -o bin -g bin $$i $(nblibdir)/utils; \
	done


install:	instbin
	@(cd netdrvr && $(MAKE) $@) || exit 1


clean:	clean-recursive


realclean: 	realclean-recursive
	rm -f make.defs
	rm -f $(bindestdir)/*.bin $(bindestdir)/*.com

distclean:	distclean-recursive
	rm -f make.defs


clean-recursive realclean-recursive distclean-recursive:
	@for subdir in $(SUBDIRS); do \
	  target=`echo $@ | sed 's/-recursive//'`; \
	  echo making $$target in $$subdir; \
	  (cd $$subdir && $(MAKE) $$target) || exit 1; \
	done



syntax highlighted by Code2HTML, v. 0.9.1