Skip to content

Commit

Permalink
Necessary changes to assemble on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Boisy Pitre committed Jul 11, 2024
1 parent f63c0a6 commit 1c3b7d4
Show file tree
Hide file tree
Showing 55 changed files with 56 additions and 168 deletions.
48 changes: 24 additions & 24 deletions Source/Libs/KLibc/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
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
Expand Down
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
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 */:
4 changes: 0 additions & 4 deletions Source/Libs/KLibc/imath/rpterr.a
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

ifp1
use /dd/defs/os9defs.a
endc

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

_rpterr: std errno,y
Expand Down
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: 0 additions & 4 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 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
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
5 changes: 0 additions & 5 deletions Source/Libs/KLibc/lib.a/ss2.a
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
* handler for _ss_attr, _ss_size, _ss_lock
*

ifp1
use /dd/defs/os9defs.a
endc


psect ss2,0,0,1,0,0

_ss_lock: pshs U
Expand Down
5 changes: 0 additions & 5 deletions Source/Libs/KLibc/lib.a/ss3.a
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
* handler for _ss_wtrk
*

ifp1
use /dd/defs/os9defs.a
endc


psect ss3,0,0,1,0,0

_ss_wtrk: pshs Y,U
Expand Down
6 changes: 4 additions & 2 deletions Source/Libs/KLibc/lib.c/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
OFILES = prof.o pwent.o getopt.o adump.o defdrive.o popen.o \
asctime.o ctime.o localtime.o mktime.o omktime.o u2otime.o isleap.o timevars.o
asctime.o ctime.o localtime.o mktime.o isleap.o timevars.o

MISSING = omktime.o u2otime.o

DFILES = dbg.r getsp.r

Expand All @@ -8,7 +10,7 @@ include ../cmoc.make
cstuff.lib: $(OFILES)
lwar -c $@ $^

dbg.lib: $(DFILES) /dd/defs/dbg.h
dbg.lib: $(DFILES) ../defs/dbg.h
lwar -c $@ $^

clean:
Expand Down
2 changes: 1 addition & 1 deletion Source/Libs/KLibc/lib.c/asctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static char *months[] = {

char *
asctime(tmp)
struct tm *tmp;
const struct tm *tmp;
{
#ifdef ASMOPT
#asm
Expand Down
2 changes: 1 addition & 1 deletion Source/Libs/KLibc/lib.c/ctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#else
char *
ctime(ticks)
time_t *ticks;
const time_t *ticks;
{
return (asctime(localtime(ticks)));
}
Expand Down
7 changes: 4 additions & 3 deletions Source/Libs/KLibc/lib.c/defdrive.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
#include <stddef.h>
#include <module.h>

static char d[12];

getdrive()
static char *getdrive()
{
char *np;
char c;
int *jnk;
struct mod_config *mp;
register char *p;

if ((mp = modlink("Init", 0x0c, 0)) != -1)
if ((mp = (struct mod_config *)modlink("Init", 0x0c, 0)) != -1)
{
np = (char *)mp + mp->m_sysdrive;
p = d;
while ((c = *np++) > 0)
*p++ = c;
*p++ = (c & 0x7f);
*p = 0;
munlink(mp);
munlink((struct mod_com *)mp);
return (d);
}
return (0);
Expand Down
4 changes: 2 additions & 2 deletions Source/Libs/KLibc/lib.c/popen.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*#define MAIN /* Only use when testing routines */
/*#define MAIN */ /* Only use when testing routines */

#ifdef MAIN
#define DEBUG
Expand Down Expand Up @@ -33,7 +33,7 @@
static int _pid[PIPEMAX];

FILE *popen(command, type)
char *command, *type;
const char *command, *type;
{
register char *p = command;
char *parameter;
Expand Down
1 change: 1 addition & 0 deletions Source/Libs/KLibc/lib.c/prof.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include <stdio.h>
#include <stddef.h>

#define MAXFUNC 63 /* maximum number of unique functions */

Expand Down
16 changes: 8 additions & 8 deletions Source/Libs/KLibc/rma2lw.sed
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#s/^\([a-zA-Z_][a-zA-Z0-9$_]\+\):/\1 EXPORT\n\1/
s/^\([a-zA-Z_][a-zA-Z0-9$_]\+\):/_\1 EXPORT\n\1 EXPORT\n_\1\n\1/
# translate sections
s/^[\t ]\+psect.*/ SECTION code/
s/^[\t ]\+vsect.*/ SECTION bss/
s/^[\t ]\+csect[\t ]\+\(.*\)/ SECTION _constant\n org \1/
s/^[\t ]\+csect/ SECTION _constant/
s/^[\t ]\+endsect.*/ ENDSECT\n SECTION code/
s/^[\t ]\+ends.*/ ENDSECT\n SECTION code/
s/^\([[:space:]]*\)psect.*/ SECTION code/
s/^\([[:space:]]*\)vsect.*/ SECTION bss/
s/^\([[:space:]]*\)csect[[[:space:]]]\+\(.*\)/ SECTION _constant\n org \1/
s/^\([[:space:]]*\)csect/ SECTION _constant/
s/^\([[:space:]]*\)endsect.*/ ENDSECT\n SECTION code/
s/^\([[:space:]]*\)ends.*/ ENDSECT\n SECTION code/
# convert fail / warn directives
s/^[\t ]\+fail\(.*\)/ ERROR\1/
s/^[\t ]\+warn\(.*\)/ WARNING\1/
s/^\([[:space:]]*\)fail\(.*\)/ ERROR\1/
s/^\([[:space:]]*\)warn\(.*\)/ WARNING\1/
2 changes: 0 additions & 2 deletions Source/Libs/KLibc/sys.a/abort.a
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use /dd/defs/os9defs.a

psect abort,0,0,1,0,0
abort: pshs d,x,y,u
leax core,pcr
Expand Down
3 changes: 0 additions & 3 deletions Source/Libs/KLibc/sys.a/access.a
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

pmode equ $0b r/w for owner, r for others

ifp1
use /dd/defs/os9defs.a
endc
psect access_a,0,0,2,0,0

* access(name,mode)
Expand Down
1 change: 0 additions & 1 deletion Source/Libs/KLibc/sys.a/brk.a
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
*
* Adjust memory allocation
*
use /dd/defs/os9defs.a
psect brk,0,0,6,0,0

* brk(pnt) set memory size to pnt, allocating or deallocating
Expand Down
2 changes: 0 additions & 2 deletions Source/Libs/KLibc/sys.a/cfinish.a
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use /dd/defs/os9defs.a

psect cfinish_a,0,0,1,0,0
* normal exit - buffers flushed if there are any
exit: lbsr _dumprof profile dump (if necessary)
Expand Down
3 changes: 0 additions & 3 deletions Source/Libs/KLibc/sys.a/chmod.a
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ifp1
use /dd/defs/os9defs.a
endc
*Carry equ %00000001
*Write. equ 2 write access
*FD.Att equ 0 FD offset to attr
Expand Down
3 changes: 0 additions & 3 deletions Source/Libs/KLibc/sys.a/chown.a
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ifp1
use /dd/defs/os9defs.a
endc
*Carry equ %00000001
*Write. equ 2 write access
*FD.Att equ 0 FD offset to attr
Expand Down
3 changes: 0 additions & 3 deletions Source/Libs/KLibc/sys.a/create.a
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
* file creation calls
*
pmode equ $0b r/w for owner, r for others
ifp1
use /dd/defs/os9defs.a
endc
psect create_a,0,0,1,0,0
* creat(fname,mode)
creat: ldx 2,s
Expand Down
4 changes: 0 additions & 4 deletions Source/Libs/KLibc/sys.a/css.a
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
ifp1
use ..../defs/os9defs.a
endc

pushzero macro
clr ,-s clear a byte on stack
endm
Expand Down
4 changes: 0 additions & 4 deletions Source/Libs/KLibc/sys.a/cstart.a
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
ifp1
use /dd/defs/os9defs.a
endc

* 09-04-85 CK add stack space for one file.
* branch short on clrbss to ensure clear
* 04-09-86 CK fix memory wrap bug in stkcheck
Expand Down
1 change: 0 additions & 1 deletion Source/Libs/KLibc/sys.a/dir.a
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Directory change system calls
*

use /dd/defs/os9defs.a
psect dir_a,0,0,1,0,0

* chdir(dirname)
Expand Down
1 change: 0 additions & 1 deletion Source/Libs/KLibc/sys.a/ibrk.a
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
*
* Make pointers within initial memory allocation
*
use /dd/defs/os9defs.a
psect ibrk,0,0,6,0,0

* ibrk(size) get memory within data allocation
Expand Down
3 changes: 0 additions & 3 deletions Source/Libs/KLibc/sys.a/id.a
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
*
* Identity system calls
*
ifp1
use /dd/defs/os9defs.a
endc
*
* Equates for level one pointers (sorry!)
D.Proc equ $4b
Expand Down
1 change: 0 additions & 1 deletion Source/Libs/KLibc/sys.a/intercept.a
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* an 'entry name clash' error in the loader if an attempt is made
* to use both.

use /dd/defs/os9defs.a
psect intercept_a,0,0,1,0,0

vsect
Expand Down
Loading

0 comments on commit 1c3b7d4

Please sign in to comment.