summaryrefslogtreecommitdiff
path: root/Makefile
blob: de590e82aba2ee1ed0f233bc554a1dd68293b0c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
CFLAGS  = -Os -pipe -std=c99 -D_POSIX_C_SOURCE=200809L
LDFLAGS =

BOOTSRCS = $(sort $(wildcard boot/*.c))
BOOTELFS = $(patsubst %.c,%.elf,$(BOOTSRCS))
BOOTBINS = $(patsubst boot/%.c,share/%.boot,$(BOOTSRCS))

SRCS = $(sort $(wildcard src/*.c))
DATA = $(sort $(wildcard src/*.bin))
OBJS = $(SRCS:.c=.o) $(DATA:.bin=.o)
BINS = bin/satmkboot

.PHONY: all clean

all: $(BINS) $(BOOTBINS)

clean:
	rm -f $(BINS) $(OBJS) $(BOOTBINS) $(BOOTELFS)

bin/satmkboot:         \
	src/satmkboot.o    \
	src/securitycode.o \
	src/symbols.o

share/%.boot: boot/%.elf
	saturn-objcopy -O binary $< $@

%.elf: %.c boot/ldscript
	saturn-gcc -nostdlib -T boot/ldscript $(CFLAGS) $< -o $@

%.c: %.bin
	tools/bin2c $< > $@

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

%:
	$(CC) $(LDFLAGS) $^ -o $@