menuetlibc: drop support for exotic configurations, it doesn't work anyway

git-svn-id: svn://kolibrios.org@5145 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
CleverMouse 2014-10-08 16:14:52 +00:00
parent 908f9c8bce
commit 9757da66f4
19 changed files with 41 additions and 513 deletions

View File

@ -1,26 +1,12 @@
include osrules.mak
all: genconfig
@echo Building library for $(VERSION_OS)
all:
gcc mkversion.c -o mkversion$(EXESUFFIX)
ifdef ON_MINGW
mkversion$(EXESUFFIX) < version > include/libc/version.h
else
./mkversion$(EXESUFFIX) < version > include/libc/version.h
endif
make -C linuxtools
make -C src depend
make -C src
make -C stub
genconfig:
ifdef ON_MINGW
@echo #$(NEED_UNDERSCORES) NEEDS_UNDERSCORES> config.h
else
@echo "#$(NEED_UNDERSCORES) NEEDS_UNDERSCORES" > config.h
endif
clean:
make -C src clean
make -C linuxtools clean
make -C stub clean
$(RM) mkversion$(EXESUFFIX)

View File

@ -1,6 +0,0 @@
if tup.getconfig("TUP_PLATFORM") == "win32"
-- on win32 '#' is not a special character, but backslash and quotes would be printed as is
then tup.rule('echo #define NEEDS_UNDERSCORES > %o', {"config.h"})
-- on unix '#' should be escaped
else tup.rule('echo "#define NEEDS_UNDERSCORES" > %o', {"config.h"})
end

View File

@ -0,0 +1 @@
#define NEEDS_UNDERSCORES

View File

@ -1,30 +0,0 @@
include $(MENUETDEV)/osrules.mak
WAIT =
ifdef ON_MINGW
WAIT = -DWEXITSTATUS=
endif
TOOLS = mgcc$(EXESUFFIX) mld$(EXESUFFIX) mgpp$(EXESUFFIX) mmkdep$(EXESUFFIX) \
mchmem$(EXESUFFIX)
all: $(TOOLS)
mgcc$(EXESUFFIX): mgcc.c
gcc mgcc.c -o mgcc$(EXESUFFIX) -DHAS_DEVENV=$(HAS_DEVENV) -s $(WAIT)
mgpp$(EXESUFFIX): mgpp.c
gcc mgpp.c -o mgpp$(EXESUFFIX) -DHAS_DEVENV=$(HAS_DEVENV) -s \
-DTOOLNAME=\"$(GPP_TOOLNAME)\" $(WAIT)
mld$(EXESUFFIX): mld.c
gcc mld.c -o mld$(EXESUFFIX) -DHAS_DEVENV=$(HAS_DEVENV) -s $(WAIT)
mchmem$(EXESUFFIX): mchmem.c
gcc mchmem.c -o mchmem$(EXESUFFIX) -DHAS_DEVENV=$(HAS_DEVENV) -s $(WAIT)
mmkdep$(EXESUFFIX): mmkdep.c
gcc mmkdep.c -o mmkdep$(EXESUFFIX) -DHAS_DEVENV=$(HAS_DEVENV) -s $(WAIT)
clean:
$(RM) $(TOOLS)

View File

@ -1,49 +0,0 @@
#define OFF 20
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(int argc,char * argv[])
{
FILE * f;
char * buf;
unsigned long sz,newsz;
if(argc<3)
{
printf("Usage:\n");
printf("%s filename memsize_hex\n",argv[0]);
printf("Example:\n\t%s test.app 100000\n",argv[0]);
return -1;
}
sscanf(argv[2],"%x",&newsz);
if(newsz<0x10000 || newsz>0x2000000) /* Min 64kB max 32MB */
{
printf("Impossibly large memory size %x\n",newsz);
return -1;
}
f=fopen(argv[1],"rb");
if(!f)
{
printf("Unable to open file\n");
return -1;
}
fseek(f,0,SEEK_END);
sz=ftell(f);
fseek(f,0,SEEK_SET);
buf=malloc(sz);
if(!buf)
{
printf("Unable to allocate temporary buffer\n");
fclose(f);
return -1;
}
fread(buf,1,sz,f);
fclose(f);
f=fopen(argv[1],"wb");
*((unsigned long *)(buf+OFF))=newsz;
fwrite(buf,1,sz,f);
fclose(f);
free(buf);
return 0;
}

View File

@ -1,51 +0,0 @@
#include<stdio.h>
#include<stdlib.h>
#ifndef WEXITSTATUS
#include <sys/wait.h>
#endif
char buf[32768];
#if (HAS_DEVENV == 0)
char * __dev_env;
#endif
static void __env(void)
{
char * p=getenv("MENUETDEV");
if(!p)
{
printf("MENUETDEV system variable not set !!!\n");
exit(-1);
}
#if (HAS_DEVENV == 0)
__dev_env=p;
#endif
}
int main(int argc,char * argv[])
{
int u;
__env();
if(argc<3)
{
fprintf(stderr,"Usage: %s infile.c outfile.o\n",argv[0]);
return 1;
}
#if (HAS_DEVENV==1)
sprintf(buf,"gcc -c %s -o %s -Os -nostdinc -fno-builtin -I/dev/env/MENUETDEV/include "
"-fno-common -DMENUETDEV='\"/dev/env/MENUETDEV\"' "
"-D__DEV_CONFIG_H='</dev/env/MENUETDEV/config.h>' -D__MENUETOS__ ",argv[1],argv[2]);
#else
sprintf(buf,"gcc -c %s -o %s -Os -nostdinc -fno-builtin -I%s/include "
"-fno-common -DMENUETDEV='\"%s\"' "
"-D__DEV_CONFIG_H=\"<%s/config.h>\" -D__MENUETOS__ ",argv[1],argv[2],__dev_env,__dev_env,__dev_env);
#endif
if(argc>3)
for(u=3;u<argc;u++)
{
strcat(buf,argv[u]);
strcat(buf," ");
}
return WEXITSTATUS(system(buf));
}

View File

@ -1,52 +0,0 @@
#include<stdio.h>
#include<stdlib.h>
#ifndef WEXITSTATUS
#include <sys/wait.h>
#endif
char buf[32768];
#if (HAS_DEVENV==0)
char * __dev_env;
#endif
static void __env(void)
{
char * p=getenv("MENUETDEV");
if(!p)
{
printf("MENUETDEV system variable not set !!!\n");
exit(-1);
}
#if (HAS_DEVENV==0)
__dev_env=p;
#endif
}
int main(int argc,char * argv[])
{
int u;
__env();
if(argc<3)
{
fprintf(stderr,"Usage: %s infile.cpp outfile.o\n",argv[0]);
return 1;
}
#if (HAS_DEVENV==1)
sprintf(buf,"%s -c %s -o %s -nostdinc -fno-builtin -I/dev/env/MENUETDEV/include -fno-common "
"-I/dev/env/MENUETDEV/include/STL "
"-O1 -fno-rtti -fno-exceptions -fomit-frame-pointer -D__MENUETOS__ ",TOOLNAME,argv[1],argv[2]);
#else
sprintf(buf,"%s -c %s -o %s -nostdinc -fno-builtin -I%s/include -fno-common "
"-I%s/include/STL -D__MENUETOS__ "
"-O1 -fno-rtti -fno-exceptions -fomit-frame-pointer ",TOOLNAME,argv[1],argv[2],
__dev_env,__dev_env);
#endif
if(argc>3)
for(u=3;u<argc;u++)
{
strcat(buf,argv[u]);
strcat(buf," ");
}
return WEXITSTATUS(system(buf));
}

View File

@ -1,51 +0,0 @@
#include<stdio.h>
#include<stdlib.h>
#ifndef WEXITSTATUS
#include <sys/wait.h>
#endif
char buf[32768];
#if (HAS_DEVENV==0)
char * __dev_env;
#endif
static void __env(void)
{
char * p=getenv("MENUETDEV");
if(!p)
{
printf("MENUETDEV system variable not set !!!\n");
exit(-1);
}
#if (HAS_DEVENV==0)
__dev_env=p;
#endif
}
int main(int argc,char * argv[])
{
int u;
__env();
if(argc<3)
{
fprintf(stderr,"Usage: %s outprogramname file1.o file2.o ...\n",argv[0]);
return 1;
}
#if (HAS_DEVENV == 1)
sprintf(buf,"ld -T/dev/env/MENUETDEV/include/scripts/menuetos_app_v01.ld "
"-nostdlib -L/dev/env/MENUETDEV/lib -o %s "
"/dev/env/MENUETDEV/stub/crt0.o ",argv[1]);
#else
sprintf(buf,"ld -T%s/include/scripts/menuetos_app_v01.ld "
"-nostdlib -L%s/lib -o %s "
"%s/stub/crt0.o ",__dev_env,__dev_env,argv[1],__dev_env);
#endif
for(u=2;u<argc;u++)
{
strcat(buf,argv[u]);
strcat(buf," ");
}
strcat(buf,"-lc");
return WEXITSTATUS(system(buf));
}

View File

@ -1,46 +0,0 @@
#include<stdio.h>
#include<stdlib.h>
#ifndef WEXITSTATUS
#include <sys/wait.h>
#endif
char buf[32768];
#if (HAS_DEVENV == 0)
char * __dev_env;
#endif
static void __env(void)
{
char * p=getenv("MENUETDEV");
if(!p)
{
printf("MENUETDEV system variable not set !!!\n");
exit(-1);
}
#if (HAS_DEVENV == 0)
__dev_env=p;
#endif
}
int main(int argc,char * argv[])
{
int u;
__env();
if(argc<2)
{
fprintf(stderr,"Usage: %s file1.c file2.s ...\n",argv[0]);
return 1;
}
#if (HAS_DEVENV == 0)
sprintf(buf,"gcc -nostdinc -I%s/include -D__DEV_CONFIG_H=\"<%s/config.h>\" -M ",__dev_env,__dev_env);
#else
sprintf(buf,"gcc -nostdinc -I/dev/env/MENUETDEV/include -D__DEV_CONFIG_H='\"/dev/env/MENUETDEV/config.h\"' -M ");
#endif
for(u=1;u<argc;u++)
{
strcat(buf,argv[u]);
strcat(buf," ");
}
return WEXITSTATUS(system(buf));
}

View File

@ -3,23 +3,23 @@ include $(MENUETDEV)/osrules.mak
.SUFFIXES: .asm;
$(OUTFILE): $(OBJS)
$(MLD) $(OUTFILE) $(OBJS) -lcpp $(LIBS) $(LDFLAGS) $(LD32OPT)
$(MLD) -o $(OUTFILE) $(OBJS) -lcpp $(LIBS) $(LDFLAGS) -lc
.c.o:
$(MGCC) $*.c $*.o $(CFLAGS) $(GCC32OPT)
$(MGCC) $*.c -o $*.o $(CFLAGS)
.cpp.o:
$(MGPP) $*.cpp $*.o $(CPPFLAGS) $(GCC32OPT)
$(MGPP) $*.cpp -o $*.o $(CPPFLAGS)
.cc.o:
$(MGPP) $*.cc $*.o $(CPPFLAGS) $(GCC32OPT)
$(MGPP) $*.cc -o $*.o $(CPPFLAGS)
.asm.o:
nasm $*.asm -f $(ASMFMT) -o $*.o
.s.o:
cpp $*.s -o $*.asm -nostdinc -I$(MENUETDEV)/include $(SFLAGS)
as $*.asm $(AS32OPT) -o $*.o
kos32-cpp $*.s -o $*.asm -nostdinc -I$(MENUETDEV)/include $(SFLAGS)
kos32-as $*.asm -o $*.o
$(RM) $*.asm
clean:

View File

@ -3,23 +3,23 @@ include $(MENUETDEV)/osrules.mak
.SUFFIXES: .asm;
$(OUTFILE): $(OBJS)
ar rcs $(OUTFILE) $(OBJS)
kos32-ar rcs $(OUTFILE) $(OBJS)
.c.o:
$(MGCC) $*.c $*.o $(CFLAGS) $(GCC32OPT)
$(MGCC) $*.c -o $*.o $(CFLAGS)
.cpp.o:
$(MGPP) $*.cpp $*.o $(CPPFLAGS) $(GCC32OPT)
$(MGPP) $*.cpp -o $*.o $(CPPFLAGS)
.cc.o:
$(MGPP) $*.cc $*.o $(CPPFLAGS) $(GCC32OPT)
$(MGPP) $*.cc -o $*.o $(CPPFLAGS)
.asm.o:
nasm $*.asm -f $(ASMFMT) -o $*.o
.s.o:
cpp $*.s -o $*.asm -nostdinc -I$(MENUETDEV)/include
as $*.asm $(AS32OPT) -o $*.o
kos32-cpp $*.s -o $*.asm -nostdinc -I$(MENUETDEV)/include
kos32-as $*.asm -o $*.o
$(RM) $*.asm
clean:

View File

@ -3,23 +3,23 @@ include $(MENUETDEV)/osrules.mak
.SUFFIXES: .asm;
$(OUTFILE): $(OBJS)
ld -r -o $(OUTFILE) $(OBJS) $(LDFLAGS) $(LD32OPT)
kos32-ld -r -o $(OUTFILE) $(OBJS) $(LDFLAGS)
.c.o:
$(MGCC) $*.c $*.o $(CFLAGS) $(GCC32OPT)
$(MGCC) $*.c -o $*.o $(CFLAGS)
.cpp.o:
$(MGPP) $*.cpp $*.o $(CPPFLAGS) $(GCC32OPT)
$(MGPP) $*.cpp -o $*.o $(CPPFLAGS)
.cc.o:
$(MGPP) $*.cc $*.o $(CPPFLAGS) $(GCC32OPT)
$(MGPP) $*.cc -o $*.o $(CPPFLAGS)
.asm.o:
nasm $*.asm -f $(ASMFMT) -o $*.o
.s.o:
cpp $*.s -o $*.asm -nostdinc -I$(MENUETDEV)/include
as $*.asm $(AS32OPT) -o $*.o
kos32-cpp $*.s -o $*.asm -nostdinc -I$(MENUETDEV)/include
kos32-as $*.asm -o $*.o
$(RM) $*.asm
clean:

View File

@ -1,31 +1,27 @@
include $(MENUETDEV)/osrules.mak
ifdef ON_WINDOWS
ALIGN = --section-alignment=16 --file-alignment=16
else
ALIGN =
endif
.SUFFIXES: .asm;
$(OUTFILE): $(OBJS)
$(MLD) $(OUTFILE) $(OBJS) $(LIBS) $(LDFLAGS) -n -Map $(OUTFILE).map $(LD32OPT)$(ALIGN)
$(MLD) -o $(OUTFILE) $(OBJS) $(LIBS) $(LDFLAGS) -n -Map $(OUTFILE).map $(ALIGN) -lc
objcopy $(OUTFILE) -O binary
.c.o:
$(MGCC) $*.c $*.o $(CFLAGS) $(GCC32OPT)
$(MGCC) $*.c -o $*.o $(CFLAGS)
.cpp.o:
$(MGPP) $*.cpp $*.o $(CPPFLAGS) $(GCC32OPT)
$(MGPP) $*.cpp -o $*.o $(CPPFLAGS)
.cc.o:
$(MGPP) $*.cc $*.o $(CPPFLAGS) $(GCC32OPT)
$(MGPP) $*.cc -o $*.o $(CPPFLAGS)
.asm.o:
nasm $*.asm -f $(ASMFMT) -o $*.o
.s.o:
cpp $*.s -o $*.asm -nostdinc -I$(MENUETDEV)/include
as $*.asm $(AS32OPT) -o $*.o
kos32-cpp $*.s -o $*.asm -nostdinc -I$(MENUETDEV)/include
kos32-as $*.asm -o $*.o
$(RM) $*.asm
clean:

View File

@ -1,58 +1,10 @@
ifdef windir
ON_WINDOWS = 1
else
ifdef WINDIR
ON_WINDOWS = 1
endif
endif
ifndef ON_WINDOWS
VERSION_OS = linux
NEED_UNDERSCORES = undef
EXESUFFIX =
RM = rm -f
MV = mv
D_ECHO = echo
LIBDIR = $(MENUETDEV)/lib
ASMFMT = elf
else
ifdef HOME
VERSION_OS = cygwin
NEED_UNDERSCORES = define
EXESUFFIX = .exe
RM = rm -f
MV = mv
D_ECHO = echo
LIBDIR = $(MENUETDEV)/lib
ASMFMT = elf
else
VERSION_OS = MinGW
NEED_UNDERSCORES = define
EXESUFFIX = .exe
RM = del
MV = move
D_ECHO = echo.
ON_MINGW = 1
LIBDIR = $(MENUETDEV)\lib
ASMFMT = coff
endif
endif
HAS_DEVENV = 0
GPP_TOOLNAME = g++
STUBFMT = elf
MMKDEP = $(MENUETDEV)/linuxtools/mmkdep
MGCC = $(MENUETDEV)/linuxtools/mgcc
MGPP = $(MENUETDEV)/linuxtools/mgpp
MLD = $(MENUETDEV)/linuxtools/mld
MCHMEM = $(MENUETDEV)/linuxtools/mchmem
GCC32OPT =
AS32OPT =
LD32OPT =
ifneq (,$(findstring 64,$(shell gcc -dumpmachine)))
GCC32OPT = -m32
AS32OPT = --32
LD32OPT = -m$(ASMFMT)_i386
endif
MGCC=kos32-gcc -c -Os -nostdinc -fno-builtin -I$(MENUETDEV)/include -fno-common -D__DEV_CONFIG_H="\"../../config.h\"" -D__MENUETOS__
MGPP=kos32-g++ -c -Os -nostdinc -fno-builtin -I$(MENUETDEV)/include -fno-common -I$(MENUETDEV)/include/STL -D__MENUETOS__ -fno-rtti -fno-exceptions -fomit-frame-pointer
MLD=kos32-ld -T$(MENUETDEV)/include/scripts/menuetos_app_v01.ld -nostdlib -L$(MENUETDEV)/lib $(MENUETDEV)/stub/crt0.o
MMKDEP=kos32-gcc -nostdinc -I$(MENUETDEV)/include -D__DEV_CONFIG_H="\"../../config.h\"" -M

View File

@ -2,24 +2,24 @@ include $(MENUETDEV)/osrules.mak
.SUFFIXES: .asm;
AS = as
AS = kos32-as
NASM = nasm
CPP = cpp
CPP = kos32-cpp
DEBUG = 0
.c.o:
$(MGCC) $*.c $*.o $(CFLAGS) $(GCC32OPT)
$(MGCC) $*.c -o $*.o $(CFLAGS)
.cpp.o:
$(MGPP) $*.cpp $*.o $(CPPFLAGS) $(GCC32OPT)
$(MGPP) $*.cpp -o $*.o $(CPPFLAGS)
.asm.o:
$(NASM) $*.asm -o $*.o -f $(ASMFMT)
.s.o:
$(CPP) -nostdinc -I$(MENUETDEV)/include $*.s -o $*.sx $(CSFLAGS) -DMENUETDEV=$(MENUETDEV) -D__DEV_CONFIG_H=\"$(MENUETDEV)/config.h\"
as $*.sx $(AS32OPT) -o $*.o
$(AS) $*.sx -o $*.o
$(RM) $*.sx
ATHIS_LIBC_OBJS += $(subst .c,.o,$(filter %.c,$(THIS_SRCS))) \
@ -44,15 +44,8 @@ else
@echo "# nothing" > ./ldepend
endif
ifdef DJDIR
depend:
echo $(THIS_SRCS) > __tmp.1
$(MMKDEP) @__tmp.1 > ./ldepend
$(RM) __tmp.1
else
depend:
$(MMKDEP) $(THIS_SRCS) > ./ldepend
endif
ifeq ($(wildcard ./ldepend),)
check_ldepend:

View File

@ -6,5 +6,5 @@ ifdef ON_MINGW
else
../mks $(OUTFILE) < ../tmp_make > tmp_make.ars
endif
ar -M < tmp_make.ars
kos32-ar -M < tmp_make.ars
$(RM) tmp_make.ars

View File

@ -2,17 +2,14 @@ include $(MENUETDEV)/osrules.mak
.SUFFIXES: .asm;
OBJS = crt0.o
OBJS = crt0.o crt0_dynstack.o
all: $(OBJS)
ifdef ON_WINDOWS
crt0.o: crt0_$(STUBFMT).asm
fasm crt0_$(STUBFMT).asm crt0.o
else
crt0.o: crt0_$(STUBFMT)_nounderscores.asm
fasm crt0_$(STUBFMT)_nounderscores.asm crt0.o
endif
crt0.o: crt0_coff.asm
fasm crt0_coff.asm crt0.o
crt0_dynstack.o: crt0_coff_dynstack.asm
fasm crt0_coff_dynstack.asm crt0_dynstack.o
clean:
$(RM) $(OBJS)

View File

@ -1,56 +0,0 @@
CATCH_NULL_CALL = 0
format ELF
section '.text' executable
public start
EXTRN _edata
EXTRN ___menuet__app_param_area
EXTRN ___menuet__app_path_area
EXTRN ___crt1_startup
start:
public ___menuet__app_header
public ___menuet__memsize
___menuet__app_header:
db 'MENUET01'
dd 0x01
if CATCH_NULL_CALL
dd do_start
else
dd ___crt1_startup
end if
dd _edata
___menuet__memsize:
dd 0x400000
dd app_stack
dd ___menuet__app_param_area
dd ___menuet__app_path_area
if CATCH_NULL_CALL
do_start:
mov byte [0], 0xE9
mov dword [1], _libc_null_call-5
call ___crt1_startup
; Handle exit if __crt1_startup returns (shouldn't happen)
mov eax,-1
int 0x40
end if
if CATCH_NULL_CALL
EXTRN ___libc_null_call
_libc_null_call:
push eax
push ebx
push ecx
push edx
push esi
push edi
push ebp
call ___libc_null_call
mov eax,-1
int 0x40
end if
section '.bss' writeable
rd 0x20000
app_stack:

View File

@ -1,56 +0,0 @@
CATCH_NULL_CALL = 0
format ELF
section '.text' executable
public start
EXTRN edata
EXTRN __menuet__app_param_area
EXTRN __menuet__app_path_area
EXTRN __crt1_startup
start:
public __menuet__app_header
public __menuet__memsize
__menuet__app_header:
db 'MENUET01'
dd 0x01
if CATCH_NULL_CALL
dd do_start
else
dd __crt1_startup
end if
dd edata
__menuet__memsize:
dd 0x400000
dd app_stack
dd __menuet__app_param_area
dd __menuet__app_path_area
if CATCH_NULL_CALL
do_start:
mov byte [0], 0xE9
mov dword [1], _libc_null_call-5
call __crt1_startup
; Handle exit if __crt1_startup returns (shouldn't happen)
mov eax,-1
int 0x40
end if
if CATCH_NULL_CALL
EXTRN __libc_null_call
_libc_null_call:
push eax
push ebx
push ecx
push edx
push esi
push edi
push ebp
call __libc_null_call
mov eax,-1
int 0x40
end if
section '.bss' writeable
rd 4096*4
app_stack: