#
# Makefile  -  makefile for boot rom kernel
#
# Copyright (C) 1995-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.
#
# $Id: Makefile,v 1.5 2003/01/25 23:29:40 gkminix Exp $
#


#
#  Include user configuration:
#
include ../make.config


#
# Name of this module
#
MODULE		= kernel


#
#  List of subdirectories
#
SUBDIRS		= init arpa boot lib net


#
#  List of source and object files:
#
LIBS		= libnet.a libromlib.a libarpa.a libboot.a
INITOBJS	= kernel.o
SEGEND		= segend.o
TARGET		= kernel.bin


#
#  Include system dependent definitions:
#
include ../make.defs


#
#  The checksize script verifies that the kernel image doesn't grow too
#  large in order to fit into a certain amount of memory. MAXSIZE defines
#  that amount of memory. It represents the number of kB typically available
#  in a PC starting from 0x98000 up to the extended BIOS data area. STACKSIZE
#  defines the name of the file which contains the size of the stack in bytes.
#
MAXSIZE		= 31
STACKSIZE	= $(srcdir)/kernel/init/kernel.S


#
#  Target rules.
#
all:	subdirs
	(cd $(MODOBJDIR); \
	  $(LD86) $(LD86FLAGS) -M -o $(TARGET) $(INITOBJS) $(LIBS:lib%.a=-l%) $(SEGEND) | $(MAPSORT) >kernel.map; \
	  chmod 0644 $(TARGET); \
	  cp $(TARGET) $(bindestdir)/kernel.bin \
	)
	(cd $(MODOBJDIR); \
	  $(LD86) $(LD86FLAGS) -M -o $(TARGET:%.bin=%m.bin) $(INITOBJS:.o=.om) $(LIBS:lib%.a=-l%-m) $(SEGEND:.o=.om) | $(MAPSORT) >kernelm.map; \
	  chmod 0644 $(TARGET:%.bin=%m.bin); \
	  cp $(TARGET:%.bin=%m.bin) $(bindestdir)/kernelm.bin \
	)
	(cd $(MODOBJDIR); \
	  $(LD86) $(LD86FLAGS) -M -o $(TARGET:%.bin=%86.bin) $(INITOBJS:.o=.o16) $(LIBS:lib%.a=-l%-16) $(SEGEND:.o=.o16) | $(MAPSORT) >kernel86.map; \
	  chmod 0644 $(TARGET:%.bin=%86.bin); \
	  cp $(TARGET:%.bin=%86.bin) $(bindestdir)/kernel86.bin \
	)


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


#
#  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


install:


clean:	clean-recursive
	rm -f $(MODOBJDIR)/*.o
	rm -f $(MODOBJDIR)/*.o16
	rm -f $(MODOBJDIR)/*.om
	rm -f $(MODOBJDIR)/*.a
	rm -f $(MODOBJDIR)/*.bin
	rm -f $(MODOBJDIR)/*.map

realclean distclean:	distclean-recursive
	rm -f $(MODOBJDIR)/*.o
	rm -f $(MODOBJDIR)/*.o16
	rm -f $(MODOBJDIR)/*.om
	rm -f $(MODOBJDIR)/*.a
	rm -f $(MODOBJDIR)/*.bin
	rm -f $(MODOBJDIR)/*.map

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