#
# Makefile  -  makefile for boot rom kernel
#
# Copyright (C) 1995,1996 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 system dependent definitions:
#
include ../config.mk


#
#  List of source and object files:
#
LIBS	= obj/minidos.lib obj/net.lib obj/romlib.lib obj/arpa.lib obj/boot.lib
OBJS	= obj/main.obj obj/kernel.obj


#
#  Target rules.
#
all:		kernel.bin

obj/exebin.bat:	dummy
	@cd obj
	@$(RM) exebin.bat
	@echo @$(DOBIN) %1.exe ..\%1.bin >exebin.bat
	@cd ..

kernel.bin:	objs $(LIBS) obj/exebin.bat
	@cd obj
	$(LNKP) $(LFLAGS) kernel.obj+main.obj, \
		kernel.exe, kernel.map,\
		minidos.lib+net.lib+romlib.lib+arpa.lib+boot.lib ;
	exebin kernel
	@cd ..
ifdef P86
	@copy kernel.bin ..\binaries\kernel86.bin >NUL
else
ifdef MINIMAL
	@copy kernel.bin ..\binaries\kernelm.bin >NUL
else
	@copy kernel.bin ..\binaries\kernel.bin >NUL
endif
endif


#
#  Rules for creating the object files:
#
objs:			dummy
	@cd init
	@$(MAKE) all
	@copy main.obj ..\obj\main.obj >NUL
	@copy kernel.obj ..\obj\kernel.obj >NUL
	@cd ..


#
#  Rules for creating the libraries:
#
obj/minidos.lib:	dummy
	@cd dossim
	@$(MAKE) all
	@copy minidos.lib ..\obj\minidos.lib >NUL
	@cd ..


obj/net.lib:		dummy
	@cd net
	@$(MAKE) all
	@copy net.lib ..\obj\net.lib >NUL
	@cd ..


obj/romlib.lib:		dummy
	@cd lib
	@$(MAKE) all
	@copy romlib.lib ..\obj\romlib.lib >NUL
	@cd ..


obj/arpa.lib:		dummy
	@cd arpa
	@$(MAKE) all
	@copy arpa.lib ..\obj\arpa.lib >NUL
	@cd ..


obj/boot.lib:		dummy
	@cd boot
	@$(MAKE) all
	@copy boot.lib ..\obj\boot.lib >NUL
	@cd ..


#
#  Maintenance rules for cleaning up.
#
.PHONY:	clean

clean:
	-$(RM) kernel.bin
	-$(RM) *.bak
	@cd obj
	@-$(RM) exebin.bat
	-$(RM) *.obj
	-$(RM) *.lib
	-$(RM) *.map
	-$(RM) *.exe
	-$(RM) *.bak
	-$(RM) *.bin
	@cd ..
	@cd dossim
	@$(MAKE) clean
	@cd ..
	@cd net
	@$(MAKE) clean
	@cd ..
	@cd lib
	@$(MAKE) clean
	@cd ..
	@cd init
	@$(MAKE) clean
	@cd ..
	@cd arpa
	@$(MAKE) clean
	@cd ..
	@cd boot
	@$(MAKE) clean
	@cd ..


dummy:

