2021-03-02 18:58:11 +01:00
|
|
|
AR = ar -rcs
|
2021-03-02 21:22:37 +01:00
|
|
|
CLINK = ../linuxtools/clink
|
2021-03-09 10:09:11 +01:00
|
|
|
MKEXP = ../linuxtools/mkexp
|
2021-03-02 21:22:37 +01:00
|
|
|
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
|
|
|
|
|
2021-03-09 12:05:29 +01:00
|
|
|
all: $(cfiles) $(asmfiles) $(LIB_DIR) $(LIBC.A)
|
2021-03-02 18:58:11 +01:00
|
|
|
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:
|
2021-03-09 12:05:29 +01:00
|
|
|
$(RM) $(cfiles) $(asmfiles) exports/exports.c
|
2021-03-02 18:58:11 +01:00
|
|
|
$(RM) $(LIBNAME)
|
|
|
|
|
|
|
|
shared: $(cfiles) $(asmfiles)
|
|
|
|
$(CLINK) $^
|
2021-03-03 21:00:50 +01:00
|
|
|
$(KPACK) a.out.obj
|
2021-03-02 18:58:11 +01:00
|
|
|
mv a.out.obj $(LIBC.OBJ)
|
2021-03-09 10:09:11 +01:00
|
|
|
|
2021-03-02 18:58:11 +01:00
|
|
|
test:
|
|
|
|
make -C ../test -f Makefile.tcc
|
|
|
|
kex ../test/test
|