Make complains that there is no rule for target 'build/libc/string/strlen.c' when it's clearly defined. Weirdly, it successfully compiled all but one dependency for 'build/libc/libc.a'. I had, or at least attempted to, disabled the builtin implicit rules and variables to avoid spending hours debugging while pulling my hair out but it doesn't seem to help because I'm completely lost.
Makefile:
.SUFFIXES:
MAKEFLAGS += -rR
STD = gnu11
CFLAGS = -O2 -g -ffreestanding -fbuiltin -Wall -Wno-div-by-zero -D__is_vos_kernel__ -Iinclude
LFLAGS = -O2 -g -ffreestanding -fbuiltin -Wall -Wextra
LIBC_FLAGS = -O2 -g -D__is_vos_libc__ -Iinclude
LIBK_FLAGS = -O2 -g -ffreestanding -fbuiltin -D__is_vos_libc__ -Iinclude -D__is_vos_kernel__
CC = i386-elf-gcc
LD = i386-elf-ld
AR = i386-elf-ar
AS = /usr/local/bin/nasm
SYSROOT = sysroot
BUILDDIR = builddir
SYSARG = --sysroot=sysroot -isystem=/usr/include
LIBC_OBJECTS = $(wildcard libc/*.c)
LIBC_HEADERS = $(wildcard libc/*.h)
LLIBC_HEADERS = $(wildcard sysroot/usr/include/*.h)
header:=$(shell find libc -type f -name "*.h")
prepare-dir:
mkdir -p sysroot/usr/include sysroot/usr/lib build
sysroot/usr/include/%.h: libc/%.h prepare-dir
cd libc; rsync -R $(<:libc/%=%) ../sysroot/usr/include
prepare-headers: $(addprefix sysroot/usr/include/, $(header:libc/%=%))
@echo $^
prepare: prepare-dir prepare-headers
build/libc/%.o: libc/%.c prepare
$(CC) $(SYSARG) -c $< -o $@ -std=$(STD) $(LIBC_FLAGS)
libc_objects = $(shell find libc -type f -name "*.c")
libco_pre = $(addprefix build/, $(libc_objects)))
build/libc/libc.a: $(libco_pre:.c=.o)
$(AR) rcs $@ $^
clean:
find . -type f -name "*.o" -delete
find sysroot -type f -name "*" -delete
# find sysroot -type d -name "*" -delete
find build -type f -name "*" -delete
# find build -type d -name "*" -delete
Command log:
G16-MACBOOKPRO:VioletOS ghifari160$ make -rR build/libc/libc.a
mkdir -p sysroot/usr/include sysroot/usr/lib build
cd libc; rsync -R stdbool.h ../sysroot/usr/include
cd libc; rsync -R stdint.h ../sysroot/usr/include
cd libc; rsync -R stdlib.h ../sysroot/usr/include
cd libc; rsync -R string.h ../sysroot/usr/include
cd libc; rsync -R sys/cdefs.h ../sysroot/usr/include
sysroot/usr/include/stdbool.h sysroot/usr/include/stdint.h sysroot/usr/include/stdlib.h sysroot/usr/include/string.h sysroot/usr/include/sys/cdefs.h
i386-elf-gcc --sysroot=sysroot -isystem=/usr/include -c libc/stdlib/abort.c -o build/libc/stdlib/abort.o -std=gnu11 -O2 -g -D__is_vos_libc__ -Iinclude
i386-elf-gcc --sysroot=sysroot -isystem=/usr/include -c libc/string/malloc.c -o build/libc/string/malloc.o -std=gnu11 -O2 -g -D__is_vos_libc__ -Iinclude
i386-elf-gcc --sysroot=sysroot -isystem=/usr/include -c libc/string/memcmp.c -o build/libc/string/memcmp.o -std=gnu11 -O2 -g -D__is_vos_libc__ -Iinclude
i386-elf-gcc --sysroot=sysroot -isystem=/usr/include -c libc/string/memcpy.c -o build/libc/string/memcpy.o -std=gnu11 -O2 -g -D__is_vos_libc__ -Iinclude
i386-elf-gcc --sysroot=sysroot -isystem=/usr/include -c libc/string/memmove.c -o build/libc/string/memmove.o -std=gnu11 -O2 -g -D__is_vos_libc__ -Iinclude
i386-elf-gcc --sysroot=sysroot -isystem=/usr/include -c libc/string/memset.c -o build/libc/string/memset.o -std=gnu11 -O2 -g -D__is_vos_libc__ -Iinclude
i386-elf-gcc --sysroot=sysroot -isystem=/usr/include -c libc/string/strcat.c -o build/libc/string/strcat.o -std=gnu11 -O2 -g -D__is_vos_libc__ -Iinclude
make: *** No rule to make target `build/libc/string/strlen.c)', needed by `build/libc/libc.a'. Stop.