# The produced executable filename
TARGET	:= hns

CROSS_COMPILE = human68k-

AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
OBJCOPY = $(CROSS_COMPILE)objcopy

AFLAGS		:= -m68000 --register-prefix-optional
LDFLAGS		:= 
CFLAGS		:= -m68000 -std=c99 -fomit-frame-pointer
LDSCRIPT	:= 
LIBS		:= -ldos
OCFLAGS		:= -O xfile

ifneq ($(LDSCRIPT),)
LDFLAGS		+=  -T $(LDSCRIPT)
endif

XTARGET	:= $(TARGET).X

OBJS	:= main.o

%.o: %.S
	$(AS) $(AFLAGS) -o $@ $<
	
%.o: %.c
	$(CC) -c $(CFLAGS) $<

$(TARGET): $(OBJS) $(CRT0)
	
	$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
	$(OBJCOPY) $(OCFLAGS) $@ bin/$(XTARGET)
	
all: $(TARGET)
	
clean:
	rm -f $(TARGET) bin/$(XTARGET) $(OBJS) $(CRT0)