#
# Copyright (c) 1996-1995 The University of Utah and
# the Computer Systems Laboratory (CSL).  All rights reserved.
#
# Permission to use, copy, modify and distribute this software and its
# documentation is hereby granted, provided that both the copyright
# notice and this permission notice appear in all copies of the
# software, derivative works or modified versions, and any portions
# thereof, and that both notices appear in supporting documentation.
#
# THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
# IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
# ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
#
# CSL requests users of this software to return to csl-dist@cs.utah.edu any
# improvements that they make and grant CSL redistribution rights.
#
#      Author: Bryan Ford, University of Utah CSL
#
ifndef _oskit_libkern_makerules_
_oskit_libkern_makerules_ = yes

TARGETS = multiboot multiboot-gdb multiboot-smp fdev_test part_read

all: $(TARGETS)

SRCDIRS +=	$(OSKIT_SRCDIR)/examples/x86
CLEAN_FILES +=	$(TARGETS)

include $(OSKIT_SRCDIR)/GNUmakerules

INCDIRS += $(OSKIT_SRCDIR)/libfdev_linux/include
DEFINES += -DOSKIT -D__KERNEL__
DEPENDLIBS = $(filter %.a, $(foreach DIR,$(LIBDIRS),$(wildcard $(DIR)/*)))

multiboot: $(OBJDIR)/lib/multiboot.o multiboot.o $(DEPENDLIBS)
	$(LD) -Ttext 100000 $(LDFLAGS) $(OSKIT_LDFLAGS) \
		-o $@ $(filter-out %.a,$^)		\
		-lkern -lmc -llmm $(OBJDIR)/lib/crtn.o

multiboot-gdb: $(OBJDIR)/lib/multiboot.o multiboot-gdb.o $(DEPENDLIBS)
	$(LD) -Ttext 100000 $(LDFLAGS) $(OSKIT_LDFLAGS) \
		-o $@ $(filter-out %.a,$^)		\
		-lkern -lmc -llmm $(OBJDIR)/lib/crtn.o

multiboot-smp: $(OBJDIR)/lib/multiboot.o multiboot-smp.o $(DEPENDLIBS)
	$(LD) -Ttext 100000 $(LDFLAGS) $(OSKIT_LDFLAGS) \
		-o $@ $(filter-out %.a,$^)		\
		-lsmp -lkern -lmc -llmm $(OBJDIR)/lib/crtn.o
# XXX -lsmp must be before -lkern for Bryan's base_critical_XXX hack

part_read: $(OBJDIR)/lib/multiboot.o part_read.o $(DEPENDLIBS)
	$(LD) -Ttext 100000 $(LDFLAGS) $(OSKIT_LDFLAGS) \
		-o $@ $(filter-out %.a,$^)		\
		-lfdev -lfdev_linux -ldiskpart -lkern -lmc -llmm -lfdev -llmm \
		$(OBJDIR)/lib/crtn.o

fdev_test: $(OBJDIR)/lib/multiboot.o fdev_test.o $(DEPENDLIBS)
	$(LD) -Ttext 100000 $(LDFLAGS) $(OSKIT_LDFLAGS) \
		-o $@ $(filter-out %.a,$^)		\
		-lfdev -lfdev_linux -lkern -lmc -llmm -lfdev -llmm \
		$(OBJDIR)/lib/crtn.o

endif
