refactor: use for ia86-elf-gcc toolchain + linker file
[swan-dev] / Makefile
index de9a494..f949274 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,31 +1,39 @@
-# simple makefile
-INC=./inc
-CC=bcc
-LD=ld86
-AS=nasm
-MED=mednafen
-
-#$(LD) -M src/*.o
-
-# -d delete headers
-# -s strip symbols
-all:
-       $(LD) -T0x0 -D0xF000 src/*.o -d -s -o test.wsc
-
-# use -x to for -ffreestanding
-c-files:
-       $(CC) -0 -c src/*.c -I$(INC)
-init:
-       $(AS) -fas86 src/*.s -i $(INC)
+#
+# makefile for swan-sdk
+#
 
-add:
-       cp test.wsc tools/
-       cd tools && ./romheader
+OUT = test.wsc
+CC = ia16-elf-gcc
+LD = ia16-elf-ld
+ODIR = obj
+ADIR = objs
+SDIR = src
+INC = -Iinc
 
-run:
-       $(MED) tools/test.wsc
+CFLAGS = -march=v30 -ffreestanding # use NEC v30 chip
 
-clean:
-       rm -rf src/*.o test.wsc
+_OBJS = entry.o main.o # todo: make sure entry is forced as entry point for linker
+
+OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
+
+LDFILE = swan.ld
+
+
+$(ODIR)/%.o: $(SDIR)/%.c
+       $(CC) -c $(INC) -o $@ $< $(CFLAGS)
 
+$(ODIR)/entry.o: $(SDIR)/entry.S
+       $(CC) -c $(INC) -o $@ $< $(CFLAGS)
 
+$(OUT): $(OBJS)
+       $(LD) -T $(LDFILE) $^ -o $(OUT)
+
+add:
+       ./romheader
+run:
+       mednafen test.wsc
+
+.PHONY: clean
+
+clean:
+       rm -f $(ODIR)/*.o $(OUT)