diff --git a/programs/develop/libraries/menuetlibc/Makefile b/programs/develop/libraries/menuetlibc/Makefile index 0d7578054e..8643035cd8 100644 --- a/programs/develop/libraries/menuetlibc/Makefile +++ b/programs/develop/libraries/menuetlibc/Makefile @@ -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) diff --git a/programs/develop/libraries/menuetlibc/Tupfile.lua b/programs/develop/libraries/menuetlibc/Tupfile.lua deleted file mode 100644 index 2ec5420f4a..0000000000 --- a/programs/develop/libraries/menuetlibc/Tupfile.lua +++ /dev/null @@ -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 diff --git a/programs/develop/libraries/menuetlibc/config.h b/programs/develop/libraries/menuetlibc/config.h new file mode 100644 index 0000000000..2622153aae --- /dev/null +++ b/programs/develop/libraries/menuetlibc/config.h @@ -0,0 +1 @@ +#define NEEDS_UNDERSCORES diff --git a/programs/develop/libraries/menuetlibc/linuxtools/Makefile b/programs/develop/libraries/menuetlibc/linuxtools/Makefile deleted file mode 100644 index 1f6637b878..0000000000 --- a/programs/develop/libraries/menuetlibc/linuxtools/Makefile +++ /dev/null @@ -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) diff --git a/programs/develop/libraries/menuetlibc/linuxtools/mchmem.c b/programs/develop/libraries/menuetlibc/linuxtools/mchmem.c deleted file mode 100644 index 60bf5021ff..0000000000 --- a/programs/develop/libraries/menuetlibc/linuxtools/mchmem.c +++ /dev/null @@ -1,49 +0,0 @@ -#define OFF 20 - -#include -#include -#include - -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; -} diff --git a/programs/develop/libraries/menuetlibc/linuxtools/mgcc.c b/programs/develop/libraries/menuetlibc/linuxtools/mgcc.c deleted file mode 100644 index faab7ed855..0000000000 --- a/programs/develop/libraries/menuetlibc/linuxtools/mgcc.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#ifndef WEXITSTATUS -#include -#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='' -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 -#include -#ifndef WEXITSTATUS -#include -#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 -#include -#ifndef WEXITSTATUS -#include -#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 -#include -#ifndef WEXITSTATUS -#include -#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 ./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: diff --git a/programs/develop/libraries/menuetlibc/src/libc/Makefile-link b/programs/develop/libraries/menuetlibc/src/libc/Makefile-link index 6b4983d5b0..84de30d834 100644 --- a/programs/develop/libraries/menuetlibc/src/libc/Makefile-link +++ b/programs/develop/libraries/menuetlibc/src/libc/Makefile-link @@ -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 diff --git a/programs/develop/libraries/menuetlibc/stub/Makefile b/programs/develop/libraries/menuetlibc/stub/Makefile index ecf3361235..f80c7b8a1d 100644 --- a/programs/develop/libraries/menuetlibc/stub/Makefile +++ b/programs/develop/libraries/menuetlibc/stub/Makefile @@ -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) diff --git a/programs/develop/libraries/menuetlibc/stub/crt0_elf.asm b/programs/develop/libraries/menuetlibc/stub/crt0_elf.asm deleted file mode 100644 index bc47fcf86f..0000000000 --- a/programs/develop/libraries/menuetlibc/stub/crt0_elf.asm +++ /dev/null @@ -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: diff --git a/programs/develop/libraries/menuetlibc/stub/crt0_elf_nounderscores.asm b/programs/develop/libraries/menuetlibc/stub/crt0_elf_nounderscores.asm deleted file mode 100644 index 4c0a36fb95..0000000000 --- a/programs/develop/libraries/menuetlibc/stub/crt0_elf_nounderscores.asm +++ /dev/null @@ -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: