#
# aboot/Makefile
#
# 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) 1995 by David Mosberger (davidm@cs.arizona.edu)
#

CC	= gcc
#
# ROOT should be set to the empty string  on a self-hosting system.
# Otherwise, it should be the path that leads to the Linux-specific
# include files (the kernel-header files are all that is needed).
#
ROOT	= ../../root
TOP	= $(shell pwd)
CFGDEFS	= -DCONFIG_COMPRESSED_BOOT
CPPFLAGS= $(CFGDEFS) -I$(TOP)/include -I$(ROOT)/usr/include
CFLAGS	= $(CPPFLAGS) -D__KERNEL__ -g -O2 -Wall -mno-fp-regs
ASFLAGS	= $(CPPFLAGS)

.c.s:
	$(CC) $(CFLAGS) -S -o $*.s $<
.s.o:
	$(AS) -o $*.o $<
.c.o:
	$(CC) $(CFLAGS) -c -o $*.o $<
.S.s:
	$(CC) $(ASFLAGS) -D__ASSEMBLY__ -traditional -E -o $*.o $<
.S.o:
	$(CC) $(ASFLAGS) -D__ASSEMBLY__ -traditional -c -o $*.o $<

OBJECTS = \
	head.o main.o cons.o utils.o \
	fs/ext2.o fs/ufs.o \
	zip/misc.o zip/unzip.o zip/inflate.o \
	lib/vsprintf.o lib/memcpy.o lib/memset.o lib/string.o \
	lib/__divqu.o lib/__remqu.o lib/__divlu.o lib/__remlu.o \
	lib/_setjmp.o lib/_longjmp.o

all:	aboot

lib/__divqu.o: lib/divide.S
	$(CC) -DDIV -c -o $@ lib/divide.S

lib/__remqu.o: lib/divide.S
	$(CC) -DREM -c -o $@ lib/divide.S

lib/__divlu.o: lib/divide.S
	$(CC) -DDIV -DINTSIZE -c -o $@ lib/divide.S

lib/__remlu.o: lib/divide.S
	$(CC) -DREM -DINTSIZE -c -o $@ lib/divide.S

aboot:	$(OBJECTS)
	$(LD) -static -T aboot.lds -N \
		$(OBJECTS) \
		-o $@

clean:
	rm -f aboot $(OBJECTS)

distclean: clean
	find . -name \*~ | xargs rm -f

dep:
