2021-03-02 18:58:11 +01:00
|
|
|
AR = ar -rcs
|
2021-03-02 21:22:37 +01:00
|
|
|
CLINK = ../linuxtools/clink
|
|
|
|
KPACK = kpack
|
2021-03-02 18:58:11 +01:00
|
|
|
|
|
|
|
INCLUDE = include
|
2021-03-02 21:22:37 +01:00
|
|
|
LIB_DIR = ../lib
|
2021-03-02 18:58:11 +01:00
|
|
|
|
|
|
|
LIBC.A = $(LIB_DIR)/libc.a
|
|
|
|
LIBC.OBJ = $(LIB_DIR)/libc.obj
|
|
|
|
|
|
|
|
CFLAGS = -I$(INCLUDE) -m32 -nostdinc -nostdlib -DGNUC -Os -fno-common -fno-builtin -fno-leading-underscore -fno-pie
|
2021-03-03 15:56:26 +01:00
|
|
|
DIRS := string stdlib stdio sys math ctype exports setjmp shell_api
|
2021-03-02 18:58:11 +01:00
|
|
|
|
|
|
|
cfiles := $(foreach dir,$(DIRS),$(patsubst %.c, %.o, $(wildcard $(dir)/*.c)))
|
|
|
|
asmfiles := $(foreach dir,$(DIRS),$(patsubst %.s, %.o, $(wildcard $(dir)/*.s)))
|
|
|
|
.PHONY: clean all
|
|
|
|
|
|
|
|
ifdef windir
|
|
|
|
cfiles := $(subst /,\,$(cfiles))
|
|
|
|
asmfiles := $(subst /,\,$(asmfiles))
|
|
|
|
LIB_DIR := $(subst /,\,$(LIB_DIR))
|
|
|
|
LIBNAME := $(subst /,\,$(LIBNAME))
|
|
|
|
RM = del /F /Q
|
|
|
|
MKDIR_P = md
|
|
|
|
else
|
|
|
|
RM = rm -rf
|
|
|
|
MKDIR_P = mkdir -p
|
|
|
|
endif
|
|
|
|
|
|
|
|
all: $(cfiles) $(asmfiles) $(LIB_DIR) $(LIBC.A)
|
|
|
|
fasm crt/crt0.asm $(LIB_DIR)/crt0.o
|
|
|
|
|
|
|
|
$(LIBC.A): $(cfiles) $(asmfiles)
|
|
|
|
$(AR) $(LIBC.A) $^
|
|
|
|
|
|
|
|
$(LIB_DIR):
|
|
|
|
$(MKDIR_P) $(LIB_DIR)
|
|
|
|
|
|
|
|
$(asmfiles):
|
|
|
|
$(CC) -E -x c -nostdinc -Imath $*.s > $*.sx
|
|
|
|
$(AS) --32 $*.sx -o $*.o
|
|
|
|
$(RM) $*.sx
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) $(cfiles) $(asmfiles)
|
|
|
|
$(RM) $(LIBNAME)
|
|
|
|
|
|
|
|
shared: $(cfiles) $(asmfiles)
|
|
|
|
$(CLINK) $^
|
2021-03-03 15:56:26 +01:00
|
|
|
#$(KPACK) a.out.obj
|
2021-03-02 18:58:11 +01:00
|
|
|
mv a.out.obj $(LIBC.OBJ)
|
|
|
|
|
|
|
|
test:
|
|
|
|
make -C ../test -f Makefile.tcc
|
|
|
|
kex ../test/test
|