-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (29 loc) · 1.01 KB
/
Makefile
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
LIBCA=libc.a
OLIB=lib/
CRTI_LIBCA=crti_$(LIBCA)
export CC CFLAGS INCFLAGS LIBCA CRTI_LIBCA NOSTDFLAGS
CC=c99
NOSTDFLAGS=-nostdlib -ffreestanding
SHUTUP= -Wno-pointer-arith -Wno-discarded-qualifiers
CFLAGS= -pedantic -Wall -funsigned-char -static -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-pie -Os -fdata-sections -ffunction-sections -fno-stack-protector $(MYCFLAGS) $(SHUTUP)
INCFLAGS= -I include/ -nostdinc
CSOURCE=$(wildcard src/*.c)
ASMSOURCE=$(wildcard src/*.S)
OBJFILES= $(patsubst src/%.c, obj/%.o, $(CSOURCE)) $(patsubst src/%.S, obj/%.o, $(ASMSOURCE))
Q=@
.PHONY: all clean test
all: $(LIBCA)
$(LIBCA): $(OBJFILES)
rm -f $(LIBCA)
ar rs $(OLIB)$@ $^
# SPECIAL CASE: We need the syscall numbers from asm/unistd.h
obj/syscalls.o: src/syscalls.S
$(Q)printf "CC %-20s -> $@\n" "$<"
$(Q)$(CC) $(CFLAGS) $(NOSTDFLAGS) $< -c -o $@
obj/%.o: src/%.[cS]
$(Q)printf "CC %-20s -> $@\n" "$<"
$(Q)$(CC) $(CFLAGS) $(INCFLAGS) $(NOSTDFLAGS) $< -c -o $@
clean:
rm -f $(OLIB)* obj/*.o
test: $(LIBCA)
@./test.sh