#
# Copyright (c) 1994, 1997-2000 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 _oskit_kern_x86_makerules_
_oskit_kern_x86_makerules_ = yes

SRCDIRS +=	$(OSKIT_SRCDIR)/kern/x86		\
		$(OSKIT_SRCDIR)/kern/x86/pc		\
		$(OSKIT_SRCDIR)/kern/x86/dos

ifneq "$(filter have_code16, $(OSKIT_OPTIONS))" ""
SRCDIRS +=	$(OSKIT_SRCDIR)/kern/x86/i16		\
		$(OSKIT_SRCDIR)/kern/x86/pc/i16		\
		$(OSKIT_SRCDIR)/kern/x86/dos/i16
endif

inline-headers := proc_reg.h atomic.h debug_reg.h pmode.h seg.h \
		  paging.h base_paging.h \
		  pc/i16_bios.h pc/i16_dos.h

CLEAN_FILES += $(inline-headers:%.h=inline-%.c) inline-pc
OBJFILES += $(inline-headers:%.h=inline-%.o)

prepare:: $(inline-headers:%.h=inline-%.c) inline-pc


include $(OSKIT_SRCDIR)/kern/GNUmakerules

gdb_trap_ss.o i16_real_int.o: trap_asm.h
i16_raw.o base_irq_inittab.o: pc_asm.h
i16_raw.o i16_base_gdt_init.o: x86_asm.h
CLEAN_FILES += trap_asm.h pc_asm.h x86_asm.h

prepare:: trap_asm.h pc_asm.h x86_asm.h

$(inline-headers:%.h=inline-%.c): inline-%.c: $(OSKIT_SRCDIR)/oskit/x86/%.h
# XXX avoid inline-pc/ subdir.
	@test -d $(@D) || ln -s . $(@D)
	$(OSKIT_QUIET_MAKE_INFORM) "Generating $@"
	($(foreach h,$(filter-out $*.h $(includes-$*.h),$(inline-headers)),\
	echo '#include <oskit/x86/$h>';)\
	echo '#undef OSKIT_INLINE'; echo '#define OSKIT_INLINE';\
	echo '#include <oskit/x86/$*.h>'\
	) > $@

includes-proc_reg.h	:= base_paging.h
includes-paging.h	:= base_paging.h

endif
