Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bringing in changes to compile KLibC #23

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
58 changes: 34 additions & 24 deletions Source/Libs/KLibc/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,51 @@
RFILES1 = lib.c/cstuff.lib lib.a/main.lib
RFILE_F = fmath/cfloats.lib
RFILE_T = tmath/trans.lib
RFILES2 = imath/math.lib sys.a/syslib.lib
RFILES1 = lib.c/cstuff.l lib.a/main.l
RFILE_F = fmath/cfloats.l
RFILE_T = tmath/trans.l
RFILES2 = imath/math.l sys.a/syslib.l

all: libc.a libct.a

before-libc:
cd lib.c; $(MAKE) $(MAKEFLAGS)
cd lib.c; $(MAKE) $(MAKEFLAGS) dbg.l
cd lib.a; $(MAKE) $(MAKEFLAGS)
cd fmath; $(MAKE) $(MAKEFLAGS)
cd imath; $(MAKE) $(MAKEFLAGS)
cd sys.a; $(MAKE) $(MAKEFLAGS)
# cd sys.a; $(MAKE) $(MAKEFLAGS) cstart.r
cd lib.c; $(MAKE) -f GNUMakefile $(MAKEFLAGS)
cd lib.c; $(MAKE) -f GNUMakefile $(MAKEFLAGS) dbg.l
cd lib.a; $(MAKE) -f GNUMakefile $(MAKEFLAGS)
cd fmath; $(MAKE) -f GNUMakefile $(MAKEFLAGS)
cd imath; $(MAKE) -f GNUMakefile $(MAKEFLAGS)
cd sys.a; $(MAKE) -f GNUMakefile $(MAKEFLAGS)
# cd sys.a; $(MAKE) -f GNUMakefile $(MAKEFLAGS) cstart.r

before-libct:
cd tmath; $(MAKE) $(MAKEFLAGS)
cd tmath; $(MAKE) -f GNUMakefile $(MAKEFLAGS)

clean:
cd lib.c; make $(MAKEFLAGS) clean
cd lib.a; make $(MAKEFLAGS) clean
cd fmath; make $(MAKEFLAGS) clean
cd imath; make $(MAKEFLAGS) clean
cd tmath; make $(MAKEFLAGS) clean
cd sys.a; make $(MAKEFLAGS) clean
-del libc.a
-del libct.a
cd lib.c; make -f GNUMakefile $(MAKEFLAGS) clean
cd lib.a; make -f GNUMakefile $(MAKEFLAGS) clean
cd fmath; make -f GNUMakefile $(MAKEFLAGS) clean
cd imath; make -f GNUMakefile $(MAKEFLAGS) clean
cd tmath; make -f GNUMakefile $(MAKEFLAGS) clean
cd sys.a; make -f GNUMakefile $(MAKEFLAGS) clean
-rm libc.a
-rm libct.a

libc.a: before-libc $(RFILES1) $(RFILE_F) $(RFILES2)
-del libc.a
lwar --merge libc.a $(RFILES1) $(RFILE_F) $(RFILES2)
-rm libc.a
lwar --create libc.a $(RFILES1) $(RFILE_F) $(RFILES2)

libct.a: before-libct $(RFILES1) $(RFILE_T) $(RFILES2) before-libct
-del libct.a
lwar --merge libct.a $(RFILES1) $(RFILE_T) $(RFILES2)
-rm libct.a
lwar --create libct.a $(RFILES1) $(RFILE_T) $(RFILES2)

install: clib.l clibt.l
copy -rw=$(LIB) clib.l clibt.l

# Package up libraries for testing
cmoc_kreider: libct.a
rm -rf $@/lib $@/defs
mkdir $@/lib
cp libct.a $@/lib
mkdir $@/defs
cp -r ../../../Defs/* $@/defs
cp $(NITROS9DIR)/lib/libnos96809l1.a $@/lib
tar cvzf [email protected] $@

.PHONY: dummy before-libc before-libct
3 changes: 2 additions & 1 deletion Source/Libs/KLibc/cmoc.make
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MAKEFLAGS+=-rR

AFLAGS= --pragma=index0tonone,condundefzero,undefextern,dollarnotlocal,noforwardrefmax
CFLAGS= -I/dd/defs -O2 -nodefaultlibs --function-stack=0 --os9
CFLAGS= -I../../../../Defs -I../defs -O2 -nodefaultlibs --function-stack=0 --os9

# default top level to current dir
TOP?= $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
Expand All @@ -14,6 +14,7 @@ O2U?= tr '\015' '\012'
#our scripts
DCCMOC = $(TOP)/dccmoc.sed
RMA2LW = $(TOP)/rma2lw.sed
CC = $(CMOC)

# implicit rules to compile with CMOC/lwasm
%.s: %.a $(RMA2LW)
Expand Down
2 changes: 2 additions & 0 deletions Source/Libs/KLibc/cmoc_kreider/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
helloworld: helloworld.c
cmoc --os9 -nodefaultlibs -Idefs -o helloworld helloworld.c -Llib -lct -lnos96809l1
6 changes: 6 additions & 0 deletions Source/Libs/KLibc/cmoc_kreider/helloworld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

int main(int argc, char **argv) {
printf("Hello, CMOC OS-9 World!\n");
return 0;
}
4 changes: 2 additions & 2 deletions Source/Libs/KLibc/dccmoc.sed
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
s:^#[\t ]*asm:asm { /* #asm */:
s:^#[\t ]*endasm:} /* #endasm */:
s:^#[[:space:]]*asm:asm { /* #asm */:
s:^#[[:space:]]*endasm:} /* #endasm */:
9 changes: 9 additions & 0 deletions Source/Libs/KLibc/fmath/GNUMakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include ../cmoc.make

OFILES = cfloats.o

cfloats.l: $(OFILES)
lwar -c $@ $^

clean:
-rm *.l *.o *.list *.map
11 changes: 11 additions & 0 deletions Source/Libs/KLibc/imath/GNUMakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include ../cmoc.make

OFILES = abs.o minmax.o uminmax.o clmul.o cldiv.o cludiv.o claddsub.o clcompare.o \
clbits.o clnegcompl.o clconvert.o clmove.o clincdec.o clshifts.o \
clcommon.o ccmult.o ccmod.o ccdiv.o cshifts.o rpterr.o

math.l: $(OFILES)
lwar -c $@ $^

clean:
-rm *.l *.o *.list *.map
4 changes: 4 additions & 0 deletions Source/Libs/KLibc/imath/clcommon.a
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

psect clcommon_a,0,0,1,0,0

vsect
_flacc: rmb 8 floating point & longs accumlator
endsect

_lbexit: tfr cc,a save carry
puls x get ret adr
stx 2,s overwrite ls word
Expand Down
6 changes: 1 addition & 5 deletions Source/Libs/KLibc/imath/rpterr.a
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@

ifp1
use /dd/defs/os9defs.a
endc

psect rpterr_a,0,0,0,0,0

_rpterr: std errno,y
_rpterr: std _errno,y
pshs y,b
os9 F$ID
puls y,b
Expand Down
6 changes: 3 additions & 3 deletions Source/Libs/KLibc/lib.a/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OFILES4 = system.o reverse.o strings.o strcmp.o strlen.o strncpy.o strncat.o \
OFILES5 = stringsu.o strucmp.o strnucmp.o case.o strclr.o memccpy.o memchr.o \
memcmp.o memcpy.o memset.o atol.o atoi.o iob_data.o chcodes.o
OFILES6 = sleep.o setjmp.o strass.o realloc.o calloc.o memory.o rand.o
OFILES7 = gs1.o gs2.o ss1.o ss2.o ss3.o
OFILES7 = gs1.o gs2.o ss1.o ss2.o ss3.o MUL168.o

OFILES = $(OFILES1) $(OFILES2) $(OFILES3) $(OFILES4) $(OFILES5) \
$(OFILES6) $(OFILES7)
Expand All @@ -17,10 +17,10 @@ NFILES = atof.o scale.o ldexp.o frexp.o

include ../cmoc.make

main.lib: $(OFILES)
main.l: $(OFILES)
lwar -c $@ $^

clean:
-rm *.o *.s *.cp
-rm *.o *.s *.cp *.list *.map

$(OFILES): GNUmakefile $(DCCMOC) $(RMA2LW)
3 changes: 0 additions & 3 deletions Source/Libs/KLibc/lib.a/datmods.a
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
* In all cases, 'datptr' points to the lock byte.
* User space starts at 'datptr' + 1

ifp1
use /dd/defs/os9defs.a
endc
pag
psect datmods_a,0,0,1,0,0

Expand Down
4 changes: 0 additions & 4 deletions Source/Libs/KLibc/lib.a/devtyp.a
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

psect devtyp_a,0,0,0,0,0

ifp1
use /dd/defs/os9defs.a
endc

isatty: ldd 2,s get pn
pshs d
bsr devtyp check it out
Expand Down
4 changes: 2 additions & 2 deletions Source/Libs/KLibc/lib.a/errmsg.a
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _errmsg:
lbsr _prgname
pshs d
leau _2,pcr
leax _iob+26,y
leax __iob+26,y
pshs x,u
lbsr fprintf
leas 6,s
Expand All @@ -15,7 +15,7 @@ _errmsg:
ldd 8,s
pshs d,x,u
ldu 12,s
leax _iob+26,y
leax __iob+26,y
pshs x,u
lbsr fprintf
leas 10,s
Expand Down
12 changes: 6 additions & 6 deletions Source/Libs/KLibc/lib.a/fopen.a
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

* input: d = pn
* x = *mode
* u = *_iob = fp
* output: _iob allocated of necessary, iniz _flag in any case
* u = *__iob = fp
* output: __iob allocated of necessary, iniz _flag in any case
* to _READ or _WRITE or both. Stash path num in _fd.
* setbase will fill in the rest since _iob is static
* setbase will fill in the rest since __iob is static
* and all zeros

setiob
pshs d save path number
stu -2,s check for fp
bne setiob3 if already have one
leau _iob,y
leau __iob,y
lda #_NFILE
setiob1 ldb _flag+1,u
andb #_READ+_WRITE
Expand All @@ -24,7 +24,7 @@ setiob1 ldb _flag+1,u
deca
bne setiob1
ldd #$c8 e$pthful
std errno,y
std _errno,y
clra
clrb
puls x,pc
Expand Down Expand Up @@ -127,7 +127,7 @@ openit7 ldd ,s
openit8 cmpb #'d
beq openit10
openit9 ldd #$cb E$BMode
erret std errno,y
erret std _errno,y
ldd #-1
bra openit13

Expand Down
4 changes: 2 additions & 2 deletions Source/Libs/KLibc/lib.a/getc.a
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ fillbuf ldd _flag,u
pshs u stack fp
lbsr _setbase init iob
leas 2,s
fillbu2 leax _iob,y
fillbu2 leax __iob,y
pshs x
cmpu ,s++
bne fillbu3 if not stdin
ldb _flag+1,u
andb #_SCF
beq fillbu3 if rbf
leax _iob+13,y
leax __iob+13,y
pshs x
lbsr fflush flush std out if scf on std in
leas 2,s
Expand Down
2 changes: 1 addition & 1 deletion Source/Libs/KLibc/lib.a/gets.a
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gets: pshs u
bra gets2

gets1 stb ,u+
gets2 leax _iob,y
gets2 leax __iob,y
pshs x
lbsr getc
leas 2,s
Expand Down
6 changes: 1 addition & 5 deletions Source/Libs/KLibc/lib.a/gs1.a
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
* remember to declare the returns as long!!!
*

ifp1
use /dd/defs/os9defs.a
endc

psect gs1,0,0,1,0,0

_gs_size:
Expand All @@ -22,7 +18,7 @@ common1 pshs U
ldx #-1 return -1
tfr X,U sign extend
clra
std errno,Y only an error sometimes
std _errno,Y only an error sometimes
common2 stx _flacc,Y top half
leax _flacc,Y need a pointer for lmove
stu 2,X bottom half
Expand Down
4 changes: 0 additions & 4 deletions Source/Libs/KLibc/lib.a/gs2.a
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
* handler for _gs_rdy, _gs_opt, _gs_opt, _gs_devnm
*

ifp1
use /dd/defs/os9defs.a
endc

psect gs2,0,0,1,0,0

_gs_rdy:
Expand Down
11 changes: 7 additions & 4 deletions Source/Libs/KLibc/lib.a/iob_data.a
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
psect iob_data_a,0,0,1,0,0

ifp1
use ../defs/stdio.a
endc
vsect
_iob: fdb 0 _ptr

__iob EXPORT

SECTION rwdata

__iob EQU *
fdb 0 _ptr
fdb 0 _base
fdb 0 _end
fdb _READ _flag
Expand Down
4 changes: 2 additions & 2 deletions Source/Libs/KLibc/lib.a/printf.a
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dectbl fdb 10000,1000,100,10

printf: pshs u
leau 6,s *expr
leax _iob+13,y
leax __iob+13,y
ldd 4,s *format
bra printf1

Expand Down Expand Up @@ -369,7 +369,7 @@ blanks ldd fldsiz+6,s
getdec clr ,-s
clr ,-s
leau -1,u back up to char
leax _chcodes,y
leax __chcodes,y
bra getdec2

getdec1 ldd ,s
Expand Down
2 changes: 1 addition & 1 deletion Source/Libs/KLibc/lib.a/putc.a
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ putw: pshs u
* closes all 16 files

_tidyup: pshs u
leax _iob,y point to array beg
leax __iob,y point to array beg
ldb #_NFILE set up loop count
pshs b

Expand Down
2 changes: 1 addition & 1 deletion Source/Libs/KLibc/lib.a/puts.a
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* -> *s (or c)

puts: pshs u
leax _iob+13,y stdout fp
leax __iob+13,y stdout fp
ldd 4,s *s
pshs d,x stack *s,fp
bsr fputs
Expand Down
3 changes: 0 additions & 3 deletions Source/Libs/KLibc/lib.a/sleep.a
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

f$tps set $25
*F$NMLink set $21
ifp1
use /dd/defs/os9defs.a
endc

vsect
_tps: rmb 2
Expand Down
4 changes: 0 additions & 4 deletions Source/Libs/KLibc/lib.a/ss1.a
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
* _ss_pfd, _ss_ssig, _ss_tiks
*

ifp1
use /dd/defs/os9defs.a
endc

psect ss1,0,0,1,0,0

_ss_rel:
Expand Down
Loading