#
# ataboot/Makefile
#
# This file is subject to the terms and conditions of the GNU General Public
# License.
#

# possible options:
#   AOUT_KERNEL:
#     Include support for a.out kernels (may go away in future!)
#   BOOTINFO_COMPAT_1_0:
#     Include support for booting kernel with bootinfo version 1.0 (up
#     to 2.0.x)
#   USE_BOOTP:
#     Include support for retrieving the kernel image via BOOTP/TFTP
OPTIONS  = -DBOOTINFO_COMPAT_1_0 # -DAOUT_KERNEL

# cross compiler for TOS
HOSTCC = m68k-tos-gcc
HOSTFLAGS = -m68030 -m68881 -Dlinux -O2 -fomit-frame-pointer -Wall $(OPTIONS)

# adjust to where your Linux/68k kernel source is
KERNELINC = /usr/src/linux/include

CSRC := bootstrap.c linuxboot.c stream.c file_mod.c gunzip_mod.c
OBJS := bootstrap.o linuxboot.o stream.o file_mod.o gunzip_mod.o

# BOOTP/TFTP support in bootstrap?
# USE_BOOTP = y

ifdef USE_BOOTP
CSRC += bootp_mod.c
OBJS += bootp_mod.o
HOSTFLAGS += -DUSE_BOOTP

# low-level Ethernet drivers:

# Lance (RieblCard, PAM-VME)
CSRC += ethlance.c
OBJS += ethlance.o
HOSTFLAGS += -DETHLL_LANCE

endif


bootstrap: $(OBJS)
	$(HOSTCC) -I$(KERNELINC) $(HOSTFLAGS) -o $@ $(OBJS)
	ln -f $@ ataboot.ttp

$(OBJS): %.o: %.c
	$(HOSTCC) -I$(KERNELINC) $(HOSTFLAGS) -c $< -o $@

clean:
	rm -f *.o bootstrap ataboot.ttp

distclean: clean
	rm -f .#* #*# *~ *.orig *.rej *.s

dep:
	$(HOSTCC) -I$(KERNELINC) $(HOSTFLAGS) -MM $(CSRC) >.depend

dist: distclean
	name=$$(basename $$(pwd)); (cd ..; tar cf $$name-src.tar $$name; \
		gzip -9f $$name-src.tar)
	$(MAKE)
	name=$$(basename $$(pwd)); cp bootstrap ..; \
		gzip -9f ../bootstrap; mv ../bootstrap.gz ../$$name.gz; \
		chmod a-x ../$$name.gz
	$(MAKE) clean
	$(MAKE) USE_BOOTP=y
	name=$$(basename $$(pwd)); cp bootstrap ..; \
		gzip -9f ../bootstrap; mv ../bootstrap.gz ../$$name-bootp.gz; \
		chmod a-x ../$$name-bootp.gz

-include .depend
