summaryrefslogtreecommitdiff
path: root/lib/libc/Makefile
blob: fabb532bc784688c2793ab80b845fb22f9c57c03 (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
CFLAGS = -c -fno-stack-protector -nostdlib -static -Iinclude/
LIBC_CFILES = $(shell find src/ -name "*.c")
LIBC_ASMFILES = $(shell find src/ -name "*.S")

LIBC_OBJ = $(LIBC_CFILES:.c=.o)
LIBC_ASMOBJ = $(LIBC_ASMFILES:.S=.S.o)

all: $(LIBC_OBJ) build/ld.so

build/ld.so: build/ linker/entry.c linker/entry.S
	mkdir -p $(@D)
	$(CC) $(CFLAGS) linker/entry.S -o build/entry.S.o
	$(CC) $(CFLAGS) linker/entry.c -o build/entry.o
	$(LD) -znoexecstack $(LIBC_OBJ) \
		build/entry.o build/entry.S.o -o $@

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

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

.PHONY:
build/:
	mkdir -p build/

.PHONY: clean
clean:
	rm -rf build/