#
# i386/Makefile
#
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies. Remember to do have actions
# for "archclean" and "archdep" for cleaning up and making dependencies for
# this architecture
#
# This file is subject to the terms and conditions of the GNU General Public
# License.  See the file "COPYING" in the main directory of this archive
# for more details.
#
# Copyright (C) 1994 by Linus Torvalds
#

L4_DIR = $(TOPDIR)/../l4

# L4 adaptions
CFLAGS := $(CFLAGS) -I$(L4_DIR)/lib/libl4sys/include \
  -I$(L4_DIR)/server/rmgr/include -DLINUX_ON_L4
FINDHPATH:= $(FINDHPATH) $(L4_DIR)/lib/libl4sys/include $(TOPDIR)/arch/$(ARCH)/include

L4_DEBUG=1

ifdef L4_DEBUG
CFLAGS+= -g
EXTRA_LDFLAGS= -g
endif

/* NO_M4_PAGES=1 */
ifndef NO_M4_PAGES
IMAGE_OFFSET=0x3ff000 #0x400000-0x1000
CFLAGS+= -DCONFIG_M4_PAGES
else
IMAGE_OFFSET=0x400000
endif

ifdef CONFIG_KERNEL_ELF

# no special magic here... ELF is the default toolset on Debian Linux
LINKFLAGS =-Ttext $(IMAGE_OFFSET) $(EXTRA_LDFLAGS)

else

# use the Debian a.out compiler toolset
CROSS_COMPILE = /usr/i486-linuxaout/bin/
LINKFLAGS =-qmagic -Ttext  $(IMAGE_OFFSET) $(EXTRA_LDFLAGS)

endif

CFLAGS := $(CFLAGS) -pipe

ifdef CONFIG_M386
CFLAGS := $(CFLAGS) -m386 -DCPU=386
endif

ifdef CONFIG_M486
CFLAGS := $(CFLAGS) -m486 -DCPU=486
endif

ifdef CONFIG_M586
CFLAGS := $(CFLAGS) -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=586
endif

ifdef CONFIG_M686
CFLAGS := $(CFLAGS) -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=686
endif

ifdef SMP
CFLAGS := $(CFLAGS) -D__SMP__
endif

HEAD := arch/l4-i386/kernel/head.o

SUBDIRS := $(SUBDIRS) arch/l4-i386/kernel arch/l4-i386/mm arch/l4-i386/lib \
  arch/l4-i386/emulib arch/l4-i386/drivers

ARCHIVES := arch/l4-i386/kernel/kernel.o arch/l4-i386/mm/mm.o \
   arch/l4-i386/emulib/emulib.o arch/l4-i386/drivers/drivers.o $(ARCHIVES)

#LIBS := $(TOPDIR)/arch/l4-i386/lib/lib.a $(LIBS) $(TOPDIR)/arch/l4-i386/lib/lib.a $(L4_DIR)/lib/libl4dbg/libl4dbg.a
LIBS := $(TOPDIR)/arch/l4-i386/lib/lib.a $(LIBS) $(TOPDIR)/arch/l4-i386/lib/lib.a

arch/l4-i386/kernel arch/l4-i386/kernel/head.o: dummy
	$(MAKE) linuxsubdirs SUBDIRS=arch/l4-i386/kernel

arch/l4-i386/drivers: dummy
	$(MAKE) linuxsubdirs SUBDIRS=arch/l4-i386/drivers

arch/l4-i386/mm: dummy
	$(MAKE) linuxsubdirs SUBDIRS=arch/l4-i386/mm

arch/l4-i386/emulib: dummy
	$(MAKE) linuxsubdirs SUBDIRS=arch/l4-i386/mm

MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot

glinux:	vmlinux
	@$(MAKEBOOT) $@

zImage: vmlinux
	@$(MAKEBOOT) zImage

bzImage: vmlinux
	@$(MAKEBOOT) bzImage

compressed: zImage

zlilo: vmlinux
	@$(MAKEBOOT) BOOTIMAGE=zImage zlilo

bzlilo: vmlinux
	@$(MAKEBOOT) BOOTIMAGE=bzImage zlilo

zdisk: vmlinux
	@$(MAKEBOOT) BOOTIMAGE=zImage zdisk

bzdisk: vmlinux
	@$(MAKEBOOT) BOOTIMAGE=bzImage zdisk

install: vmlinux
	@$(MAKEBOOT) install

archlib: dummy
	$(MAKE)	linuxsubdirs SUBDIRS=arch/l4-i386/lib

emulib:	dummy
	$(MAKE)	linuxsubdirs SUBDIRS=arch/l4-i386/emulib

archclean:
	@$(MAKEBOOT) clean
	$(MAKE) -C arch/$(ARCH)/kernel clean

archdep:
	@$(MAKEBOOT) dep
