LIBC_SOURCES = \
  entry.cpp std/string.cpp std/cstring.cpp syscall.cpp std/cstdlib.cpp \
  heap.cpp syscall.asm std/cctype.cpp std/cstdio.cpp stream.cpp

clean:
	rm -rf build

build/%.asm.o: source/%.asm
	@mkdir -p $(@D)
	$(HILBERT_NASM) $^ -o $@

build/%.cpp.o: source/%.cpp
	@mkdir -p $(@D)
	$(HILBERT_CC) -ffreestanding -c $^ -o $@

build/crt0.o: build/empty.asm.o
	cp $^ $@

build/libc.a: ${LIBC_SOURCES:%=build/%.o}
	$(HILBERT_AR) rcs $@ $^

build/libg.a: build/empty.asm.o
	$(HILBERT_AR) rcs $@ $^

build/libm.a: build/empty.asm.o
	$(HILBERT_AR) rcs $@ $^
