#
# l4/Makefile, adapted from 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_INST_DIR = /home/drops

LD=$(CROSS_COMPILE)ld -m elf_i386
CPP=$(CC) -E
OBJCOPY=$(CROSS_COMPILE)objcopy -O binary -R .note -R .comment -S
LDFLAGS=-e stext -N
ifdef CONFIG_L4_FIXUP4MB
LINKFLAGS =-T $(TOPDIR)/arch/l4/$(L4ARCH)/vmlinux.lds.4mb $(LDFLAGS)
else
LINKFLAGS =-T $(TOPDIR)/arch/l4/$(L4ARCH)/vmlinux.lds $(LDFLAGS)
endif

FINDHPATH += $(HPATH)/l4linux
AFLAGS := 

GCCINCDIR = $(shell $(CC) -print-search-dirs | \
	    awk '/^install:/{print $$2}')/include
CFLAGS_L4 := -DLINUX_ON_L4 -g -nostdinc -I$(GCCINCDIR)
CFLAGS_PIPE := -pipe
CFLAGS_NSR  := $(shell if $(CC) -march=i486 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo ""; else echo "-fno-strength-reduce"; fi)
CFLAGS := $(CFLAGS) $(CFLAGS_PIPE) $(CFLAGS_NSR) $(CFLAGS_L4)

ifdef CONFIG_FRAME_POINTER
CFLAGS          := $(CFLAGS:-fomit-frame-pointer=)
endif

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_M586TSC
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

HEAD := arch/l4/$(L4ARCH)/kernel/head.o arch/l4/$(L4ARCH)/kernel/init_task.o

SUBDIRS := $(SUBDIRS) \
	arch/l4/$(L4ARCH)/kernel \
	arch/l4/$(L4ARCH)/mm \
	arch/l4/$(L4ARCH)/lib \
	arch/l4/$(L4ARCH)/emulib \
	arch/l4/$(L4ARCH)/driver

CORE_FILES := \
	arch/l4/$(L4ARCH)/kernel/kernel.o \
	arch/l4/$(L4ARCH)/mm/mm.o \
	arch/l4/$(L4ARCH)/driver/drivers.o \
	$(CORE_FILES)

LIBS := \
	$(TOPDIR)/arch/l4/$(L4ARCH)/lib/lib.a \
	$(LIBS) \
	$(TOPDIR)/arch/l4/$(L4ARCH)/lib/lib.a \
	$(TOPDIR)/arch/l4/$(L4ARCH)/emulib/emulib.o

arch/l4/$(L4ARCH)/kernel: dummy
	$(MAKE) linuxsubdirs SUBDIRS=arch/l4/$(L4ARCH)/kernel

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

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

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) BOOTIMAGE=bzImage install

archclean:
	@$(MAKEBOOT) clean
	@$(MAKE) -C arch/l4/$(L4ARCH) l4archclean

archmrproper:
	@$(MAKE) -C arch/l4/$(L4ARCH) l4archmrproper
	rm -f $(TOPDIR)/include/asm-l4/l4arch
	rm -f $(TOPDIR)/arch/l4/l4arch
	rm -f $(TOPDIR)/glinux

archdep:
	@$(MAKEBOOT) dep
