Skip to content

Commit

Permalink
[libc,c86] Compile all of ELKS C library with C86
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Dec 27, 2024
1 parent 1740881 commit e29b22a
Show file tree
Hide file tree
Showing 28 changed files with 1,945 additions and 6 deletions.
2 changes: 1 addition & 1 deletion elks/include/arch/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#endif

#ifdef __C86__
#define __HAS_NO_FLOATS__
#define __HAS_NO_FLOATS__ 1
#define __far
#define noreturn
#define stdcall
Expand Down
5 changes: 5 additions & 0 deletions elks/include/arch/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ typedef unsigned int uintptr_t;
#endif
#endif

#ifdef __C86__
typedef int intptr_t;
typedef unsigned int uintptr_t;
#endif

#endif
3 changes: 3 additions & 0 deletions libc/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ libc.lst
build-ml/
*.obj
*.lib
*.ocj
*.as
*.i
56 changes: 56 additions & 0 deletions libc/c86.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Makefile include for C86 build

ifeq "$(TOPDIR)" ""
$(error TOPDIR environment variable not set)
endif

ifeq "$(C86)" ""
$(error C86 environment variable not set)
endif

INCLUDES = -I$(TOPDIR)/libc/include -I$(TOPDIR)/elks/include
INCLUDES += -I$(C86)/libc/include
DEFINES = -D__LIBC__ -D__HAS_NO_FLOATS__=1 -D__HAS_NO_LONGLONG__
LIBOBJS=$(OBJS:.o=.ocj)

CPP86FLAGS=\
-0 \

C86FLAGS =\
-g \
-v \
-O \
-bas86 \
-warn=4 \
-lang=c99 \
-align=yes \
-separate=yes \
-stackopt=minimum \
-peep=all \
-stackcheck=no \

AS86FLAGS =\
-0 \
-O \
-j \
-w- \

CPP=cpp86
CC=c86
AR=ar86
AS=as86

CPPFLAGS=$(CPP86FLAGS) $(INCLUDES) $(DEFINES)
CFLAGS=$(C86FLAGS)
ASFLAGS=$(AS86FLAGS)
ARFLAGS_SUB=r

%.i: %.c
$(CPP) $(CPPFLAGS) -o $*.i $<

%.as: %.i
$(CC) $(CFLAGS) $< $*.as

%.ocj: %.as
cp $*.as /tmp
$(AS) $(ASFLAGS) -o $*.ocj $*.as
39 changes: 39 additions & 0 deletions libc/c86.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# C86 Makefile for ELKS C Library

include c86.inc

#NOTBUILT = \
asm \
debug \
gcc \
math \
crt0.S \
SUBDIRS = \
c86 \
ctype \
error \
getent \
malloc \
misc \
net \
regex \
stdio \
string \
termcap \
termios \
time \
# end of list

.PHONY: all
all:
$(MAKE) -C system -f out.mk COMPILER=c86 LIB=out.lib
for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR COMPILER=c86 LIB=out.lib || exit 1; done
$(AR) $(ARFLAGS_SUB) libc86.a */*.lib
cp libc86.a $(TOPDIR)/elkscmd/rootfs_template/root

.PHONY: clean
clean:
rm -f */*.i */*.as */*.ocj */*.lst */*.lib
for DIR in $(SUBDIRS); do rm -f $$DIR/*.ocj $$DIR/*.lib || exit 1; done
rm -f libc86.a
21 changes: 21 additions & 0 deletions libc/c86/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Makefile of libc/c86 module

COMPILER ?= c86
LIB ?= out.lib

include $(TOPDIR)/libc/$(COMPILER).inc

OBJS = $(patsubst %.s,%.ocj,$(wildcard *.s))

all: $(LIB)

$(LIB): $(LIBOBJS)
$(RM) $@
$(AR) $(ARFLAGS_SUB) $@ $(LIBOBJS)

%.ocj: %.s
$(AS) $(ASFLAGS) -o $@ -l $*.lst $^


clean:
$(RM) *.ocj *.lib *.lst
Loading

0 comments on commit e29b22a

Please sign in to comment.