2020-11-12 03:57:05 +03:00
|
|
|
PROGRAM=example
|
2020-11-12 03:43:46 +03:00
|
|
|
SOURCES=syscalls.o colors.go.o colors.gox os.go.o os.gox $(PROGRAM).go.o
|
|
|
|
LIBOBJ=os.go.o syscalls.o colors.go.o
|
2020-05-03 12:30:20 +03:00
|
|
|
GOFLAGS= -nostdlib -nostdinc -fno-stack-protector -fno-split-stack -static -m32 -g -I.
|
|
|
|
GO=gccgo
|
|
|
|
ASFLAGS= -felf
|
|
|
|
NASM= nasm $(ASFLAGS)
|
|
|
|
OBJCOPY=objcopy
|
2020-11-12 03:43:46 +03:00
|
|
|
|
2020-05-03 12:30:20 +03:00
|
|
|
LDFLAGS=-T static.lds -n -m elf_i386
|
|
|
|
|
2020-11-12 03:43:46 +03:00
|
|
|
|
2020-05-03 12:30:20 +03:00
|
|
|
all: $(SOURCES) link
|
2020-11-12 03:43:46 +03:00
|
|
|
clean:
|
|
|
|
rm *.o *.gox $(PROGRAM).kex
|
2020-05-03 12:30:20 +03:00
|
|
|
link:
|
2020-11-12 03:43:46 +03:00
|
|
|
ld $(LDFLAGS) -o $(PROGRAM).kex $(SOURCES)
|
|
|
|
$(OBJCOPY) $(PROGRAM).kex -O binary
|
2020-05-03 12:30:20 +03:00
|
|
|
%.gox: %.go.o
|
2020-11-12 03:43:46 +03:00
|
|
|
$(OBJCOPY) -j .go_export $< $@
|
2020-05-03 12:30:20 +03:00
|
|
|
%.go.o: %.go
|
2020-11-12 03:43:46 +03:00
|
|
|
$(GO) $(GOFLAGS) -o $@ -c $<
|
2020-05-03 12:30:20 +03:00
|
|
|
%.o: %.s
|
|
|
|
$(NASM) $<
|