#
# Makefile for the linux kernel.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#
# Note 2! The CFLAGS definitions are now in the main makefile...

.S.o:
ifdef CONFIG_ALTIVEC
	$(CC) $(CFLAGS) -D__ASSEMBLY__ -Wa,-mvec -c $< -o $*.o 
else
	$(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $*.o
endif

O_TARGET := kernel.o
OX_OBJS := ppc_ksyms.o setup.o

O_OBJS := traps.o irq.o idle.o time.o process.o signal.o syscalls.o misc.o \
	  bitops.o ptrace.o align.o ppc_htab.o
ifdef CONFIG_PCI
O_OBJS += pci.o
endif
ifdef CONFIG_KGDB
O_OBJS += ppc-stub.o
endif
ifdef CONFIG_TOTALMP
O_OBJS += totalmp.o
endif
ifdef CONFIG_PMAC_PBOOK
O_OBJS += sleep.o
endif

ifeq ($(CONFIG_8xx),y)
ifeq ($(CONFIG_MATH_EMULATION),y)
O_OBJS += m8xx_setup.o ppc8xx_pic.o
else
O_OBJS += m8xx_setup.o softemu8xx.o ppc8xx_pic.o
endif
ifdef CONFIG_PCI
O_OBJS += qspan_pci.o
endif
ifdef CONFIG_MBX
O_OBJS += i8259.o
endif
else
ifeq ($(CONFIG_APUS),y)
O_OBJS += apus_setup.o prom.o openpic.o
else
ifeq ($(CONFIG_K2),y)
O_OBJS += k2_setup.o k2_pic.o k2_pci.o i8259.o \
	indirect_pci.o m48t3x.o multi_pci.o ppc_stubs.o
endif
ifeq ($(CONFIG_PCORE),y)
O_OBJS += pcore_setup.o pcore_pci.o
endif
ifneq ($(CONFIG_PPC_EMBEDDED),y)
O_OBJS += prep_time.o pmac_time.o chrp_time.o \
	  pmac_setup.o pmac_support.o \
	  prep_pci.o pmac_pci.o chrp_pci.o \
	  residual.o prom.o openpic.o feature.o \
	  prep_nvram.o open_pic.o i8259.o pmac_pic.o indirect_pci.o \
	  gemini_pci.o gemini_prom.o gemini_setup.o
OX_OBJS += chrp_setup.o prep_setup.o
endif
endif
endif

ifdef CONFIG_SMP
O_OBJS += smp.o
endif

all: head.o kernel.o

head.o: head.S $(TOPDIR)/include/linux/tasks.h ppc_defs.h

ppc_defs.h: mk_defs.c ppc_defs.head \
		$(TOPDIR)/include/asm/mmu.h \
		$(TOPDIR)/include/asm/processor.h \
		$(TOPDIR)/include/asm/pgtable.h \
		$(TOPDIR)/include/asm/ptrace.h
	$(CC) ${CFLAGS} -S mk_defs.c
	cat ppc_defs.head >ppc_defs.h
	grep '^#define' mk_defs.s >>ppc_defs.h
	rm mk_defs.s

find_name : find_name.c
	$(HOSTCC) -o find_name find_name.c

checks: checks.c
	$(HOSTCC) ${CFLAGS} -D__KERNEL__ -o checks checks.c
	./checks

include $(TOPDIR)/Rules.make
