#
# Copyright (c) 1997-1998 University of Utah and the Flux Group.
# All rights reserved.
# 
# This file is part of the Flux OSKit.  The OSKit is free software, also known
# as "open source;" you can redistribute it and/or modify it under the terms
# of the GNU General Public License (GPL), version 2, as published by the Free
# Software Foundation (FSF).  To explore alternate licensing terms, contact
# the University of Utah at csl-dist@cs.utah.edu or +1-801-585-3271.
# 
# The OSKit 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 GPL for more details.  You should have
# received a copy of the GPL along with the OSKit; see the file COPYING.  If
# not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
#

ifndef _boot_dos_makerules_
_boot_dos_makerules_ = yes

TARGETS = dosboot.exe mkdosimage
CLEAN_FILES += dosboot.exe

# This must come before any includes since make runs the first rule
# found if not explicitly told not to.
all: $(TARGETS)

# Where to look for src files.
SRCDIRS += $(OSKIT_SRCDIR)/boot/dos $(OSKIT_SRCDIR)/boot 

# Include the makefile containing the generic rules.
# This must come here since it depends on SRCDIRS and sets OBJFILES.
include $(OSKIT_SRCDIR)/GNUmakerules

# DEPENDLIBS is kind of bogus.  It makes it so we get rebuilt if *any*
# of the LIBS are newer than us.  It doesn't cause any libraries we
# need to be built though.
LIBS = -loskit_exec -loskit_kern -loskit_c -loskit_lmm
DEPENDLIBS = $(filter %.a, $(foreach DIR,$(LIBDIRS),$(wildcard $(DIR)/*)))

dosboot.exe: $(OBJFILES) $(DEPENDLIBS)
	$(LD) -Ttext 0 -oformat msdos -o $@ $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/dos.o $(OBJFILES) $(OBJDIR)/lib/crtn.o $(LIBS)

dosboot: $(OBJFILES) $(DEPENDLIBS)
	$(LD) -Ttext 0 -o $@ $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/dos.o $(OBJFILES) $(OBJDIR)/lib/crtn.o $(LIBS)

.PHONY: mkdosimage
mkdosimage:
	chmod +x $@

# How to install it.  The rule to make $(INSTALL_BINDIR/mkdosimage
# comes from the generic rule file
install: $(INSTALL_LIBDIR)/oskit/dosboot.exe $(INSTALL_BINDIR)/mkdosimage

endif
