summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcpplover0 <osdev555@yandex.com>2025-10-29 09:00:35 +0300
committercpplover0 <osdev555@yandex.com>2025-10-29 09:00:35 +0300
commit87e973d53cd59e5d578f594fd23fa6ee446c4aa3 (patch)
tree1b389801aea7d9335180e86625ecb6a679fccc9b
parent26f6e245f9c29be753e4618195439d06219a0a8c (diff)
xorg port
-rw-r--r--build-pkg.sh6
-rw-r--r--kernel/include/arch/x86_64/scheduling.hpp15
-rw-r--r--kernel/include/arch/x86_64/syscalls/sockets.hpp1
-rw-r--r--kernel/include/arch/x86_64/syscalls/syscalls.hpp106
-rw-r--r--kernel/include/drivers/serial.hpp1
-rw-r--r--kernel/include/etc/logging.hpp5
-rw-r--r--kernel/include/generic/locks/spinlock.hpp4
-rw-r--r--kernel/include/generic/mm/pmm.hpp10
-rw-r--r--kernel/include/generic/mm/vmm.hpp99
-rw-r--r--kernel/include/generic/vfs/fd.hpp3
-rw-r--r--kernel/include/generic/vfs/tmpfs.hpp10
-rw-r--r--kernel/include/generic/vfs/vfs.hpp24
-rw-r--r--kernel/src/arch/x86_64/interrupts/panic.cpp16
-rw-r--r--kernel/src/arch/x86_64/scheduling.cpp72
-rw-r--r--kernel/src/arch/x86_64/syscalls/file.cpp244
-rw-r--r--kernel/src/arch/x86_64/syscalls/futex.cpp7
-rw-r--r--kernel/src/arch/x86_64/syscalls/process.cpp97
-rw-r--r--kernel/src/arch/x86_64/syscalls/sockets.cpp41
-rw-r--r--kernel/src/arch/x86_64/syscalls/syscalls.cpp14
-rw-r--r--kernel/src/generic/mm/pmm.cpp37
-rw-r--r--kernel/src/generic/vfs/devfs.cpp2
-rw-r--r--kernel/src/generic/vfs/tmpfs.cpp52
-rw-r--r--kernel/src/generic/vfs/vfs.cpp95
-rw-r--r--kernel/src/main.cpp1
-rwxr-xr-x[-rw-r--r--]tar-initrd.sh9
-rw-r--r--tools/diffs/gcc.diff28
-rw-r--r--tools/diffs/gccn.diff286
-rw-r--r--tools/initbase/etc/X11/xorg.conf15
-rw-r--r--tools/initbase/etc/gaster33
-rw-r--r--tools/initbase/etc/localtimebin0 -> 114 bytes
-rw-r--r--tools/pkg/1/nop/pkg.sh2
-rw-r--r--tools/pkg/1/pkg-config/diff/libtool.diff366
-rw-r--r--tools/pkg/1/pkg-config/diff/pkg-config.diff12
-rw-r--r--tools/pkg/1/pkg-config/info.txt1
-rw-r--r--tools/pkg/1/pkg-config/pkg.sh52
-rw-r--r--tools/pkg/2/debug/info.txt1
-rw-r--r--tools/pkg/2/debug/main.c15
-rw-r--r--tools/pkg/2/debug/pkg.sh2
-rw-r--r--tools/pkg/2/init/pkg.sh8
-rw-r--r--tools/pkg/2/init/src/include/etc.hpp64
-rw-r--r--tools/pkg/2/ncurses/pkg.sh3
-rw-r--r--tools/pkg/2/ps2_driver/pkg.sh2
-rw-r--r--tools/pkg/2/ps2_driver/src/main.c2
-rw-r--r--tools/pkg/2/xhci_driver/pkg.sh2
-rw-r--r--tools/pkg/2/xhci_driver/src/main.cpp6
-rw-r--r--tools/pkg/3/bash/diff/bash.diff12
-rw-r--r--tools/pkg/3/bash/pkg.sh4
-rw-r--r--tools/pkg/3/coreutils/pkg.sh3
-rw-r--r--tools/pkg/3/doomgeneric/diff/doomgeneric.diff4
-rw-r--r--tools/pkg/3/fastfetch/pkg.sh1
-rw-r--r--tools/pkg/3/lua/pkg.sh2
-rw-r--r--tools/pkg/3/nano/pkg.sh3
-rw-r--r--tools/pkg/3/poll_test/pkg.sh2
-rw-r--r--tools/pkg/3/pthread_test/info.txt1
-rw-r--r--tools/pkg/3/pthread_test/main.c33
-rw-r--r--tools/pkg/3/pthread_test/pkg.sh1
-rw-r--r--tools/pkg/4/xorg-server/diff/1.diff401
-rw-r--r--tools/pkg/4/xorg-server/diff/libgpg-error.diff53
-rw-r--r--tools/pkg/4/xorg-server/diff/openssl.diff40
-rw-r--r--tools/pkg/4/xorg-server/diff/xfbdev.diff51
-rw-r--r--tools/pkg/4/xorg-server/diff/xkeyboard.diff246
-rw-r--r--tools/pkg/4/xorg-server/diff/xorgproto.diff26
-rw-r--r--tools/pkg/4/xorg-server/diff/xorgserver.diff426
-rw-r--r--tools/pkg/4/xorg-server/info.txt1
-rw-r--r--tools/pkg/4/xorg-server/pkg.sh142
-rw-r--r--tools/pkg/5/twm/diff/fontconfig.diff12
-rw-r--r--tools/pkg/5/twm/diff/libxt.diff16
-rw-r--r--tools/pkg/5/twm/diff/xterm.diff148
-rw-r--r--tools/pkg/5/twm/info.txt1
-rw-r--r--tools/pkg/5/twm/pkg.sh32
-rw-r--r--tools/pkg/5/xorg-modules/diff/xfbdev.diff51
-rw-r--r--tools/pkg/5/xorg-modules/diff/xkeyboard.diff246
-rw-r--r--tools/pkg/5/xorg-modules/info.txt1
-rw-r--r--tools/pkg/5/xorg-modules/pkg.sh29
-rw-r--r--tools/pkg/build-pkg.sh11
-rw-r--r--tools/pkg/config.guess1818
-rw-r--r--tools/pkg/config.sub2364
-rw-r--r--tools/pkg/pkg-lib.sh134
-rw-r--r--tools/pkg/toolchain.cmake4
-rw-r--r--tools/pkg/x86_64-orange.crossfile12
-rw-r--r--tools/toolchain-build.sh12
81 files changed, 7998 insertions, 216 deletions
diff --git a/build-pkg.sh b/build-pkg.sh
index 820d195..4fcd5aa 100644
--- a/build-pkg.sh
+++ b/build-pkg.sh
@@ -1,8 +1,14 @@
export PATH="$HOME/opt/cross/orange/bin:$PATH"
+sysroot_path="$(realpath initrd)"
+
+export PKG_CONFIG_SYSROOT_DIR="$sysroot_path"
+export PKG_CONFIG_PATH="$sysroot_path/usr/lib/pkgconfig:$sysroot_path/usr/share/pkgconfig:$sysroot_path/usr/local/lib/pkgconfig:$sysroot_path/usr/local/share/pkgconfig:$HOME/opt/cross/orange/lib/pkgconfig:$HOME/opt/cross/orange/share/pkgconfig"
INITRDDIR=""$(realpath initrd)""
+export CFLAGS="-fPIC -Wno-error -O2"
+
cd tools/pkg/$1
sh pkg.sh "$INITRDDIR"
cd ../../../../
diff --git a/kernel/include/arch/x86_64/scheduling.hpp b/kernel/include/arch/x86_64/scheduling.hpp
index 32fddd8..4650796 100644
--- a/kernel/include/arch/x86_64/scheduling.hpp
+++ b/kernel/include/arch/x86_64/scheduling.hpp
@@ -15,6 +15,9 @@
#define PROCESS_STATE_RUNNING 2
#define PROCESS_STATE_ZOMBIE 3
+#define WNOHANG 1 /* Don't block waiting. */
+#define WUNTRACED 2 /* Report status of stopped children. */
+
#define MIN2(a, b) ((a) < (b) ? (a) : (b))
#define MAX2(a, b) ((a) > (b) ? (a) : (b))
@@ -130,7 +133,12 @@ namespace arch {
locks::spinlock lock;
locks::spinlock kill_lock; /* Never should be setup by not kill() function */
+ locks::spinlock futex_lock;
+
std::uint32_t fd_ptr;
+
+ std::uint32_t reversedforid;
+ std::uint32_t* vmm_id;
userspace_fd_t* fd;
char* vmm_start;
@@ -141,6 +149,8 @@ namespace arch {
char* name;
int exit_code;
+ int is_cloned;
+ std::uint64_t* original_cr3_pointer;
std::uint64_t futex;
std::uint64_t syscall_stack;
@@ -151,6 +161,8 @@ namespace arch {
std::uint32_t parent_id;
+ int is_debug;
+
struct process* next;
} process_t;
@@ -166,10 +178,11 @@ namespace arch {
static void init();
static process_t* create();
static process_t* fork(process_t* proc,int_frame_t* ctx);
+ static process_t* clone(process_t* proc,int_frame_t* ctx);
static void kill(process_t* proc);
static void wakeup(process_t* proc);
static void futexwake(process_t* proc, int* lock);
- static void futexwait(process_t* proc, int* lock, int val);
+ static void futexwait(process_t* proc, int* lock, int val, int* original_lock);
static int loadelf(process_t* proc,char* path,char** argv,char** envp,int free_mem);
static process_t* head_proc_();
diff --git a/kernel/include/arch/x86_64/syscalls/sockets.hpp b/kernel/include/arch/x86_64/syscalls/sockets.hpp
index 4aca66e..3892c0a 100644
--- a/kernel/include/arch/x86_64/syscalls/sockets.hpp
+++ b/kernel/include/arch/x86_64/syscalls/sockets.hpp
@@ -127,6 +127,7 @@ typedef struct socket_pending_obj {
typedef struct socket_node {
char path[128];
char is_used;
+ uint64_t socket_counter;
socket_pending_obj_t* pending_list;
struct socket_node* next;
} socket_node_t;
diff --git a/kernel/include/arch/x86_64/syscalls/syscalls.hpp b/kernel/include/arch/x86_64/syscalls/syscalls.hpp
index 24d29bf..5788bab 100644
--- a/kernel/include/arch/x86_64/syscalls/syscalls.hpp
+++ b/kernel/include/arch/x86_64/syscalls/syscalls.hpp
@@ -10,24 +10,102 @@
#include <etc/bootloaderinfo.hpp>
#include <etc/libc.hpp>
+#include <generic/mm/vmm.hpp>
+#include <etc/etc.hpp>
+
#include <arch/x86_64/cpu/data.hpp>
inline void copy_in_userspace(arch::x86_64::process_t* proc,void* dest, void* src, std::uint64_t size) {
- memory::paging::enablepaging(proc->original_cr3);
- memcpy(dest,src,size);
- memory::paging::enablekernel();
+
+ void* ddest = 0;
+ void* ssrc = 0;
+
+ if((std::uint64_t)dest > BootloaderInfo::AccessHHDM()) {
+ ddest = dest;
+ }
+
+ if((std::uint64_t)src > BootloaderInfo::AccessHHDM()) {
+ ssrc = src;
+ }
+
+ if((std::uint64_t)dest < BootloaderInfo::AccessHHDM()) {
+ vmm_obj_t* vmm_object = memory::vmm::getlen(proc,(std::uint64_t)dest);
+
+ if(!vmm_object)
+ return;
+
+ uint64_t need_phys = vmm_object->phys + ((std::uint64_t)dest - vmm_object->base);
+ ddest = Other::toVirt(need_phys);
+ }
+
+ if((std::uint64_t)src < BootloaderInfo::AccessHHDM()) {
+ vmm_obj_t* vmm_object = memory::vmm::getlen(proc,(std::uint64_t)src);
+
+ if(!vmm_object)
+ return;
+
+ uint64_t need_phys = vmm_object->phys + ((std::uint64_t)src - vmm_object->base);
+ ssrc = Other::toVirt(need_phys);
+ }
+
+ memcpy(ddest,ssrc,size);
}
inline void copy_in_userspace_string(arch::x86_64::process_t* proc,void* dest, void* src, std::uint64_t size) {
- memory::paging::enablepaging(proc->original_cr3);
- memcpy(dest,src,strlen((char*)src) > size ? size : strlen((char*)src));
- memory::paging::enablekernel();
+
+ void* ddest = 0;
+ void* ssrc = 0;
+
+ if((std::uint64_t)dest > BootloaderInfo::AccessHHDM()) {
+ ddest = dest;
+ }
+
+ if((std::uint64_t)src > BootloaderInfo::AccessHHDM()) {
+ ssrc = src;
+ }
+
+ if((std::uint64_t)dest < BootloaderInfo::AccessHHDM()) {
+ vmm_obj_t* vmm_object = memory::vmm::getlen(proc,(std::uint64_t)dest);
+
+ if(!vmm_object)
+ return;
+
+ uint64_t need_phys = vmm_object->phys + ((std::uint64_t)dest - vmm_object->base);
+ ddest = Other::toVirt(need_phys);
+ }
+
+ if((std::uint64_t)src < BootloaderInfo::AccessHHDM()) {
+ vmm_obj_t* vmm_object = memory::vmm::getlen(proc,(std::uint64_t)src);
+
+ if(!vmm_object)
+ return;
+
+ uint64_t need_phys = vmm_object->phys + ((std::uint64_t)src - vmm_object->base);
+ ssrc = Other::toVirt(need_phys);
+ }
+
+ memcpy(ddest,ssrc,strlen((char*)ssrc) > size ? size : strlen((char*)ssrc));
}
inline void zero_in_userspace(arch::x86_64::process_t* proc,void* buf, std::uint64_t size) {
- memory::paging::enablepaging(proc->original_cr3);
- memset(buf,0,size);
- memory::paging::enablekernel();
+
+ void* bbuf;
+
+ if((std::uint64_t)buf > BootloaderInfo::AccessHHDM()) {
+ bbuf = buf;
+ }
+
+ if((std::uint64_t)buf < BootloaderInfo::AccessHHDM()) {
+ vmm_obj_t* vmm_object = memory::vmm::getlen(proc,(std::uint64_t)buf);
+
+ if(!vmm_object)
+ return;
+
+ uint64_t need_phys = vmm_object->phys + ((std::uint64_t)buf - vmm_object->base);
+ bbuf = Other::toVirt(need_phys);
+ }
+
+ memset(bbuf,0,size);
}
class syscall_safe {
@@ -136,6 +214,10 @@ syscall_ret_t sys_fchdir(int fd);
syscall_ret_t sys_poll(struct pollfd *fds, int count, int timeout);
syscall_ret_t sys_readlinkat(int dirfd, const char* path, void* buffer, int_frame_t* ctx);
+syscall_ret_t sys_link(char* old_path, char* new_path);
+syscall_ret_t sys_mkdirat(int dirfd, char* path, int mode);
+syscall_ret_t sys_chmod(char* path, int mode);
+
/* Process */
syscall_ret_t sys_mmap(std::uint64_t hint, std::uint64_t size, int fd0, int_frame_t* ctx);
syscall_ret_t sys_free(void *pointer, size_t size);
@@ -157,7 +239,7 @@ syscall_ret_t sys_getppid();
syscall_ret_t sys_gethostname(void* buffer, std::uint64_t bufsize);
syscall_ret_t sys_getcwd(void* buffer, std::uint64_t bufsize);
-syscall_ret_t sys_waitpid(int pid);
+syscall_ret_t sys_waitpid(int pid, int flags);
syscall_ret_t sys_sleep(long us);
@@ -170,6 +252,10 @@ syscall_ret_t sys_timestamp();
syscall_ret_t sys_mkfifoat(int dirfd, const char *path, int mode);
+syscall_ret_t sys_enabledebugmode();
+
+syscall_ret_t sys_clone(std::uint64_t stack, std::uint64_t rip, int c, int_frame_t* ctx);
+
/* Futex */
syscall_ret_t sys_futex_wait(int* pointer, int excepted);
syscall_ret_t sys_futex_wake(int* pointer);
diff --git a/kernel/include/drivers/serial.hpp b/kernel/include/drivers/serial.hpp
index abf5ad9..f6c93a5 100644
--- a/kernel/include/drivers/serial.hpp
+++ b/kernel/include/drivers/serial.hpp
@@ -37,6 +37,7 @@ public:
}
void write(std::uint8_t* data,std::size_t len) {
+ //return;
for(std::size_t i = 0; i < len; i++) {
send(data[i]);
}
diff --git a/kernel/include/etc/logging.hpp b/kernel/include/etc/logging.hpp
index 1539de6..57002a0 100644
--- a/kernel/include/etc/logging.hpp
+++ b/kernel/include/etc/logging.hpp
@@ -34,4 +34,7 @@ public:
static void SerialDisplay(int level,char* msg,...);
};
-#define BREAKPOINT() Log::Display(LEVEL_MESSAGE_INFO,"breakpoint %s:%d\n ",__FILE__,__LINE__) \ No newline at end of file
+#define BREAKPOINT() Log::Display(LEVEL_MESSAGE_INFO,"breakpoint %s:%d\n ",__FILE__,__LINE__)
+
+#define DEBUG(is_enabled,fmt,...) if(is_enabled) Log::SerialDisplay(LEVEL_MESSAGE_INFO,"%s(): " fmt "\n", __FUNCTION__, ##__VA_ARGS__)
+#define STUB(is_enabled) if(is_enabled) Log::SerialDisplay(LEVEL_MESSAGE_INFO, "%s() is a stub !\n", __FUNCTION__) \ No newline at end of file
diff --git a/kernel/include/generic/locks/spinlock.hpp b/kernel/include/generic/locks/spinlock.hpp
index c450f5e..6940ccc 100644
--- a/kernel/include/generic/locks/spinlock.hpp
+++ b/kernel/include/generic/locks/spinlock.hpp
@@ -11,7 +11,7 @@ namespace locks {
class spinlock {
private:
volatile std::atomic_flag flag = ATOMIC_FLAG_INIT;
- char is_process_switch = 0;
+ char is_cli = 0;
public:
spinlock() {
@@ -23,7 +23,7 @@ namespace locks {
}
void enable_scheduling_optimization() {
- is_process_switch = 1;
+
}
std::uint8_t test_and_set() {
diff --git a/kernel/include/generic/mm/pmm.hpp b/kernel/include/generic/mm/pmm.hpp
index bb20111..3f35db6 100644
--- a/kernel/include/generic/mm/pmm.hpp
+++ b/kernel/include/generic/mm/pmm.hpp
@@ -34,6 +34,12 @@ typedef struct {
buddy_info_t* mem;
} __attribute__((packed)) buddy_t;
+typedef struct {
+ std::uint64_t virt;
+ std::uint64_t real_size; //optimization for tmpfs
+} alloc_t;
+
+
namespace memory {
class buddy {
private:
@@ -45,15 +51,19 @@ namespace memory {
static void init();
static void free(std::uint64_t phys);
static void fullfree(std::uint32_t id);
+ static alloc_t alloc_ext(std::size_t size);
static std::int64_t alloc(std::size_t size);
static std::int64_t allocid(std::size_t size, std::uint32_t id);
};
namespace pmm {
+
+
class _physical {
public:
static void init();
static void free(std::uint64_t phys);
static void fullfree(std::uint32_t id);
+ static alloc_t alloc_ext(std::size_t size);
static std::int64_t alloc(std::size_t size);
static std::int64_t allocid(std::size_t size, std::uint32_t id);
diff --git a/kernel/include/generic/mm/vmm.hpp b/kernel/include/generic/mm/vmm.hpp
index 9419cee..3170cb7 100644
--- a/kernel/include/generic/mm/vmm.hpp
+++ b/kernel/include/generic/mm/vmm.hpp
@@ -20,8 +20,12 @@ typedef struct vmm_obj {
uint64_t phys;
uint64_t len;
uint64_t flags;
+
+ uint8_t is_shared;
uint8_t is_mapped;
+ int* how_much_connected; // used for sharedmem
+
uint64_t src_len;
struct vmm_obj* next;
@@ -141,11 +145,11 @@ namespace memory {
new_vmm->phys = base;
new_vmm->src_len = length;
new_vmm->is_mapped = 1;
- paging::maprangeid(proc->original_cr3,base,new_vmm->base,length,flags,proc->id);
+ paging::maprangeid(proc->original_cr3,base,new_vmm->base,length,flags,*proc->vmm_id);
return (void*)new_vmm->base;
}
- inline static void* mark(arch::x86_64::process_t* proc, std::uint64_t base, std::uint64_t phys, std::uint64_t length, std::uint64_t flags) {
+ inline static void* mark(arch::x86_64::process_t* proc, std::uint64_t base, std::uint64_t phys, std::uint64_t length, std::uint64_t flags, int is_shared) {
vmm_obj_t* current = (vmm_obj_t*)proc->vmm_start;
vmm_obj_t* new_vmm = v_find(current,base,length);
new_vmm->flags = flags;
@@ -154,6 +158,7 @@ namespace memory {
new_vmm->base = base;
new_vmm->is_mapped = 0;
new_vmm->len = ALIGNUP(length,4096);
+ new_vmm->is_shared = is_shared;
return (void*)new_vmm->base;
}
@@ -172,6 +177,24 @@ namespace memory {
}
}
+ inline static vmm_obj_t* getlen(arch::x86_64::process_t* proc, std::uint64_t addr) {
+ vmm_obj_t* current = (vmm_obj_t*)proc->vmm_start;
+
+ while (current) {
+
+ if (addr >= current->base && addr < current->base + current->len) {
+ return current;
+ }
+
+ if (current->base == (std::uint64_t)Other::toVirt(0) - 4096)
+ break;
+
+ current = current->next;
+ }
+
+ return 0;
+ }
+
inline static void clone(arch::x86_64::process_t* dest_proc, arch::x86_64::process_t* src_proc) {
if(dest_proc && src_proc) {
@@ -182,17 +205,23 @@ namespace memory {
uint64_t phys;
if(src_current->phys) {
- if(src_current->src_len <= 4096 && !src_current->is_mapped)
- phys = memory::pmm::_physical::alloc(4096);
- else if(src_current->src_len > 4096 && !src_current->is_mapped)
- phys = memory::pmm::_physical::alloc(src_current->src_len);
- else if(src_current->is_mapped)
- phys = src_current->phys;
-
- if(!src_current->is_mapped)
- memcpy((void*)Other::toVirt(phys),(void*)Other::toVirt(src_current->phys),src_current->len);
- mark(dest_proc,src_current->base,phys,src_current->src_len,src_current->flags);
+ if(src_current->is_shared) {
+ *src_current->how_much_connected = *src_current->how_much_connected + 1;
+ phys = src_current->phys;
+ } else {
+ if(src_current->src_len <= 4096 && !src_current->is_mapped)
+ phys = memory::pmm::_physical::alloc(4096);
+ else if(src_current->src_len > 4096 && !src_current->is_mapped)
+ phys = memory::pmm::_physical::alloc(src_current->src_len);
+ else if(src_current->is_mapped)
+ phys = src_current->phys;
+
+ if(!src_current->is_mapped)
+ memcpy((void*)Other::toVirt(phys),(void*)Other::toVirt(src_current->phys),src_current->len);
+ }
+
+ mark(dest_proc,src_current->base,phys,src_current->src_len,src_current->flags,src_current->is_shared);
get(dest_proc,src_current->base)->is_mapped = src_current->is_mapped;
}
@@ -209,19 +238,19 @@ namespace memory {
inline static void reload(arch::x86_64::process_t* proc) {
vmm_obj_t* current = (vmm_obj_t*)proc->vmm_start;
if(proc->ctx.cr3 && proc->original_cr3) { /* We should free all paging memory */
- memory::pmm::_physical::fullfree(proc->id);
+ memory::pmm::_physical::fullfree(*proc->vmm_id);
memory::pmm::_physical::free(proc->original_cr3);
}
proc->ctx.cr3 = memory::pmm::_physical::alloc(4096);
proc->original_cr3 = proc->ctx.cr3;
std::uint64_t cr3 = proc->ctx.cr3;
- memory::paging::mapkernel(cr3,proc->id);
- memory::paging::alwaysmappedmap(cr3,proc->id);
- memory::paging::maprangeid(cr3,Other::toPhys(proc->syscall_stack),(std::uint64_t)proc->syscall_stack,SYSCALL_STACK_SIZE,PTE_USER | PTE_PRESENT | PTE_RW,proc->id);
+ memory::paging::mapkernel(cr3,*proc->vmm_id);
+ memory::paging::alwaysmappedmap(cr3,*proc->vmm_id);
+ memory::paging::maprangeid(cr3,Other::toPhys(proc->syscall_stack),(std::uint64_t)proc->syscall_stack,SYSCALL_STACK_SIZE,PTE_USER | PTE_PRESENT | PTE_RW,*proc->vmm_id);
while(current) {
if(current->phys) {
- memory::paging::maprangeid(cr3,current->phys,current->base,current->len,current->flags,proc->id);
+ memory::paging::maprangeid(cr3,current->phys,current->base,current->len,current->flags,*proc->vmm_id);
}
if(current->base == (std::uint64_t)Other::toVirt(0) - 4096)
@@ -239,7 +268,7 @@ namespace memory {
if(current->base == dest_base) {
current->phys = new_phys;
- memory::paging::maprangeid(proc->original_cr3,current->phys,current->base,current->len,current->flags,proc->id);
+ memory::paging::maprangeid(proc->original_cr3,current->phys,current->base,current->len,current->flags,*proc->vmm_id);
return;
@@ -265,10 +294,16 @@ namespace memory {
if(current->base == (std::uint64_t)Other::toVirt(0) - 4096)
next = 0;
- if(!current->is_mapped) {
+ if(!current->is_mapped && !current->is_shared) {
memory::pmm::_physical::free(current->phys);
+ } else if(current->is_shared && !current->is_mapped) {
+ if(*current->how_much_connected == 1) {
+ memory::pmm::_physical::free(current->phys);
+ delete (void*)current->how_much_connected;
+ } else
+ *current->how_much_connected = *current->how_much_connected - 1;
}
-
+
delete current;
if(!next)
@@ -277,7 +312,7 @@ namespace memory {
current = next;
}
- memory::pmm::_physical::fullfree(proc->id);
+ memory::pmm::_physical::fullfree(*proc->vmm_id);
memory::pmm::_physical::free(proc->original_cr3);
proc->original_cr3 = 0;
@@ -286,7 +321,7 @@ namespace memory {
}
- inline static void* alloc(arch::x86_64::process_t* proc, std::uint64_t len, std::uint64_t flags) {
+ inline static void* alloc(arch::x86_64::process_t* proc, std::uint64_t len, std::uint64_t flags, int is_shared) {
vmm_obj_t* current = (vmm_obj_t*)proc->vmm_start;
vmm_obj_t* new_vmm = v_alloc(current,len);
new_vmm->flags = flags;
@@ -294,15 +329,27 @@ namespace memory {
new_vmm->is_mapped = 0;
std::uint64_t phys = memory::pmm::_physical::alloc(len);
new_vmm->phys = phys;
- paging::maprangeid(proc->original_cr3,new_vmm->phys,new_vmm->base,new_vmm->len,flags,proc->id);
+
+ if(is_shared) {
+ new_vmm->is_shared = 1;
+ new_vmm->how_much_connected = new int;
+ }
+
+ paging::maprangeid(proc->original_cr3,new_vmm->phys,new_vmm->base,new_vmm->len,flags,*proc->vmm_id);
return (void*)new_vmm->base;
}
- inline static void* customalloc(arch::x86_64::process_t* proc, std::uint64_t virt, std::uint64_t len, std::uint64_t flags) {
+ inline static void* customalloc(arch::x86_64::process_t* proc, std::uint64_t virt, std::uint64_t len, std::uint64_t flags, int is_shared) {
vmm_obj_t* current = (vmm_obj_t*)proc->vmm_start;
std::uint64_t phys = memory::pmm::_physical::alloc(len);
- void* new_virt = mark(proc,virt,phys,len,flags);
- paging::maprangeid(proc->original_cr3,phys,(std::uint64_t)virt,len,flags,proc->id);
+ void* new_virt = mark(proc,virt,phys,len,flags,is_shared);
+ paging::maprangeid(proc->original_cr3,phys,(std::uint64_t)virt,len,flags,*proc->vmm_id);
+
+ vmm_obj_t* new_vmm = get(proc,virt);
+ if(is_shared) {
+ new_vmm->is_shared = 1;
+ new_vmm->how_much_connected = new int;
+ }
return (void*)virt;
}
diff --git a/kernel/include/generic/vfs/fd.hpp b/kernel/include/generic/vfs/fd.hpp
index c3835e1..255bd0d 100644
--- a/kernel/include/generic/vfs/fd.hpp
+++ b/kernel/include/generic/vfs/fd.hpp
@@ -30,6 +30,9 @@ namespace vfs {
current->read_counter = -1;
current->write_counter = -1;
current->can_be_closed = 0;
+ current->is_cached_path = 0;
+
+ memset(current->path,0,2048);
return current->index;
diff --git a/kernel/include/generic/vfs/tmpfs.hpp b/kernel/include/generic/vfs/tmpfs.hpp
index 2dc11f1..3ad34b6 100644
--- a/kernel/include/generic/vfs/tmpfs.hpp
+++ b/kernel/include/generic/vfs/tmpfs.hpp
@@ -16,6 +16,7 @@ namespace vfs {
std::uint64_t vars[8];
std::uint8_t type;
std::uint8_t* content;
+ std::uint64_t real_size; // real size in ram (optimization)
struct tmpfs_node* next;
char name[2048];
} tmpfs_node_t;
@@ -24,4 +25,11 @@ namespace vfs {
public:
static void mount(vfs_node_t* node);
};
-}; \ No newline at end of file
+};
+
+#define NODE_POOL_BLOCK_SIZE (16 * 1024 * 1024)
+
+struct NodePoolBlock {
+ vfs::tmpfs_node_t* block;
+ NodePoolBlock* next;
+};
diff --git a/kernel/include/generic/vfs/vfs.hpp b/kernel/include/generic/vfs/vfs.hpp
index b27bfbf..e888aca 100644
--- a/kernel/include/generic/vfs/vfs.hpp
+++ b/kernel/include/generic/vfs/vfs.hpp
@@ -112,7 +112,6 @@ namespace vfs {
class pipe {
private:
char* buffer;
- std::int64_t size = 0;
std::uint64_t total_size = 0;
std::uint64_t read_ptr = 0;
locks::spinlock lock;
@@ -124,6 +123,7 @@ namespace vfs {
public:
+ std::int64_t size = 0;
std::uint64_t write_counter = 0;
std::uint64_t read_counter = 0;
@@ -211,6 +211,7 @@ namespace vfs {
force_write(src_buffer + written, to_write);
written += to_write;
+ this->read_counter++;
asm volatile("sti");
@@ -221,33 +222,41 @@ namespace vfs {
}
std::uint64_t read(char* dest_buffer, std::uint64_t count) {
+
std::uint64_t read_bytes = 0;
while (true) {
this->lock.lock();
+ asm volatile("cli");
if (this->size == 0) {
if (this->is_closed.test(std::memory_order_acquire)) {
this->lock.unlock();
+ asm volatile("sti");
return 0;
}
if (flags & O_NONBLOCK) {
this->lock.unlock();
+ asm volatile("sti");
return 0;
}
this->lock.unlock();
+ asm volatile("sti");
asm volatile("pause");
continue;
}
- asm volatile("cli");
-
+
read_bytes = (count < this->size) ? count : this->size;
memcpy(dest_buffer, this->buffer, read_bytes);
memmove(this->buffer, this->buffer + read_bytes, this->size - read_bytes);
this->size -= read_bytes;
- asm volatile("sti");
+ if(this->size == 0) {
+ this->write_counter++;
+ } else
+ this->read_counter++;
+ asm volatile("sti");
this->lock.unlock();
break;
}
@@ -295,6 +304,7 @@ typedef struct userspace_fd {
std::uint8_t can_be_closed;
+ std::uint8_t is_listen;
vfs::pipe* read_socket_pipe;
vfs::pipe* write_socket_pipe;
@@ -310,6 +320,8 @@ typedef struct userspace_fd {
std::int64_t write_counter;
std::int64_t read_counter;
+ int is_cached_path;
+
vfs::pipe* pipe;
char path[2048];
@@ -578,4 +590,6 @@ namespace vfs {
};
-}; \ No newline at end of file
+};
+
+void __vfs_symlink_resolve(char* path, char* out); \ No newline at end of file
diff --git a/kernel/src/arch/x86_64/interrupts/panic.cpp b/kernel/src/arch/x86_64/interrupts/panic.cpp
index 13adec2..65e71eb 100644
--- a/kernel/src/arch/x86_64/interrupts/panic.cpp
+++ b/kernel/src/arch/x86_64/interrupts/panic.cpp
@@ -23,14 +23,14 @@ void panic(int_frame_t* ctx, const char* msg) {
memory::paging::enablekernel();
- // arch::x86_64::process_t* proc = arch::x86_64::cpu::data()->temp.proc;
- // if(proc) {
- // uint64_t cr2;
- // asm volatile("mov %%cr2, %0" : "=r"(cr2) : : "memory");
- // Log::SerialDisplay(LEVEL_MESSAGE_FAIL,"process %d fired cpu exception with vec %d, rip 0x%p, cr2 0x%p, error code 0x%p\n",proc->id,ctx->vec,ctx->rip,cr2,ctx->err_code);
- // arch::x86_64::scheduling::kill(proc);
- // schedulingSchedule(0);
- // }
+ arch::x86_64::process_t* proc = arch::x86_64::cpu::data()->temp.proc;
+ if(proc) {
+ uint64_t cr2;
+ asm volatile("mov %%cr2, %0" : "=r"(cr2) : : "memory");
+ Log::SerialDisplay(LEVEL_MESSAGE_FAIL,"process %d fired cpu exception with vec %d, rip 0x%p, cr2 0x%p, error code 0x%p\n",proc->id,ctx->vec,ctx->rip,cr2,ctx->err_code);
+ arch::x86_64::scheduling::kill(proc);
+ schedulingSchedule(0);
+ }
extern locks::spinlock log_lock;
log_lock.unlock();
diff --git a/kernel/src/arch/x86_64/scheduling.cpp b/kernel/src/arch/x86_64/scheduling.cpp
index 4d95af8..0397353 100644
--- a/kernel/src/arch/x86_64/scheduling.cpp
+++ b/kernel/src/arch/x86_64/scheduling.cpp
@@ -50,10 +50,10 @@ uint64_t* __elf_copy_to_stack(char** arr,uint64_t* stack,char** out, uint64_t le
uint64_t* temp_stack = stack;
for(uint64_t i = 0;i < len; i++) {
+ temp_stack -= ALIGNUP(strlen(arr[i]),8);
PUT_STACK_STRING(temp_stack,arr[i])
out[i] = (char*)temp_stack;
PUT_STACK(temp_stack,0);
- temp_stack -= ALIGNUP(strlen(arr[i]),8);
}
return temp_stack;
@@ -145,9 +145,9 @@ elfloadresult_t __scheduling_load_elf(arch::x86_64::process_t* proc, std::uint8_
void* elf_vmm;
if(head->e_type != ET_DYN) {
- elf_vmm = memory::vmm::customalloc(proc,elf_base,size,PTE_PRESENT | PTE_RW | PTE_USER);
+ elf_vmm = memory::vmm::customalloc(proc,elf_base,size,PTE_PRESENT | PTE_RW | PTE_USER,0);
} else {
- elf_vmm = memory::vmm::alloc(proc,size,PTE_PRESENT | PTE_RW | PTE_USER);
+ elf_vmm = memory::vmm::alloc(proc,size,PTE_PRESENT | PTE_RW | PTE_USER,0);
if(phdr) {
phdr += (uint64_t)elf_vmm;
@@ -208,7 +208,7 @@ int arch::x86_64::scheduling::loadelf(process_t* proc,char* path,char** argv,cha
if(elfload.status != 0)
return elfload.status;
- proc->ctx.rsp = (std::uint64_t)memory::vmm::alloc(proc,USERSPACE_STACK_SIZE,PTE_PRESENT | PTE_USER | PTE_RW) + USERSPACE_STACK_SIZE - 4096;
+ proc->ctx.rsp = (std::uint64_t)memory::vmm::alloc(proc,USERSPACE_STACK_SIZE,PTE_PRESENT | PTE_USER | PTE_RW,0) + USERSPACE_STACK_SIZE - 4096;
std::uint64_t* _stack = (std::uint64_t*)proc->ctx.rsp;
std::uint64_t auxv_stack[] = {(std::uint64_t)elfload.real_entry,AT_ENTRY,elfload.phdr,AT_PHDR,elfload.phentsize,AT_PHENT,elfload.phnum,AT_PHNUM,4096,AT_PAGESZ};
@@ -262,6 +262,50 @@ void arch::x86_64::scheduling::wakeup(process_t* proc) {
proc->lock.unlock(); /* Just clear */
}
+arch::x86_64::process_t* arch::x86_64::scheduling::clone(process_t* proc,int_frame_t* ctx) {
+ process_t* nproc = create();
+ memory::vmm::free(nproc);
+
+ nproc->is_cloned = 1;
+ nproc->ctx.cr3 = ctx->cr3;
+ nproc->original_cr3 = ctx->cr3;
+
+ nproc->vmm_end = proc->vmm_end;
+ nproc->vmm_start = proc->vmm_start;
+
+ nproc->parent_id = proc->id;
+ nproc->fs_base = proc->fs_base;
+ nproc->reversedforid = *proc->vmm_id;
+ nproc->vmm_id = &nproc->reversedforid;
+
+ memset(nproc->cwd,0,4096);
+ memset(nproc->name,0,4096);
+ memcpy(nproc->cwd,proc->cwd,strlen(proc->cwd));
+ memcpy(nproc->name,proc->name,strlen(proc->name));
+
+ memcpy(nproc->sse_ctx,proc->sse_ctx,arch::x86_64::cpu::sse::size());
+
+ nproc->fd_ptr = proc->fd_ptr;
+
+ userspace_fd_t* fd = proc->fd;
+ while(fd) {
+ userspace_fd_t* newfd = (userspace_fd_t*)memory::pmm::_virtual::alloc(4096);
+ memcpy(newfd,fd,sizeof(userspace_fd_t));
+
+ if(newfd->state == USERSPACE_FD_STATE_PIPE) {
+ newfd->pipe->create(newfd->pipe_side);
+ }
+
+ newfd->next = nproc->fd;
+ nproc->fd = newfd;
+ fd = fd->next;
+ }
+
+ memcpy(&nproc->ctx,ctx,sizeof(int_frame_t));
+
+ return nproc;
+}
+
arch::x86_64::process_t* arch::x86_64::scheduling::fork(process_t* proc,int_frame_t* ctx) {
process_t* nproc = create();
memory::vmm::clone(nproc,proc);
@@ -345,6 +389,7 @@ arch::x86_64::process_t* arch::x86_64::scheduling::create() {
head_proc = proc;
proc->id = id_ptr++;
+ proc->vmm_id = &proc->id;
memory::vmm::initproc(proc);
memory::vmm::reload(proc);
@@ -359,19 +404,20 @@ arch::x86_64::process_t* arch::x86_64::scheduling::create() {
void arch::x86_64::scheduling::futexwake(process_t* proc, int* lock) {
process_t* proc0 = head_proc;
while(proc0) {
- if(proc0->parent_id == proc->id && proc0->futex == (std::uint64_t)lock) {
- proc->futex = 0;
- proc->lock.unlock();
- }
- proc0 = proc->next;
+ if((proc0->parent_id == proc->id || proc->parent_id == proc0->id) && proc0->futex == (std::uint64_t)lock) {
+ proc0->futex = 0;
+ proc0->futex_lock.unlock();
+ DEBUG(proc->is_debug,"Process which we can wakeup is %d",proc0->id);
+ }
+ proc0 = proc0->next;
}
}
-void arch::x86_64::scheduling::futexwait(process_t* proc, int* lock, int val) {
+void arch::x86_64::scheduling::futexwait(process_t* proc, int* lock, int val, int* original_lock) {
int lock_val = *lock;
if(lock_val == val) {
- proc->futex = (std::uint64_t)lock;
- proc->lock.nowaitlock();
+ proc->futex_lock.lock();
+ proc->futex = (std::uint64_t)original_lock;
}
}
@@ -405,7 +451,7 @@ extern "C" void schedulingSchedule(int_frame_t* ctx) {
while (true) {
while (current) {
- if (!current->kill_lock.test() && current->id != 0 && current_cpu == current->target_cpu) {
+ if (!current->kill_lock.test() && current->id != 0 && current_cpu == current->target_cpu && !current->futex_lock.test()) {
if(!current->lock.test_and_set()) {
if(!ctx) {
diff --git a/kernel/src/arch/x86_64/syscalls/file.cpp b/kernel/src/arch/x86_64/syscalls/file.cpp
index 0c15f68..954ad9b 100644
--- a/kernel/src/arch/x86_64/syscalls/file.cpp
+++ b/kernel/src/arch/x86_64/syscalls/file.cpp
@@ -2,6 +2,8 @@
#include <arch/x86_64/syscalls/syscalls.hpp>
#include <generic/vfs/vfs.hpp>
+#include <generic/mm/vmm.hpp>
+
#include <arch/x86_64/cpu/data.hpp>
#include <arch/x86_64/scheduling.hpp>
@@ -43,6 +45,8 @@ syscall_ret_t sys_openat(int dirfd, const char* path, int flags, int_frame_t* ct
memset(result,0,2048);
vfs::resolve_path(kpath,first_path,result,1,0);
+ //DEBUG(proc->is_debug,"Trying to open %s from proc %d",result,proc->id);
+
if(result[0] == '\0') {
result[0] = '/';
result[1] = '\0';
@@ -84,11 +88,11 @@ syscall_ret_t sys_openat(int dirfd, const char* path, int flags, int_frame_t* ct
if(status != 0)
new_fd_s->state = USERSPACE_FD_STATE_UNUSED;
-
- new_fd_s->offset = 0;
if(status != 0)
- Log::SerialDisplay(LEVEL_MESSAGE_WARN,"failed to open %s\n",result);
+ DEBUG(proc->is_debug,"Failed to open %s from proc %d",result,proc->id);
+
+ new_fd_s->offset = 0;
return {1,status,status == 0 ? new_fd : -1};
}
@@ -102,37 +106,36 @@ syscall_ret_t sys_read(int fd, void *buf, size_t count) {
if(!fd_s)
return {1,EBADF,0};
- char* temp_buffer = (char*)memory::pmm::_virtual::alloc(count + 1);
- memory::paging::maprangeid(proc->original_cr3,Other::toPhys(temp_buffer),(std::uint64_t)temp_buffer,count,PTE_PRESENT | PTE_RW,proc->id);
+ vmm_obj_t* vmm_object = memory::vmm::getlen(proc,(std::uint64_t)buf);
+ uint64_t need_phys = vmm_object->phys + ((std::uint64_t)buf - vmm_object->base);
+
+ char* temp_buffer = (char*)Other::toVirt(need_phys);
+ memset(temp_buffer,0,count);
std::int64_t bytes_read;
if(fd_s->state == USERSPACE_FD_STATE_FILE)
bytes_read = vfs::vfs::read(fd_s,temp_buffer,count);
else if(fd_s->state == USERSPACE_FD_STATE_PIPE && fd_s->pipe) {
- SYSCALL_ENABLE_PREEMPT();
bytes_read = fd_s->pipe->read(temp_buffer,count);
- SYSCALL_DISABLE_PREEMPT();
} else if(fd_s->state == USERSPACE_FD_STATE_SOCKET) {
if(!fd_s->write_socket_pipe || !fd_s->read_socket_pipe)
return {1,EFAULT,0};
+ DEBUG(proc->is_debug,"reading socket %d, buf 0x%p, count %d (target_size: %d)",fd,buf,count,fd_s->other_state == USERSPACE_FD_OTHERSTATE_MASTER ? fd_s->write_socket_pipe->size : fd_s->read_socket_pipe->size);
+
if(fd_s->other_state == USERSPACE_FD_OTHERSTATE_MASTER) {
- SYSCALL_ENABLE_PREEMPT();
bytes_read = fd_s->write_socket_pipe->read(temp_buffer,count);
- SYSCALL_DISABLE_PREEMPT();
} else {
- SYSCALL_ENABLE_PREEMPT();
bytes_read = fd_s->read_socket_pipe->read(temp_buffer,count);
- SYSCALL_DISABLE_PREEMPT();
}
+
+ if(bytes_read == 0)
+ return {1,EAGAIN,0};
+
} else
return {1,EBADF,0};
- copy_in_userspace(proc,buf,temp_buffer,bytes_read);
-
- memory::pmm::_virtual::free(temp_buffer);
-
return {1,bytes_read >= 0 ? 0 : (int)(+bytes_read), bytes_read};
}
@@ -144,9 +147,14 @@ syscall_ret_t sys_write(int fd, const void *buf, size_t count) {
if(!fd_s)
return {1,EBADF,0};
- char* temp_buffer = (char*)memory::pmm::_virtual::alloc(count + 1);
- memory::paging::maprangeid(proc->original_cr3,Other::toPhys(temp_buffer),(std::uint64_t)temp_buffer,count,PTE_PRESENT | PTE_RW,proc->id);
- copy_in_userspace(proc,temp_buffer,(void*)buf,count);
+ vmm_obj_t* vmm_object = memory::vmm::getlen(proc,(std::uint64_t)buf);
+ uint64_t need_phys = vmm_object->phys + ((std::uint64_t)buf - vmm_object->base);
+
+ char* temp_buffer = (char*)Other::toVirt(need_phys);
+
+ const char* _0 = "Content view is disabled in files";
+
+ //DEBUG(proc->is_debug,"Writing to %s (fd %d) from proc %d with content \"%s\"",fd_s->path,fd,proc->id,temp_buffer,fd_s->state != USERSPACE_FD_STATE_FILE ? temp_buffer : _0);
std::int64_t bytes_written;
if(fd_s->state == USERSPACE_FD_STATE_FILE)
@@ -160,6 +168,10 @@ syscall_ret_t sys_write(int fd, const void *buf, size_t count) {
if(!fd_s->write_socket_pipe || !fd_s->read_socket_pipe)
return {1,EFAULT,0};
+ DEBUG(proc->is_debug,"Writing to socket %d from proc %d other_state: %d, buf: 0x%p, count: %d",fd,proc->id,fd_s->other_state,buf,count);
+
+
+
if(fd_s->other_state == USERSPACE_FD_OTHERSTATE_MASTER) {
SYSCALL_ENABLE_PREEMPT();
bytes_written = fd_s->read_socket_pipe->write(temp_buffer,count);
@@ -169,11 +181,13 @@ syscall_ret_t sys_write(int fd, const void *buf, size_t count) {
bytes_written = fd_s->write_socket_pipe->write(temp_buffer,count);
SYSCALL_DISABLE_PREEMPT();
}
+
+ if(bytes_written == 0)
+ return {1,EAGAIN,0};
+
} else
return {1,EBADF,0};
- memory::pmm::_virtual::free(temp_buffer);
-
return {1,bytes_written >= 0 ? 0 : (int)(+bytes_written), bytes_written};
}
@@ -192,12 +206,6 @@ syscall_ret_t sys_seek(int fd, long offset, int whence) {
if(fd_s->state == USERSPACE_FD_STATE_PIPE || fd_s->is_a_tty)
return {1,0,0};
- vfs::stat_t stat;
- int res = vfs::vfs::stat(fd_s,&stat);
-
- if(res != 0)
- return {1,res,0};
-
switch (whence)
{
case SEEK_SET:
@@ -208,9 +216,16 @@ syscall_ret_t sys_seek(int fd, long offset, int whence) {
fd_s->offset += offset;
break;
- case SEEK_END:
+ case SEEK_END: {
+ vfs::stat_t stat;
+ int res = vfs::vfs::stat(fd_s,&stat);
+
+ if(res != 0)
+ return {1,res,0};
+
fd_s->offset = stat.st_size + offset;
break;
+ }
default:
return {1,EINVAL,0};
@@ -253,6 +268,8 @@ syscall_ret_t sys_stat(int fd, void* out, int flags) {
if(!fd_s)
return {0,EBADF,0};
+ //DEBUG(proc->is_debug,"Trying to stat %s (fd %d) from proc %d",fd_s->path,fd,proc->id);
+
if(fd_s->state == USERSPACE_FD_STATE_FILE) {
vfs::stat_t stat;
int status;
@@ -286,7 +303,6 @@ syscall_ret_t sys_pipe(int flags) {
userspace_fd_t* fd1 = vfs::fdmanager::search(proc,read_fd);
userspace_fd_t* fd2 = vfs::fdmanager::search(proc,write_fd);
- Log::SerialDisplay(LEVEL_MESSAGE_INFO,"sys_pipe flags 0x%p\n",flags);
vfs::pipe* new_pipe = new vfs::pipe(flags);
fd1->pipe_side = PIPE_SIDE_READ;
fd2->pipe_side = PIPE_SIDE_WRITE;
@@ -321,6 +337,8 @@ syscall_ret_t sys_dup(int fd, int flags) {
nfd_s->read_counter = fd_s->read_counter;
nfd_s->write_counter = fd_s->write_counter;
nfd_s->can_be_closed = fd_s->can_be_closed;
+ nfd_s->write_socket_pipe = fd_s->write_socket_pipe;
+ nfd_s->read_socket_pipe = fd_s->read_socket_pipe;
memcpy(nfd_s->path,fd_s->path,sizeof(fd_s->path));
@@ -335,8 +353,6 @@ syscall_ret_t sys_dup2(int fd, int flags, int newfd) {
userspace_fd_t* fd_s = vfs::fdmanager::search(proc,fd);
- Log::SerialDisplay(LEVEL_MESSAGE_INFO,"dup2 from %d to %d in proc %d with flags 0x%p\n",fd,newfd,proc->id,flags);
-
if(!fd_s)
return {0,EBADF,0};
@@ -361,6 +377,8 @@ syscall_ret_t sys_dup2(int fd, int flags, int newfd) {
nfd_s->write_counter = fd_s->write_counter;
nfd_s->read_counter = fd_s->read_counter;
nfd_s->can_be_closed = fd_s->can_be_closed;
+ nfd_s->read_socket_pipe = fd_s->read_socket_pipe;
+ nfd_s->write_socket_pipe = fd_s->write_socket_pipe;
if(nfd_s->state == USERSPACE_FD_STATE_PIPE)
nfd_s->pipe->create(nfd_s->pipe_side);
@@ -458,8 +476,6 @@ syscall_ret_t sys_isatty(int fd) {
if(!fd_s)
return {0,EBADF,0};
- Log::SerialDisplay(LEVEL_MESSAGE_INFO,"isatty fd %d with state %d\n",fd,fd_s->state);
-
if(fd_s->state == USERSPACE_FD_STATE_PIPE || fd_s->state == USERSPACE_FD_STATE_SOCKET)
return {0,ENOTTY,0};
@@ -553,7 +569,7 @@ syscall_ret_t sys_read_dir(int fd, void* buffer) {
}
syscall_ret_t sys_fcntl(int fd, int request, std::uint64_t arg) {
- Log::SerialDisplay(LEVEL_MESSAGE_INFO,"fcntl %d\n",request);
+
switch(request) {
case F_DUPFD: {
return sys_dup(fd,arg);
@@ -577,9 +593,22 @@ syscall_ret_t sys_fcntl(int fd, int request, std::uint64_t arg) {
fd_s->flags &= ~(O_APPEND | O_ASYNC | O_NONBLOCK);
fd_s->flags |= (arg & (O_APPEND | O_ASYNC | O_NONBLOCK));
+ DEBUG(proc->is_debug,"Fcntl fd %d O_NONBLOCK %d from proc %d",fd,(fd_s->flags & O_NONBLOCK) ? 1 : 0,proc->id);
+
if(fd_s->state == USERSPACE_FD_STATE_PIPE) {
fd_s->pipe->flags & ~(O_NONBLOCK);
fd_s->pipe->flags |= (arg & O_NONBLOCK);
+ } else if(fd_s->state == USERSPACE_FD_STATE_SOCKET) {
+ if(fd_s->read_socket_pipe) {
+ fd_s->read_socket_pipe->flags & ~(O_NONBLOCK);
+ fd_s->read_socket_pipe->flags |= (arg & O_NONBLOCK);
+ }
+
+ if(fd_s->write_socket_pipe) {
+ fd_s->write_socket_pipe->flags & ~(O_NONBLOCK);
+ fd_s->write_socket_pipe->flags |= (arg & O_NONBLOCK);
+ }
+
}
return {1,0,0};
@@ -635,6 +664,7 @@ syscall_ret_t sys_mkfifoat(int dirfd, const char *path, int mode) {
vfs::resolve_path(kpath,first_path,result,1,0);
userspace_fd_t new_fd_s;
+ new_fd_s.is_cached_path = 0;
memset(new_fd_s.path,0,2048);
memcpy(new_fd_s.path,result,strlen(result));
@@ -645,7 +675,6 @@ syscall_ret_t sys_mkfifoat(int dirfd, const char *path, int mode) {
int status = vfs::vfs::create_fifo(result);
- Log::SerialDisplay(LEVEL_MESSAGE_INFO,"new fifo %s status %d\n",result,status);
return {0,status,0};
}
@@ -673,12 +702,19 @@ syscall_ret_t sys_poll(struct pollfd *fds, int count, int timeout) {
if(!fd0)
return {1,EINVAL,0};
+ DEBUG(proc->is_debug,"Trying to poll %s operation %d (fd %d with state %d, read_socket: 0x%p, write_socket: 0x%p) with timeout %d in proc %d",fd0->path,fd[i].events,fd[i].fd,fd0->state,fd0->read_socket_pipe,fd0->write_socket_pipe,timeout,proc->id);
+
if(fd[i].events & POLLIN)
total_events++;
if(fd[i].events & POLLOUT)
total_events++;
+ if(fd0->state == USERSPACE_FD_STATE_SOCKET && fd0->is_listen && fd0->read_counter == -1) {
+ fd0->read_counter = 0;
+ fd0->write_counter = 0;
+ }
+
if(fd0->write_counter == -1) {
std::int64_t ret = vfs::vfs::poll(fd0,POLLOUT);
fd0->write_counter = ret < 0 ? 0 : ret;
@@ -693,9 +729,46 @@ syscall_ret_t sys_poll(struct pollfd *fds, int count, int timeout) {
int num_events = 0;
- SYSCALL_ENABLE_PREEMPT();
-
int success = true;
+ int something_bad = 0;
+
+ if(timeout == -1) {
+ for(int i = 0;i < count; i++) {
+ userspace_fd_t* fd0 = vfs::fdmanager::search(proc,fd[i].fd);
+ if(fd[i].events & POLLIN) {
+ std::int64_t ret = vfs::vfs::poll(fd0,POLLIN);
+ if(fd0->is_listen)
+ DEBUG(proc->is_debug,"ret %d readcounter %d",ret,fd0->read_counter);
+ if(ret > fd0->read_counter) {
+ fd0->read_counter = ret;
+ num_events++;
+ fd[i].revents |= POLLIN;
+ }
+ }
+
+ if(fd[i].events & POLLOUT) {
+ std::int64_t ret = vfs::vfs::poll(fd0,POLLOUT);
+ if(ret > fd0->write_counter || ret == 0) {
+ fd0->write_counter = ret;
+ num_events++;
+ fd[i].revents |= POLLOUT;
+ }
+
+ }
+
+ if(num_events)
+ success = false;
+ }
+ }
+
+ if(success == false) {
+ copy_in_userspace(proc,fds,fd,count * sizeof(struct pollfd));
+
+ return {1,0,num_events};
+ }
+
+ success = true;
+ num_events = 0;
if(timeout == -1) {
while(success) {
@@ -705,22 +778,26 @@ syscall_ret_t sys_poll(struct pollfd *fds, int count, int timeout) {
SYSCALL_DISABLE_PREEMPT();
std::int64_t ret = vfs::vfs::poll(fd0,POLLIN);
SYSCALL_ENABLE_PREEMPT();
+ if(fd0->is_listen)
+ DEBUG(proc->is_debug,"ret %d readcounter %d",ret,fd0->read_counter);
if(ret > fd0->read_counter) {
fd0->read_counter = ret;
num_events++;
fd[i].revents |= POLLIN;
}
+
}
if(fd[i].events & POLLOUT) {
SYSCALL_DISABLE_PREEMPT();
std::int64_t ret = vfs::vfs::poll(fd0,POLLOUT);
SYSCALL_ENABLE_PREEMPT();
- if(ret > fd0->write_counter) {
+ if(ret > fd0->write_counter || ret == 0) {
fd0->write_counter = ret;
num_events++;
fd[i].revents |= POLLOUT;
}
+
}
if(num_events)
@@ -740,6 +817,7 @@ syscall_ret_t sys_poll(struct pollfd *fds, int count, int timeout) {
num_events++;
fd[i].revents |= POLLIN;
}
+
}
if(fd[i].events & POLLOUT) {
@@ -751,6 +829,7 @@ syscall_ret_t sys_poll(struct pollfd *fds, int count, int timeout) {
num_events++;
fd[i].revents |= POLLOUT;
}
+
}
if(num_events)
@@ -795,11 +874,100 @@ syscall_ret_t sys_readlinkat(int dirfd, const char* path, void* buffer, int_fram
int ret = vfs::vfs::readlink(result,readlink_buf,2048);
vfs::vfs::unlock();
- if(ret != 0)
+ if(ret != 0) {
+
return {1,ret,0};
+ }
copy_in_userspace(proc,buffer,readlink_buf, strlen(readlink_buf) > max_size ? max_size : strlen(readlink_buf));
return {1,0,(int64_t)(strlen(readlink_buf) > max_size ? max_size : strlen(readlink_buf))};
+}
+
+syscall_ret_t sys_link(char* old_path, char* new_path) {
+ char old_path0[2048];
+ char new_path0[2048];
+ memset(old_path0,0,2048);
+ memset(new_path0,0,2048);
+
+ SYSCALL_IS_SAFEA((void*)old_path,2048);
+ SYSCALL_IS_SAFEA((void*)new_path,2048);
+
+ arch::x86_64::process_t* proc = CURRENT_PROC;
+
+ copy_in_userspace_string(proc,old_path0,old_path,2048);
+ copy_in_userspace_string(proc,new_path0,new_path,2048);
+
+ int ret = vfs::vfs::create(new_path0,VFS_TYPE_SYMLINK);
+
+ if(ret != 0)
+ return {0,ret,0};
+
+ userspace_fd_t fd;
+ fd.is_cached_path = 0;
+ fd.offset = 0;
+ memset(fd.path,0,2048);
+ memcpy(fd.path,new_path0,strlen(new_path0));
+
+ ret = vfs::vfs::write(&fd,old_path0,2047);
+
+ return {0,0,0};
+
+}
+
+syscall_ret_t sys_mkdirat(int dirfd, char* path, int mode) {
+ SYSCALL_IS_SAFEA((void*)path,0);
+
+ arch::x86_64::process_t* proc = CURRENT_PROC;
+
+ char first_path[2048];
+ memset(first_path,0,2048);
+ if(dirfd >= 0)
+ memcpy(first_path,vfs::fdmanager::search(proc,dirfd)->path,strlen(vfs::fdmanager::search(proc,dirfd)->path));
+ else if(dirfd == AT_FDCWD)
+ memcpy(first_path,proc->cwd,strlen(proc->cwd));
+
+ char kpath[2048];
+ memset(kpath,0,2048);
+ copy_in_userspace_string(proc,kpath,(void*)path,2048);
+
+ char result[2048];
+ memset(result,0,2048);
+ vfs::resolve_path(kpath,first_path,result,1,0);
+
+ int ret = vfs::vfs::create(result,VFS_TYPE_DIRECTORY);
+
+ userspace_fd_t fd;
+ fd.is_cached_path = 0;
+ memcpy(fd.path,result,2048);
+
+ vfs::vfs::var(&fd,mode,TMPFS_VAR_CHMOD | (1 << 7));
+ return {0,ret,0};
+}
+
+syscall_ret_t sys_chmod(char* path, int mode) {
+ SYSCALL_IS_SAFEA((void*)path,0);
+
+ arch::x86_64::process_t* proc = CURRENT_PROC;
+
+ char result[2048];
+ memset(result,0,2048);
+
+ copy_in_userspace_string(proc,result,path,2048);
+
+ userspace_fd_t fd;
+ fd.is_cached_path = 0;
+ memset(&fd,0,sizeof(fd));
+ memcpy(fd.path,result,2048);
+
+ uint64_t value;
+ int ret = vfs::vfs::var(&fd,(uint64_t)&value,TMPFS_VAR_CHMOD);
+
+ if(ret != 0)
+ return {0,ret,0};
+
+ ret = vfs::vfs::var(&fd,value | mode, TMPFS_VAR_CHMOD | (1 << 7));
+
+ return {0,ret,0};
} \ No newline at end of file
diff --git a/kernel/src/arch/x86_64/syscalls/futex.cpp b/kernel/src/arch/x86_64/syscalls/futex.cpp
index cf1249a..7e32717 100644
--- a/kernel/src/arch/x86_64/syscalls/futex.cpp
+++ b/kernel/src/arch/x86_64/syscalls/futex.cpp
@@ -5,16 +5,19 @@
#include <arch/x86_64/scheduling.hpp>
syscall_ret_t sys_futex_wait(int* pointer, int excepted) {
- Log::SerialDisplay(LEVEL_MESSAGE_INFO,"sys_futex_wait\n");
+
arch::x86_64::process_t* proc = arch::x86_64::cpu::data()->temp.proc;
int copied_pointer_val = 0;
copy_in_userspace(proc,&copied_pointer_val,pointer,sizeof(int));
- arch::x86_64::scheduling::futexwait(proc,&copied_pointer_val,excepted);
+ DEBUG(proc->is_debug,"Waiting for futex, pointer: 0x%p excepted: %d, pointer_value %d in proc %d",pointer,excepted,copied_pointer_val,proc->id);
+ arch::x86_64::scheduling::futexwait(proc,&copied_pointer_val,excepted,pointer);
+ asm volatile("int $32"); // yield
return {0,0,0};
}
syscall_ret_t sys_futex_wake(int* pointer) {
arch::x86_64::process_t* proc = arch::x86_64::cpu::data()->temp.proc;
+ DEBUG(proc->is_debug,"Wakeup futex with pointer 0x%p in proc %d",pointer,proc->id);
arch::x86_64::scheduling::futexwake(proc,pointer);
return {0,0,0};
}
diff --git a/kernel/src/arch/x86_64/syscalls/process.cpp b/kernel/src/arch/x86_64/syscalls/process.cpp
index ab04ba5..c06c407 100644
--- a/kernel/src/arch/x86_64/syscalls/process.cpp
+++ b/kernel/src/arch/x86_64/syscalls/process.cpp
@@ -32,6 +32,7 @@
syscall_ret_t sys_tcb_set(std::uint64_t fs) {
arch::x86_64::process_t* proc = CURRENT_PROC;
__wrmsr(0xC0000100,fs);
+ DEBUG(proc->is_debug,"Setting tcb %p to proc %d",fs,proc->id);
return {0,0,0};
}
@@ -40,7 +41,8 @@ syscall_ret_t sys_libc_log(const char* msg) {
char buffer[2048];
memset(buffer,0,2048);
copy_in_userspace_string(proc,buffer,(void*)msg,2048);
- Log::SerialDisplay(LEVEL_MESSAGE_INFO,"libc_log from proc %d: %s\n",proc->id,buffer);
+ DEBUG(proc->is_debug,"%s from proc %d",buffer,proc->id);
+
return {0,0,0};
}
@@ -62,12 +64,14 @@ syscall_ret_t sys_exit(int status) {
}
arch::x86_64::scheduling::kill(proc);
- memory::vmm::free(proc);
+
+ if(!proc->is_cloned)
+ memory::vmm::free(proc);
+
memory::pmm::_virtual::free(proc->cwd);
memory::pmm::_virtual::free(proc->name);
memory::pmm::_virtual::free(proc->sse_ctx);
-
- Log::SerialDisplay(LEVEL_MESSAGE_INFO,"Process %d exited with code %d\n",proc->id,proc->exit_code);
+ DEBUG(proc->is_debug,"Process %d exited with code %d",proc->id,status);
schedulingScheduleAndChangeStack(arch::x86_64::cpu::data()->timer_ist_stack,0);
__builtin_unreachable();
}
@@ -77,10 +81,11 @@ syscall_ret_t sys_mmap(std::uint64_t hint, std::uint64_t size, int fd0, int_fram
arch::x86_64::process_t* proc = CURRENT_PROC;
if(flags & MAP_ANONYMOUS) {
std::uint64_t new_hint = hint;
+ int is_shared = (flags & MAP_SHARED) ? 1 : 0;
if(!new_hint)
- new_hint = (std::uint64_t)memory::vmm::alloc(proc,size,PTE_PRESENT | PTE_USER | PTE_RW);
+ new_hint = (std::uint64_t)memory::vmm::alloc(proc,size,PTE_PRESENT | PTE_USER | PTE_RW,is_shared == 1 ? 1 : 0);
else
- memory::vmm::customalloc(proc,new_hint,size,PTE_PRESENT | PTE_RW | PTE_USER);
+ memory::vmm::customalloc(proc,new_hint,size,PTE_PRESENT | PTE_RW | PTE_USER,is_shared == 1 ? 1 : 0);
return {1,0,(std::int64_t)new_hint};
} else {
@@ -89,13 +94,18 @@ syscall_ret_t sys_mmap(std::uint64_t hint, std::uint64_t size, int fd0, int_fram
std::uint64_t mmap_size = 0;
std::uint64_t mmap_flags = 0;
userspace_fd_t* fd = vfs::fdmanager::search(proc,fd0);
+
+ DEBUG(proc->is_debug,"Trying to mmap fd %d from proc %d",fd0,proc->id);
if(!fd)
return {1,EBADF,0};
+ DEBUG(proc->is_debug,"Trying to mmap %s from proc %d",fd->path,proc->id);
+
int status = vfs::vfs::mmap(fd,&mmap_base,&mmap_size,&mmap_flags);
if(status != 0)
return {1,status,0};
std::uint64_t new_hint_hint = (std::uint64_t)memory::vmm::map(proc,mmap_base,mmap_size,PTE_PRESENT | PTE_USER | PTE_RW | mmap_flags);
+
return {1,0,(std::int64_t)new_hint_hint};
}
}
@@ -119,6 +129,8 @@ syscall_ret_t sys_fork(int D, int S, int d, int_frame_t* ctx) {
arch::x86_64::scheduling::wakeup(new_proc);
+ DEBUG(proc->is_debug,"Fork from proc %d, new proc %d",proc->id,new_proc->id);
+ new_proc->is_debug = proc->is_debug;
return {1,0,new_proc->id};
}
@@ -215,11 +227,19 @@ syscall_ret_t sys_exec(char* path, char** argv, char** envp, int_frame_t* ctx) {
vfs::stat_t stat;
userspace_fd_t fd;
+ fd.is_cached_path = 0;
memset(fd.path,0,2048);
memcpy(fd.path,result,strlen(result));
int status = vfs::vfs::stat(&fd,&stat);
+ DEBUG(proc->is_debug,"Exec file %s from proc %d",fd.path,proc->id);
+ if(proc->is_debug) {
+ for(int i = 0;i < argv_length;i++) {
+ DEBUG(proc->is_debug,"Argv %d: %s",i,argv0[i]);
+ }
+ }
+
if(status == 0) {
if((stat.st_mode & S_IXUSR) && (stat.st_mode & S_IFREG)) {
@@ -254,10 +274,19 @@ syscall_ret_t sys_exec(char* path, char** argv, char** envp, int_frame_t* ctx) {
schedulingScheduleAndChangeStack(arch::x86_64::cpu::data()->timer_ist_stack,0);
__builtin_unreachable();
}
- status = -1;
+
+ // maybe sh ?
+ char interp[2048];
+ memset(interp,0,2048);
+
+ int i = 0;
+ memcpy(interp,"/bin/sh",strlen("/bin/sh"));
+
}
}
+
+
for(int i = 0;i < argv_length; i++) {
memory::heap::free(argv0[i]);
}
@@ -269,13 +298,9 @@ syscall_ret_t sys_exec(char* path, char** argv, char** envp, int_frame_t* ctx) {
memory::heap::free(argv0);
memory::heap::free(envp0);
- if(status == -1) {
- Log::SerialDisplay(LEVEL_MESSAGE_INFO,"exec error\n");
- arch::x86_64::scheduling::kill(proc);
- schedulingScheduleAndChangeStack(arch::x86_64::cpu::data()->timer_ist_stack,0);
- __builtin_unreachable();
- } else
- return {0,status,0};
+ arch::x86_64::scheduling::kill(proc);
+ schedulingScheduleAndChangeStack(arch::x86_64::cpu::data()->timer_ist_stack,0);
+ __builtin_unreachable();
}
syscall_ret_t sys_getpid() {
@@ -320,11 +345,13 @@ syscall_ret_t sys_getcwd(void* buffer, std::uint64_t bufsize) {
return {0,0,0};
}
-syscall_ret_t sys_waitpid(int pid) {
+syscall_ret_t sys_waitpid(int pid,int flags) {
arch::x86_64::process_t* proc = CURRENT_PROC;
arch::x86_64::process_t* current = arch::x86_64::scheduling::head_proc_();
+
+ DEBUG(proc->is_debug,"Trying to waitpid with pid %d from proc %d",pid,proc->id);
if(pid < -1 || pid == 0)
return {0,ENOSYS,0};
@@ -371,11 +398,24 @@ syscall_ret_t sys_waitpid(int pid) {
current->waitpid_state = 2;
std::int64_t bro = (std::int64_t)(((std::uint64_t)current->exit_code) << 32) | current->id;
current->status = PROCESS_STATE_KILLED;
+ DEBUG(proc->is_debug,"Waitpid done pid %d from proc %d",pid,proc->id);
return {1,0,bro};
}
}
current = current->next;
}
+
+ if(flags & WNOHANG) {
+ arch::x86_64::process_t* pro = arch::x86_64::scheduling::head_proc_();
+ while(pro) {
+ if(pro->parent_id == parent_id && proc->waitpid_state == 1)
+ proc->waitpid_state = 0;
+ pro = pro->next;
+ }
+ DEBUG(proc->is_debug,"Waitpid return WNOHAND from proc %d",proc->id);
+ return {1,0,0};
+ }
+
current = arch::x86_64::scheduling::head_proc_();
}
@@ -403,4 +443,31 @@ syscall_ret_t sys_map_phys(std::uint64_t phys, std::uint64_t flags, std::uint64_
syscall_ret_t sys_timestamp() {
return {1,0,(std::int64_t)drivers::tsc::currentnano()};
+}
+
+syscall_ret_t sys_enabledebugmode() {
+ arch::x86_64::process_t* proc = CURRENT_PROC;
+ proc->is_debug = 1;
+ DEBUG(proc->is_debug,"Enabling debug mode for proc %d",proc->id);
+ return {0,0,0};
+}
+
+syscall_ret_t sys_clone(std::uint64_t stack, std::uint64_t rip, int c, int_frame_t* ctx) {
+ arch::x86_64::process_t* proc = CURRENT_PROC;
+
+ arch::x86_64::process_t* new_proc = arch::x86_64::scheduling::clone(proc,ctx);
+ memory::paging::maprangeid(new_proc->original_cr3,Other::toPhys(new_proc->syscall_stack),(std::uint64_t)new_proc->syscall_stack,SYSCALL_STACK_SIZE,PTE_USER | PTE_PRESENT | PTE_RW,*new_proc->vmm_id);
+
+ new_proc->ctx.rax = 0;
+ new_proc->ctx.rdx = 0;
+
+ new_proc->ctx.rsp = stack;
+ new_proc->ctx.rip = rip;
+
+ arch::x86_64::scheduling::wakeup(new_proc);
+
+ DEBUG(proc->is_debug,"Clone from proc %d, new proc %d (new syscall_stack: 0x%p)",proc->id,new_proc->id,new_proc->syscall_stack);
+ new_proc->is_debug = proc->is_debug;
+
+ return {1,0,new_proc->id};
} \ No newline at end of file
diff --git a/kernel/src/arch/x86_64/syscalls/sockets.cpp b/kernel/src/arch/x86_64/syscalls/sockets.cpp
index ed450b5..8f1f48a 100644
--- a/kernel/src/arch/x86_64/syscalls/sockets.cpp
+++ b/kernel/src/arch/x86_64/syscalls/sockets.cpp
@@ -72,10 +72,13 @@ int sockets::bind(userspace_fd_t* fd, struct sockaddr_un* path) {
memset(fd->path,0,2048);
memcpy(fd->path,path->sun_path,strlen(path->sun_path));
+ SYSCALL_DISABLE_PREEMPT();
vfs::stat_t stat;
if(vfs::vfs::stat(fd,&stat) == 0) /* Check is there vfs object with some name */
return EEXIST;
+ SYSCALL_ENABLE_PREEMPT();
+
socket_spinlock.lock();
if(find_node(path)) { socket_spinlock.unlock();
@@ -85,6 +88,7 @@ int sockets::bind(userspace_fd_t* fd, struct sockaddr_un* path) {
memset(new_node->path,0,128);
memcpy(new_node->path,path->sun_path,108);
new_node->is_used = 1;
+ new_node->socket_counter = 0;
new_node->next = head;
head = new_node;
socket_spinlock.unlock();
@@ -113,6 +117,8 @@ int sockets::connect(userspace_fd_t* fd, struct sockaddr_un* path) {
pending->is_accepted.unlock();
node->pending_list = pending;
+ node->socket_counter++;
+
while(!pending->is_accepted.test()) { socket_spinlock.unlock(); asm volatile("pause"); socket_spinlock.lock(); }
socket_spinlock.unlock();
@@ -147,6 +153,7 @@ int sockets::accept(userspace_fd_t* fd, struct sockaddr_un* path) {
new_fd_s->pipe_side = 0;
new_fd_s->cycle = 0;
new_fd_s->is_a_tty = 0;
+ new_fd_s->is_cached_path = 0;
new_fd_s->state = USERSPACE_FD_STATE_SOCKET;
new_fd_s->other_state = USERSPACE_FD_OTHERSTATE_MASTER; // master - writes to read pipe and reads from write pipe
@@ -205,10 +212,14 @@ syscall_ret_t sys_connect(int fd, struct sockaddr_un* path, int len) {
memset(&spath,0,sizeof(spath));
copy_in_userspace(proc,&spath,path,len > sizeof(spath) ? sizeof(spath) : len);
+ DEBUG(proc->is_debug,"Trying to connect to socket %s from proc %d",spath.sun_path,proc->id);
+
SYSCALL_ENABLE_PREEMPT();
int status = sockets::connect(fd_s,&spath);
SYSCALL_DISABLE_PREEMPT();
+ DEBUG(proc->is_debug,"Socket is connected %s from proc %d",spath.sun_path,proc->id);
+
return {0,status,0};
}
@@ -220,9 +231,6 @@ syscall_ret_t sys_bind(int fd, struct sockaddr_un* path, int len) {
if(!path)
return {0,EINVAL,0};
- if(path->sun_family != AF_UNIX)
- return {0,ENOSYS,0};
-
if(!fd_s)
return {0,EBADF,0};
@@ -231,7 +239,11 @@ syscall_ret_t sys_bind(int fd, struct sockaddr_un* path, int len) {
memset(&spath,0,sizeof(spath));
copy_in_userspace(proc,&spath,path,len > sizeof(spath) ? sizeof(spath) : len);
+ DEBUG(proc->is_debug,"Binding socket from fd %d to %s from proc %d",fd,spath.sun_path,proc->id);
+
+ SYSCALL_ENABLE_PREEMPT();
int status = sockets::bind(fd_s,&spath);
+ SYSCALL_DISABLE_PREEMPT();
return {0,status,0};
}
@@ -246,8 +258,6 @@ syscall_ret_t sys_accept(int fd, struct sockaddr_un* path, int len) {
if(path) {
memset(&spath,0,sizeof(spath));
copy_in_userspace(proc,&spath,path,len > sizeof(spath) ? sizeof(spath) : len);
- if(spath.sun_family != AF_UNIX)
- return {0,ENOSYS,0};
}
if(!fd_s)
@@ -257,6 +267,8 @@ syscall_ret_t sys_accept(int fd, struct sockaddr_un* path, int len) {
int status = sockets::accept(fd_s,path != 0 ? &spath : 0);
SYSCALL_DISABLE_PREEMPT();
+ DEBUG(proc->is_debug,"Accepting socket %s on fd %d from proc %d",fd_s->path,fd,proc->id);
+
if(path)
copy_in_userspace(proc,path,&spath,len > sizeof(spath) ? sizeof(spath) : len);
@@ -265,11 +277,12 @@ syscall_ret_t sys_accept(int fd, struct sockaddr_un* path, int len) {
syscall_ret_t sys_socket(int family, int type, int protocol) {
arch::x86_64::process_t* proc = CURRENT_PROC;
- int new_fd = vfs::fdmanager::create(proc);
if(family != AF_UNIX)
return {0,ENOSYS,0};
+ int new_fd = vfs::fdmanager::create(proc);
+
userspace_fd_t* new_fd_s = vfs::fdmanager::search(proc,new_fd);
memset(new_fd_s->path,0,2048);
@@ -279,14 +292,28 @@ syscall_ret_t sys_socket(int family, int type, int protocol) {
new_fd_s->pipe_side = 0;
new_fd_s->cycle = 0;
new_fd_s->is_a_tty = 0;
+ new_fd_s->is_listen = 0;
new_fd_s->state = USERSPACE_FD_STATE_SOCKET;
- Log::SerialDisplay(LEVEL_MESSAGE_INFO,"sys_socket %d\n",new_fd);
+ DEBUG(proc->is_debug,"Creating socket on fd %d from proc %d",new_fd,proc->id);
return {1,0,new_fd};
}
syscall_ret_t sys_listen(int fd, int backlog) {
+ arch::x86_64::process_t* proc = CURRENT_PROC;
+ userspace_fd_t* fd_s = vfs::fdmanager::search(proc,fd);
+
+ if(!fd_s)
+ return {0,EBADF,0};
+
+ if(fd_s->state == USERSPACE_FD_STATE_SOCKET) {
+ if(!fd_s->read_socket_pipe) { // not connected
+ fd_s->is_listen = 1;
+ }
+ } else
+ return {0,ENOTSOCK,0};
+
return {0,0,0};
}
diff --git a/kernel/src/arch/x86_64/syscalls/syscalls.cpp b/kernel/src/arch/x86_64/syscalls/syscalls.cpp
index 523eaf3..bb721be 100644
--- a/kernel/src/arch/x86_64/syscalls/syscalls.cpp
+++ b/kernel/src/arch/x86_64/syscalls/syscalls.cpp
@@ -58,7 +58,12 @@ arch::x86_64::syscall_item_t sys_table[] = {
{46,(void*)sys_timestamp},
{47,(void*)sys_mkfifoat},
{48,(void*)sys_poll},
- {49,(void*)sys_readlinkat}
+ {49,(void*)sys_readlinkat},
+ {50,(void*)sys_link},
+ {51,(void*)sys_mkdirat},
+ {52,(void*)sys_chmod},
+ {53,(void*)sys_enabledebugmode},
+ {54,(void*)sys_clone}
};
arch::x86_64::syscall_item_t* __syscall_find(int rax) {
@@ -77,8 +82,11 @@ extern "C" void syscall_handler_c(int_frame_t* ctx) {
return;
} else if(!item->syscall_func) {
return;
- }
+ }
+
+ arch::x86_64::process_t* proc = arch::x86_64::cpu::data()->temp.proc;
+
syscall_ret_t (*sys)(std::uint64_t D, std::uint64_t S, std::uint64_t d, int_frame_t* frame) = (syscall_ret_t (*)(std::uint64_t, std::uint64_t, std::uint64_t, int_frame_t*))item->syscall_func;
syscall_ret_t ret = sys(ctx->rdi,ctx->rsi,ctx->rdx,ctx);
if(ret.is_rdx_ret) {
@@ -86,7 +94,7 @@ extern "C" void syscall_handler_c(int_frame_t* ctx) {
}
if(ret.ret != 0)
- Log::Raw("non zero ret %d from sys %d\n",ret.ret,item->syscall_num);
+ DEBUG(proc->is_debug,"Syscall %d from proc %d fails with code %d",ctx->rax,proc->id,ret.ret);
ctx->rax = ret.ret;
return;
diff --git a/kernel/src/generic/mm/pmm.cpp b/kernel/src/generic/mm/pmm.cpp
index 5695214..22f89df 100644
--- a/kernel/src/generic/mm/pmm.cpp
+++ b/kernel/src/generic/mm/pmm.cpp
@@ -206,6 +206,35 @@ std::int64_t memory::buddy::alloc(std::size_t size) {
}
+alloc_t memory::buddy::alloc_ext(std::size_t size) {
+ std::uint64_t top_size = UINT64_MAX;
+ buddy_info_t* nearest_buddy = 0;
+
+ if(size < 4096)
+ size = 4096;
+
+ for(std::uint64_t i = 0;i < mem.buddy_queue; i++) {
+ if(LEVEL_TO_SIZE(mem.mem[i].level) >= size && LEVEL_TO_SIZE(mem.mem[i].level) < top_size && mem.mem[i].is_free) {
+ top_size = LEVEL_TO_SIZE(mem.mem[i].level);
+ nearest_buddy = &mem.mem[i];
+ }
+ }
+
+ if(nearest_buddy) {
+ auto blud = split_maximum(nearest_buddy,size);
+ blud->is_free = 0;
+ memset(Other::toVirt(blud->phys),0,LEVEL_TO_SIZE(blud->level));
+
+ alloc_t result;
+ result.real_size = LEVEL_TO_SIZE(blud->level);
+ result.virt = blud->phys;
+
+ return result;
+ }
+
+ return {0,0};
+}
+
std::int64_t memory::buddy::allocid(std::size_t size,std::uint32_t id0) {
std::uint64_t top_size = UINT64_MAX;
buddy_info_t* nearest_buddy = 0;
@@ -287,6 +316,14 @@ void* memory::pmm::_virtual::alloc(std::size_t size) {
return Other::toVirt(memory::pmm::_physical::alloc(size));
}
+alloc_t memory::pmm::_physical::alloc_ext(std::size_t size) {
+ pmm_lock.lock();
+ alloc_t result = memory::buddy::alloc_ext(size);
+ result.virt = (std::uint64_t)Other::toVirt(result.virt);
+ pmm_lock.unlock();
+ return result;
+}
+
/* some helper functions */
#include <generic/mm/paging.hpp>
diff --git a/kernel/src/generic/vfs/devfs.cpp b/kernel/src/generic/vfs/devfs.cpp
index ad33c7a..9b3dda0 100644
--- a/kernel/src/generic/vfs/devfs.cpp
+++ b/kernel/src/generic/vfs/devfs.cpp
@@ -219,6 +219,8 @@ std::int64_t __devfs__poll(userspace_fd_t* fd, char* path, int operation_type) {
extern locks::spinlock* vfs_lock;
+
+
std::int64_t vfs::devfs::send_packet(char* path,devfs_packet_t* packet) {
devfs_node_t* node = devfs_find_dev(path);
diff --git a/kernel/src/generic/vfs/tmpfs.cpp b/kernel/src/generic/vfs/tmpfs.cpp
index 6c4f0a0..a9acba2 100644
--- a/kernel/src/generic/vfs/tmpfs.cpp
+++ b/kernel/src/generic/vfs/tmpfs.cpp
@@ -6,6 +6,8 @@
#include <generic/mm/pmm.hpp>
#include <generic/mm/heap.hpp>
+#include <etc/etc.hpp>
+
#include <etc/libc.hpp>
#include <etc/errno.hpp>
@@ -64,6 +66,44 @@ std::uint8_t __tmpfs__exists(char* path) {
std::uint8_t __tmpfs__create_parent_dirs_by_default = 1; /* Used for ustar */
+NodePoolBlock* node_pool_blocks_head = 0;
+
+vfs::tmpfs_node_t* node_pool_current = 0;
+size_t node_pool_offset = 0;
+size_t node_pool_capacity = 0;
+
+static void allocate_node_pool_block() {
+ void* block = memory::pmm::_virtual::alloc(NODE_POOL_BLOCK_SIZE);
+ if (!block) {
+ return;
+ }
+
+ NodePoolBlock* new_block = (NodePoolBlock*)memory::pmm::_virtual::alloc(sizeof(NodePoolBlock));
+ if (!new_block) {
+ return;
+ }
+ new_block->block = reinterpret_cast<vfs::tmpfs_node_t*>(block);
+ new_block->next = node_pool_blocks_head;
+ node_pool_blocks_head = new_block;
+
+ node_pool_current = new_block->block;
+ node_pool_offset = 0;
+ node_pool_capacity = NODE_POOL_BLOCK_SIZE / sizeof(vfs::tmpfs_node_t);;
+}
+
+static vfs::tmpfs_node_t* allocate_node_from_pool() {
+ if (!node_pool_current || node_pool_offset >= node_pool_capacity) {
+ allocate_node_pool_block();
+ if (!node_pool_current) {
+ return 0;
+ }
+ }
+ vfs::tmpfs_node_t* node = node_pool_current + node_pool_offset;
+ node_pool_offset++;
+ memset(node, 0, sizeof(vfs::tmpfs_node_t));
+ return node;
+}
+
std::int32_t __tmpfs__create(char* path,std::uint8_t type) {
if(__tmpfs__exists(path))
@@ -98,7 +138,7 @@ std::int32_t __tmpfs__create(char* path,std::uint8_t type) {
}
if(!node)
- node = (vfs::tmpfs_node_t*)memory::pmm::_virtual::alloc(4096);
+ node = (vfs::tmpfs_node_t*)allocate_node_from_pool();
node->type = type;
node->content = 0;
@@ -152,14 +192,16 @@ std::int64_t __tmpfs__write(userspace_fd_t* fd, char* path, void* buffer, std::u
std::uint64_t offset = fd->offset;
std::uint64_t new_size = offset + size;
- if (new_size > node->size) {
- std::uint8_t* new_content = (std::uint8_t*)memory::pmm::_virtual::alloc(new_size);
+ if (new_size > node->real_size) {
+ alloc_t new_content0 = memory::pmm::_physical::alloc_ext(new_size);
+ std::uint8_t* new_content = (std::uint8_t*)new_content0.virt;
if (node->content) {
memcpy(new_content, node->content, node->size);
__tmpfs__dealloc(node);
}
node->content = new_content;
node->size = new_size;
+ node->real_size = new_content0.real_size;
}
memcpy(node->content + offset, buffer, size);
@@ -345,8 +387,10 @@ std::int32_t __tmpfs__readlink(char* path, char* out, std::uint32_t out_len) {
if(node->type != TMPFS_TYPE_SYMLINK)
return EINVAL;
- if(node->size >= out_len)
+ if(node->size >= out_len) {
+ Log::SerialDisplay(LEVEL_MESSAGE_INFO,"ur taking too long nodesize %d outlen %d",node->size,out_len);
return EINVAL;
+ }
if(!node->content)
return EINVAL; // symlink is not initializied now :(
diff --git a/kernel/src/generic/vfs/vfs.cpp b/kernel/src/generic/vfs/vfs.cpp
index 2b67d28..55e8969 100644
--- a/kernel/src/generic/vfs/vfs.cpp
+++ b/kernel/src/generic/vfs/vfs.cpp
@@ -190,7 +190,13 @@ std::int64_t vfs::vfs::write(userspace_fd_t* fd, void* buffer, std::uint64_t siz
char out[2048];
memset(out,0,2048);
- __vfs_symlink_resolve(fd->path,out);
+ if(!fd->is_cached_path) {
+ __vfs_symlink_resolve(fd->path,out);
+ memcpy(fd->path,out,strlen(out));
+ fd->is_cached_path = 1;
+ } else
+ memcpy(out,fd->path,strlen(fd->path));
+
if(is_fifo_exists(out)) {
fifo_node_t* fifo = fifo_get(out);
@@ -217,7 +223,12 @@ std::int64_t vfs::vfs::read(userspace_fd_t* fd, void* buffer, std::uint64_t coun
char out[2048];
memset(out,0,2048);
- __vfs_symlink_resolve(fd->path,out);
+ if(!fd->is_cached_path) {
+ __vfs_symlink_resolve(fd->path,out);
+ memcpy(fd->path,out,strlen(out));
+ fd->is_cached_path = 1;
+ } else
+ memcpy(out,fd->path,strlen(fd->path));
if(is_fifo_exists(out)) {
fifo_node_t* fifo = fifo_get(out);
@@ -270,7 +281,12 @@ std::int32_t vfs::vfs::mmap(userspace_fd_t* fd, std::uint64_t* outp, std::uint64
char out[2048];
memset(out,0,2048);
- __vfs_symlink_resolve(fd->path,out);
+ if(!fd->is_cached_path) {
+ __vfs_symlink_resolve(fd->path,out);
+ memcpy(fd->path,out,strlen(out));
+ fd->is_cached_path = 1;
+ } else
+ memcpy(out,fd->path,strlen(fd->path));
vfs_node_t* node = find_node(out);
if(!node) { vfs::vfs::unlock();
@@ -291,7 +307,12 @@ std::int32_t vfs::vfs::open(userspace_fd_t* fd) {
char out[2048];
memset(out,0,2048);
- __vfs_symlink_resolve(fd->path,out);
+ if(!fd->is_cached_path) {
+ __vfs_symlink_resolve(fd->path,out);
+ memcpy(fd->path,out,strlen(out));
+ fd->is_cached_path = 1;
+ } else
+ memcpy(out,fd->path,strlen(fd->path));
if(is_fifo_exists(out)) {
fifo_node_t* fifo = fifo_get(out);
@@ -349,7 +370,12 @@ std::int32_t vfs::vfs::ls(userspace_fd_t* fd, dirent_t* out) {
char out0[2048];
memset(out0,0,2048);
- __vfs_symlink_resolve(fd->path,out0);
+ if(!fd->is_cached_path) {
+ __vfs_symlink_resolve(fd->path,out0);
+ memcpy(fd->path,out0,strlen(out0));
+ fd->is_cached_path = 1;
+ } else
+ memcpy(out0,fd->path,strlen(fd->path));
vfs_node_t* node = find_node(out0);
if(!node) { vfs::vfs::unlock();
@@ -370,7 +396,12 @@ std::int32_t vfs::vfs::var(userspace_fd_t* fd, std::uint64_t value, std::uint8_t
char out[2048];
memset(out,0,2048);
- __vfs_symlink_resolve(fd->path,out);
+ if(!fd->is_cached_path) {
+ __vfs_symlink_resolve(fd->path,out);
+ memcpy(fd->path,out,strlen(out));
+ fd->is_cached_path = 1;
+ } else
+ memcpy(out,fd->path,strlen(fd->path));
vfs_node_t* node = find_node(out);
if(!node) { vfs::vfs::unlock();
@@ -451,7 +482,12 @@ std::int32_t vfs::vfs::stat(userspace_fd_t* fd, stat_t* out) {
char out0[2048];
memset(out0,0,2048);
- __vfs_symlink_resolve(fd->path,out0);
+ if(!fd->is_cached_path) {
+ __vfs_symlink_resolve(fd->path,out0);
+ memcpy(fd->path,out0,strlen(out0));
+ fd->is_cached_path = 1;
+ } else
+ memcpy(out0,fd->path,strlen(fd->path));
if(is_fifo_exists(out0)) {
memset(out,0,sizeof(stat_t));
@@ -486,7 +522,12 @@ std::int64_t vfs::vfs::ioctl(userspace_fd_t* fd, unsigned long req, void *arg, i
char out0[2048];
memset(out0,0,2048);
- __vfs_symlink_resolve(fd->path,out0);
+ if(!fd->is_cached_path) {
+ __vfs_symlink_resolve(fd->path,out0);
+ memcpy(fd->path,out0,strlen(out0));
+ fd->is_cached_path = 1;
+ } else
+ memcpy(out0,fd->path,strlen(fd->path));
vfs_node_t* node = find_node(out0);
if(!node) { vfs::vfs::unlock();
@@ -507,7 +548,12 @@ void vfs::vfs::close(userspace_fd_t* fd) {
char out0[2048];
memset(out0,0,2048);
- __vfs_symlink_resolve(fd->path,out0);
+ if(!fd->is_cached_path) {
+ __vfs_symlink_resolve(fd->path,out0);
+ memcpy(fd->path,out0,strlen(out0));
+ fd->is_cached_path = 1;
+ } else
+ memcpy(out0,fd->path,strlen(fd->path));
if(is_fifo_exists(out0)) {
fifo_node_t* fifo = fifo_get(out0);
@@ -536,6 +582,11 @@ std::int32_t vfs::vfs::readlink(char* path, char* out, std::uint32_t out_len) {
return EINVAL;
}
+ if(path[0] == '\0') {
+ path[0] = '/';
+ path[1] = '\n';
+ }
+
vfs_node_t* node = find_node(path);
if(!node) {
return ENOENT; }
@@ -548,12 +599,32 @@ std::int32_t vfs::vfs::readlink(char* path, char* out, std::uint32_t out_len) {
}
std::int64_t vfs::vfs::poll(userspace_fd_t* fd, int operation_type) {
- vfs_lock->lock();
+ vfs_lock->lock();
char out0[2048];
memset(out0,0,2048);
- __vfs_symlink_resolve(fd->path,out0);
+ if(!fd) {
+ vfs_lock->unlock();
+ return 0;
+ }
+
+ if(fd->state == USERSPACE_FD_STATE_SOCKET) {
+ if(fd->is_listen) {
+ uint64_t counter = 0;
+ if(operation_type == POLLIN)
+ counter = sockets::find(fd->path)->socket_counter;
+ vfs_lock->unlock();
+ return counter;
+ }
+ }
+
+ if(!fd->is_cached_path) {
+ __vfs_symlink_resolve(fd->path,out0);
+ memcpy(fd->path,out0,strlen(out0));
+ fd->is_cached_path = 1;
+ } else
+ memcpy(out0,fd->path,strlen(fd->path));
if(is_fifo_exists(out0)) {
fifo_node_t* fifo = fifo_get(out0);
@@ -581,6 +652,7 @@ std::int64_t vfs::vfs::poll(userspace_fd_t* fd, int operation_type) {
case POLLIN:
ret = fd->other_state == USERSPACE_FD_OTHERSTATE_MASTER ? fd->write_socket_pipe->read_counter : fd->read_socket_pipe->read_counter;
+
break;
case POLLOUT:
@@ -590,6 +662,7 @@ std::int64_t vfs::vfs::poll(userspace_fd_t* fd, int operation_type) {
default:
break;
}
+
vfs_lock->unlock();
return ret;
} else if(fd->state == USERSPACE_FD_STATE_PIPE) {
diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp
index ee278d2..28a949a 100644
--- a/kernel/src/main.cpp
+++ b/kernel/src/main.cpp
@@ -71,6 +71,7 @@ extern "C" void main() {
vfs::vfs::init();
Log::Display(LEVEL_MESSAGE_OK,"VFS initializied\n");
+ Log::Display(LEVEL_MESSAGE_INFO,"Loading initrd\n");
vfs::ustar::copy();
Log::Display(LEVEL_MESSAGE_OK,"USTAR parsed\n");
diff --git a/tar-initrd.sh b/tar-initrd.sh
index ae6a26e..fa0e050 100644..100755
--- a/tar-initrd.sh
+++ b/tar-initrd.sh
@@ -1,9 +1,16 @@
rm -rf initrd
+export LIBTOOL="$HOME/opt/cross/orange/bin/libtool"
+export LIBTOOLIZE="$HOME/opt/cross/orange/bin/libtoolize"
export PATH="$HOME/opt/cross/orange/bin:$PATH"
-if [ ! "$(which x86_64-orange-gcc)" ]; then
+sysroot_path="$(realpath initrd)"
+
+export CFLAGS="-fPIC -Wno-error -O2"
+export PKG_CONFIG_SYSROOT_DIR="$sysroot_path"
+export PKG_CONFIG_PATH="$sysroot_path/usr/lib/pkgconfig:$sysroot_path/usr/share/pkgconfig:$sysroot_path/usr/local/lib/pkgconfig:$sysroot_path/usr/local/share/pkgconfig:$HOME/opt/cross/orange/lib/pkgconfig:$HOME/opt/cross/orange/share/pkgconfig"
+if [ ! "$(which x86_64-orange-mlibc-gcc)" ]; then
echo "It looks like you don't have the cross-compiler installed, or it isn't in your PATH."
echo "If you built your cross-compiler, add it to your PATH with:"
echo 'export PATH="$HOME/opt/cross/orange/bin:$PATH"'
diff --git a/tools/diffs/gcc.diff b/tools/diffs/gcc.diff
index a125093..df4c770 100644
--- a/tools/diffs/gcc.diff
+++ b/tools/diffs/gcc.diff
@@ -1,15 +1,3 @@
-diff -Naur gcc-15.1.0/config.sub gcc-patched/config.sub
---- gcc-15.1.0/config.sub 2025-04-25 11:17:59.000000000 +0300
-+++ gcc-patched/config.sub 2025-07-26 08:25:33.087405360 +0300
-@@ -1745,7 +1745,7 @@
- | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
- | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
- | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
-- | skyos* | haiku* | rdos* | toppers* | drops* | es* \
-+ | skyos* | orange* | haiku* | rdos* | toppers* | drops* | es* \
- | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
- | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
- | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
diff -Naur gcc-15.1.0/fixincludes/mkfixinc.sh gcc-patched/fixincludes/mkfixinc.sh
--- gcc-15.1.0/fixincludes/mkfixinc.sh 2025-04-25 11:17:59.000000000 +0300
+++ gcc-patched/fixincludes/mkfixinc.sh 2025-07-26 08:31:28.520072553 +0300
@@ -17,8 +5,8 @@ diff -Naur gcc-15.1.0/fixincludes/mkfixinc.sh gcc-patched/fixincludes/mkfixinc.s
case $machine in
i?86-*-cygwin* | \
*-mingw32* | \
-+ *-orange* | \
-+ *-*-orange* | \
++ *-*-mlibc* | \
++ *-mlibc* | \
powerpc-*-eabisim* | \
powerpc-*-eabi* | \
powerpc-*-rtems* | \
@@ -95,7 +83,7 @@ diff -Naur gcc-15.1.0/gcc/config/orange.h gcc-patched/gcc/config/orange.h
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \
+ do { \
-+ builtin_define ("__orange__"); \
++ builtin_define ("__orange__"); builtin_define ("__mlibc__"); \
+ builtin_define ("__unix__"); \
+ builtin_assert ("system=orange"); \
+ builtin_assert ("system=unix"); \
@@ -120,7 +108,7 @@ diff -Naur gcc-15.1.0/gcc/config.gcc gcc-patched/gcc/config.gcc
rust_target_objs="${rust_target_objs} netbsd-rust.o"
target_has_targetrustm=yes
;;
-+*-*-orange*)
++*-*-*-mlibc)
+ extra_options="$extra_options gnu-user.opt"
+ gas=yes
+ gnu_ld=yes
@@ -177,11 +165,11 @@ diff -Naur gcc-15.1.0/libgcc/config.host gcc-patched/libgcc/config.host
extra_parts="$extra_parts crtfastmath.o libheapt_w.a"
tmake_file="${tmake_file} i386/t-heap-trampoline"
;;
-+i[34567]86-*-orange*)
++*-*-*-mlibc)
+ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o crtbeginS.o crtendS.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ ;;
-+x86_64-*-orange*)
++x86_64-*-*-mlibc)
+ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o crtbeginS.o crtendS.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ ;;
@@ -202,7 +190,7 @@ diff -Naur gcc-15.1.0/libstdc++-v3/crossconfig.m4 gcc-patched/libstdc++-v3/cross
GLIBCXX_CHECK_MATH_SUPPORT
GLIBCXX_CHECK_STDLIB_SUPPORT
;;
-+ *-orange*)
++ *-mlibc*)
+ GLIBCXX_CHECK_COMPILER_FEATURES
+ GLIBCXX_CHECK_LINKER_FEATURES
+ GLIBCXX_CHECK_MATH_SUPPORT
@@ -210,4 +198,4 @@ diff -Naur gcc-15.1.0/libstdc++-v3/crossconfig.m4 gcc-patched/libstdc++-v3/cross
+ ;;
*-vxworks*)
AC_DEFINE(HAVE_ACOSF)
- AC_DEFINE(HAVE_ASINF)
+ AC_DEFINE(HAVE_ASINF) \ No newline at end of file
diff --git a/tools/diffs/gccn.diff b/tools/diffs/gccn.diff
new file mode 100644
index 0000000..67de60d
--- /dev/null
+++ b/tools/diffs/gccn.diff
@@ -0,0 +1,286 @@
+diff --git gcc-host-clean/fixincludes/mkfixinc.sh gcc-host-workdir/fixincludes/mkfixinc.sh
+index 7112f4d..7aadf83 100755
+--- gcc-host-clean/fixincludes/mkfixinc.sh
++++ gcc-host-workdir/fixincludes/mkfixinc.sh
+@@ -12,6 +12,7 @@ target=fixinc.sh
+ # Check for special fix rules for particular targets
+ case $machine in
+ i?86-*-cygwin* | \
++ *-mlibc* | \
+ *-mingw32* | \
+ powerpc-*-eabisim* | \
+ powerpc-*-eabi* | \
+diff --git gcc-host-workdir/gcc/config/i386/orange.h gcc-host-workdir/gcc/config/i386/orange.h
+new file mode 100644
+index 0000000..e3017a9
+--- /dev/null
++++ gcc-host-workdir/gcc/config/i386/orange.h
+@@ -0,0 +1,30 @@
++#undef TARGET_ORANGE
++#define TARGET_ORANGE 1
++
++#undef LIB_SPEC
++#define LIB_SPEC "-lc"
++
++#undef STARTFILE_SPEC
++#define STARTFILE_SPEC "%{!shared: %{static-pie|pie|!no-pie:Scrt1.o%s;:crt1.o%s}} crti.o%s %{shared|static-pie|pie|!no-pie:crtbeginS.o%s;:crtbegin.o%s}"
++
++#undef ENDFILE_SPEC
++#define ENDFILE_SPEC "%{shared|static-pie|pie|!no-pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
++
++#define GNU_USER_LINK_EMULATION32 "elf_i386"
++#define GNU_USER_LINK_EMULATION64 "elf_x86_64"
++#define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"
++
++#define GNU_USER_DYNAMIC_LINKER32 "/does_not_exist"
++#define GNU_USER_DYNAMIC_LINKER64 "/usr/lib/ld.so"
++#define GNU_USER_DYNAMIC_LINKERX32 "/does_not_exist"
++
++#undef TARGET_OS_CPP_BUILTINS
++#define TARGET_OS_CPP_BUILTINS() \
++ do { \
++ builtin_define ("__orange__"); \
++ builtin_define ("__mlibc__"); \
++ builtin_define ("__unix__"); \
++ builtin_assert ("system=orange"); \
++ builtin_assert ("system=unix"); \
++ builtin_assert ("system=posix"); \
++ } while (0);
+diff --git gcc-host-workdir/gcc/config/riscv/orange.h gcc-host-workdir/gcc/config/riscv/orange.h
+new file mode 100644
+index 0000000..5fd4f00
+--- /dev/null
++++ gcc-host-workdir/gcc/config/riscv/orange.h
+@@ -0,0 +1,46 @@
++#undef TARGET_ORANGE
++#define TARGET_ORANGE 1
++
++#undef LIB_SPEC
++#define LIB_SPEC "-lc"
++
++#define LD_EMUL_SUFFIX \
++ "%{mabi=lp64d:}" \
++ "%{mabi=lp64f:_lp64f}" \
++ "%{mabi=lp64:_lp64}" \
++ "%{mabi=ilp32d:}" \
++ "%{mabi=ilp32f:_ilp32f}" \
++ "%{mabi=ilp32:_ilp32}"
++
++#define GNU_USER_LINK_EMULATION "elf64lriscv"
++#define GNU_USER_DYNAMIC_LINKER "/usr/lib/ld.so"
++
++#define LINK_SPEC "\
++-melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv" LD_EMUL_SUFFIX " \
++%{mno-relax:--no-relax} \
++%{mbig-endian:-EB} \
++%{mlittle-endian:-EL} \
++%{shared} \
++ %{!shared: \
++ %{!static: \
++ %{!static-pie: \
++ %{rdynamic:-export-dynamic} \
++ -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
++ %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}"
++
++#undef STARTFILE_SPEC
++#define STARTFILE_SPEC "%{!shared: %{static-pie|pie|!no-pie:Scrt1.o%s;:crt1.o%s}} crti.o%s %{shared|static-pie|pie|!no-pie:crtbeginS.o%s;:crtbegin.o%s}"
++
++#undef ENDFILE_SPEC
++#define ENDFILE_SPEC "%{shared|static-pie|pie|!no-pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
++
++#undef TARGET_OS_CPP_BUILTINS
++#define TARGET_OS_CPP_BUILTINS() \
++ do { \
++ builtin_define ("__orange__"); \
++ builtin_define ("__mlibc__"); \
++ builtin_define ("__unix__"); \
++ builtin_assert ("system=orange"); \
++ builtin_assert ("system=unix"); \
++ builtin_assert ("system=posix"); \
++ } while (0);
+diff --git gcc-host-clean/gcc/config.build gcc-host-workdir/gcc/config.build
+index 7c80a0b..8fac7e4 100644
+--- gcc-host-clean/gcc/config.build
++++ gcc-host-workdir/gcc/config.build
+@@ -45,7 +45,7 @@
+ build_xm_file=
+ build_xm_defines=
+ build_exeext=
+-build_install_headers_dir=install-headers-tar
++build_install_headers_dir=install-headers-cp
+ build_file_translate=
+
+ # System-specific settings.
+diff --git gcc-host-clean/gcc/config.gcc gcc-host-workdir/gcc/config.gcc
+index 087aaa7..0bee278 100644
+--- gcc-host-clean/gcc/config.gcc
++++ gcc-host-workdir/gcc/config.gcc
+@@ -879,6 +879,15 @@ case ${target} in
+ rust_target_objs="${rust_target_objs} freebsd-rust.o"
+ target_has_targetrustm=yes
+ ;;
++*-*-*-mlibc)
++ extra_options="$extra_options gnu-user.opt"
++ gas=yes
++ gnu_ld=yes
++ default_use_cxa_atexit=yes
++ use_gcc_stdint=wrap
++ tmake_file="${tmake_file} t-slibgcc"
++ thread_file='posix'
++ ;;
+ *-*-fuchsia*)
+ native_system_header_dir=/include
+ tmake_file="t-fuchsia"
+@@ -2320,6 +2329,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
+ ;;
+ esac
+ ;;
++x86_64-*-orange*)
++ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h gnu-user.h glibc-stdint.h i386/x86-64.h i386/gnu-user-common.h i386/gnu-user64.h i386/orange.h"
++ ;;
+ x86_64-*-fuchsia*)
+ tmake_file="${tmake_file} i386/t-x86_64-elf"
+ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h fuchsia.h"
+@@ -2519,6 +2531,13 @@ microblaze*-*-elf)
+ cxx_target_objs="${cxx_target_objs} microblaze-c.o"
+ tmake_file="${tmake_file} microblaze/t-microblaze"
+ ;;
++riscv*-*-orange*)
++ tm_file="${tm_file} elfos.h gnu-user.h glibc-stdint.h riscv/orange.h"
++ tmake_file="${tmake_file} riscv/t-riscv"
++ gnu_ld=yes
++ gas=yes
++ gcc_cv_initfini_array=yes
++ ;;
+ riscv*-*-linux*)
+ tm_file="elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} riscv/linux.h"
+ case "x${enable_multilib}" in
+diff --git gcc-host-clean/gcc/cp/module.cc gcc-host-workdir/gcc/cp/module.cc
+index 1deadcc..9b72332 100644
+--- gcc-host-clean/gcc/cp/module.cc
++++ gcc-host-workdir/gcc/cp/module.cc
+@@ -1697,8 +1697,10 @@ elf_in::defrost (const char *name)
+ set_error (errno);
+ else
+ {
++#ifndef __orange__
+ if (madvise (mapping, hdr.pos, MADV_RANDOM))
+ goto fail;
++#endif
+
+ /* These buffers are never NULL in this case. */
+ strtab.buffer = mapping + strtab.pos;
+@@ -1808,8 +1810,10 @@ elf_in::begin (location_t loc)
+ }
+ /* We'll be hopping over this randomly. Some systems declare the
+ first parm as char *, and other declare it as void *. */
++#ifndef __orange__
+ if (madvise (reinterpret_cast <char *> (mapping), size, MADV_RANDOM))
+ goto fail;
++#endif
+
+ hdr.buffer = (char *)mapping;
+ #else
+diff --git gcc-host-clean/libatomic/configure.tgt gcc-host-workdir/libatomic/configure.tgt
+index 6db039d..e4fc391 100644
+--- gcc-host-clean/libatomic/configure.tgt
++++ gcc-host-workdir/libatomic/configure.tgt
+@@ -151,7 +151,7 @@ case "${target}" in
+ *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu \
+ | *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly* \
+ | *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11* \
+- | *-*-darwin* | *-*-aix* | *-*-cygwin*)
++ | *-*-darwin* | *-*-aix* | *-*-cygwin* | *-*-mlibc*)
+ # POSIX system. The OS is supported.
+ config_path="${config_path} posix"
+ ;;
+diff --git gcc-host-clean/libcpp/Makefile.in gcc-host-workdir/libcpp/Makefile.in
+index bb07e46..821fe80 100644
+--- gcc-host-clean/libcpp/Makefile.in
++++ gcc-host-workdir/libcpp/Makefile.in
+@@ -32,10 +32,10 @@ AUTOCONF = @AUTOCONF@
+ AUTOHEADER = @AUTOHEADER@
+ CATALOGS = $(patsubst %,po/%,@CATALOGS@)
+ CC = @CC@
+-CFLAGS = @CFLAGS@
++override CFLAGS := @CFLAGS@
+ WARN_CFLAGS = @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@
+ CXX = @CXX@
+-CXXFLAGS = @CXXFLAGS@
++override CXXFLAGS := @CXXFLAGS@
+ WARN_CXXFLAGS = @warn@ @WARN_PEDANTIC@ @WERROR@
+ CPP = @CPP@
+ CPPFLAGS = @CPPFLAGS@
+@@ -45,7 +45,7 @@ INCINTL = @INCINTL@
+ INSTALL_DATA = @INSTALL_DATA@
+ INSTALL_PROGRAM = @INSTALL_PROGRAM@
+ INSTALL_SCRIPT = @INSTALL_SCRIPT@
+-LDFLAGS = @LDFLAGS@
++override LDFLAGS := @LDFLAGS@
+ LIBICONV = @LIBICONV@
+ LIBINTL = @LIBINTL@
+ PACKAGE = @PACKAGE@
+diff --git gcc-host-clean/libgcc/config.host gcc-host-workdir/libgcc/config.host
+index 6a88ee5..86bd7f3 100644
+--- gcc-host-clean/libgcc/config.host
++++ gcc-host-workdir/libgcc/config.host
+@@ -310,6 +310,11 @@ case ${host} in
+ tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-fuchsia"
+ extra_parts="crtbegin.o crtend.o"
+ ;;
++*-*-*-mlibc)
++ extra_parts="$extra_parts crtbegin.o crtbeginS.o crtend.o crtendS.o"
++ tmake_file="$tmake_file t-crtstuff-pic"
++ tmake_file="$tmake_file t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-libgcc-pic"
++ ;;
+ *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu | *-*-uclinuxfdpiceabi)
+ tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux"
+ extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
+@@ -767,6 +772,10 @@ x86_64-*-elf* | x86_64-*-rtems*)
+ x86_64-*-fuchsia*)
+ tmake_file="$tmake_file t-libgcc-pic"
+ ;;
++x86_64-*-*-mlibc)
++ extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
++ tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules"
++ ;;
+ i[34567]86-*-dragonfly*)
+ tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
+ md_unwind_header=i386/dragonfly-unwind.h
+@@ -1349,6 +1358,10 @@ pru-*-*)
+ tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl t-softfp t-gnu-prefix pru/t-pru"
+ tm_file="$tm_file pru/pru-abi.h"
+ ;;
++riscv*-*-mlibc*)
++ tmake_file="${tmake_file} riscv/t-crtstuff riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
++ extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o"
++ ;;
+ riscv*-*-linux*)
+ tmake_file="${tmake_file} riscv/t-crtstuff riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
+ extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o"
+diff --git gcc-host-clean/libstdc++-v3/configure gcc-host-workdir/libstdc++-v3/configure
+index 819a1d8..52df448 100755
+--- gcc-host-clean/libstdc++-v3/configure
++++ gcc-host-workdir/libstdc++-v3/configure
+@@ -38856,7 +38856,7 @@ $as_echo "#define HAVE_TLS 1" >>confdefs.h
+
+ fi
+ ;;
+- *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-cygwin* | *-solaris*)
++ *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-cygwin* | *-solaris* | *-mlibc*)
+
+ # All these tests are for C++; save the language and the compiler flags.
+ # The CXXFLAGS thing is suspicious, but based on similar bits previously
+diff --git gcc-host-clean/libstdc++-v3/include/bits/ios_base.h gcc-host-workdir/libstdc++-v3/include/bits/ios_base.h
+index b94b2cd..1a5eaa5 100644
+--- gcc-host-clean/libstdc++-v3/include/bits/ios_base.h
++++ gcc-host-workdir/libstdc++-v3/include/bits/ios_base.h
+@@ -225,7 +225,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ enum _Ios_Seekdir
+ {
+- _S_beg = 0,
++ _S_beg = 1,
+ _S_cur = _GLIBCXX_STDIO_SEEK_CUR,
+ _S_end = _GLIBCXX_STDIO_SEEK_END,
+ _S_ios_seekdir_end = 1L << 16 \ No newline at end of file
diff --git a/tools/initbase/etc/X11/xorg.conf b/tools/initbase/etc/X11/xorg.conf
new file mode 100644
index 0000000..8277f6e
--- /dev/null
+++ b/tools/initbase/etc/X11/xorg.conf
@@ -0,0 +1,15 @@
+Section "Module"
+ Load "fbdev"
+EndSection
+
+Section "Device"
+ Identifier "Card0"
+ Driver "fbdev"
+EndSection
+
+Section "InputDevice"
+Identifier "Keyboard"
+Driver "kbd"
+Option "Device" "/dev/ps2keyboard"
+Option "Protocol" "Standard"
+EndSection \ No newline at end of file
diff --git a/tools/initbase/etc/gaster b/tools/initbase/etc/gaster
new file mode 100644
index 0000000..7a49fce
--- /dev/null
+++ b/tools/initbase/etc/gaster
@@ -0,0 +1,33 @@
+ @@@@@@@
+ @@@ @
+ @ @ @
+ @ @ @
+ @ @@ @@@@@ @@
+ @@ @@ @@ @@@@@@ @@
+ @@ @ @@@ @@@@@@ @@
+ @@ @ @@@@@ @@@@@@ @@
+ @@ @@@@@ @@ @@
+ @@ @@ @@ @@
+ @ @ @@@ @@
+ @ @@ @@@ @
+ @ @@@@@@ @
+ @@ @@@@@ @
+ @@@@@ @@@@
+ @@@@@@@@@@@@@@@@
+ @@@@@@@@ @@@@@
+ @@@@@@@@ @@@@@@@
+ @@@@@@@@ @@@@@@@
+ @@@@@@@@@ @@@@@@@@
+ @@@@@@@@@@ @@@@@@@@
+ @@@@@@@@@@ @@@@@@@@
+ @@@@ @@@@@ @@@@@@@@@
+ @% @@@@@@@@@ @@@
+ @% @@@@@@@ @ @@
+ @@@ @@@@@@@@ @@
+ @@@@@@@@@@@@@@@@@ @@@
+ @@@@@@@@@@@@@@@@@@@@@@
+ @@@@@@@@@@@@@@@@@@@@@@
+ @@@@@@@@@@@@@@@@@@@@@@
+ @@@@@@@@@@@@@@@@@@@@@@
+ @@@@@@@@@@@@@@@@@
+
diff --git a/tools/initbase/etc/localtime b/tools/initbase/etc/localtime
new file mode 100644
index 0000000..91558be
--- /dev/null
+++ b/tools/initbase/etc/localtime
Binary files differ
diff --git a/tools/pkg/1/nop/pkg.sh b/tools/pkg/1/nop/pkg.sh
index e12b38f..15e089e 100644
--- a/tools/pkg/1/nop/pkg.sh
+++ b/tools/pkg/1/nop/pkg.sh
@@ -1,2 +1,2 @@
-x86_64-orange-gcc src/main.cpp -o "$1/usr/bin/nop" \ No newline at end of file
+x86_64-orange-mlibc-gcc src/main.cpp -o "$1/usr/bin/nop" \ No newline at end of file
diff --git a/tools/pkg/1/pkg-config/diff/libtool.diff b/tools/pkg/1/pkg-config/diff/libtool.diff
new file mode 100644
index 0000000..6891c59
--- /dev/null
+++ b/tools/pkg/1/pkg-config/diff/libtool.diff
@@ -0,0 +1,366 @@
+diff -Naur libtool-2.5.4/build-aux/config.sub libtool-patched/build-aux/config.sub
+--- libtool-2.5.4/build-aux/config.sub 2024-11-20 22:08:12.000000000 +0300
++++ libtool-patched/build-aux/config.sub 2025-10-15 15:25:52.941696228 +0300
+@@ -2013,6 +2013,7 @@
+ | gnu* \
+ | go32* \
+ | haiku* \
++ | orange* \
+ | hcos* \
+ | hiux* \
+ | hms* \
+diff -Naur libtool-2.5.4/configure libtool-patched/configure
+--- libtool-2.5.4/configure 2024-11-20 22:41:01.000000000 +0300
++++ libtool-patched/configure 2025-10-15 15:25:06.323056653 +0300
+@@ -7842,7 +7842,7 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+-*-mlibc)
++*-mlibc | orange*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+@@ -11409,7 +11409,7 @@
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fPIC'
+ lt_prog_compiler_static='-static'
+@@ -12076,7 +12076,7 @@
+ fi
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+@@ -12785,7 +12785,7 @@
+ esac
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+@@ -13980,7 +13980,7 @@
+ hardcode_into_libs=yes
+ ;;
+
+-*-mlibc)
++*-mlibc | orange*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+@@ -14457,7 +14457,7 @@
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fPIC'
+ lt_prog_compiler_static='-static'
+@@ -16278,7 +16278,7 @@
+ # at 6.2 and later dlopen does load deplibs.
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+- *-mlibc)
++ *-mlibc | orange*)
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ netbsd* | netbsdelf*-gnu)
+@@ -18356,7 +18356,7 @@
+ esac
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ ld_shlibs_CXX=yes
+ ;;
+
+@@ -19081,7 +19081,7 @@
+ ;;
+ netbsd* | netbsdelf*-gnu)
+ ;;
+- *-mlibc)
++ *-mlibc | orange*)
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+@@ -20234,7 +20234,7 @@
+ hardcode_into_libs=yes
+ ;;
+
+-*-mlibc)
++*-mlibc | orange*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+@@ -20681,7 +20681,7 @@
+ ;;
+ netbsd* | netbsdelf*-gnu)
+ ;;
+- *-mlibc)
++ *-mlibc | orange*)
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+@@ -21689,7 +21689,7 @@
+ lt_prog_compiler_static_F77='-Bstatic'
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ lt_prog_compiler_wl_F77='-Wl,'
+ lt_prog_compiler_pic_F77='-fPIC'
+ lt_prog_compiler_static_F77='-static'
+@@ -22341,7 +22341,7 @@
+ fi
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ archive_expsym_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+@@ -22998,7 +22998,7 @@
+ esac
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+@@ -24014,7 +24014,7 @@
+ hardcode_into_libs=yes
+ ;;
+
+-*-mlibc)
++*-mlibc | orange*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+@@ -24491,7 +24491,7 @@
+ lt_prog_compiler_static_F77='-Bstatic'
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ lt_prog_compiler_wl_F77='-Wl,'
+ lt_prog_compiler_pic_F77='-fPIC'
+ lt_prog_compiler_static_F77='-static'
+@@ -25628,7 +25628,7 @@
+ lt_prog_compiler_static_FC='-Bstatic'
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ lt_prog_compiler_pic_FC='-fPIC'
+ lt_prog_compiler_static_FC='-static'
+@@ -26280,7 +26280,7 @@
+ fi
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ archive_expsym_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+@@ -26937,7 +26937,7 @@
+ esac
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+@@ -27953,7 +27953,7 @@
+ hardcode_into_libs=yes
+ ;;
+
+-*-mlibc)
++*-mlibc | orange*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+@@ -28430,7 +28430,7 @@
+ lt_prog_compiler_static_FC='-Bstatic'
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ lt_prog_compiler_pic_FC='-fPIC'
+ lt_prog_compiler_static_FC='-static'
+@@ -29277,7 +29277,7 @@
+ lt_prog_compiler_static_GO='-Bstatic'
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ lt_prog_compiler_wl_GO='-Wl,'
+ lt_prog_compiler_pic_GO='-fPIC'
+ lt_prog_compiler_static_GO='-static'
+@@ -29929,7 +29929,7 @@
+ fi
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ archive_cmds_GO='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ archive_expsym_cmds_GO='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+@@ -30597,7 +30597,7 @@
+ esac
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+@@ -31568,7 +31568,7 @@
+ lt_prog_compiler_static_GCJ='-Bstatic'
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ lt_prog_compiler_wl_GCJ='-Wl,'
+ lt_prog_compiler_pic_GCJ='-fPIC'
+ lt_prog_compiler_static_GCJ='-static'
+@@ -32220,7 +32220,7 @@
+ fi
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ archive_expsym_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+@@ -32888,7 +32888,7 @@
+ esac
+ ;;
+
+- *-mlibc)
++ *-mlibc | orange*)
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+diff -Naur libtool-2.5.4/libtoolize.in libtool-patched/libtoolize.in
+--- libtool-2.5.4/libtoolize.in 2024-11-20 22:01:08.000000000 +0300
++++ libtool-patched/libtoolize.in 2025-10-15 15:25:06.323056653 +0300
+@@ -1922,7 +1922,7 @@
+ # Do not remove config.guess, config.sub or install-sh, we don't
+ # install them without --install, and the project may not be using
+ # Automake. Similarly, do not remove Gnulib files.
+- all_pkgaux_files="compile depcomp missing ltmain.sh"
++ all_pkgaux_files=""
+ all_pkgmacro_files="libtool.m4 ltargz.m4 ltdl.m4 ltoptions.m4 ltsugar.m4 ltversion.in ltversion.m4 lt~obsolete.m4"
+ all_pkgltdl_files="COPYING.LIB Makefile Makefile.in Makefile.inc Makefile.am README acinclude.m4 aclocal.m4 argz_.h argz.c config.h.in config-h.in configure configure.ac configure.in libltdl/lt__alloc.h libltdl/lt__argz.h libltdl/lt__dirent.h libltdl/lt__glibc.h libltdl/lt__private.h libltdl/lt__strl.h libltdl/lt_dlloader.h libltdl/lt_error.h libltdl/lt_system.h libltdl/slist.h loaders/dld_link.c loaders/dlopen.c loaders/dyld.c loaders/load_add_on.c loaders/loadlibrary.c loaders/preopen.c loaders/shl_load.c lt__alloc.c lt__argz.c lt__dirent.c lt__strl.c lt_dlloader.c lt_error.c ltdl.c ltdl.h ltdl.mk slist.c"
+
+diff -Naur libtool-2.5.4/m4/libtool.m4 libtool-patched/m4/libtool.m4
+--- libtool-2.5.4/m4/libtool.m4 2024-11-20 22:01:08.000000000 +0300
++++ libtool-patched/m4/libtool.m4 2025-10-15 15:25:06.324056688 +0300
+@@ -1725,7 +1725,7 @@
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+- gnu* | ironclad*)
++ gnu* | ironclad* | orange*)
+ # Under GNU Hurd and Ironclad, this test is not required because there
+ # is no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+@@ -2550,6 +2550,18 @@
+ esac
+ ;;
+
++orange*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
++ soname_spec='$libname$release$shared_ext$major'
++ dynamic_linker='mlibc ld.so'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ ;;
++
+ beos*)
+ library_names_spec='$libname$shared_ext'
+ dynamic_linker="$host_os ld.so"
+@@ -3576,6 +3588,10 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++orange*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
+ beos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+@@ -4427,6 +4443,8 @@
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
++ orange*)
++ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68*)
+@@ -4682,6 +4700,12 @@
+ ;;
+ esac
+ ;;
++
++ orange*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+@@ -5239,6 +5263,11 @@
+ ;;
+ esac
+ ;;
++
++ orange*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
++ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+@@ -5710,7 +5739,8 @@
+ ;;
+ esac
+ ;;
+-
++ orange*)
++ ;;
+ bsdi[[45]]*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+ ;;
+@@ -6776,6 +6806,10 @@
+ fi
+ fi
+ ;;
++
++ orange*)
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
diff --git a/tools/pkg/1/pkg-config/diff/pkg-config.diff b/tools/pkg/1/pkg-config/diff/pkg-config.diff
new file mode 100644
index 0000000..b815c89
--- /dev/null
+++ b/tools/pkg/1/pkg-config/diff/pkg-config.diff
@@ -0,0 +1,12 @@
+diff -Naur pkg-config-0.29.2/config.sub pkg-config-patched/config.sub
+--- pkg-config-0.29.2/config.sub 2015-09-27 17:07:23.000000000 +0300
++++ pkg-config-patched/config.sub 2025-10-14 19:04:15.422008115 +0300
+@@ -1393,7 +1393,7 @@
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
++ | -skyos* | -haiku* | -orange* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
diff --git a/tools/pkg/1/pkg-config/info.txt b/tools/pkg/1/pkg-config/info.txt
new file mode 100644
index 0000000..6d2c214
--- /dev/null
+++ b/tools/pkg/1/pkg-config/info.txt
@@ -0,0 +1 @@
+pkg-config
diff --git a/tools/pkg/1/pkg-config/pkg.sh b/tools/pkg/1/pkg-config/pkg.sh
new file mode 100644
index 0000000..a0b2afa
--- /dev/null
+++ b/tools/pkg/1/pkg-config/pkg.sh
@@ -0,0 +1,52 @@
+# https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
+
+
+. ../../pkg-lib.sh
+
+mkdir -p cached
+
+rm -rf pack
+
+mkdir -p pack
+
+cd pack
+
+wget https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
+tar -xvf pkg-config-0.29.2.tar.gz
+cd pkg-config-0.29.2
+
+diff_patch ../../diff/pkg-config.diff
+./configure --prefix="$HOME/opt/cross/orange" --with-internal-glib --target=x86_64-orange
+make -j$(nproc)
+make install
+
+mkdir -p "$HOME/opt/cross/orange"/share/pkgconfig/personality.d
+
+cat > "$HOME/opt/cross/orange"/share/pkgconfig/personality.d/x86_64-orange.personality << EOF
+Triplet: x86_64-orange
+SysrootDir: $1
+DefaultSearchPaths: $1/usr/lib/pkgconfig:$1/usr/share/pkgconfig
+SystemIncludePaths: $1/usr/include
+SystemLibraryPaths: $1/usr/lib
+EOF
+
+c="$(pwd)"
+
+cd "$HOME/opt/cross/orange/bin"
+
+ln -sf pkg-config x86_64-orange-mlibc-pkg-config
+
+cd "$c"
+
+# wget https://ftpmirror.gnu.org/gnu/libtool/libtool-2.5.4.tar.gz
+# tar -xvf libtool-2.5.4.tar.gz
+# cd libtool-2.5.4
+
+# diff_patch ../../diff/libtool.diff
+# ./configure --prefix="$HOME/opt/cross/orange" --with-gnu-ld --enable-shared --disable-static
+# make -j$(nproc)
+# make install
+
+# cd ..
+
+cd ..
diff --git a/tools/pkg/2/debug/info.txt b/tools/pkg/2/debug/info.txt
new file mode 100644
index 0000000..b2b5d0d
--- /dev/null
+++ b/tools/pkg/2/debug/info.txt
@@ -0,0 +1 @@
+debug \ No newline at end of file
diff --git a/tools/pkg/2/debug/main.c b/tools/pkg/2/debug/main.c
new file mode 100644
index 0000000..7a90c9f
--- /dev/null
+++ b/tools/pkg/2/debug/main.c
@@ -0,0 +1,15 @@
+#include <unistd.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ if (argc < 2) {
+ printf("Usage: %s <program> [args...]\n", argv[0]);
+ return 1;
+ }
+
+ asm volatile("syscall" : : "a"(53) : "rcx","r11");
+
+ execvp(argv[1], &argv[1]);
+ perror("execvp");
+ return 1;
+} \ No newline at end of file
diff --git a/tools/pkg/2/debug/pkg.sh b/tools/pkg/2/debug/pkg.sh
new file mode 100644
index 0000000..9d84dec
--- /dev/null
+++ b/tools/pkg/2/debug/pkg.sh
@@ -0,0 +1,2 @@
+
+x86_64-orange-mlibc-gcc -o "$1/usr/bin/orangedebug" main.c \ No newline at end of file
diff --git a/tools/pkg/2/init/pkg.sh b/tools/pkg/2/init/pkg.sh
index 810d5af..5d61f92 100644
--- a/tools/pkg/2/init/pkg.sh
+++ b/tools/pkg/2/init/pkg.sh
@@ -6,8 +6,8 @@ cd pack/lib/
git clone https://codeberg.org/Mintsuki/Flanterm.git
cd ../../
-x86_64-orange-g++ -c src/main.cpp -o "pack/init.o" -Ipack/lib/Flanterm/src -Isrc/include
-x86_64-orange-gcc -c pack/lib/Flanterm/src/flanterm.c -o pack/flanterm.o -Ipack/lib/Flanterm/src
-x86_64-orange-gcc -c pack/lib/Flanterm/src/flanterm_backends/fb.c -o pack/flanterm_backends.o -Ipack/lib/Flanterm/src
+x86_64-orange-mlibc-g++ -c src/main.cpp -o "pack/init.o" -Ipack/lib/Flanterm/src -Isrc/include
+x86_64-orange-mlibc-gcc -c pack/lib/Flanterm/src/flanterm.c -o pack/flanterm.o -Ipack/lib/Flanterm/src
+x86_64-orange-mlibc-gcc -c pack/lib/Flanterm/src/flanterm_backends/fb.c -o pack/flanterm_backends.o -Ipack/lib/Flanterm/src
-x86_64-orange-g++ -o "$1/usr/bin/init" pack/init.o pack/flanterm.o pack/flanterm_backends.o
+x86_64-orange-mlibc-g++ -o "$1/usr/bin/init" pack/init.o pack/flanterm.o pack/flanterm_backends.o
diff --git a/tools/pkg/2/init/src/include/etc.hpp b/tools/pkg/2/init/src/include/etc.hpp
index acd8c22..05db6eb 100644
--- a/tools/pkg/2/init/src/include/etc.hpp
+++ b/tools/pkg/2/init/src/include/etc.hpp
@@ -322,10 +322,10 @@ public:
ioctl(STDIN_FILENO, TCSETS, &t);
- liborange_create_dev(((uint64_t)DEVFS_PACKET_CREATE_DEV << 32) | 0, "/input", "/masterinput");
- liborange_setup_ring_bytelen("/input0",1);
- int master_input = open("/dev/masterinput0", O_RDWR);
- int slave_input = open("/dev/input0", O_RDWR);
+ liborange_create_dev(((uint64_t)DEVFS_PACKET_CREATE_DEV << 32) | 0, "/ps2keyboard", "/masterps2keyboard");
+ liborange_setup_ring_bytelen("/ps2keyboard0",1);
+ int master_input = open("/dev/masterps2keyboard0", O_RDWR);
+ int slave_input = open("/dev/ps2keyboard0", O_RDWR);
keybuffer = (char*)malloc(1024);
@@ -356,6 +356,8 @@ public:
}
};
+#include <emmintrin.h>
+
#define LEVEL_MESSAGE_OK 0
#define LEVEL_MESSAGE_FAIL 1
#define LEVEL_MESSAGE_WARN 2
@@ -372,16 +374,21 @@ const char* level_messages[] = {
class fbdev {
public:
- static void init() {
+
+ static void refresh(void* ptr, void* a) {
struct limine_framebuffer fb;
liborange_access_framebuffer(&fb);
- liborange_create_dev(((uint64_t)DEVFS_PACKET_CREATE_PIPE_DEV << 32) | 0, "/fb", "/masterfb");
- liborange_setup_mmap("/fb0",fb.address,fb.pitch * fb.width,PTE_WC);
+ int buffer_in_use = 0;
+ void* real_fb = liborange_map_phys(fb.address, PTE_WC, fb.pitch * fb.height);
+
+ while(1) {
+ memcpy(real_fb,ptr,fb.height * fb.pitch);
+ }
+ }
+
+ static void setup_ioctl(int fb0_dev ,struct limine_framebuffer fb) {
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
- liborange_setup_ioctl("/fb0",sizeof(struct fb_var_screeninfo),FBIOGET_VSCREENINFO,0x1);
- liborange_setup_ioctl("/fb0",sizeof(struct fb_fix_screeninfo),FBIOGET_FSCREENINFO,0x2);
- int fb0_dev = open("/dev/fb0",O_RDWR);
vinfo.red.length = fb.red_mask_size;
vinfo.red.offset = fb.red_mask_shift;
vinfo.blue.offset = fb.blue_mask_shift;
@@ -393,12 +400,49 @@ public:
vinfo.bits_per_pixel = fb.bpp < 5 ? (fb.bpp * 8) : fb.bpp;
vinfo.xres_virtual = fb.width;
vinfo.yres_virtual = fb.height;
+ vinfo.red.msb_right = 1;
+ vinfo.green.msb_right = 1;
+ vinfo.blue.msb_right = 1;
+ vinfo.transp.msb_right = 1;
+ vinfo.height = -1;
+ vinfo.width = -1;
finfo.line_length = fb.pitch;
finfo.smem_len = fb.pitch * fb.height;
+ finfo.visual = FB_VISUAL_TRUECOLOR;
+ finfo.type = FB_TYPE_PACKED_PIXELS;
+ finfo.mmio_len = fb.pitch * fb.height;
ioctl(fb0_dev,0x1,&vinfo);
ioctl(fb0_dev,0x2,&finfo);
+ }
+
+ static void init() {
+ struct limine_framebuffer fb;
+ liborange_access_framebuffer(&fb);
+ liborange_create_dev(((uint64_t)DEVFS_PACKET_CREATE_PIPE_DEV << 32) | 0, "/fb", "/masterfb");
+ liborange_create_dev(((uint64_t)DEVFS_PACKET_CREATE_PIPE_DEV << 32) | 0, "/vbe", "/mastervbe");
+
+ uint64_t doublebuffer_dma = liborange_alloc_dma(fb.pitch * fb.height);
+ void* mapped_dma = liborange_map_phys(doublebuffer_dma,0,fb.pitch * fb.height);
+
+ void* a = aligned_alloc(4096,fb.pitch * fb.height);
+ void* b = aligned_alloc(4096,fb.pitch * fb.height);
+
+ int pid = fork();
+ if(pid == 0) {
+ refresh(mapped_dma,a);
+ }
+
+ liborange_setup_mmap("/fb0",doublebuffer_dma,fb.pitch * fb.height,0);
+
+ liborange_setup_ioctl("/fb0",sizeof(struct fb_var_screeninfo),FBIOGET_VSCREENINFO,0x1);
+ liborange_setup_ioctl("/fb0",sizeof(struct fb_fix_screeninfo),FBIOGET_FSCREENINFO,0x2);
+ int fb0_dev = open("/dev/fb0",O_RDWR);
+
+ setup_ioctl(fb0_dev,fb);
+
close(fb0_dev);
}
+
};
#define DIR_PATH "/etc/drivers/"
diff --git a/tools/pkg/2/ncurses/pkg.sh b/tools/pkg/2/ncurses/pkg.sh
index c6bad76..3137859 100644
--- a/tools/pkg/2/ncurses/pkg.sh
+++ b/tools/pkg/2/ncurses/pkg.sh
@@ -13,10 +13,11 @@ mkdir -p ncurses-build
cd ncurses-6.5
diff_patch ../../diff/ncurses.diff
+patch_config_sub "$(realpath $1/..)"
cd ..
cd ncurses-build
-../ncurses-6.5/configure --host=x86_64-orange --prefix="/usr" --with-shared --without-ada CFLAGS="-std=gnu17"
+../ncurses-6.5/configure --host=x86_64-orange-mlibc --prefix="/usr" --with-shared --without-ada CFLAGS="-std=gnu17"
make -j$(nproc)
make install -j$(nproc) DESTDIR="$1"
diff --git a/tools/pkg/2/ps2_driver/pkg.sh b/tools/pkg/2/ps2_driver/pkg.sh
index ca56c35..1a68b39 100644
--- a/tools/pkg/2/ps2_driver/pkg.sh
+++ b/tools/pkg/2/ps2_driver/pkg.sh
@@ -1,4 +1,4 @@
mkdir -p "$1/etc/drivers/"
-x86_64-orange-gcc -o "$1/etc/drivers/ps2driver.sys" src/main.c \ No newline at end of file
+x86_64-orange-mlibc-gcc -o "$1/etc/drivers/ps2driver.sys" src/main.c \ No newline at end of file
diff --git a/tools/pkg/2/ps2_driver/src/main.c b/tools/pkg/2/ps2_driver/src/main.c
index 9ce2a0a..78fadd7 100644
--- a/tools/pkg/2/ps2_driver/src/main.c
+++ b/tools/pkg/2/ps2_driver/src/main.c
@@ -11,7 +11,7 @@
#include <string.h>
int main() {
- int masterinput = open("/dev/masterinput0",O_RDWR);
+ int masterinput = open("/dev/masterps2keyboard",O_RDWR);
liborange_setup_iopl_3();
diff --git a/tools/pkg/2/xhci_driver/pkg.sh b/tools/pkg/2/xhci_driver/pkg.sh
index 512829f..7e52716 100644
--- a/tools/pkg/2/xhci_driver/pkg.sh
+++ b/tools/pkg/2/xhci_driver/pkg.sh
@@ -1,4 +1,4 @@
mkdir -p "$1/etc/drivers/"
-x86_64-orange-g++ -o "$1/etc/drivers/xhcidriver.wsys" src/main.cpp -Iinclude -std=c++17 \ No newline at end of file
+x86_64-orange-mlibc-g++ -o "$1/etc/drivers/xhcidriver.wsys" src/main.cpp -Iinclude -std=c++17 \ No newline at end of file
diff --git a/tools/pkg/2/xhci_driver/src/main.cpp b/tools/pkg/2/xhci_driver/src/main.cpp
index 274a109..30bdbc3 100644
--- a/tools/pkg/2/xhci_driver/src/main.cpp
+++ b/tools/pkg/2/xhci_driver/src/main.cpp
@@ -553,7 +553,7 @@ int __xhci_reset_dev(xhci_device_t* dev,uint32_t portnum) {
while((*portsc & (1 << 1)) == old_bit) {
if(time-- == 0) {
log(LEVEL_MESSAGE_FAIL,"Can't reset USB 2.0 device with port %d, ignoring\n",portnum);
- return 0;
+ return 1;
}
usleep(50000);
}
@@ -1082,8 +1082,6 @@ void __xhci_iterate_usb_ports(xhci_device_t* dev) {
usb_cap.thirdhalf = cap[2];
usb_cap.fourhalf = cap[3];
- //INFO("UsbCap with major %d\n",usb_cap.major);
-
if(usb_cap.major == 3) {
for(uint8_t i = usb_cap.portoffset - 1;i <= (usb_cap.portoffset - 1) + usb_cap.portcount - 1;i++) {
dev->usb3ports[i] = 1;
@@ -1382,7 +1380,7 @@ void __usbkeyboard_handler(xhci_usb_device_t* usbdev, xhci_done_trb_t* trb) {
int main() {
liborange_setup_iopl_3();
- input0_fd = open("/dev/masterinput0",O_RDWR);
+ input0_fd = open("/dev/masterps2keyboard",O_RDWR);
log(LEVEL_MESSAGE_WARN,"XHCI Driver is currently under development so it's unstable\n");
diff --git a/tools/pkg/3/bash/diff/bash.diff b/tools/pkg/3/bash/diff/bash.diff
deleted file mode 100644
index f2a137c..0000000
--- a/tools/pkg/3/bash/diff/bash.diff
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur bash-5.2/support/config.sub bash-patched/support/config.sub
---- bash-5.2/support/config.sub 2022-01-11 22:38:29.000000000 +0300
-+++ bash-patched/support/config.sub 2025-05-20 21:13:50.415630202 +0300
-@@ -1750,7 +1750,7 @@
- | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
- | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
- | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
-- | skyos* | haiku* | rdos* | toppers* | drops* | es* \
-+ | skyos* | orange* | haiku* | rdos* | toppers* | drops* | es* \
- | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
- | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
- | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ \ No newline at end of file
diff --git a/tools/pkg/3/bash/pkg.sh b/tools/pkg/3/bash/pkg.sh
index 7e07a15..60fde57 100644
--- a/tools/pkg/3/bash/pkg.sh
+++ b/tools/pkg/3/bash/pkg.sh
@@ -12,11 +12,11 @@ installgnu bash bash 5.2.21
mkdir -p bash-build
cd bash-5.2.21
-diff_patch ../../diff/bash.diff
+patch_config_sub "$(realpath $1/..)"
cd ..
cd bash-build
-../bash-5.2.21/configure --host=x86_64-orange --prefix="/usr" --disable-readline --with-curses --without-bash-malloc CFLAGS="-std=gnu17 -fPIC -Os"
+../bash-5.2.21/configure --host=x86_64-orange-mlibc --prefix="/usr" --disable-readline --with-curses --without-bash-malloc CFLAGS="-std=gnu17 -fPIC -Os"
make install-strip -j$(nproc) DESTDIR="$1"
cz=$(pwd)
diff --git a/tools/pkg/3/coreutils/pkg.sh b/tools/pkg/3/coreutils/pkg.sh
index 8a5b686..5e10aaf 100644
--- a/tools/pkg/3/coreutils/pkg.sh
+++ b/tools/pkg/3/coreutils/pkg.sh
@@ -13,10 +13,11 @@ mkdir -p coreutils-build
cd coreutils-9.7
diff_patch ../../diff/coreutils.diff
+patch_config_sub "$(realpath $1/..)"
cd ..
cd coreutils-build
-../coreutils-9.7/configure --host=x86_64-orange --prefix="/usr"
+../coreutils-9.7/configure --host=x86_64-orange-mlibc --prefix="/usr"
make install-strip -j$(nproc) DESTDIR="$1"
cd .. \ No newline at end of file
diff --git a/tools/pkg/3/doomgeneric/diff/doomgeneric.diff b/tools/pkg/3/doomgeneric/diff/doomgeneric.diff
index 477a4f2..8e7c3e3 100644
--- a/tools/pkg/3/doomgeneric/diff/doomgeneric.diff
+++ b/tools/pkg/3/doomgeneric/diff/doomgeneric.diff
@@ -42,7 +42,7 @@ diff -Naur doomgeneric/doomgeneric/doomgeneric_orange.c doomgeneric-patched/doom
+
+void DG_Init() {
+ fb_fd = open("/dev/fb0", O_RDWR);
-+ kbd_fd = open("/dev/input0", O_RDWR);
++ kbd_fd = open("/dev/ps2keyboard", O_RDWR);
+
+ char dummy[1024];
+ for(int i = 0;i < 128;i++) {
@@ -221,7 +221,7 @@ diff -Naur doomgeneric/doomgeneric/Makefile doomgeneric-patched/doomgeneric/Make
-CC=clang # gcc or g++
-CFLAGS+=-ggdb3 -Os
-+CC=x86_64-orange-gcc # gcc or g++
++CC=x86_64-orange-mlibc-gcc # gcc or g++
+CFLAGS+=-ggdb3 -Os -std=gnu17
LDFLAGS+=-Wl,--gc-sections
CFLAGS+=-ggdb3 -Wall -DNORMALUNIX -DLINUX -DSNDSERV -D_DEFAULT_SOURCE # -DUSEASM
diff --git a/tools/pkg/3/fastfetch/pkg.sh b/tools/pkg/3/fastfetch/pkg.sh
index 26308b0..1ee0e87 100644
--- a/tools/pkg/3/fastfetch/pkg.sh
+++ b/tools/pkg/3/fastfetch/pkg.sh
@@ -14,6 +14,7 @@ tar -xvf 2.44.0.tar.gz
cd fastfetch-2.44.0
diff_patch ../../diff/fastfetch.diff
+patch_config_sub "$(realpath $1/..)"
cd ..
mkdir -p fastfetch-build
diff --git a/tools/pkg/3/lua/pkg.sh b/tools/pkg/3/lua/pkg.sh
index 72cc8db..595e2cf 100644
--- a/tools/pkg/3/lua/pkg.sh
+++ b/tools/pkg/3/lua/pkg.sh
@@ -10,7 +10,7 @@ wget https://www.lua.org/ftp/lua-5.4.7.tar.gz
tar -xvf lua-5.4.7.tar.gz
cd lua-5.4.7
-make CC=x86_64-orange-gcc LD=x86_64-orange-ld generic -j$(nproc)
+make CC=x86_64-orange-mlibc-gcc LD=x86_64-orange-mlibc-ld generic -j$(nproc)
cp -rf src/lua "$1/usr/bin"
cp -rf src/luac "$1/usr/bin"
diff --git a/tools/pkg/3/nano/pkg.sh b/tools/pkg/3/nano/pkg.sh
index 372e754..cf20434 100644
--- a/tools/pkg/3/nano/pkg.sh
+++ b/tools/pkg/3/nano/pkg.sh
@@ -13,10 +13,11 @@ mkdir -p nano-build
cd nano-8.4
diff_patch ../../diff/nano.diff
+patch_config_sub "$(realpath $1/..)"
cd ..
cd nano-build
-../nano-8.4/configure --host=x86_64-orange --prefix="/usr" gl_cv_func_strcasecmp_works=yes CFLAGS="-std=gnu17"
+../nano-8.4/configure --host=x86_64-orange-mlibc --prefix="/usr" gl_cv_func_strcasecmp_works=yes CFLAGS="-std=gnu17"
make install -j$(nproc) DESTDIR="$1"
cd .. \ No newline at end of file
diff --git a/tools/pkg/3/poll_test/pkg.sh b/tools/pkg/3/poll_test/pkg.sh
index 458be2d..d99379d 100644
--- a/tools/pkg/3/poll_test/pkg.sh
+++ b/tools/pkg/3/poll_test/pkg.sh
@@ -1,2 +1,2 @@
-x86_64-orange-g++ -o "$1/usr/bin/poll_test" src/main.c \ No newline at end of file
+x86_64-orange-mlibc-g++ -o "$1/usr/bin/poll_test" src/main.c \ No newline at end of file
diff --git a/tools/pkg/3/pthread_test/info.txt b/tools/pkg/3/pthread_test/info.txt
new file mode 100644
index 0000000..8d3b30e
--- /dev/null
+++ b/tools/pkg/3/pthread_test/info.txt
@@ -0,0 +1 @@
+ptherad_test \ No newline at end of file
diff --git a/tools/pkg/3/pthread_test/main.c b/tools/pkg/3/pthread_test/main.c
new file mode 100644
index 0000000..e330d8a
--- /dev/null
+++ b/tools/pkg/3/pthread_test/main.c
@@ -0,0 +1,33 @@
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+// Function to be executed by the thread
+void* print_message(void* thread_id) {
+ long tid = (long)thread_id;
+ printf("Hello from thread %ld\n", tid);
+ pthread_exit(NULL);
+}
+
+int main() {
+ pthread_t threads[2];
+ int rc;
+ long t;
+
+ for(t = 0; t < 2; t++) {
+ printf("Creating thread %ld\n", t);
+ rc = pthread_create(&threads[t], NULL, print_message, (void *)t);
+ if (rc) {
+ printf("ERROR; return code from pthread_create() is %d\n", rc);
+ exit(-1);
+ }
+ }
+
+ // Wait for all threads to complete
+ for(t = 0; t < 2; t++) {
+ pthread_join(threads[t], NULL);
+ }
+
+ printf("All threads completed.\n");
+ return 0;
+}
diff --git a/tools/pkg/3/pthread_test/pkg.sh b/tools/pkg/3/pthread_test/pkg.sh
new file mode 100644
index 0000000..e096038
--- /dev/null
+++ b/tools/pkg/3/pthread_test/pkg.sh
@@ -0,0 +1 @@
+x86_64-orange-mlibc-g++ -o "$1/usr/bin/pthread_test" main.c -lpthread \ No newline at end of file
diff --git a/tools/pkg/4/xorg-server/diff/1.diff b/tools/pkg/4/xorg-server/diff/1.diff
new file mode 100644
index 0000000..76d9c84
--- /dev/null
+++ b/tools/pkg/4/xorg-server/diff/1.diff
@@ -0,0 +1,401 @@
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Bus.c xorg-server-patched/hw/xfree86/common/xf86Bus.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Bus.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Bus.c 2025-10-23 12:44:22.775506715 +0300
+@@ -556,21 +556,7 @@
+ void
+ xf86PostProbe(void)
+ {
+- if (fbSlotClaimed && (
+-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+- sbusSlotClaimed ||
+-#endif
+-#ifdef XSERVER_PLATFORM_BUS
+- platformSlotClaimed ||
+-#endif
+-#ifdef XSERVER_LIBPCIACCESS
+- pciSlotClaimed
+-#else
+- TRUE
+-#endif
+- ))
+- FatalError("Cannot run in framebuffer mode. Please specify busIDs "
+- " for all framebuffer devices\n");
++
+ }
+
+ Bool
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Config.c xorg-server-patched/hw/xfree86/common/xf86Config.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Config.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Config.c 2025-10-18 14:14:41.313332537 +0300
+@@ -49,6 +49,8 @@
+ #include <sys/types.h>
+ #include <grp.h>
+
++#include <sys/stat.h>
++
+ #include "xf86.h"
+ #include "xf86Modes.h"
+ #include "xf86Parser.h"
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Configure.c xorg-server-patched/hw/xfree86/common/xf86Configure.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Configure.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Configure.c 2025-10-18 14:15:07.924147512 +0300
+@@ -27,6 +27,8 @@
+ #include <xorg-config.h>
+ #endif
+
++#include <errno.h>
++
+ #include "xf86.h"
+ #include "xf86Config.h"
+ #include "xf86_OSlib.h"
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Events.c xorg-server-patched/hw/xfree86/common/xf86Events.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Events.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Events.c 2025-10-18 14:15:29.363803215 +0300
+@@ -53,6 +53,8 @@
+ #include <xorg-config.h>
+ #endif
+
++#include <errno.h>
++
+ #include <X11/X.h>
+ #include <X11/Xproto.h>
+ #include <X11/Xatom.h>
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Helper.c xorg-server-patched/hw/xfree86/common/xf86Helper.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Helper.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Helper.c 2025-10-23 14:57:42.305808491 +0300
+@@ -34,6 +34,8 @@
+ * different drivers.
+ */
+
++#include <sys/stat.h>
++
+ #ifdef HAVE_XORG_CONFIG_H
+ #include <xorg-config.h>
+ #endif
+@@ -851,49 +853,65 @@
+ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
+ {
+ MessageType from = X_DEFAULT;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ xf86MonPtr DDC = (xf86MonPtr) (pScrn->monitor->DDC);
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ int probedWidthmm, probedHeightmm;
+ int widthErr, heightErr;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ xf86OutputPtr compat = xf86CompatOutput(pScrn);
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+
+ /* XXX Maybe there is no need for widthmm/heightmm in ScrnInfoRec */
+ pScrn->widthmm = pScrn->monitor->widthmm;
+ pScrn->heightmm = pScrn->monitor->heightmm;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+
+ if (DDC && (DDC->features.hsize > 0 && DDC->features.vsize > 0)) {
+ /* DDC gives display size in mm for individual modes,
+ * but cm for monitor
+ */
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy1\n");
+ probedWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
+ probedHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy1\n");
+ }
+ else if (compat && compat->mm_width > 0 && compat->mm_height > 0) {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy2\n");
+ probedWidthmm = compat->mm_width;
+ probedHeightmm = compat->mm_height;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy2\n");
+ }
+ else {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy3\n");
+ probedWidthmm = probedHeightmm = 0;
+ }
+
+ if (monitorResolution > 0) {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy4\n");
+ pScrn->xDpi = monitorResolution;
+ pScrn->yDpi = monitorResolution;
+ from = X_CMDLINE;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy5\n");
+ }
+ else if (pScrn->widthmm > 0 || pScrn->heightmm > 0) {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy6\n");
+ from = X_CONFIG;
+ if (pScrn->widthmm > 0) {
+ pScrn->xDpi =
+ (int) ((double) pScrn->virtualX * MMPERINCH / pScrn->widthmm);
+ }
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ if (pScrn->heightmm > 0) {
+ pScrn->yDpi =
+ (int) ((double) pScrn->virtualY * MMPERINCH / pScrn->heightmm);
+ }
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
+ pScrn->yDpi = pScrn->xDpi;
+ if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
+ pScrn->xDpi = pScrn->yDpi;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
+ pScrn->widthmm, pScrn->heightmm);
+
+@@ -919,8 +937,10 @@
+ pScrn->heightmm);
+ }
+ }
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ }
+ else if (probedWidthmm && probedHeightmm) {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guyZ\n");
+ from = X_PROBED;
+ xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
+ probedWidthmm, probedHeightmm);
+@@ -940,6 +960,7 @@
+ pScrn->xDpi = pScrn->yDpi;
+ }
+ else {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guyX\n");
+ if (x > 0)
+ pScrn->xDpi = x;
+ else
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Init.c xorg-server-patched/hw/xfree86/common/xf86Init.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Init.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Init.c 2025-10-18 14:17:21.699226880 +0300
+@@ -34,6 +34,8 @@
+ #include <xorg-config.h>
+ #endif
+
++#include <sys/stat.h>
++
+ #include <stdlib.h>
+ #include <errno.h>
+
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Mode.c xorg-server-patched/hw/xfree86/common/xf86Mode.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Mode.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Mode.c 2025-10-23 14:29:02.407987453 +0300
+@@ -2118,5 +2118,6 @@
+ if (hsync != 0 && refresh != 0)
+ xf86PrintModeline(scrp->scrnIndex, p);
+ p = p->next;
++
+ } while (p != NULL && p != scrp->modes);
+ }
+diff -Naur xorg-server-21.1.0/hw/xfree86/fbdevhw/fbdevhw.c xorg-server-patched/hw/xfree86/fbdevhw/fbdevhw.c
+--- xorg-server-21.1.0/hw/xfree86/fbdevhw/fbdevhw.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/fbdevhw/fbdevhw.c 2025-10-19 09:37:47.188152245 +0300
+@@ -9,13 +9,10 @@
+ #include "xf86Modes.h"
+ #include "xf86_OSproc.h"
+
+-/* pci stuff */
+-#include "xf86Pci.h"
+-
+ #include "xf86cmap.h"
+
+ #include "fbdevhw.h"
+-#include "fbpriv.h"
++#include <linux/fb.h>
+ #include "globals.h"
+ #include <X11/extensions/dpmsconst.h>
+
+@@ -253,57 +250,6 @@
+ mode->CrtcVAdjusted = FALSE;
+ }
+
+-/* -------------------------------------------------------------------- */
+-/* open correct framebuffer device */
+-
+-/**
+- * Try to find the framebuffer device for a given PCI device
+- */
+-static int
+-fbdev_open_pci(struct pci_device *pPci, char **namep)
+-{
+- struct fb_fix_screeninfo fix;
+- char filename[256];
+- int fd, i;
+-
+- for (i = 0; i < 8; i++) {
+- snprintf(filename, sizeof(filename),
+- "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics/fb%d",
+- pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
+-
+- fd = open(filename, O_RDONLY, 0);
+- if (fd < 0) {
+- snprintf(filename, sizeof(filename),
+- "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics:fb%d",
+- pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
+- fd = open(filename, O_RDONLY, 0);
+- }
+- if (fd >= 0) {
+- close(fd);
+- snprintf(filename, sizeof(filename), "/dev/fb%d", i);
+-
+- fd = open(filename, O_RDWR, 0);
+- if (fd != -1) {
+- if (ioctl(fd, FBIOGET_FSCREENINFO, (void *) &fix) != -1) {
+- if (namep) {
+- *namep = xnfalloc(16);
+- strncpy(*namep, fix.id, 16);
+- }
+-
+- return fd;
+- }
+- close(fd);
+- }
+- }
+- }
+-
+- if (namep)
+- *namep = NULL;
+-
+- xf86DrvMsg(-1, X_ERROR, "Unable to find a valid framebuffer device\n");
+- return -1;
+-}
+-
+ static int
+ fbdev_open(int scrnIndex, const char *dev, char **namep)
+ {
+@@ -329,22 +275,6 @@
+ return -1;
+ }
+
+- /* only touch non-PCI devices on this path */
+- {
+- char buf[PATH_MAX] = {0};
+- char *sysfs_path = NULL;
+- char *node = strrchr(dev, '/') + 1;
+-
+- if (asprintf(&sysfs_path, "/sys/class/graphics/%s", node) < 0 ||
+- readlink(sysfs_path, buf, sizeof(buf) - 1) < 0 ||
+- strstr(buf, "devices/pci")) {
+- free(sysfs_path);
+- close(fd);
+- return -1;
+- }
+- free(sysfs_path);
+- }
+-
+ if (namep) {
+ if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, (void *) (&fix))) {
+ *namep = NULL;
+@@ -363,14 +293,12 @@
+ /* -------------------------------------------------------------------- */
+
+ Bool
+-fbdevHWProbe(struct pci_device *pPci, char *device, char **namep)
++fbdevHWProbe(void *pPci, char *device, char **namep)
+ {
+ int fd;
+-
+- if (pPci)
+- fd = fbdev_open_pci(pPci, namep);
+- else
+- fd = fbdev_open(-1, device, namep);
++
++ fd = fbdev_open(-1, device, namep);
++
+
+ if (-1 == fd)
+ return FALSE;
+@@ -379,18 +307,15 @@
+ }
+
+ Bool
+-fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device)
++fbdevHWInit(ScrnInfoPtr pScrn, void *pPci, char *device)
+ {
+ fbdevHWPtr fPtr;
+
+ fbdevHWGetRec(pScrn);
+ fPtr = FBDEVHWPTR(pScrn);
+
+- /* open device */
+- if (pPci)
+- fPtr->fd = fbdev_open_pci(pPci, NULL);
+- else
+- fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL);
++ fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL);
++
+ if (-1 == fPtr->fd) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to open framebuffer device, consult warnings"
+diff -Naur xorg-server-21.1.0/hw/xfree86/fbdevhw/fbdevhw.h xorg-server-patched/hw/xfree86/fbdevhw/fbdevhw.h
+--- xorg-server-21.1.0/hw/xfree86/fbdevhw/fbdevhw.h 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/fbdevhw/fbdevhw.h 2025-10-19 09:38:08.190818849 +0300
+@@ -16,9 +16,9 @@
+
+ extern _X_EXPORT int fbdevHWGetFD(ScrnInfoPtr pScrn);
+
+-extern _X_EXPORT Bool fbdevHWProbe(struct pci_device *pPci, char *device,
++extern _X_EXPORT Bool fbdevHWProbe(void *pPci, char *device,
+ char **namep);
+-extern _X_EXPORT Bool fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci,
++extern _X_EXPORT Bool fbdevHWInit(ScrnInfoPtr pScrn, void *pPci,
+ char *device);
+
+ extern _X_EXPORT char *fbdevHWGetName(ScrnInfoPtr pScrn);
+diff -Naur xorg-server-21.1.0/hw/xfree86/os-support/shared/posix_tty.c xorg-server-patched/hw/xfree86/os-support/shared/posix_tty.c
+--- xorg-server-21.1.0/hw/xfree86/os-support/shared/posix_tty.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/os-support/shared/posix_tty.c 2025-10-18 14:18:16.925903537 +0300
+@@ -56,6 +56,9 @@
+ #include <xorg-config.h>
+ #endif
+
++#include <termios.h>
++#include <errno.h>
++
+ #include <X11/X.h>
+ #include <xserver_poll.h>
+ #include "xf86.h"
+diff -Naur xorg-server-21.1.0/hw/xfree86/os-support/shared/sigio.c xorg-server-patched/hw/xfree86/os-support/shared/sigio.c
+--- xorg-server-21.1.0/hw/xfree86/os-support/shared/sigio.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/os-support/shared/sigio.c 2025-10-18 14:18:36.612500292 +0300
+@@ -56,6 +56,9 @@
+ #include <xorg-config.h>
+ #endif
+
++#include <sys/stat.h>
++#include <errno.h>
++
+ #include <X11/X.h>
+ #include <xserver_poll.h>
+ #include "xf86.h"
+diff -Naur xorg-server-21.1.0/include/os.h xorg-server-patched/include/os.h
+--- xorg-server-21.1.0/include/os.h 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/include/os.h 2025-10-18 14:19:09.429494076 +0300
+@@ -51,6 +51,7 @@
+ #include <stdarg.h>
+ #include <stdint.h>
+ #include <string.h>
++#include <strings.h>
+ #ifdef MONOTONIC_CLOCK
+ #include <time.h>
+ #endif
+diff -Naur xorg-server-21.1.0/os/access.c xorg-server-patched/os/access.c
+--- xorg-server-21.1.0/os/access.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/os/access.c 2025-10-18 14:19:29.654105938 +0300
+@@ -116,7 +116,7 @@
+ #endif
+ #endif
+
+-#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__)
++#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__) || defined(__orange__)
+ #include <sys/utsname.h>
+ #endif
+ #if defined(SYSV) && defined(__i386__)
+diff -Naur xorg-server-21.1.0/os/ospoll.c xorg-server-patched/os/ospoll.c
+--- xorg-server-21.1.0/os/ospoll.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/os/ospoll.c 2025-10-18 14:20:06.530220468 +0300
+@@ -45,12 +45,6 @@
+ #define HAVE_OSPOLL 1
+ #endif
+
+-#if !HAVE_OSPOLL && defined(HAVE_EPOLL_CREATE1)
+-#include <sys/epoll.h>
+-#define EPOLL 1
+-#define HAVE_OSPOLL 1
+-#endif
+-
+ #if !HAVE_OSPOLL
+ #include "xserver_poll.h"
+ #define POLL 1
diff --git a/tools/pkg/4/xorg-server/diff/libgpg-error.diff b/tools/pkg/4/xorg-server/diff/libgpg-error.diff
new file mode 100644
index 0000000..f936e08
--- /dev/null
+++ b/tools/pkg/4/xorg-server/diff/libgpg-error.diff
@@ -0,0 +1,53 @@
+diff -Naur libgpg-error-1.45/build-aux/config.sub libgpg-error-patched3/build-aux/config.sub
+--- libgpg-error-1.45/build-aux/config.sub 2018-10-24 11:00:20.000000000 +0300
++++ libgpg-error-patched3/build-aux/config.sub 2025-10-15 14:39:02.553948824 +0300
+@@ -1358,7 +1358,7 @@
+ | os2* | vos* | palmos* | uclinux* | nucleus* \
+ | morphos* | superux* | rtmk* | windiss* \
+ | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
+- | skyos* | haiku* | rdos* | toppers* | drops* | es* \
++ | skyos* | orange* | haiku* | rdos* | toppers* | drops* | es* \
+ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
+ | midnightbsd*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+diff -Naur libgpg-error-1.45/src/syscfg/lock-obj-pub.orange.h libgpg-error-patched3/src/syscfg/lock-obj-pub.orange.h
+--- libgpg-error-1.45/src/syscfg/lock-obj-pub.orange.h 1970-01-01 03:00:00.000000000 +0300
++++ libgpg-error-patched3/src/syscfg/lock-obj-pub.orange.h 2018-10-12 18:12:38.000000000 +0300
+@@ -0,0 +1,25 @@
++## lock-obj-pub.x86_64-pc-linux-gnu.h
++## File created by gen-posix-lock-obj - DO NOT EDIT
++## To be included by mkheader into gpg-error.h
++
++typedef struct
++{
++ long _vers;
++ union {
++ volatile char _priv[40];
++ long _x_align;
++ long *_xp_align;
++ } u;
++} gpgrt_lock_t;
++
++#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \
++ 0,0,0,0,0,0,0,0, \
++ 0,0,0,0,0,0,0,0, \
++ 0,0,0,0,0,0,0,0, \
++ 0,0,0,0,0,0,0,0}}}
++##
++## Local Variables:
++## mode: c
++## buffer-read-only: t
++## End:
++##
+diff -Naur libgpg-error-1.45/tests/t-printf.c libgpg-error-patched3/tests/t-printf.c
+--- libgpg-error-1.45/tests/t-printf.c 2018-12-12 11:14:31.000000000 +0300
++++ libgpg-error-patched3/tests/t-printf.c 2025-10-15 14:44:20.729513269 +0300
+@@ -449,7 +449,7 @@
+ static void
+ check_fprintf_sf (void)
+ {
+- volatile char *nullptr = NULL; /* Avoid compiler warning. */
++
+ struct sfstate_s sfstate = {NULL};
+ gpgrt_stream_t stream;
+ const char *expect;
diff --git a/tools/pkg/4/xorg-server/diff/openssl.diff b/tools/pkg/4/xorg-server/diff/openssl.diff
new file mode 100644
index 0000000..c1c65a5
--- /dev/null
+++ b/tools/pkg/4/xorg-server/diff/openssl.diff
@@ -0,0 +1,40 @@
+diff --git openssl-clean/Configurations/10-main.conf openssl-workdir/Configurations/10-main.conf
+index 2a047ca..357fd04 100644
+--- openssl-clean/Configurations/10-main.conf
++++ openssl-workdir/Configurations/10-main.conf
+@@ -192,6 +192,35 @@ my %targets = (
+ thread_scheme => "(unknown)",
+ },
+
++#### Oranges config
++ "orange-generic64" => {
++ inherit_from => [ "BASE_unix" ],
++ CFLAGS => picker(default => "-Wall",
++ debug => "-O0 -g",
++ release => "-O3"),
++ CXXFLAGS => picker(default => "-Wall",
++ debug => "-O0 -g",
++ release => "-O3"),
++ cxxflags => add("-std=c++11"),
++ lib_cppflags => combine("-DOPENSSL_USE_NODELETE", "-DL_ENDIAN"),
++ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
++ thread_scheme => "pthreads",
++ dso_scheme => "dlfcn",
++ shared_target => "linux-shared",
++ shared_cflag => "-fPIC",
++ shared_ldflag => sub { $disabled{pinshared} ? () : "-Wl,-znodelete" },
++ shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
++ },
++
++ "x86_64-orange-mlibc" => {
++ inherit_from => [ "orange-generic64", asm("x86_64_asm") ],
++ perlasm_scheme => "elf",
++
++ CC => "x86_64-orange-mlibc-gcc",
++ CXX => "x86_64-orange-mlibcss-g++",
++
++ },
++
+ #### VOS Configurations
+ "vos-gcc" => {
+ inherit_from => [ "BASE_unix" ], \ No newline at end of file
diff --git a/tools/pkg/4/xorg-server/diff/xfbdev.diff b/tools/pkg/4/xorg-server/diff/xfbdev.diff
new file mode 100644
index 0000000..602adc5
--- /dev/null
+++ b/tools/pkg/4/xorg-server/diff/xfbdev.diff
@@ -0,0 +1,51 @@
+diff --git xf86-video-fbdev-clean/src/Makefile.in xf86-video-fbdev-workdir/src/Makefile.in
+index 016d61d..84213a5 100644
+--- xf86-video-fbdev-clean/src/Makefile.in
++++ xf86-video-fbdev-workdir/src/Makefile.in
+@@ -373,7 +373,7 @@ top_srcdir = @top_srcdir@
+ # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
+ AM_CFLAGS = $(BASE_CFLAGS) $(XORG_CFLAGS)
+ fbdev_drv_la_LTLIBRARIES = fbdev_drv.la
+-fbdev_drv_la_LDFLAGS = -module -avoid-version
++fbdev_drv_la_LDFLAGS = -module -avoid-version -L/ -lfbdevhw -lshadow
+ fbdev_drv_ladir = @moduledir@/drivers
+ fbdev_drv_la_SOURCES = \
+ fbdev.c
+diff --git xf86-video-fbdev-clean/src/fbdev.c xf86-video-fbdev-workdir/src/fbdev.c
+index 939c5b8..4ec1ccb 100644
+--- xf86-video-fbdev-clean/src/fbdev.c
++++ xf86-video-fbdev-workdir/src/fbdev.c
+@@ -331,7 +331,7 @@ FBDevProbe(DriverPtr drv, int flags)
+
+ dev = xf86FindOptionValue(devSections[i]->options,"fbdev");
+ if (devSections[i]->busID) {
+-#ifndef XSERVER_LIBPCIACCESS
++#ifdef XSERVER_LIBPCIACCESS
+ if (xf86ParsePciBusString(devSections[i]->busID,&bus,&device,
+ &func)) {
+ if (!xf86CheckPciSlot(bus,device,func))
+@@ -343,7 +343,7 @@ FBDevProbe(DriverPtr drv, int flags)
+ if (fbdevHWProbe(NULL,dev,NULL)) {
+ pScrn = NULL;
+ if (isPci) {
+-#ifndef XSERVER_LIBPCIACCESS
++#ifdef XSERVER_LIBPCIACCESS
+ /* XXX what about when there's no busID set? */
+ int entity;
+
+@@ -419,6 +419,7 @@ FBDevPreInit(ScrnInfoPtr pScrn, int flags)
+ fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+
+ #ifndef XSERVER_LIBPCIACCESS
++#if 0
+ pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
+ /* XXX Is this right? Can probably remove RAC_FB */
+ pScrn->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
+@@ -429,6 +430,7 @@ FBDevPreInit(ScrnInfoPtr pScrn, int flags)
+ "xf86RegisterResources() found resource conflicts\n");
+ return FALSE;
+ }
++#endif
+ #else
+ if (fPtr->pEnt->location.type == BUS_PCI)
+ pci_dev = fPtr->pEnt->location.id.pci; \ No newline at end of file
diff --git a/tools/pkg/4/xorg-server/diff/xkeyboard.diff b/tools/pkg/4/xorg-server/diff/xkeyboard.diff
new file mode 100644
index 0000000..f3cbff5
--- /dev/null
+++ b/tools/pkg/4/xorg-server/diff/xkeyboard.diff
@@ -0,0 +1,246 @@
+diff --git xf86-input-keyboard-clean/configure xf86-input-keyboard-workdir/configure
+index 76f1212..c2b8867 100755
+--- xf86-input-keyboard-clean/configure
++++ xf86-input-keyboard-workdir/configure
+@@ -664,6 +664,8 @@ SOLARIS_FALSE
+ SOLARIS_TRUE
+ BSD_FALSE
+ BSD_TRUE
++ORANGE_FALSE
++ORANGE_TRUE
+ OS_FLAGS
+ inputdir
+ XORG_LIBS
+@@ -19840,6 +19842,10 @@ inputdir=${moduledir}/input
+
+ # The keyboard driver code is O/S specific
+ case $host_os in
++ orange*)
++ IS_ORANGE="yes"
++ ;;
++
+ linux*)
+ as_fn_error $? "This is not the keyboard driver you are looking for. Use evdev or libinput." "$LINENO" 5
+ ;;
+@@ -19878,6 +19884,14 @@ case $host_os in
+ esac
+
+
++ if test "x$IS_ORANGE" = xyes; then
++ ORANGE_TRUE=
++ ORANGE_FALSE='#'
++else
++ ORANGE_TRUE='#'
++ ORANGE_FALSE=
++fi
++
+ if test "x$IS_BSD" = xyes; then
+ BSD_TRUE=
+ BSD_FALSE='#'
+@@ -20053,6 +20067,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+ as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${ORANGE_TRUE}" && test -z "${ORANGE_FALSE}"; then
++ as_fn_error $? "conditional \"ORANGE\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+ if test -z "${BSD_TRUE}" && test -z "${BSD_FALSE}"; then
+ as_fn_error $? "conditional \"BSD\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+diff --git xf86-input-keyboard-clean/src/Makefile.in xf86-input-keyboard-workdir/src/Makefile.in
+index 6daf679..9a63513 100644
+--- xf86-input-keyboard-clean/src/Makefile.in
++++ xf86-input-keyboard-workdir/src/Makefile.in
+@@ -113,6 +113,7 @@ host_triplet = @host@
+ @BSD_TRUE@am__append_1 = $(BSD_SRCS)
+ @SOLARIS_TRUE@am__append_2 = $(SOLARIS_SRCS)
+ @HURD_TRUE@am__append_3 = $(HURD_SRCS)
++@ORANGE_TRUE@am__append_4 = $(ORANGE_SRCS)
+ subdir = src
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+@@ -155,15 +156,17 @@ am__DEPENDENCIES_1 =
+ kbd_drv_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+ am__kbd_drv_la_SOURCES_DIST = kbd.c xf86OSKbd.h xf86Keymap.h \
+ atKeynames.h bsd_KbdMap.c bsd_kbd.c bsd_kbd.h at_scancode.c \
+- sun_kbd.c sun_kbd.h sun_kbdMap.c hurd_kbd.c
++ sun_kbd.c sun_kbd.h sun_kbdMap.c hurd_kbd.c orange_kbd.c
+ am__objects_1 = bsd_KbdMap.lo bsd_kbd.lo at_scancode.lo
+ @BSD_TRUE@am__objects_2 = $(am__objects_1)
+ am__objects_3 = sun_kbd.lo sun_kbdMap.lo
+ @SOLARIS_TRUE@am__objects_4 = $(am__objects_3)
+ am__objects_5 = hurd_kbd.lo at_scancode.lo
+ @HURD_TRUE@am__objects_6 = $(am__objects_5)
++am__objects_7 = orange_kbd.lo at_scancode.lo
++@ORANGE_TRUE@am__objects_8 = $(am__objects_7)
+ am_kbd_drv_la_OBJECTS = kbd.lo $(am__objects_2) $(am__objects_4) \
+- $(am__objects_6)
++ $(am__objects_6) $(am__objects_8)
+ kbd_drv_la_OBJECTS = $(am_kbd_drv_la_OBJECTS)
+ AM_V_lt = $(am__v_lt_@AM_V@)
+ am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+@@ -189,7 +192,7 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp
+ am__maybe_remake_depfiles = depfiles
+ am__depfiles_remade = ./$(DEPDIR)/at_scancode.Plo \
+ ./$(DEPDIR)/bsd_KbdMap.Plo ./$(DEPDIR)/bsd_kbd.Plo \
+- ./$(DEPDIR)/hurd_kbd.Plo ./$(DEPDIR)/kbd.Plo \
++ ./$(DEPDIR)/hurd_kbd.Plo ./$(DEPDIR)/orange_kbd.Plo ./$(DEPDIR)/kbd.Plo \
+ ./$(DEPDIR)/sun_kbd.Plo ./$(DEPDIR)/sun_kbdMap.Plo
+ am__mv = mv -f
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+@@ -388,13 +391,14 @@ AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS) $(OS_FLAGS)
+ kbd_drv_la_LTLIBRARIES = kbd_drv.la
+ kbd_drv_la_LDFLAGS = -avoid-version -module
+ kbd_drv_la_SOURCES = kbd.c xf86OSKbd.h xf86Keymap.h atKeynames.h \
+- $(am__append_1) $(am__append_2) $(am__append_3)
++ $(am__append_1) $(am__append_2) $(am__append_3) $(am__append_4)
+ kbd_drv_la_LIBADD = $(XORG_LIBS)
+ kbd_drv_ladir = @inputdir@
++ORANGE_SRCS = orange_kbd.c at_scancode.c
+ BSD_SRCS = bsd_KbdMap.c bsd_kbd.c bsd_kbd.h at_scancode.c
+ HURD_SRCS = hurd_kbd.c at_scancode.c
+ SOLARIS_SRCS = sun_kbd.c sun_kbd.h sun_kbdMap.c
+-EXTRA_DIST = $(BSD_SRCS) $(HURD_SRCS) $(SOLARIS_SRCS)
++EXTRA_DIST = $(ORANGE_SRCS) $(BSD_SRCS) $(HURD_SRCS) $(SOLARIS_SRCS)
+ all: all-am
+
+ .SUFFIXES:
+@@ -475,6 +479,7 @@ distclean-compile:
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_KbdMap.Plo@am__quote@ # am--include-marker
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_kbd.Plo@am__quote@ # am--include-marker
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hurd_kbd.Plo@am__quote@ # am--include-marker
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orange_kbd.Plo@am__quote@ # am--include-marker
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kbd.Plo@am__quote@ # am--include-marker
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_kbd.Plo@am__quote@ # am--include-marker
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_kbdMap.Plo@am__quote@ # am--include-marker
+@@ -643,6 +648,7 @@ distclean: distclean-am
+ -rm -f ./$(DEPDIR)/bsd_KbdMap.Plo
+ -rm -f ./$(DEPDIR)/bsd_kbd.Plo
+ -rm -f ./$(DEPDIR)/hurd_kbd.Plo
++ -rm -f ./$(DEPDIR)/orange_kbd.Plo
+ -rm -f ./$(DEPDIR)/kbd.Plo
+ -rm -f ./$(DEPDIR)/sun_kbd.Plo
+ -rm -f ./$(DEPDIR)/sun_kbdMap.Plo
+@@ -695,6 +701,7 @@ maintainer-clean: maintainer-clean-am
+ -rm -f ./$(DEPDIR)/bsd_KbdMap.Plo
+ -rm -f ./$(DEPDIR)/bsd_kbd.Plo
+ -rm -f ./$(DEPDIR)/hurd_kbd.Plo
++ -rm -f ./$(DEPDIR)/orange_kbd.Plo
+ -rm -f ./$(DEPDIR)/kbd.Plo
+ -rm -f ./$(DEPDIR)/sun_kbd.Plo
+ -rm -f ./$(DEPDIR)/sun_kbdMap.Plo
+diff --git xf86-input-keyboard-workdir/src/orange_kbd.c xf86-input-keyboard-workdir/src/orange_kbd.c
+new file mode 100644
+index 0000000..3f20d5c
+--- /dev/null
++++ xf86-input-keyboard-workdir/src/orange_kbd.c
+@@ -0,0 +1,108 @@
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#include <X11/X.h>
++#include <xorg-server.h>
++
++#include "compiler.h"
++
++#include "xf86.h"
++#include "xf86Priv.h"
++#include "xf86_OSlib.h"
++
++#include "atKeynames.h"
++#include "xf86Keymap.h"
++#include "xf86OSKbd.h"
++#include "xf86Xinput.h"
++
++#include <assert.h>
++#include <errno.h>
++#include <stdio.h>
++#include <sys/file.h>
++#include <sys/ioctl.h>
++#include <sys/time.h>
++
++static int KbdOn(InputInfoPtr pInfo, int what) {
++ return Success;
++}
++
++static int KbdOff(InputInfoPtr pInfo, int what) {
++ printf("kbdOff is a stub!\n");
++ return -1;
++}
++
++static void SoundKbdBell(InputInfoPtr pInfo, int loudness, int pitch, int duration) {
++ printf("SoundKbdBell is a stub!\n");
++}
++
++static void SetKbdLeds(InputInfoPtr pInfo, int leds) {
++ printf("SetKbdLeds: is a stub!\n");
++}
++
++static int GetKbdLeds(InputInfoPtr pInfo) {
++ printf("GetKbdLeds is a stub!\n");
++ return -1;
++}
++
++// Save the initial keyboard state. This function is called at the start
++// of each server generation.
++static int KbdInit(InputInfoPtr pInfo, int what) {
++ return Success;
++}
++
++static void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap) {
++ printf("KbdGetMapping is a stub!\n");
++}
++
++static void ReadInput(InputInfoPtr pInfo) {
++ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
++
++ uint8_t scancodes[64];
++ ssize_t result = read(pInfo->fd, scancodes, sizeof(scancodes));
++ if (result > 0) {
++ for (ssize_t i = 0; i < result; i++) {
++ pKbd->PostEvent(pInfo, scancodes[i] & 0x7f, scancodes[i] & 0x80 ? FALSE : TRUE);
++ }
++ }
++}
++
++static Bool OpenKeyboard(InputInfoPtr pInfo) {
++ char *kbdPath = xf86SetStrOption(pInfo->options, "Device", "/dev/ps2keyboard");
++ Bool ret;
++
++ pInfo->fd = open(kbdPath, O_RDONLY | O_NONBLOCK);
++
++ if (pInfo->fd == -1) {
++ xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, kbdPath);
++ ret = FALSE;
++ } else {
++ xf86MsgVerb(X_INFO, 3, "%s: opened device \"%s\"\n", pInfo->name, kbdPath);
++ pInfo->read_input = ReadInput;
++ ret = TRUE;
++
++ // in case it wasn't set and we fell back to default.
++ xf86ReplaceStrOption(pInfo->options, "Device", kbdPath);
++ }
++
++ free(kbdPath);
++ return ret;
++}
++
++Bool xf86OSKbdPreInit(InputInfoPtr pInfo) {
++ KbdDevPtr pKbd = pInfo->private;
++
++ pKbd->KbdInit = KbdInit;
++ pKbd->KbdOn = KbdOn;
++ pKbd->KbdOff = KbdOff;
++ pKbd->Bell = SoundKbdBell;
++ pKbd->SetLeds = SetKbdLeds;
++ pKbd->GetLeds = GetKbdLeds;
++ pKbd->KbdGetMapping = KbdGetMapping;
++ pKbd->OpenKeyboard = OpenKeyboard;
++
++ pKbd->RemapScanCode = NULL;
++ pKbd->private = NULL;
++
++ return TRUE;
++}
diff --git a/tools/pkg/4/xorg-server/diff/xorgproto.diff b/tools/pkg/4/xorg-server/diff/xorgproto.diff
new file mode 100644
index 0000000..2026562
--- /dev/null
+++ b/tools/pkg/4/xorg-server/diff/xorgproto.diff
@@ -0,0 +1,26 @@
+diff --git xorgproto-clean/include/X11/Xfuncs.h xorgproto-workdir/include/X11/Xfuncs.h
+index b23c283..82c856c 100644
+--- xorgproto-clean/include/X11/Xfuncs.h
++++ xorgproto-workdir/include/X11/Xfuncs.h
+@@ -44,7 +44,7 @@ void bcopy();
+ # define bcmp(b1,b2,len) memcmp(b1, b2, len)
+ # else
+ # include <string.h>
+-# if defined(__SCO__) || defined(__sun) || defined(__UNIXWARE__) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__)
++# if defined(__SCO__) || defined(__sun) || defined(__UNIXWARE__) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__) || defined(__orange__)
+ # include <strings.h>
+ # endif
+ # define _XFUNCS_H_INCLUDED_STRING_H
+diff --git xorgproto-clean/include/X11/Xos.h xorgproto-workdir/include/X11/Xos.h
+index 28dfc67..f46490a 100644
+--- xorgproto-clean/include/X11/Xos.h
++++ xorgproto-workdir/include/X11/Xos.h
+@@ -60,7 +60,7 @@ in this Software without prior written authorization from The Open Group.
+ */
+
+ # include <string.h>
+-# if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__)
++# if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__) || defined(__orange__)
+ # include <strings.h>
+ # else
+ # ifndef index \ No newline at end of file
diff --git a/tools/pkg/4/xorg-server/diff/xorgserver.diff b/tools/pkg/4/xorg-server/diff/xorgserver.diff
new file mode 100644
index 0000000..741c5f9
--- /dev/null
+++ b/tools/pkg/4/xorg-server/diff/xorgserver.diff
@@ -0,0 +1,426 @@
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Bus.c xorg-server-patched/hw/xfree86/common/xf86Bus.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Bus.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Bus.c 2025-10-23 12:44:22.775506715 +0300
+@@ -556,21 +556,7 @@
+ void
+ xf86PostProbe(void)
+ {
+- if (fbSlotClaimed && (
+-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+- sbusSlotClaimed ||
+-#endif
+-#ifdef XSERVER_PLATFORM_BUS
+- platformSlotClaimed ||
+-#endif
+-#ifdef XSERVER_LIBPCIACCESS
+- pciSlotClaimed
+-#else
+- TRUE
+-#endif
+- ))
+- FatalError("Cannot run in framebuffer mode. Please specify busIDs "
+- " for all framebuffer devices\n");
++
+ }
+
+ Bool
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Config.c xorg-server-patched/hw/xfree86/common/xf86Config.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Config.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Config.c 2025-10-18 14:14:41.313332537 +0300
+@@ -49,6 +49,8 @@
+ #include <sys/types.h>
+ #include <grp.h>
+
++#include <sys/stat.h>
++
+ #include "xf86.h"
+ #include "xf86Modes.h"
+ #include "xf86Parser.h"
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Configure.c xorg-server-patched/hw/xfree86/common/xf86Configure.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Configure.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Configure.c 2025-10-18 14:15:07.924147512 +0300
+@@ -27,6 +27,8 @@
+ #include <xorg-config.h>
+ #endif
+
++#include <errno.h>
++
+ #include "xf86.h"
+ #include "xf86Config.h"
+ #include "xf86_OSlib.h"
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Events.c xorg-server-patched/hw/xfree86/common/xf86Events.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Events.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Events.c 2025-10-18 14:15:29.363803215 +0300
+@@ -53,6 +53,8 @@
+ #include <xorg-config.h>
+ #endif
+
++#include <errno.h>
++
+ #include <X11/X.h>
+ #include <X11/Xproto.h>
+ #include <X11/Xatom.h>
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Helper.c xorg-server-patched/hw/xfree86/common/xf86Helper.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Helper.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Helper.c 2025-10-23 14:57:42.305808491 +0300
+@@ -34,6 +34,8 @@
+ * different drivers.
+ */
+
++#include <sys/stat.h>
++
+ #ifdef HAVE_XORG_CONFIG_H
+ #include <xorg-config.h>
+ #endif
+@@ -851,49 +853,65 @@
+ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
+ {
+ MessageType from = X_DEFAULT;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ xf86MonPtr DDC = (xf86MonPtr) (pScrn->monitor->DDC);
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ int probedWidthmm, probedHeightmm;
+ int widthErr, heightErr;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ xf86OutputPtr compat = xf86CompatOutput(pScrn);
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+
+ /* XXX Maybe there is no need for widthmm/heightmm in ScrnInfoRec */
+ pScrn->widthmm = pScrn->monitor->widthmm;
+ pScrn->heightmm = pScrn->monitor->heightmm;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+
+ if (DDC && (DDC->features.hsize > 0 && DDC->features.vsize > 0)) {
+ /* DDC gives display size in mm for individual modes,
+ * but cm for monitor
+ */
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy1\n");
+ probedWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
+ probedHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy1\n");
+ }
+ else if (compat && compat->mm_width > 0 && compat->mm_height > 0) {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy2\n");
+ probedWidthmm = compat->mm_width;
+ probedHeightmm = compat->mm_height;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy2\n");
+ }
+ else {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy3\n");
+ probedWidthmm = probedHeightmm = 0;
+ }
+
+ if (monitorResolution > 0) {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy4\n");
+ pScrn->xDpi = monitorResolution;
+ pScrn->yDpi = monitorResolution;
+ from = X_CMDLINE;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy5\n");
+ }
+ else if (pScrn->widthmm > 0 || pScrn->heightmm > 0) {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy6\n");
+ from = X_CONFIG;
+ if (pScrn->widthmm > 0) {
+ pScrn->xDpi =
+ (int) ((double) pScrn->virtualX * MMPERINCH / pScrn->widthmm);
+ }
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ if (pScrn->heightmm > 0) {
+ pScrn->yDpi =
+ (int) ((double) pScrn->virtualY * MMPERINCH / pScrn->heightmm);
+ }
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
+ pScrn->yDpi = pScrn->xDpi;
+ if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
+ pScrn->xDpi = pScrn->yDpi;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
+ pScrn->widthmm, pScrn->heightmm);
+
+@@ -919,8 +937,10 @@
+ pScrn->heightmm);
+ }
+ }
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guy\n");
+ }
+ else if (probedWidthmm && probedHeightmm) {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guyZ\n");
+ from = X_PROBED;
+ xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
+ probedWidthmm, probedHeightmm);
+@@ -940,6 +960,7 @@
+ pScrn->xDpi = pScrn->yDpi;
+ }
+ else {
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "guyX\n");
+ if (x > 0)
+ pScrn->xDpi = x;
+ else
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Init.c xorg-server-patched/hw/xfree86/common/xf86Init.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Init.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Init.c 2025-10-18 14:17:21.699226880 +0300
+@@ -34,6 +34,8 @@
+ #include <xorg-config.h>
+ #endif
+
++#include <sys/stat.h>
++
+ #include <stdlib.h>
+ #include <errno.h>
+
+diff -Naur xorg-server-21.1.0/hw/xfree86/common/xf86Mode.c xorg-server-patched/hw/xfree86/common/xf86Mode.c
+--- xorg-server-21.1.0/hw/xfree86/common/xf86Mode.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/common/xf86Mode.c 2025-10-23 14:29:02.407987453 +0300
+@@ -2118,5 +2118,6 @@
+ if (hsync != 0 && refresh != 0)
+ xf86PrintModeline(scrp->scrnIndex, p);
+ p = p->next;
++
+ } while (p != NULL && p != scrp->modes);
+ }
+diff -Naur xorg-server-21.1.0/hw/xfree86/fbdevhw/fbdevhw.c xorg-server-patched/hw/xfree86/fbdevhw/fbdevhw.c
+--- xorg-server-21.1.0/hw/xfree86/fbdevhw/fbdevhw.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/fbdevhw/fbdevhw.c 2025-10-19 09:37:47.188152245 +0300
+@@ -9,13 +9,10 @@
+ #include "xf86Modes.h"
+ #include "xf86_OSproc.h"
+
+-/* pci stuff */
+-#include "xf86Pci.h"
+-
+ #include "xf86cmap.h"
+
+ #include "fbdevhw.h"
+-#include "fbpriv.h"
++#include <linux/fb.h>
+ #include "globals.h"
+ #include <X11/extensions/dpmsconst.h>
+
+@@ -253,57 +250,6 @@
+ mode->CrtcVAdjusted = FALSE;
+ }
+
+-/* -------------------------------------------------------------------- */
+-/* open correct framebuffer device */
+-
+-/**
+- * Try to find the framebuffer device for a given PCI device
+- */
+-static int
+-fbdev_open_pci(struct pci_device *pPci, char **namep)
+-{
+- struct fb_fix_screeninfo fix;
+- char filename[256];
+- int fd, i;
+-
+- for (i = 0; i < 8; i++) {
+- snprintf(filename, sizeof(filename),
+- "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics/fb%d",
+- pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
+-
+- fd = open(filename, O_RDONLY, 0);
+- if (fd < 0) {
+- snprintf(filename, sizeof(filename),
+- "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics:fb%d",
+- pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
+- fd = open(filename, O_RDONLY, 0);
+- }
+- if (fd >= 0) {
+- close(fd);
+- snprintf(filename, sizeof(filename), "/dev/fb%d", i);
+-
+- fd = open(filename, O_RDWR, 0);
+- if (fd != -1) {
+- if (ioctl(fd, FBIOGET_FSCREENINFO, (void *) &fix) != -1) {
+- if (namep) {
+- *namep = xnfalloc(16);
+- strncpy(*namep, fix.id, 16);
+- }
+-
+- return fd;
+- }
+- close(fd);
+- }
+- }
+- }
+-
+- if (namep)
+- *namep = NULL;
+-
+- xf86DrvMsg(-1, X_ERROR, "Unable to find a valid framebuffer device\n");
+- return -1;
+-}
+-
+ static int
+ fbdev_open(int scrnIndex, const char *dev, char **namep)
+ {
+@@ -329,22 +275,6 @@
+ return -1;
+ }
+
+- /* only touch non-PCI devices on this path */
+- {
+- char buf[PATH_MAX] = {0};
+- char *sysfs_path = NULL;
+- char *node = strrchr(dev, '/') + 1;
+-
+- if (asprintf(&sysfs_path, "/sys/class/graphics/%s", node) < 0 ||
+- readlink(sysfs_path, buf, sizeof(buf) - 1) < 0 ||
+- strstr(buf, "devices/pci")) {
+- free(sysfs_path);
+- close(fd);
+- return -1;
+- }
+- free(sysfs_path);
+- }
+-
+ if (namep) {
+ if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, (void *) (&fix))) {
+ *namep = NULL;
+@@ -363,14 +293,12 @@
+ /* -------------------------------------------------------------------- */
+
+ Bool
+-fbdevHWProbe(struct pci_device *pPci, char *device, char **namep)
++fbdevHWProbe(void *pPci, char *device, char **namep)
+ {
+ int fd;
+-
+- if (pPci)
+- fd = fbdev_open_pci(pPci, namep);
+- else
+- fd = fbdev_open(-1, device, namep);
++
++ fd = fbdev_open(-1, device, namep);
++
+
+ if (-1 == fd)
+ return FALSE;
+@@ -379,18 +307,15 @@
+ }
+
+ Bool
+-fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device)
++fbdevHWInit(ScrnInfoPtr pScrn, void *pPci, char *device)
+ {
+ fbdevHWPtr fPtr;
+
+ fbdevHWGetRec(pScrn);
+ fPtr = FBDEVHWPTR(pScrn);
+
+- /* open device */
+- if (pPci)
+- fPtr->fd = fbdev_open_pci(pPci, NULL);
+- else
+- fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL);
++ fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL);
++
+ if (-1 == fPtr->fd) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to open framebuffer device, consult warnings"
+diff -Naur xorg-server-21.1.0/hw/xfree86/fbdevhw/fbdevhw.h xorg-server-patched/hw/xfree86/fbdevhw/fbdevhw.h
+--- xorg-server-21.1.0/hw/xfree86/fbdevhw/fbdevhw.h 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/fbdevhw/fbdevhw.h 2025-10-19 09:38:08.190818849 +0300
+@@ -16,9 +16,9 @@
+
+ extern _X_EXPORT int fbdevHWGetFD(ScrnInfoPtr pScrn);
+
+-extern _X_EXPORT Bool fbdevHWProbe(struct pci_device *pPci, char *device,
++extern _X_EXPORT Bool fbdevHWProbe(void *pPci, char *device,
+ char **namep);
+-extern _X_EXPORT Bool fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci,
++extern _X_EXPORT Bool fbdevHWInit(ScrnInfoPtr pScrn, void *pPci,
+ char *device);
+
+ extern _X_EXPORT char *fbdevHWGetName(ScrnInfoPtr pScrn);
+diff -Naur xorg-server-21.1.0/hw/xfree86/modes/xf86Crtc.h xorg-server-patched/hw/xfree86/modes/xf86Crtc.h
+--- xorg-server-21.1.0/hw/xfree86/modes/xf86Crtc.h 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/modes/xf86Crtc.h 2025-10-23 18:17:12.719700281 +0300
+@@ -837,8 +837,12 @@
+ static _X_INLINE xf86OutputPtr
+ xf86CompatOutput(ScrnInfoPtr pScrn)
+ {
++
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+
++ if(!config)
++ return NULL;
++
+ if (config->compat_output < 0)
+ return NULL;
+ return config->output[config->compat_output];
+@@ -849,6 +853,8 @@
+ {
+ xf86OutputPtr compat_output = xf86CompatOutput(pScrn);
+
++
++
+ if (!compat_output)
+ return NULL;
+ return compat_output->crtc;
+diff -Naur xorg-server-21.1.0/hw/xfree86/os-support/shared/posix_tty.c xorg-server-patched/hw/xfree86/os-support/shared/posix_tty.c
+--- xorg-server-21.1.0/hw/xfree86/os-support/shared/posix_tty.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/os-support/shared/posix_tty.c 2025-10-18 14:18:16.925903537 +0300
+@@ -56,6 +56,9 @@
+ #include <xorg-config.h>
+ #endif
+
++#include <termios.h>
++#include <errno.h>
++
+ #include <X11/X.h>
+ #include <xserver_poll.h>
+ #include "xf86.h"
+diff -Naur xorg-server-21.1.0/hw/xfree86/os-support/shared/sigio.c xorg-server-patched/hw/xfree86/os-support/shared/sigio.c
+--- xorg-server-21.1.0/hw/xfree86/os-support/shared/sigio.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/hw/xfree86/os-support/shared/sigio.c 2025-10-18 14:18:36.612500292 +0300
+@@ -56,6 +56,9 @@
+ #include <xorg-config.h>
+ #endif
+
++#include <sys/stat.h>
++#include <errno.h>
++
+ #include <X11/X.h>
+ #include <xserver_poll.h>
+ #include "xf86.h"
+diff -Naur xorg-server-21.1.0/include/os.h xorg-server-patched/include/os.h
+--- xorg-server-21.1.0/include/os.h 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/include/os.h 2025-10-18 14:19:09.429494076 +0300
+@@ -51,6 +51,7 @@
+ #include <stdarg.h>
+ #include <stdint.h>
+ #include <string.h>
++#include <strings.h>
+ #ifdef MONOTONIC_CLOCK
+ #include <time.h>
+ #endif
+diff -Naur xorg-server-21.1.0/os/access.c xorg-server-patched/os/access.c
+--- xorg-server-21.1.0/os/access.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/os/access.c 2025-10-18 14:19:29.654105938 +0300
+@@ -116,7 +116,7 @@
+ #endif
+ #endif
+
+-#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__)
++#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__) || defined(__orange__)
+ #include <sys/utsname.h>
+ #endif
+ #if defined(SYSV) && defined(__i386__)
+diff -Naur xorg-server-21.1.0/os/ospoll.c xorg-server-patched/os/ospoll.c
+--- xorg-server-21.1.0/os/ospoll.c 2021-10-27 13:47:08.000000000 +0300
++++ xorg-server-patched/os/ospoll.c 2025-10-18 14:20:06.530220468 +0300
+@@ -45,12 +45,6 @@
+ #define HAVE_OSPOLL 1
+ #endif
+
+-#if !HAVE_OSPOLL && defined(HAVE_EPOLL_CREATE1)
+-#include <sys/epoll.h>
+-#define EPOLL 1
+-#define HAVE_OSPOLL 1
+-#endif
+-
+ #if !HAVE_OSPOLL
+ #include "xserver_poll.h"
+ #define POLL 1
diff --git a/tools/pkg/4/xorg-server/info.txt b/tools/pkg/4/xorg-server/info.txt
new file mode 100644
index 0000000..0e680f2
--- /dev/null
+++ b/tools/pkg/4/xorg-server/info.txt
@@ -0,0 +1 @@
+xorg-server \ No newline at end of file
diff --git a/tools/pkg/4/xorg-server/pkg.sh b/tools/pkg/4/xorg-server/pkg.sh
new file mode 100644
index 0000000..fcd1d84
--- /dev/null
+++ b/tools/pkg/4/xorg-server/pkg.sh
@@ -0,0 +1,142 @@
+
+. ../../pkg-lib.sh
+export PKG_CONFIG_PATh
+
+mkdir -p cached
+
+rm -rf pack
+
+mkdir -p pack
+
+cd pack
+
+wget https://www.zlib.net/fossils/zlib-1.3.tar.gz
+
+tar -xvf zlib-1.3.tar.gz
+
+cd zlib-1.3
+
+CHOST=x86_64-orange-mlibc prefix="/usr" ./configure
+make -j$(nproc)
+make install DESTDIR="$1"
+
+cd ..
+
+CFLAGS="-fPIC" fast_install "$1" "https://downloads.sourceforge.net/libpng/libpng-1.6.37.tar.gz"
+
+fast_install "$1" https://downloads.sourceforge.net/freetype/freetype-2.12.1.tar.gz
+
+wget https://www.x.org/pub/individual/util/util-macros-1.20.0.tar.gz
+tar -xvf util-macros-1.20.0.tar.gz
+
+cd util-macros-1.20.0
+
+./configure --prefix="$HOME/opt/cross/orange"
+make -j$(nproc)
+make install
+
+cd ..
+
+wget https://www.openssl.org/source/openssl-1.1.1q.tar.gz
+tar -xvf openssl-1.1.1q.tar.gz
+
+cd openssl-1.1.1q
+diff_patch ../../diff/openssl.diff
+
+CFLAGS="-Wno-implicit-function-declaration" CC=x86_64-orange-mlibc-gcc CXX=x86_64-orange-mlibc-gcc ./Configure --prefix=/usr --openssldir=/etc/ssl --libdir=lib "x86_64-orange-mlibc" shared zlib-dynamic no-afalgeng
+
+make -j$(nproc)
+
+make install MANSUFFIX=ssl DESTDIR="$1"
+
+cd ..
+
+fast_install "$1" https://www.x.org/archive/individual/lib/xtrans-1.4.0.tar.gz
+
+fast_install "$1" https://www.x.org/releases/individual/proto/xproto-7.0.31.tar.gz "--enable-shared" "../../diff/libxproto.diff"
+
+fast_install "$1" https://www.x.org/releases/individual/proto/fontsproto-2.1.3.tar.gz
+
+fast_install "$1" https://www.x.org/archive/individual/lib/libfontenc-1.1.8.tar.gz
+fast_install "$1" https://www.x.org/archive/individual/lib/libXfont2-2.0.6.tar.gz
+fast_install "$1" https://cairographics.org/releases/pixman-0.40.0.tar.gz
+wget https://www.x.org/releases/individual/proto/xorgproto-2022.2.tar.gz
+
+tar -xvf xorgproto-2022.2.tar.gz
+
+cd xorgproto-2022.2
+
+diff_patch ../../diff/xorgproto.diff
+patch_config_sub "$(realpath $1/..)"
+
+mkdir -p build0
+
+meson --cross-file="$1/../tools/pkg/x86_64-orange.crossfile" --prefix=/usr -Dlegacy=true build0
+
+cd build0
+
+ninja
+DESTDIR="$1" ninja install
+
+cd ../..
+
+fast_install "$1" https://www.x.org/releases/individual/xcb/libpthread-stubs-0.5.tar.gz
+
+fast_install "$1" https://www.x.org/releases/individual/xcb/xcb-proto-1.15.tar.gz
+
+fast_install "$1" https://www.x.org/releases/individual/lib/libXau-1.0.9.tar.gz
+fast_install "$1" https://www.x.org/releases/individual/xcb/libxcb-1.15.tar.gz
+fast_install "$1" https://www.x.org/releases/individual/lib/libX11-1.8.1.tar.gz
+
+fast_install "$1" https://www.x.org/archive/individual/lib/libxkbfile-1.1.1.tar.gz
+
+fast_install "$1" https://www.x.org/releases/individual/lib/libXfixes-6.0.0.tar.gz
+
+wget https://www.x.org/releases/individual/lib/libxcvt-0.1.2.tar.xz
+tar -xvf libxcvt-0.1.2.tar.xz
+
+cd libxcvt-0.1.2
+
+mkdir -p build
+
+meson --cross-file="$1/../tools/pkg/x86_64-orange.crossfile" --prefix="/usr" build
+
+cd build
+ninja
+DESTDIR="$1" ninja install
+cd ../..
+
+fast_install "$1" https://www.x.org/archive/individual/app/xkbcomp-1.4.5.tar.gz
+
+wget http://www.x.org/releases/individual/data/xkeyboard-config/xkeyboard-config-2.36.tar.xz
+tar -xvf xkeyboard-config-2.36.tar.xz
+
+pushd xkeyboard-config-2.36
+sed -i -E "s/(ln -s)/\1f/" rules/meson.build
+popd
+
+cd xkeyboard-config-2.36
+
+mkdir -p build
+meson --cross-file="$1/../tools/pkg/x86_64-orange.crossfile" --prefix="/usr" build
+
+cd build
+ninja
+sudo DESTDIR="$1" ninja install
+
+cd ../..
+
+rm -rf "$1/usr/share/X11/xkb"
+
+ooo="$(pwd)"
+cd "$1/usr/share/X11"
+ln -s ../xkeyboard-config-2 xkb
+
+cd "$ooo"
+
+fast_install "$1" https://www.x.org/releases/individual/xserver/xorg-server-21.1.4.tar.gz "--with-xkb-bin-directory=/usr/bin --disable-pciaccess --disable-libdrm --disable-glx --disable-int10-module --disable-glamor --disable-vgahw --disable-dri3 --disable-dri2 --disable-dri --disable-xephyr --disable-xwayland --disable-xnest --disable-dmx --with-fontrootdir=/usr/share/fonts/X11 --disable-strict-compilation" "../../diff/xorgserver.diff"
+
+
+# at this point i just tired so ill use ironclad patches
+
+mkdir -p "$1"/usr/lib/xorg/modules/extensions \ No newline at end of file
diff --git a/tools/pkg/5/twm/diff/fontconfig.diff b/tools/pkg/5/twm/diff/fontconfig.diff
new file mode 100644
index 0000000..fa0bb11
--- /dev/null
+++ b/tools/pkg/5/twm/diff/fontconfig.diff
@@ -0,0 +1,12 @@
+diff -Naur fontconfig-2.13.94/src/fcstat.c fontconfig-patched/src/fcstat.c
+--- fontconfig-2.13.94/src/fcstat.c 2020-12-03 14:45:00.000000000 +0300
++++ fontconfig-patched/src/fcstat.c 2025-10-26 08:27:40.889979729 +0300
+@@ -386,7 +386,7 @@
+ # endif
+ # if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME)
+ p = buf.f_fstypename;
+-# elif defined(__linux__)
++# elif defined(__linux__) || defined(__orange__)
+ switch (buf.f_type)
+ {
+ case 0x6969: /* nfs */
diff --git a/tools/pkg/5/twm/diff/libxt.diff b/tools/pkg/5/twm/diff/libxt.diff
new file mode 100644
index 0000000..228f540
--- /dev/null
+++ b/tools/pkg/5/twm/diff/libxt.diff
@@ -0,0 +1,16 @@
+diff -Naur libXt-1.2.1/src/Shell.c libXt-patched/src/Shell.c
+--- libXt-1.2.1/src/Shell.c 2021-01-24 17:47:39.000000000 +0300
++++ libXt-patched/src/Shell.c 2025-10-26 08:06:07.473650705 +0300
+@@ -1003,10 +1003,10 @@
+ static void
+ _XtShellAncestorSensitive(Widget widget, int closure, XrmValue *value)
+ {
+- static Boolean true = True;
++ int xx = 1;
+
+ if (widget->core.parent == NULL)
+- value->addr = (XPointer) (&true);
++ value->addr = (XPointer) (&xx);
+ else
+ _XtCopyFromParent(widget, closure, value);
+ }
diff --git a/tools/pkg/5/twm/diff/xterm.diff b/tools/pkg/5/twm/diff/xterm.diff
new file mode 100644
index 0000000..c2d2714
--- /dev/null
+++ b/tools/pkg/5/twm/diff/xterm.diff
@@ -0,0 +1,148 @@
+diff --git xterm-clean/Makefile.in xterm-workdir/Makefile.in
+index bb6da23..9500664 100644
+--- xterm-clean/Makefile.in
++++ xterm-workdir/Makefile.in
+@@ -68,7 +68,7 @@ PIXMAPDIR_DEF = @no_pixmapdir@-DPIXMAP_ROOTDIR=\"@PIXMAPDIR@/\"
+ CPPFLAGS = -I. -I$(srcdir) -DHAVE_CONFIG_H @CPPFLAGS@ -DDEFCLASS=\"@APP_CLASS@\" $(PIXMAPDIR_DEF) $(EXTRA_CPPFLAGS)
+ CFLAGS = @CFLAGS@ $(EXTRA_CFLAGS)
+ LDFLAGS = @LDFLAGS@ @EXTRA_LDFLAGS@
+-LIBS = @LIBS@
++LIBS = @LIBS@ -lncursesw -ltinfow
+
+ prefix = @prefix@
+ exec_prefix = @exec_prefix@
+diff --git xterm-clean/main.c xterm-workdir/main.c
+index 3d2ad4c..3f235d0 100644
+--- xterm-clean/main.c
++++ xterm-workdir/main.c
+@@ -92,6 +92,7 @@
+ #include <xterm.h>
+ #include <version.h>
+ #include <graphics.h>
++#include <termios.h>
+
+ /* xterm uses these X Toolkit resource names, which are exported in array */
+ #undef XtNborderWidth
+@@ -172,7 +173,7 @@ static GCC_NORETURN void HsSysError(int);
+ #define KANJI
+ #endif
+
+-#ifdef linux
++#if defined(linux) || defined(__orange__)
+ #define USE_SYSV_PGRP
+ #define USE_SYSV_SIGNALS
+ #define WTMP
+@@ -315,7 +316,7 @@ ttyslot(void)
+ #ifndef NOFILE
+ #define NOFILE OPEN_MAX
+ #endif
+-#elif !(defined(VMS) || defined(WIN32) || defined(Lynx) || defined(__GNU__) || defined(__MVS__))
++#elif !(defined(VMS) || defined(WIN32) || defined(Lynx) || defined(__GNU__) || defined(__MVS__) || defined(__orange__))
+ #include <sys/param.h> /* for NOFILE */
+ #endif
+
+@@ -716,11 +717,12 @@ static struct {
+ #endif
+
+ #ifndef TAB3
+-#if defined(OXTABS)
+-#define TAB3 OXTABS
+-#elif defined(XTABS)
+-#define TAB3 XTABS
+-#endif
++#define TAB3 0014000
++//#if defined(OXTABS)
++//#define TAB3 OXTABS
++//#elif defined(XTABS)
++//#define TAB3 XTABS
++//#endif
+ #endif
+
+ #ifndef TABDLY
+@@ -3011,7 +3013,7 @@ main(int argc, char *argv[]ENVP_ARG)
+ }
+ #endif
+ #endif
+-#if defined(USE_ANY_SYSV_TERMIO) || defined(__MVS__) || defined(__minix)
++#if defined(USE_ANY_SYSV_TERMIO) || defined(__MVS__) || defined(__minix) || defined(__orange__)
+ if (0 > (mode = fcntl(screen->respond, F_GETFL, 0)))
+ SysError(ERROR_F_GETFL);
+ #ifdef O_NDELAY
+@@ -3753,7 +3755,7 @@ ourValidShell(const char *pathname)
+ return findValidShell(x_strtrim(resource.valid_shells), pathname);
+ }
+
+-#if defined(HAVE_GETUSERSHELL) && defined(HAVE_ENDUSERSHELL)
++#if defined(HAVE_GETUSERSHELL) && defined(HAVE_ENDUSERSHELL) && 0
+ static Boolean
+ validShell(const char *pathname)
+ {
+@@ -4356,7 +4358,7 @@ spawnXTerm(XtermWidget xw, unsigned line_speed)
+ /*
+ * now in child process
+ */
+-#if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) || defined(__SCO__) || defined(__QNX__)
++#if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) || defined(__SCO__) || defined(__QNX__) || defined(__orange__)
+ int pgrp = setsid(); /* variable may not be used... */
+ #else
+ int pgrp = getpid();
+@@ -4496,7 +4498,7 @@ spawnXTerm(XtermWidget xw, unsigned line_speed)
+ /* make /dev/tty work */
+ ioctl(ttyfd, TCSETCTTY, 0);
+ #endif
+-#if ((defined(__GLIBC__) && defined(__FreeBSD_kernel__)) || defined(__GNU__)) && defined(TIOCSCTTY)
++#if ((defined(__GLIBC__) && defined(__FreeBSD_kernel__)) || defined(__GNU__) || defined(__orange__)) && defined(TIOCSCTTY)
+ /* make /dev/tty work */
+ ioctl(ttyfd, TIOCSCTTY, 0);
+ #endif
+diff --git xterm-clean/xterm.h xterm-workdir/xterm.h
+index 89590cb..9a99f0c 100644
+--- xterm-clean/xterm.h
++++ xterm-workdir/xterm.h
+@@ -80,7 +80,7 @@
+ #define HAVE_PUTENV 1
+ #endif
+
+-#if defined(CSRG_BASED) || defined(__GNU__) || defined(__minix)
++#if defined(CSRG_BASED) || defined(__GNU__) || defined(__minix) || defined(__orange__)
+ #define USE_POSIX_TERMIOS 1
+ #endif
+
+@@ -176,7 +176,7 @@
+ #define USE_SYSV_UTMP
+ #endif
+
+-#if defined(__GNU__) || defined(__MVS__) || defined(__osf__)
++#if defined(__GNU__) || defined(__MVS__) || defined(__osf__) || defined(__orange__)
+ #define USE_TTY_GROUP
+ #endif
+
+diff --git xterm-clean/xterm_io.h xterm-workdir/xterm_io.h
+index 130d365..72ebd01 100644
+--- xterm-clean/xterm_io.h
++++ xterm-workdir/xterm_io.h
+@@ -92,13 +92,14 @@
+ #undef SYSV /* pretend to be bsd (sgtty.h) */
+ #endif /* macII */
+
+-#ifdef __GNU__
++#if defined(__GNU__) || defined(__orange__)
+ #define USE_POSIX_TERMIOS
+ #define HAVE_POSIX_OPENPT 1
+ #define HAVE_PTSNAME 1
+ #define HAVE_GRANTPT_PTY_ISATTY 1
+ #endif
+
++
+ #if defined(__GLIBC__) && !(defined(linux) || defined(__GNU__))
+ #define USE_POSIX_TERMIOS /* GNU/KFreeBSD and GNU/KNetBSD */
+ #endif
+@@ -212,7 +213,7 @@
+ #undef FIONCLEX
+ #endif /* macII */
+
+-#if defined(__QNX__) || defined(__GNU__) || defined(__MVS__) || defined(__osf__)
++#if defined(__QNX__) || defined(__GNU__) || defined(__MVS__) || defined(__osf__) || defined(__orange__)
+ #undef TIOCSLTC /* <sgtty.h> conflicts with <termios.h> */
+ #undef TIOCSLTC
+ #endif \ No newline at end of file
diff --git a/tools/pkg/5/twm/info.txt b/tools/pkg/5/twm/info.txt
new file mode 100644
index 0000000..3047a9f
--- /dev/null
+++ b/tools/pkg/5/twm/info.txt
@@ -0,0 +1 @@
+twm and xapps \ No newline at end of file
diff --git a/tools/pkg/5/twm/pkg.sh b/tools/pkg/5/twm/pkg.sh
new file mode 100644
index 0000000..8a59848
--- /dev/null
+++ b/tools/pkg/5/twm/pkg.sh
@@ -0,0 +1,32 @@
+
+. ../../pkg-lib.sh
+
+rm -rf pack
+mkdir -p pack
+
+cd pack
+
+fast_install "$1" https://www.x.org/releases/individual/lib/libXext-1.3.4.tar.gz
+fast_install "$1" https://www.x.org/releases/individual/lib/libICE-1.1.0.tar.gz
+fast_install "$1" https://www.x.org/releases/individual/lib/libSM-1.2.4.tar.gz
+fast_install "$1" https://www.x.org/releases/individual/lib/libXt-1.2.1.tar.gz "--enable-shared" "../../diff/libxt.diff"
+fast_install "$1" https://www.x.org/releases/individual/lib/libXmu-1.1.3.tar.gz
+
+fast_install "$1" https://www.x.org/archive//individual/app/twm-1.0.11.tar.gz
+
+fast_install "$1" https://www.x.org/releases/individual/lib/libXpm-3.5.14.tar.gz
+fast_install "$1" https://www.x.org/releases/individual/lib/libXaw-1.0.14.tar.gz
+
+fast_install "$1" https://github.com/libexpat/libexpat/releases/download/R_2_4_9/expat-2.4.9.tar.xz
+fast_install "$1" https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.94.tar.gz "--enable-shared" "../../diff/fontconfig.diff"
+
+fast_install "$1" https://www.x.org/releases/individual/lib/libXrender-0.9.11.tar.gz
+fast_install "$1" https://www.x.org/releases/individual/lib/libXft-2.3.4.tar.gz
+
+fast_install "$1" https://www.x.org/releases/individual/lib/libXi-1.8.1.tar.gz
+
+fast_install "$1" https://www.x.org/pub/individual/app/xclock-1.1.1.tar.xz
+fast_install "$1" https://invisible-mirror.net/archives/xterm/xterm-390.tgz "--disable-tcap-fkeys --disable-tcap-query --enable-256-color" "../../diff/xterm.diff"
+fast_install "$1" https://www.x.org/releases/individual/app/xeyes-1.2.0.tar.gz
+
+fast_install "$1" https://www.x.org/releases/individual/app/xinit-1.4.1.tar.gz \ No newline at end of file
diff --git a/tools/pkg/5/xorg-modules/diff/xfbdev.diff b/tools/pkg/5/xorg-modules/diff/xfbdev.diff
new file mode 100644
index 0000000..e2e13e5
--- /dev/null
+++ b/tools/pkg/5/xorg-modules/diff/xfbdev.diff
@@ -0,0 +1,51 @@
+diff --git xf86-video-fbdev-clean/src/Makefile.in xf86-video-fbdev-workdir/src/Makefile.in
+index 016d61d..84213a5 100644
+--- xf86-video-fbdev-clean/src/Makefile.in
++++ xf86-video-fbdev-workdir/src/Makefile.in
+@@ -373,7 +373,7 @@ top_srcdir = @top_srcdir@
+ # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
+ AM_CFLAGS = $(BASE_CFLAGS) $(XORG_CFLAGS)
+ fbdev_drv_la_LTLIBRARIES = fbdev_drv.la
+-fbdev_drv_la_LDFLAGS = -module -avoid-version
++fbdev_drv_la_LDFLAGS = -module -avoid-version -lfbdevhw -lshadow
+ fbdev_drv_ladir = @moduledir@/drivers
+ fbdev_drv_la_SOURCES = \
+ fbdev.c
+diff --git xf86-video-fbdev-clean/src/fbdev.c xf86-video-fbdev-workdir/src/fbdev.c
+index 939c5b8..4ec1ccb 100644
+--- xf86-video-fbdev-clean/src/fbdev.c
++++ xf86-video-fbdev-workdir/src/fbdev.c
+@@ -331,7 +331,7 @@ FBDevProbe(DriverPtr drv, int flags)
+
+ dev = xf86FindOptionValue(devSections[i]->options,"fbdev");
+ if (devSections[i]->busID) {
+-#ifndef XSERVER_LIBPCIACCESS
++#ifdef XSERVER_LIBPCIACCESS
+ if (xf86ParsePciBusString(devSections[i]->busID,&bus,&device,
+ &func)) {
+ if (!xf86CheckPciSlot(bus,device,func))
+@@ -343,7 +343,7 @@ FBDevProbe(DriverPtr drv, int flags)
+ if (fbdevHWProbe(NULL,dev,NULL)) {
+ pScrn = NULL;
+ if (isPci) {
+-#ifndef XSERVER_LIBPCIACCESS
++#ifdef XSERVER_LIBPCIACCESS
+ /* XXX what about when there's no busID set? */
+ int entity;
+
+@@ -419,6 +419,7 @@ FBDevPreInit(ScrnInfoPtr pScrn, int flags)
+ fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+
+ #ifndef XSERVER_LIBPCIACCESS
++#if 0
+ pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
+ /* XXX Is this right? Can probably remove RAC_FB */
+ pScrn->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
+@@ -429,6 +430,7 @@ FBDevPreInit(ScrnInfoPtr pScrn, int flags)
+ "xf86RegisterResources() found resource conflicts\n");
+ return FALSE;
+ }
++#endif
+ #else
+ if (fPtr->pEnt->location.type == BUS_PCI)
+ pci_dev = fPtr->pEnt->location.id.pci; \ No newline at end of file
diff --git a/tools/pkg/5/xorg-modules/diff/xkeyboard.diff b/tools/pkg/5/xorg-modules/diff/xkeyboard.diff
new file mode 100644
index 0000000..f3cbff5
--- /dev/null
+++ b/tools/pkg/5/xorg-modules/diff/xkeyboard.diff
@@ -0,0 +1,246 @@
+diff --git xf86-input-keyboard-clean/configure xf86-input-keyboard-workdir/configure
+index 76f1212..c2b8867 100755
+--- xf86-input-keyboard-clean/configure
++++ xf86-input-keyboard-workdir/configure
+@@ -664,6 +664,8 @@ SOLARIS_FALSE
+ SOLARIS_TRUE
+ BSD_FALSE
+ BSD_TRUE
++ORANGE_FALSE
++ORANGE_TRUE
+ OS_FLAGS
+ inputdir
+ XORG_LIBS
+@@ -19840,6 +19842,10 @@ inputdir=${moduledir}/input
+
+ # The keyboard driver code is O/S specific
+ case $host_os in
++ orange*)
++ IS_ORANGE="yes"
++ ;;
++
+ linux*)
+ as_fn_error $? "This is not the keyboard driver you are looking for. Use evdev or libinput." "$LINENO" 5
+ ;;
+@@ -19878,6 +19884,14 @@ case $host_os in
+ esac
+
+
++ if test "x$IS_ORANGE" = xyes; then
++ ORANGE_TRUE=
++ ORANGE_FALSE='#'
++else
++ ORANGE_TRUE='#'
++ ORANGE_FALSE=
++fi
++
+ if test "x$IS_BSD" = xyes; then
+ BSD_TRUE=
+ BSD_FALSE='#'
+@@ -20053,6 +20067,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+ as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${ORANGE_TRUE}" && test -z "${ORANGE_FALSE}"; then
++ as_fn_error $? "conditional \"ORANGE\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+ if test -z "${BSD_TRUE}" && test -z "${BSD_FALSE}"; then
+ as_fn_error $? "conditional \"BSD\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+diff --git xf86-input-keyboard-clean/src/Makefile.in xf86-input-keyboard-workdir/src/Makefile.in
+index 6daf679..9a63513 100644
+--- xf86-input-keyboard-clean/src/Makefile.in
++++ xf86-input-keyboard-workdir/src/Makefile.in
+@@ -113,6 +113,7 @@ host_triplet = @host@
+ @BSD_TRUE@am__append_1 = $(BSD_SRCS)
+ @SOLARIS_TRUE@am__append_2 = $(SOLARIS_SRCS)
+ @HURD_TRUE@am__append_3 = $(HURD_SRCS)
++@ORANGE_TRUE@am__append_4 = $(ORANGE_SRCS)
+ subdir = src
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+@@ -155,15 +156,17 @@ am__DEPENDENCIES_1 =
+ kbd_drv_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+ am__kbd_drv_la_SOURCES_DIST = kbd.c xf86OSKbd.h xf86Keymap.h \
+ atKeynames.h bsd_KbdMap.c bsd_kbd.c bsd_kbd.h at_scancode.c \
+- sun_kbd.c sun_kbd.h sun_kbdMap.c hurd_kbd.c
++ sun_kbd.c sun_kbd.h sun_kbdMap.c hurd_kbd.c orange_kbd.c
+ am__objects_1 = bsd_KbdMap.lo bsd_kbd.lo at_scancode.lo
+ @BSD_TRUE@am__objects_2 = $(am__objects_1)
+ am__objects_3 = sun_kbd.lo sun_kbdMap.lo
+ @SOLARIS_TRUE@am__objects_4 = $(am__objects_3)
+ am__objects_5 = hurd_kbd.lo at_scancode.lo
+ @HURD_TRUE@am__objects_6 = $(am__objects_5)
++am__objects_7 = orange_kbd.lo at_scancode.lo
++@ORANGE_TRUE@am__objects_8 = $(am__objects_7)
+ am_kbd_drv_la_OBJECTS = kbd.lo $(am__objects_2) $(am__objects_4) \
+- $(am__objects_6)
++ $(am__objects_6) $(am__objects_8)
+ kbd_drv_la_OBJECTS = $(am_kbd_drv_la_OBJECTS)
+ AM_V_lt = $(am__v_lt_@AM_V@)
+ am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+@@ -189,7 +192,7 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp
+ am__maybe_remake_depfiles = depfiles
+ am__depfiles_remade = ./$(DEPDIR)/at_scancode.Plo \
+ ./$(DEPDIR)/bsd_KbdMap.Plo ./$(DEPDIR)/bsd_kbd.Plo \
+- ./$(DEPDIR)/hurd_kbd.Plo ./$(DEPDIR)/kbd.Plo \
++ ./$(DEPDIR)/hurd_kbd.Plo ./$(DEPDIR)/orange_kbd.Plo ./$(DEPDIR)/kbd.Plo \
+ ./$(DEPDIR)/sun_kbd.Plo ./$(DEPDIR)/sun_kbdMap.Plo
+ am__mv = mv -f
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+@@ -388,13 +391,14 @@ AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS) $(OS_FLAGS)
+ kbd_drv_la_LTLIBRARIES = kbd_drv.la
+ kbd_drv_la_LDFLAGS = -avoid-version -module
+ kbd_drv_la_SOURCES = kbd.c xf86OSKbd.h xf86Keymap.h atKeynames.h \
+- $(am__append_1) $(am__append_2) $(am__append_3)
++ $(am__append_1) $(am__append_2) $(am__append_3) $(am__append_4)
+ kbd_drv_la_LIBADD = $(XORG_LIBS)
+ kbd_drv_ladir = @inputdir@
++ORANGE_SRCS = orange_kbd.c at_scancode.c
+ BSD_SRCS = bsd_KbdMap.c bsd_kbd.c bsd_kbd.h at_scancode.c
+ HURD_SRCS = hurd_kbd.c at_scancode.c
+ SOLARIS_SRCS = sun_kbd.c sun_kbd.h sun_kbdMap.c
+-EXTRA_DIST = $(BSD_SRCS) $(HURD_SRCS) $(SOLARIS_SRCS)
++EXTRA_DIST = $(ORANGE_SRCS) $(BSD_SRCS) $(HURD_SRCS) $(SOLARIS_SRCS)
+ all: all-am
+
+ .SUFFIXES:
+@@ -475,6 +479,7 @@ distclean-compile:
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_KbdMap.Plo@am__quote@ # am--include-marker
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_kbd.Plo@am__quote@ # am--include-marker
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hurd_kbd.Plo@am__quote@ # am--include-marker
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orange_kbd.Plo@am__quote@ # am--include-marker
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kbd.Plo@am__quote@ # am--include-marker
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_kbd.Plo@am__quote@ # am--include-marker
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_kbdMap.Plo@am__quote@ # am--include-marker
+@@ -643,6 +648,7 @@ distclean: distclean-am
+ -rm -f ./$(DEPDIR)/bsd_KbdMap.Plo
+ -rm -f ./$(DEPDIR)/bsd_kbd.Plo
+ -rm -f ./$(DEPDIR)/hurd_kbd.Plo
++ -rm -f ./$(DEPDIR)/orange_kbd.Plo
+ -rm -f ./$(DEPDIR)/kbd.Plo
+ -rm -f ./$(DEPDIR)/sun_kbd.Plo
+ -rm -f ./$(DEPDIR)/sun_kbdMap.Plo
+@@ -695,6 +701,7 @@ maintainer-clean: maintainer-clean-am
+ -rm -f ./$(DEPDIR)/bsd_KbdMap.Plo
+ -rm -f ./$(DEPDIR)/bsd_kbd.Plo
+ -rm -f ./$(DEPDIR)/hurd_kbd.Plo
++ -rm -f ./$(DEPDIR)/orange_kbd.Plo
+ -rm -f ./$(DEPDIR)/kbd.Plo
+ -rm -f ./$(DEPDIR)/sun_kbd.Plo
+ -rm -f ./$(DEPDIR)/sun_kbdMap.Plo
+diff --git xf86-input-keyboard-workdir/src/orange_kbd.c xf86-input-keyboard-workdir/src/orange_kbd.c
+new file mode 100644
+index 0000000..3f20d5c
+--- /dev/null
++++ xf86-input-keyboard-workdir/src/orange_kbd.c
+@@ -0,0 +1,108 @@
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#include <X11/X.h>
++#include <xorg-server.h>
++
++#include "compiler.h"
++
++#include "xf86.h"
++#include "xf86Priv.h"
++#include "xf86_OSlib.h"
++
++#include "atKeynames.h"
++#include "xf86Keymap.h"
++#include "xf86OSKbd.h"
++#include "xf86Xinput.h"
++
++#include <assert.h>
++#include <errno.h>
++#include <stdio.h>
++#include <sys/file.h>
++#include <sys/ioctl.h>
++#include <sys/time.h>
++
++static int KbdOn(InputInfoPtr pInfo, int what) {
++ return Success;
++}
++
++static int KbdOff(InputInfoPtr pInfo, int what) {
++ printf("kbdOff is a stub!\n");
++ return -1;
++}
++
++static void SoundKbdBell(InputInfoPtr pInfo, int loudness, int pitch, int duration) {
++ printf("SoundKbdBell is a stub!\n");
++}
++
++static void SetKbdLeds(InputInfoPtr pInfo, int leds) {
++ printf("SetKbdLeds: is a stub!\n");
++}
++
++static int GetKbdLeds(InputInfoPtr pInfo) {
++ printf("GetKbdLeds is a stub!\n");
++ return -1;
++}
++
++// Save the initial keyboard state. This function is called at the start
++// of each server generation.
++static int KbdInit(InputInfoPtr pInfo, int what) {
++ return Success;
++}
++
++static void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap) {
++ printf("KbdGetMapping is a stub!\n");
++}
++
++static void ReadInput(InputInfoPtr pInfo) {
++ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
++
++ uint8_t scancodes[64];
++ ssize_t result = read(pInfo->fd, scancodes, sizeof(scancodes));
++ if (result > 0) {
++ for (ssize_t i = 0; i < result; i++) {
++ pKbd->PostEvent(pInfo, scancodes[i] & 0x7f, scancodes[i] & 0x80 ? FALSE : TRUE);
++ }
++ }
++}
++
++static Bool OpenKeyboard(InputInfoPtr pInfo) {
++ char *kbdPath = xf86SetStrOption(pInfo->options, "Device", "/dev/ps2keyboard");
++ Bool ret;
++
++ pInfo->fd = open(kbdPath, O_RDONLY | O_NONBLOCK);
++
++ if (pInfo->fd == -1) {
++ xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, kbdPath);
++ ret = FALSE;
++ } else {
++ xf86MsgVerb(X_INFO, 3, "%s: opened device \"%s\"\n", pInfo->name, kbdPath);
++ pInfo->read_input = ReadInput;
++ ret = TRUE;
++
++ // in case it wasn't set and we fell back to default.
++ xf86ReplaceStrOption(pInfo->options, "Device", kbdPath);
++ }
++
++ free(kbdPath);
++ return ret;
++}
++
++Bool xf86OSKbdPreInit(InputInfoPtr pInfo) {
++ KbdDevPtr pKbd = pInfo->private;
++
++ pKbd->KbdInit = KbdInit;
++ pKbd->KbdOn = KbdOn;
++ pKbd->KbdOff = KbdOff;
++ pKbd->Bell = SoundKbdBell;
++ pKbd->SetLeds = SetKbdLeds;
++ pKbd->GetLeds = GetKbdLeds;
++ pKbd->KbdGetMapping = KbdGetMapping;
++ pKbd->OpenKeyboard = OpenKeyboard;
++
++ pKbd->RemapScanCode = NULL;
++ pKbd->private = NULL;
++
++ return TRUE;
++}
diff --git a/tools/pkg/5/xorg-modules/info.txt b/tools/pkg/5/xorg-modules/info.txt
new file mode 100644
index 0000000..1a7e25d
--- /dev/null
+++ b/tools/pkg/5/xorg-modules/info.txt
@@ -0,0 +1 @@
+xorg-modules \ No newline at end of file
diff --git a/tools/pkg/5/xorg-modules/pkg.sh b/tools/pkg/5/xorg-modules/pkg.sh
new file mode 100644
index 0000000..8f3811b
--- /dev/null
+++ b/tools/pkg/5/xorg-modules/pkg.sh
@@ -0,0 +1,29 @@
+
+. ../../pkg-lib.sh
+
+rm -rf pack
+mkdir -p pack
+
+cd pack
+
+ca="$(pwd)"
+
+cd "$1/usr/lib"
+
+for file in xorg/modules/*.so; do ln -s "$file" .; done
+
+cd "$ca"
+
+fast_install "$1" https://www.x.org/archive//individual/font/font-util-1.4.1.tar.xz
+
+fast_install "$1" https://www.x.org/pub/individual/font/font-alias-1.0.5.tar.xz
+
+wget https://ftp.debian.org/debian/pool/main/x/xfonts-base/xfonts-base_1.0.5_all.deb
+ar -x xfonts-base_1.0.5_all.deb
+
+tar -xvf data.tar.xz
+cp -rf usr/* "$1/usr"
+cp -rf etc/* "$1/etc"
+
+CFLAGS="-fPIC" SYSROOT="$1/" fast_install "$1" https://www.x.org/releases/individual/driver/xf86-video-fbdev-0.5.1.tar.gz "--disable-pciaccess --disable-static --enable-shared" "../../diff/xfbdev.diff"
+CFLAGS="-fPIC" SYSROOT="$1/" fast_install "$1" https://www.x.org/releases/individual/driver/xf86-input-keyboard-2.1.0.tar.gz "--disable-static --enable-shared" "../../diff/xkeyboard.diff"
diff --git a/tools/pkg/build-pkg.sh b/tools/pkg/build-pkg.sh
index a4dae9c..5001559 100644
--- a/tools/pkg/build-pkg.sh
+++ b/tools/pkg/build-pkg.sh
@@ -1,6 +1,17 @@
echo "Building orange's packages"
+export PATH="$HOME/opt/cross/orange/bin:$PATH"
+
+if [ ! "$(which x86_64-orange-mlibc-gcc)" ]; then
+ echo "It looks like you don't have the cross-compiler installed, or it isn't in your PATH."
+ echo "If you built your cross-compiler, add it to your PATH with:"
+ echo 'export PATH="$HOME/opt/cross/orange/bin:$PATH"'
+ echo 'Alternatively, you can build the cross-compiler with: sh build-cross.sh'
+ echo 'Also you should have host gcc with version < 14 (i am using 13.3.0)'
+ exit 1
+fi
+
max_depth=0
while IFS= read -r -d '' dir; do
dir="${dir#./}"
diff --git a/tools/pkg/config.guess b/tools/pkg/config.guess
new file mode 100644
index 0000000..344680a
--- /dev/null
+++ b/tools/pkg/config.guess
@@ -0,0 +1,1818 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright 1992-2025 Free Software Foundation, Inc.
+
+# shellcheck disable=SC2006,SC2268 # see below for rationale
+
+timestamp='2025-07-10'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+#
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
+#
+# You can get the latest version of this script from:
+# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
+#
+# Please send patches to <config-patches@gnu.org>.
+
+
+# The "shellcheck disable" line above the timestamp inhibits complaints
+# about features and limitations of the classic Bourne shell that were
+# superseded or lifted in POSIX. However, this script identifies a wide
+# variety of pre-POSIX systems that do not have POSIX shells at all, and
+# even some reasonably current systems (Solaris 10 as case-in-point) still
+# have a pre-POSIX /bin/sh.
+
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system '$me' is run on.
+
+Options:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright 1992-2025 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try '$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+# Just in case it came from the environment.
+GUESS=
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
+# use 'HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+tmp=
+# shellcheck disable=SC2172
+trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
+
+set_cc_for_build() {
+ # prevent multiple calls if $tmp is already set
+ test "$tmp" && return 0
+ : "${TMPDIR=/tmp}"
+ # shellcheck disable=SC2039,SC3028
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
+ dummy=$tmp/dummy
+ case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
+ ,,) echo "int x;" > "$dummy.c"
+ for driver in cc gcc c17 c99 c89 ; do
+ if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
+ CC_FOR_BUILD=$driver
+ break
+ fi
+ done
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+ esac
+}
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if test -f /.attbin/uname ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+case $UNAME_SYSTEM in
+Linux|GNU|GNU/*)
+ LIBC=unknown
+
+ set_cc_for_build
+ cat <<-EOF > "$dummy.c"
+ #if defined(__ANDROID__)
+ LIBC=android
+ #else
+ #include <features.h>
+ #if defined(__UCLIBC__)
+ LIBC=uclibc
+ #elif defined(__dietlibc__)
+ LIBC=dietlibc
+ #elif defined(__GLIBC__)
+ LIBC=gnu
+ #elif defined(__LLVM_LIBC__)
+ LIBC=llvm
+ #else
+ #include <stdarg.h>
+ /* First heuristic to detect musl libc. */
+ #ifdef __DEFINED_va_list
+ LIBC=musl
+ #endif
+ #endif
+ #endif
+ EOF
+ cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+ eval "$cc_set_libc"
+
+ # Second heuristic to detect musl libc.
+ if [ "$LIBC" = unknown ] &&
+ command -v ldd >/dev/null &&
+ ldd --version 2>&1 | grep -q ^musl; then
+ LIBC=musl
+ fi
+
+ # If the system lacks a compiler, then just pick glibc.
+ # We could probably try harder.
+ if [ "$LIBC" = unknown ]; then
+ LIBC=gnu
+ fi
+ ;;
+esac
+
+# Note: order is significant - the case branches are not exclusive.
+
+case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
+ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
+ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
+ echo unknown)`
+ case $UNAME_MACHINE_ARCH in
+ aarch64eb) machine=aarch64_be-unknown ;;
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ earmv*)
+ arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+ endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
+ machine=${arch}${endian}-unknown
+ ;;
+ *) machine=$UNAME_MACHINE_ARCH-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently (or will in the future) and ABI.
+ case $UNAME_MACHINE_ARCH in
+ earm*)
+ os=netbsdelf
+ ;;
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ELF__
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # Determine ABI tags.
+ case $UNAME_MACHINE_ARCH in
+ earm*)
+ expr='s/^earmv[0-9]/-eabi/;s/eb$//'
+ abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case $UNAME_VERSION in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ GUESS=$machine-${os}${release}${abi-}
+ ;;
+ *:Bitrig:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+ GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
+ ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
+ ;;
+ *:SecBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
+ GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
+ ;;
+ *:LibertyBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
+ GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
+ ;;
+ *:MidnightBSD:*:*)
+ GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
+ ;;
+ *:ekkoBSD:*:*)
+ GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
+ ;;
+ *:SolidBSD:*:*)
+ GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
+ ;;
+ *:OS108:*:*)
+ GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
+ ;;
+ macppc:MirBSD:*:*)
+ GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
+ ;;
+ *:MirBSD:*:*)
+ GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
+ ;;
+ *:Sortix:*:*)
+ GUESS=$UNAME_MACHINE-unknown-sortix
+ ;;
+ *:Twizzler:*:*)
+ GUESS=$UNAME_MACHINE-unknown-twizzler
+ ;;
+ *:Redox:*:*)
+ GUESS=$UNAME_MACHINE-unknown-redox
+ ;;
+ mips:OSF1:*.*)
+ GUESS=mips-dec-osf1
+ ;;
+ alpha:OSF1:*:*)
+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+ trap '' 0
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case $ALPHA_CPU_TYPE in
+ "EV4 (21064)")
+ UNAME_MACHINE=alpha ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE=alpha ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE=alpha ;;
+ "EV5 (21164)")
+ UNAME_MACHINE=alphaev5 ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE=alphaev56 ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE=alphapca56 ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE=alphapca57 ;;
+ "EV6 (21264)")
+ UNAME_MACHINE=alphaev6 ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE=alphaev67 ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE=alphaev68 ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE=alphaev68 ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE=alphaev68 ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE=alphaev69 ;;
+ "EV7 (21364)")
+ UNAME_MACHINE=alphaev7 ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE=alphaev79 ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+ GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
+ ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ GUESS=m68k-unknown-sysv4
+ ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ GUESS=$UNAME_MACHINE-unknown-amigaos
+ ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ GUESS=$UNAME_MACHINE-unknown-morphos
+ ;;
+ *:OS/390:*:*)
+ GUESS=i370-ibm-openedition
+ ;;
+ *:z/VM:*:*)
+ GUESS=s390-ibm-zvmoe
+ ;;
+ *:OS400:*:*)
+ GUESS=powerpc-ibm-os400
+ ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ GUESS=arm-acorn-riscix$UNAME_RELEASE
+ ;;
+ arm*:riscos:*:*|arm*:RISCOS:*:*)
+ GUESS=arm-unknown-riscos
+ ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ GUESS=hppa1.1-hitachi-hiuxmpp
+ ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ case `(/bin/universe) 2>/dev/null` in
+ att) GUESS=pyramid-pyramid-sysv3 ;;
+ *) GUESS=pyramid-pyramid-bsd ;;
+ esac
+ ;;
+ NILE*:*:*:dcosx)
+ GUESS=pyramid-pyramid-svr4
+ ;;
+ DRS?6000:unix:4.0:6*)
+ GUESS=sparc-icl-nx6
+ ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) GUESS=sparc-icl-nx7 ;;
+ esac
+ ;;
+ s390x:SunOS:*:*)
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
+ ;;
+ sun4H:SunOS:5.*:*)
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=sparc-hal-solaris2$SUN_REL
+ ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=sparc-sun-solaris2$SUN_REL
+ ;;
+ i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+ GUESS=i386-pc-auroraux$UNAME_RELEASE
+ ;;
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+ set_cc_for_build
+ SUN_ARCH=i386
+ # If there is a compiler, see if it is configured for 64-bit objects.
+ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+ # This test works for both compilers.
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
+ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ SUN_ARCH=x86_64
+ fi
+ fi
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
+ ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=sparc-sun-solaris3$SUN_REL
+ ;;
+ sun4*:SunOS:*:*)
+ case `/usr/bin/arch -k` in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like '4.1.3-JL'.
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
+ GUESS=sparc-sun-sunos$SUN_REL
+ ;;
+ sun3*:SunOS:*:*)
+ GUESS=m68k-sun-sunos$UNAME_RELEASE
+ ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
+ case `/bin/arch` in
+ sun3)
+ GUESS=m68k-sun-sunos$UNAME_RELEASE
+ ;;
+ sun4)
+ GUESS=sparc-sun-sunos$UNAME_RELEASE
+ ;;
+ esac
+ ;;
+ aushp:SunOS:*:*)
+ GUESS=sparc-auspex-sunos$UNAME_RELEASE
+ ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ GUESS=m68k-atari-mint$UNAME_RELEASE
+ ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ GUESS=m68k-atari-mint$UNAME_RELEASE
+ ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ GUESS=m68k-atari-mint$UNAME_RELEASE
+ ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ GUESS=m68k-milan-mint$UNAME_RELEASE
+ ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ GUESS=m68k-hades-mint$UNAME_RELEASE
+ ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ GUESS=m68k-unknown-mint$UNAME_RELEASE
+ ;;
+ m68k:machten:*:*)
+ GUESS=m68k-apple-machten$UNAME_RELEASE
+ ;;
+ powerpc:machten:*:*)
+ GUESS=powerpc-apple-machten$UNAME_RELEASE
+ ;;
+ RISC*:Mach:*:*)
+ GUESS=mips-dec-mach_bsd4.3
+ ;;
+ RISC*:ULTRIX:*:*)
+ GUESS=mips-dec-ultrix$UNAME_RELEASE
+ ;;
+ VAX*:ULTRIX*:*:*)
+ GUESS=vax-dec-ultrix$UNAME_RELEASE
+ ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ GUESS=clipper-intergraph-clix$UNAME_RELEASE
+ ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ set_cc_for_build
+ sed 's/^ //' << EOF > "$dummy.c"
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
+ dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ GUESS=mips-mips-riscos$UNAME_RELEASE
+ ;;
+ Motorola:PowerMAX_OS:*:*)
+ GUESS=powerpc-motorola-powermax
+ ;;
+ Motorola:*:4.3:PL8-*)
+ GUESS=powerpc-harris-powermax
+ ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ GUESS=powerpc-harris-powermax
+ ;;
+ Night_Hawk:Power_UNIX:*:*)
+ GUESS=powerpc-harris-powerunix
+ ;;
+ m88k:CX/UX:7*:*)
+ GUESS=m88k-harris-cxux7
+ ;;
+ m88k:*:4*:R4*)
+ GUESS=m88k-motorola-sysv4
+ ;;
+ m88k:*:3*:R3*)
+ GUESS=m88k-motorola-sysv3
+ ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
+ then
+ if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
+ test "$TARGET_BINARY_INTERFACE"x = x
+ then
+ GUESS=m88k-dg-dgux$UNAME_RELEASE
+ else
+ GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
+ fi
+ else
+ GUESS=i586-dg-dgux$UNAME_RELEASE
+ fi
+ ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ GUESS=m88k-dolphin-sysv3
+ ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ GUESS=m88k-motorola-sysv3
+ ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ GUESS=m88k-tektronix-sysv3
+ ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ GUESS=m68k-tektronix-bsd
+ ;;
+ *:IRIX*:*:*)
+ IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
+ GUESS=mips-sgi-irix$IRIX_REL
+ ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ GUESS=i386-ibm-aix
+ ;;
+ ia64:AIX:*:*)
+ if test -x /usr/bin/oslevel ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
+ fi
+ GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
+ ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ set_cc_for_build
+ sed 's/^ //' << EOF > "$dummy.c"
+ #include <sys/systemcfg.h>
+
+ int
+ main ()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
+ then
+ GUESS=$SYSTEM_NAME
+ else
+ GUESS=rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ GUESS=rs6000-ibm-aix3.2.4
+ else
+ GUESS=rs6000-ibm-aix3.2
+ fi
+ ;;
+ *:AIX:*:[4567])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if test -x /usr/bin/lslpp ; then
+ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
+ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
+ else
+ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
+ fi
+ GUESS=$IBM_ARCH-ibm-aix$IBM_REV
+ ;;
+ *:AIX:*:*)
+ GUESS=rs6000-ibm-aix
+ ;;
+ ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
+ GUESS=romp-ibm-bsd4.4
+ ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to
+ ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ GUESS=rs6000-bull-bosx
+ ;;
+ DPX/2?00:B.O.S.:*:*)
+ GUESS=m68k-bull-sysv3
+ ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ GUESS=m68k-hp-bsd
+ ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ GUESS=m68k-hp-bsd4.4
+ ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
+ case $UNAME_MACHINE in
+ 9000/31?) HP_ARCH=m68000 ;;
+ 9000/[34]??) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if test -x /usr/bin/getconf; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case $sc_cpu_version in
+ 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case $sc_kernel_bits in
+ 32) HP_ARCH=hppa2.0n ;;
+ 64) HP_ARCH=hppa2.0w ;;
+ '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if test "$HP_ARCH" = ""; then
+ set_cc_for_build
+ sed 's/^ //' << EOF > "$dummy.c"
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int
+ main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if test "$HP_ARCH" = hppa2.0w
+ then
+ set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep -q __LP64__
+ then
+ HP_ARCH=hppa2.0w
+ else
+ HP_ARCH=hppa64
+ fi
+ fi
+ GUESS=$HP_ARCH-hp-hpux$HPUX_REV
+ ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
+ GUESS=ia64-hp-hpux$HPUX_REV
+ ;;
+ 3050*:HI-UX:*:*)
+ set_cc_for_build
+ sed 's/^ //' << EOF > "$dummy.c"
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ GUESS=unknown-hitachi-hiuxwe2
+ ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
+ GUESS=hppa1.1-hp-bsd
+ ;;
+ 9000/8??:4.3bsd:*:*)
+ GUESS=hppa1.0-hp-bsd
+ ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ GUESS=hppa1.0-hp-mpeix
+ ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
+ GUESS=hppa1.1-hp-osf
+ ;;
+ hp8??:OSF1:*:*)
+ GUESS=hppa1.0-hp-osf
+ ;;
+ i*86:OSF1:*:*)
+ if test -x /usr/sbin/sysversion ; then
+ GUESS=$UNAME_MACHINE-unknown-osf1mk
+ else
+ GUESS=$UNAME_MACHINE-unknown-osf1
+ fi
+ ;;
+ parisc*:Lites*:*:*)
+ GUESS=hppa1.1-hp-lites
+ ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ GUESS=c1-convex-bsd
+ ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ GUESS=c34-convex-bsd
+ ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ GUESS=c38-convex-bsd
+ ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ GUESS=c4-convex-bsd
+ ;;
+ CRAY*Y-MP:*:*:*)
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=ymp-cray-unicos$CRAY_REL
+ ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=t90-cray-unicos$CRAY_REL
+ ;;
+ CRAY*T3E:*:*:*)
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=alphaev5-cray-unicosmk$CRAY_REL
+ ;;
+ CRAY*SV1:*:*:*)
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=sv1-cray-unicos$CRAY_REL
+ ;;
+ *:UNICOS/mp:*:*)
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=craynv-cray-unicosmp$CRAY_REL
+ ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
+ FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
+ GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
+ ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
+ FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
+ GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
+ ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
+ ;;
+ sparc*:BSD/OS:*:*)
+ GUESS=sparc-unknown-bsdi$UNAME_RELEASE
+ ;;
+ *:BSD/OS:*:*)
+ GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
+ ;;
+ arm:FreeBSD:*:*)
+ UNAME_PROCESSOR=`uname -p`
+ set_cc_for_build
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
+ else
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
+ fi
+ ;;
+ *:FreeBSD:*:*)
+ UNAME_PROCESSOR=`uname -p`
+ case $UNAME_PROCESSOR in
+ amd64)
+ UNAME_PROCESSOR=x86_64 ;;
+ i386)
+ UNAME_PROCESSOR=i586 ;;
+ esac
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
+ ;;
+ i*:CYGWIN*:*)
+ GUESS=$UNAME_MACHINE-pc-cygwin
+ ;;
+ *:MINGW64*:*)
+ GUESS=$UNAME_MACHINE-pc-mingw64
+ ;;
+ *:MINGW*:*)
+ GUESS=$UNAME_MACHINE-pc-mingw32
+ ;;
+ *:MSYS*:*)
+ GUESS=$UNAME_MACHINE-pc-msys
+ ;;
+ i*:PW*:*)
+ GUESS=$UNAME_MACHINE-pc-pw32
+ ;;
+ *:SerenityOS:*:*)
+ GUESS=$UNAME_MACHINE-pc-serenity
+ ;;
+ *:Interix*:*)
+ case $UNAME_MACHINE in
+ x86)
+ GUESS=i586-pc-interix$UNAME_RELEASE
+ ;;
+ authenticamd | genuineintel | EM64T)
+ GUESS=x86_64-unknown-interix$UNAME_RELEASE
+ ;;
+ IA64)
+ GUESS=ia64-unknown-interix$UNAME_RELEASE
+ ;;
+ esac ;;
+ i*:UWIN*:*)
+ GUESS=$UNAME_MACHINE-pc-uwin
+ ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ GUESS=x86_64-pc-cygwin
+ ;;
+ prep*:SunOS:5.*:*)
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=powerpcle-unknown-solaris2$SUN_REL
+ ;;
+ *:GNU:*:*)
+ # the GNU system
+ GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
+ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
+ GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
+ ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
+ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
+ ;;
+ x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
+ GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
+ ;;
+ *:[Mm]anagarm:*:*)
+ GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
+ ;;
+ *:Minix:*:*)
+ GUESS=$UNAME_MACHINE-unknown-minix
+ ;;
+ aarch64:Linux:*:*)
+ set_cc_for_build
+ CPU=$UNAME_MACHINE
+ LIBCABI=$LIBC
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
+ ABI=64
+ sed 's/^ //' << EOF > "$dummy.c"
+ #ifdef __ARM_EABI__
+ #ifdef __ARM_PCS_VFP
+ ABI=eabihf
+ #else
+ ABI=eabi
+ #endif
+ #endif
+EOF
+ cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
+ eval "$cc_set_abi"
+ case $ABI in
+ eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
+ esac
+ fi
+ GUESS=$CPU-unknown-linux-$LIBCABI
+ ;;
+ aarch64_be:Linux:*:*)
+ UNAME_MACHINE=aarch64_be
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep -q ld.so.1
+ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ arm*:Linux:*:*)
+ set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_EABI__
+ then
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ else
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
+ else
+ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
+ fi
+ fi
+ ;;
+ avr32*:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ cris:Linux:*:*)
+ GUESS=$UNAME_MACHINE-axis-linux-$LIBC
+ ;;
+ crisv32:Linux:*:*)
+ GUESS=$UNAME_MACHINE-axis-linux-$LIBC
+ ;;
+ e2k:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ frv:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ hexagon:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ i*86:Linux:*:*)
+ GUESS=$UNAME_MACHINE-pc-linux-$LIBC
+ ;;
+ ia64:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ k1om:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ kvx:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ kvx:cos:*:*)
+ GUESS=$UNAME_MACHINE-unknown-cos
+ ;;
+ kvx:mbr:*:*)
+ GUESS=$UNAME_MACHINE-unknown-mbr
+ ;;
+ loongarch32:Linux:*:* | loongarch64:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ m32r*:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ m68*:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ mips:Linux:*:* | mips64:Linux:*:*)
+ set_cc_for_build
+ IS_GLIBC=0
+ test x"${LIBC}" = xgnu && IS_GLIBC=1
+ sed 's/^ //' << EOF > "$dummy.c"
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #undef mips64
+ #undef mips64el
+ #if ${IS_GLIBC} && defined(_ABI64)
+ LIBCABI=gnuabi64
+ #else
+ #if ${IS_GLIBC} && defined(_ABIN32)
+ LIBCABI=gnuabin32
+ #else
+ LIBCABI=${LIBC}
+ #endif
+ #endif
+
+ #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
+ CPU=mipsisa64r6
+ #else
+ #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
+ CPU=mipsisa32r6
+ #else
+ #if defined(__mips64)
+ CPU=mips64
+ #else
+ CPU=mips
+ #endif
+ #endif
+ #endif
+
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ MIPS_ENDIAN=el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ MIPS_ENDIAN=
+ #else
+ MIPS_ENDIAN=
+ #endif
+ #endif
+EOF
+ cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
+ eval "$cc_set_vars"
+ test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
+ ;;
+ mips64el:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ openrisc*:Linux:*:*)
+ GUESS=or1k-unknown-linux-$LIBC
+ ;;
+ or32:Linux:*:* | or1k*:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ padre:Linux:*:*)
+ GUESS=sparc-unknown-linux-$LIBC
+ ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ GUESS=hppa64-unknown-linux-$LIBC
+ ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
+ PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
+ *) GUESS=hppa-unknown-linux-$LIBC ;;
+ esac
+ ;;
+ ppc64:Linux:*:*)
+ GUESS=powerpc64-unknown-linux-$LIBC
+ ;;
+ ppc:Linux:*:*)
+ GUESS=powerpc-unknown-linux-$LIBC
+ ;;
+ ppc64le:Linux:*:*)
+ GUESS=powerpc64le-unknown-linux-$LIBC
+ ;;
+ ppcle:Linux:*:*)
+ GUESS=powerpcle-unknown-linux-$LIBC
+ ;;
+ riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
+ ;;
+ sh64*:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ sh*:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ tile*:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ vax:Linux:*:*)
+ GUESS=$UNAME_MACHINE-dec-linux-$LIBC
+ ;;
+ x86_64:Linux:*:*)
+ set_cc_for_build
+ CPU=$UNAME_MACHINE
+ LIBCABI=$LIBC
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
+ ABI=64
+ sed 's/^ //' << EOF > "$dummy.c"
+ #ifdef __i386__
+ ABI=x86
+ #else
+ #ifdef __ILP32__
+ ABI=x32
+ #endif
+ #endif
+EOF
+ cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
+ eval "$cc_set_abi"
+ case $ABI in
+ x86) CPU=i686 ;;
+ x32) LIBCABI=${LIBC}x32 ;;
+ esac
+ fi
+ GUESS=$CPU-pc-linux-$LIBCABI
+ ;;
+ xtensa*:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ GUESS=i386-sequent-sysv4
+ ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
+ ;;
+ i*86:OS/2:*:*)
+ # If we were able to find 'uname', then EMX Unix compatibility
+ # is probably installed.
+ GUESS=$UNAME_MACHINE-pc-os2-emx
+ ;;
+ i*86:XTS-300:*:STOP)
+ GUESS=$UNAME_MACHINE-unknown-stop
+ ;;
+ i*86:atheos:*:*)
+ GUESS=$UNAME_MACHINE-unknown-atheos
+ ;;
+ i*86:syllable:*:*)
+ GUESS=$UNAME_MACHINE-pc-syllable
+ ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+ GUESS=i386-unknown-lynxos$UNAME_RELEASE
+ ;;
+ i*86:*DOS:*:*)
+ GUESS=$UNAME_MACHINE-pc-msdosdjgpp
+ ;;
+ i*86:*:4.*:*)
+ UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
+ else
+ GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
+ fi
+ ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
+ else
+ GUESS=$UNAME_MACHINE-pc-sysv32
+ fi
+ ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i586.
+ # Note: whatever this is, it MUST be the same as what config.sub
+ # prints for the "djgpp" host, or else GDB configure will decide that
+ # this is a cross-build.
+ GUESS=i586-pc-msdosdjgpp
+ ;;
+ Intel:Mach:3*:*)
+ GUESS=i386-pc-mach3
+ ;;
+ paragon:*:*:*)
+ GUESS=i860-intel-osf1
+ ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4
+ fi
+ ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ GUESS=m68010-convergent-sysv
+ ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ GUESS=m68k-convergent-sysv
+ ;;
+ M680?0:D-NIX:5.3:*)
+ GUESS=m68k-diab-dnix
+ ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+ OS_REL='.3'
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ GUESS=m68k-unknown-lynxos$UNAME_RELEASE
+ ;;
+ mc68030:UNIX_System_V:4.*:*)
+ GUESS=m68k-atari-sysv4
+ ;;
+ TSUNAMI:LynxOS:2.*:*)
+ GUESS=sparc-unknown-lynxos$UNAME_RELEASE
+ ;;
+ rs6000:LynxOS:2.*:*)
+ GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
+ ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+ GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
+ ;;
+ SM[BE]S:UNIX_SV:*:*)
+ GUESS=mips-dde-sysv$UNAME_RELEASE
+ ;;
+ RM*:ReliantUNIX-*:*:*)
+ GUESS=mips-sni-sysv4
+ ;;
+ RM*:SINIX-*:*:*)
+ GUESS=mips-sni-sysv4
+ ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ GUESS=$UNAME_MACHINE-sni-sysv4
+ else
+ GUESS=ns32k-sni-sysv
+ fi
+ ;;
+ PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ GUESS=i586-unisys-sysv4
+ ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ GUESS=hppa1.1-stratus-sysv4
+ ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ GUESS=i860-stratus-sysv4
+ ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ GUESS=$UNAME_MACHINE-stratus-vos
+ ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ GUESS=hppa1.1-stratus-vos
+ ;;
+ mc68*:A/UX:*:*)
+ GUESS=m68k-apple-aux$UNAME_RELEASE
+ ;;
+ news*:NEWS-OS:6*:*)
+ GUESS=mips-sony-newsos6
+ ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if test -d /usr/nec; then
+ GUESS=mips-nec-sysv$UNAME_RELEASE
+ else
+ GUESS=mips-unknown-sysv$UNAME_RELEASE
+ fi
+ ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ GUESS=powerpc-be-beos
+ ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ GUESS=powerpc-apple-beos
+ ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ GUESS=i586-pc-beos
+ ;;
+ BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
+ GUESS=i586-pc-haiku
+ ;;
+ ppc:Haiku:*:*) # Haiku running on Apple PowerPC
+ GUESS=powerpc-apple-haiku
+ ;;
+ *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat)
+ GUESS=$UNAME_MACHINE-unknown-haiku
+ ;;
+ SX-4:SUPER-UX:*:*)
+ GUESS=sx4-nec-superux$UNAME_RELEASE
+ ;;
+ SX-5:SUPER-UX:*:*)
+ GUESS=sx5-nec-superux$UNAME_RELEASE
+ ;;
+ SX-6:SUPER-UX:*:*)
+ GUESS=sx6-nec-superux$UNAME_RELEASE
+ ;;
+ SX-7:SUPER-UX:*:*)
+ GUESS=sx7-nec-superux$UNAME_RELEASE
+ ;;
+ SX-8:SUPER-UX:*:*)
+ GUESS=sx8-nec-superux$UNAME_RELEASE
+ ;;
+ SX-8R:SUPER-UX:*:*)
+ GUESS=sx8r-nec-superux$UNAME_RELEASE
+ ;;
+ SX-ACE:SUPER-UX:*:*)
+ GUESS=sxace-nec-superux$UNAME_RELEASE
+ ;;
+ Power*:Rhapsody:*:*)
+ GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
+ ;;
+ *:Rhapsody:*:*)
+ GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
+ ;;
+ arm64:Darwin:*:*)
+ GUESS=aarch64-apple-darwin$UNAME_RELEASE
+ ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p`
+ case $UNAME_PROCESSOR in
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ if command -v xcode-select > /dev/null 2> /dev/null && \
+ ! xcode-select --print-path > /dev/null 2> /dev/null ; then
+ # Avoid executing cc if there is no toolchain installed as
+ # cc will be a stub that puts up a graphical alert
+ # prompting the user to install developer tools.
+ CC_FOR_BUILD=no_compiler_found
+ else
+ set_cc_for_build
+ fi
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ case $UNAME_PROCESSOR in
+ i386) UNAME_PROCESSOR=x86_64 ;;
+ powerpc) UNAME_PROCESSOR=powerpc64 ;;
+ esac
+ fi
+ # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
+ if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_PPC >/dev/null
+ then
+ UNAME_PROCESSOR=powerpc
+ fi
+ elif test "$UNAME_PROCESSOR" = i386 ; then
+ # uname -m returns i386 or x86_64
+ UNAME_PROCESSOR=$UNAME_MACHINE
+ fi
+ GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
+ ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = x86; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
+ ;;
+ *:QNX:*:4*)
+ GUESS=i386-pc-qnx
+ ;;
+ NEO-*:NONSTOP_KERNEL:*:*)
+ GUESS=neo-tandem-nsk$UNAME_RELEASE
+ ;;
+ NSE-*:NONSTOP_KERNEL:*:*)
+ GUESS=nse-tandem-nsk$UNAME_RELEASE
+ ;;
+ NSR-*:NONSTOP_KERNEL:*:*)
+ GUESS=nsr-tandem-nsk$UNAME_RELEASE
+ ;;
+ NSV-*:NONSTOP_KERNEL:*:*)
+ GUESS=nsv-tandem-nsk$UNAME_RELEASE
+ ;;
+ NSX-*:NONSTOP_KERNEL:*:*)
+ GUESS=nsx-tandem-nsk$UNAME_RELEASE
+ ;;
+ *:NonStop-UX:*:*)
+ GUESS=mips-compaq-nonstopux
+ ;;
+ BS2000:POSIX*:*:*)
+ GUESS=bs2000-siemens-sysv
+ ;;
+ DS/*:UNIX_System_V:*:*)
+ GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
+ ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "${cputype-}" = 386; then
+ UNAME_MACHINE=i386
+ elif test "x${cputype-}" != x; then
+ UNAME_MACHINE=$cputype
+ fi
+ GUESS=$UNAME_MACHINE-unknown-plan9
+ ;;
+ *:TOPS-10:*:*)
+ GUESS=pdp10-unknown-tops10
+ ;;
+ *:TENEX:*:*)
+ GUESS=pdp10-unknown-tenex
+ ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ GUESS=pdp10-dec-tops20
+ ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ GUESS=pdp10-xkl-tops20
+ ;;
+ *:TOPS-20:*:*)
+ GUESS=pdp10-unknown-tops20
+ ;;
+ *:ITS:*:*)
+ GUESS=pdp10-unknown-its
+ ;;
+ SEI:*:*:SEIUX)
+ GUESS=mips-sei-seiux$UNAME_RELEASE
+ ;;
+ *:DragonFly:*:*)
+ DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
+ ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case $UNAME_MACHINE in
+ A*) GUESS=alpha-dec-vms ;;
+ I*) GUESS=ia64-dec-vms ;;
+ V*) GUESS=vax-dec-vms ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ GUESS=i386-pc-xenix
+ ;;
+ i*86:skyos:*:*)
+ SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
+ GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
+ ;;
+ i*86:rdos:*:*)
+ GUESS=$UNAME_MACHINE-pc-rdos
+ ;;
+ i*86:Fiwix:*:*)
+ GUESS=$UNAME_MACHINE-pc-fiwix
+ ;;
+ *:AROS:*:*)
+ GUESS=$UNAME_MACHINE-unknown-aros
+ ;;
+ x86_64:VMkernel:*:*)
+ GUESS=$UNAME_MACHINE-unknown-esx
+ ;;
+ amd64:Isilon\ OneFS:*:*)
+ GUESS=x86_64-unknown-onefs
+ ;;
+ *:Unleashed:*:*)
+ GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
+ ;;
+ x86_64:[Oo]range:*:*|i?86:[Oo]range:*:*)
+ GUESS=x86_64-orange
+ ;;
+ *:[Oo]range:*:*)
+ GUESS=x86_64-orange
+ ;;
+esac
+
+# Do we have a guess based on uname results?
+if test "x$GUESS" != x; then
+ echo "$GUESS"
+ exit
+fi
+
+# No uname command or uname output not recognized.
+set_cc_for_build
+cat > "$dummy.c" <<EOF
+#ifdef _SEQUENT_
+#include <sys/types.h>
+#include <sys/utsname.h>
+#endif
+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
+#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
+#include <signal.h>
+#if defined(_SIZE_T_) || defined(SIGLOST)
+#include <sys/utsname.h>
+#endif
+#endif
+#endif
+int
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+#include <sys/param.h>
+#if defined (BSD)
+#if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+#else
+#if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#else
+ printf ("vax-dec-bsd\n"); exit (0);
+#endif
+#endif
+#else
+ printf ("vax-dec-bsd\n"); exit (0);
+#endif
+#else
+#if defined(_SIZE_T_) || defined(SIGLOST)
+ struct utsname un;
+ uname (&un);
+ printf ("vax-dec-ultrix%s\n", un.release); exit (0);
+#else
+ printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+#endif
+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
+#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
+#if defined(_SIZE_T_) || defined(SIGLOST)
+ struct utsname *un;
+ uname (&un);
+ printf ("mips-dec-ultrix%s\n", un.release); exit (0);
+#else
+ printf ("mips-dec-ultrix\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
+
+echo "$0: unable to guess system type" >&2
+
+case $UNAME_MACHINE:$UNAME_SYSTEM in
+ mips:Linux | mips64:Linux)
+ # If we got here on MIPS GNU/Linux, output extra information.
+ cat >&2 <<EOF
+
+NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
+the system type. Please install a C compiler and try again.
+EOF
+ ;;
+esac
+
+cat >&2 <<EOF
+
+This script (version $timestamp), has failed to recognize the
+operating system you are using. If your script is old, overwrite *all*
+copies of config.guess and config.sub with the latest versions from:
+
+ https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
+and
+ https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
+EOF
+
+our_year=`echo $timestamp | sed 's,-.*,,'`
+thisyear=`date +%Y`
+# shellcheck disable=SC2003
+script_age=`expr "$thisyear" - "$our_year"`
+if test "$script_age" -lt 3 ; then
+ cat >&2 <<EOF
+
+If $0 has already been updated, send the following data and any
+information you think might be pertinent to config-patches@gnu.org to
+provide the necessary information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = "$UNAME_MACHINE"
+UNAME_RELEASE = "$UNAME_RELEASE"
+UNAME_SYSTEM = "$UNAME_SYSTEM"
+UNAME_VERSION = "$UNAME_VERSION"
+EOF
+fi
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%Y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/tools/pkg/config.sub b/tools/pkg/config.sub
new file mode 100644
index 0000000..0917997
--- /dev/null
+++ b/tools/pkg/config.sub
@@ -0,0 +1,2364 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright 1992-2025 Free Software Foundation, Inc.
+
+# shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale
+
+timestamp='2025-07-10'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+
+
+# Please send patches to <config-patches@gnu.org>.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# You can get the latest version of this script from:
+# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+# The "shellcheck disable" line above the timestamp inhibits complaints
+# about features and limitations of the classic Bourne shell that were
+# superseded or lifted in POSIX. However, this script identifies a wide
+# variety of pre-POSIX systems that do not have POSIX shells at all, and
+# even some reasonably current systems (Solaris 10 as case-in-point) still
+# have a pre-POSIX /bin/sh.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
+
+Canonicalize a configuration name.
+
+Options:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright 1992-2025 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try '$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo "$1"
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Split fields of configuration type
+saved_IFS=$IFS
+IFS="-" read field1 field2 field3 field4 <<EOF
+$1
+EOF
+IFS=$saved_IFS
+
+# Separate into logical components for further validation
+case $1 in
+ *-*-*-*-*)
+ echo "Invalid configuration '$1': more than four components" >&2
+ exit 1
+ ;;
+ *-*-*-*)
+ basic_machine=$field1-$field2
+ basic_os=$field3-$field4
+ ;;
+ *-*-*)
+ # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
+ # parts
+ maybe_os=$field2-$field3
+ case $maybe_os in
+ cloudabi*-eabi* \
+ | kfreebsd*-gnu* \
+ | knetbsd*-gnu* \
+ | kopensolaris*-gnu* \
+ | orange-* \
+ | linux-* \
+ | managarm-* \
+ | netbsd*-eabi* \
+ | netbsd*-gnu* \
+ | nto-qnx* \
+ | os2-emx* \
+ | rtmk-nova* \
+ | storm-chaos* \
+ | uclinux-gnu* \
+ | uclinux-uclibc* \
+ | windows-* )
+ basic_machine=$field1
+ basic_os=$maybe_os
+ ;;
+ android-linux)
+ basic_machine=$field1-unknown
+ basic_os=linux-android
+ ;;
+ *)
+ basic_machine=$field1-$field2
+ basic_os=$field3
+ ;;
+ esac
+ ;;
+ *-*)
+ case $field1-$field2 in
+ # Shorthands that happen to contain a single dash
+ convex-c[12] | convex-c3[248])
+ basic_machine=$field2-convex
+ basic_os=
+ ;;
+ decstation-3100)
+ basic_machine=mips-dec
+ basic_os=
+ ;;
+ *-*)
+ # Second component is usually, but not always the OS
+ case $field2 in
+ # Do not treat sunos as a manufacturer
+ sun*os*)
+ basic_machine=$field1
+ basic_os=$field2
+ ;;
+ # Manufacturers
+ 3100* \
+ | 32* \
+ | 3300* \
+ | 3600* \
+ | 7300* \
+ | acorn \
+ | altos* \
+ | apollo \
+ | apple \
+ | atari \
+ | att* \
+ | axis \
+ | be \
+ | bull \
+ | cbm \
+ | ccur \
+ | cisco \
+ | commodore \
+ | convergent* \
+ | convex* \
+ | cray \
+ | crds \
+ | dec* \
+ | delta* \
+ | dg \
+ | digital \
+ | dolphin \
+ | encore* \
+ | gould \
+ | harris \
+ | highlevel \
+ | hitachi* \
+ | hp \
+ | ibm* \
+ | intergraph \
+ | isi* \
+ | knuth \
+ | masscomp \
+ | microblaze* \
+ | mips* \
+ | motorola* \
+ | ncr* \
+ | news \
+ | next \
+ | ns \
+ | oki \
+ | omron* \
+ | pc533* \
+ | rebel \
+ | rom68k \
+ | rombug \
+ | semi \
+ | sequent* \
+ | sgi* \
+ | siemens \
+ | sim \
+ | sni \
+ | sony* \
+ | stratus \
+ | sun \
+ | sun[234]* \
+ | tektronix \
+ | tti* \
+ | ultra \
+ | unicom* \
+ | wec \
+ | winbond \
+ | wrs)
+ basic_machine=$field1-$field2
+ basic_os=
+ ;;
+ tock* | zephyr*)
+ basic_machine=$field1-unknown
+ basic_os=$field2
+ ;;
+ *)
+ basic_machine=$field1
+ basic_os=$field2
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ *)
+ # Convert single-component short-hands not valid as part of
+ # multi-component configurations.
+ case $field1 in
+ 386bsd)
+ basic_machine=i386-pc
+ basic_os=bsd
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ basic_os=udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ basic_os=scout
+ ;;
+ alliant)
+ basic_machine=fx80-alliant
+ basic_os=
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ basic_os=
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ basic_os=bsd
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ basic_os=sysv
+ ;;
+ amiga)
+ basic_machine=m68k-unknown
+ basic_os=
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ basic_os=amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ basic_os=sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ basic_os=sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ basic_os=bsd
+ ;;
+ aros)
+ basic_machine=i386-pc
+ basic_os=aros
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ basic_os=aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ basic_os=dynix
+ ;;
+ blackfin)
+ basic_machine=bfin-unknown
+ basic_os=linux
+ ;;
+ cegcc)
+ basic_machine=arm-unknown
+ basic_os=cegcc
+ ;;
+ cray)
+ basic_machine=j90-cray
+ basic_os=unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ basic_os=
+ ;;
+ da30)
+ basic_machine=m68k-da30
+ basic_os=
+ ;;
+ decstation | pmax | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ basic_os=
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ basic_os=sysv3
+ ;;
+ dicos)
+ basic_machine=i686-pc
+ basic_os=dicos
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ basic_os=msdosdjgpp
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ basic_os=ebmon
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ basic_os=ose
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ basic_os=sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ basic_os=go32
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ basic_os=hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ basic_os=xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ basic_os=hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ basic_os=sysv3
+ ;;
+ hp300 | hp300hpux)
+ basic_machine=m68k-hp
+ basic_os=hpux
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ basic_os=bsd
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ basic_os=osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ basic_os=proelf
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ basic_os=mach
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ basic_os=sysv
+ ;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ basic_os=linux
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ basic_os=sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ basic_os=sysv
+ ;;
+ mingw64)
+ basic_machine=x86_64-pc
+ basic_os=mingw64
+ ;;
+ mingw32)
+ basic_machine=i686-pc
+ basic_os=mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ basic_os=mingw32ce
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ basic_os=coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ basic_os=morphos
+ ;;
+ moxiebox)
+ basic_machine=moxie-unknown
+ basic_os=moxiebox
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ basic_os=msdos
+ ;;
+ msys)
+ basic_machine=i686-pc
+ basic_os=msys
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ basic_os=mvs
+ ;;
+ nacl)
+ basic_machine=le32-unknown
+ basic_os=nacl
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ basic_os=sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-pc
+ basic_os=netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ basic_os=linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ basic_os=newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ basic_os=newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ basic_os=sysv
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ basic_os=cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ basic_os=cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ basic_os=nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ basic_os=mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ basic_os=nonstopux
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ basic_os=os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ basic_os=ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ basic_os=os68k
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ basic_os=osf
+ ;;
+ parisc)
+ basic_machine=hppa-unknown
+ basic_os=linux
+ ;;
+ psp)
+ basic_machine=mipsallegrexel-sony
+ basic_os=psp
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ basic_os=pw32
+ ;;
+ rdos | rdos64)
+ basic_machine=x86_64-pc
+ basic_os=rdos
+ ;;
+ rdos32)
+ basic_machine=i386-pc
+ basic_os=rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ basic_os=coff
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ basic_os=udi
+ ;;
+ sei)
+ basic_machine=mips-sei
+ basic_os=seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ basic_os=
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ basic_os=sysv2
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ basic_os=
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ basic_os=sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ basic_os=
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ basic_os=sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ basic_os=sunos4
+ ;;
+ sun3)
+ basic_machine=m68k-sun
+ basic_os=
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ basic_os=sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ basic_os=sunos4
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ basic_os=
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ basic_os=sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ basic_os=sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ basic_os=solaris2
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ basic_os=
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ basic_os=unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ basic_os=dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ basic_os=unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ basic_os=unicos
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ basic_os=tops20
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ basic_os=tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ basic_os=udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ basic_os=sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ basic_os=none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ basic_os=sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ basic_os=vms
+ ;;
+ vsta)
+ basic_machine=i386-pc
+ basic_os=vsta
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ basic_os=vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ basic_os=vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ basic_os=vxworks
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ basic_os=mingw32
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ basic_os=unicos
+ ;;
+ *)
+ basic_machine=$1
+ basic_os=
+ ;;
+ esac
+ ;;
+esac
+
+# Decode 1-component or ad-hoc basic machines
+case $basic_machine in
+ # Here we handle the default manufacturer of certain CPU types. It is in
+ # some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ cpu=hppa1.1
+ vendor=winbond
+ ;;
+ op50n)
+ cpu=hppa1.1
+ vendor=oki
+ ;;
+ op60c)
+ cpu=hppa1.1
+ vendor=oki
+ ;;
+ ibm*)
+ cpu=i370
+ vendor=ibm
+ ;;
+ orion105)
+ cpu=clipper
+ vendor=highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ cpu=m68k
+ vendor=apple
+ ;;
+ pmac | pmac-mpw)
+ cpu=powerpc
+ vendor=apple
+ ;;
+
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ cpu=m68000
+ vendor=att
+ ;;
+ 3b*)
+ cpu=we32k
+ vendor=att
+ ;;
+ bluegene*)
+ cpu=powerpc
+ vendor=ibm
+ basic_os=cnk
+ ;;
+ decsystem10* | dec10*)
+ cpu=pdp10
+ vendor=dec
+ basic_os=tops10
+ ;;
+ decsystem20* | dec20*)
+ cpu=pdp10
+ vendor=dec
+ basic_os=tops20
+ ;;
+ delta | 3300 | delta-motorola | 3300-motorola | motorola-delta | motorola-3300)
+ cpu=m68k
+ vendor=motorola
+ ;;
+ # This used to be dpx2*, but that gets the RS6000-based
+ # DPX/20 and the x86-based DPX/2-100 wrong. See
+ # https://oldskool.silicium.org/stations/bull_dpx20.htm
+ # https://www.feb-patrimoine.com/english/bull_dpx2.htm
+ # https://www.feb-patrimoine.com/english/unix_and_bull.htm
+ dpx2 | dpx2[23]00 | dpx2[23]xx)
+ cpu=m68k
+ vendor=bull
+ ;;
+ dpx2100 | dpx21xx)
+ cpu=i386
+ vendor=bull
+ ;;
+ dpx20)
+ cpu=rs6000
+ vendor=bull
+ ;;
+ encore | umax | mmax)
+ cpu=ns32k
+ vendor=encore
+ ;;
+ elxsi)
+ cpu=elxsi
+ vendor=elxsi
+ basic_os=${basic_os:-bsd}
+ ;;
+ fx2800)
+ cpu=i860
+ vendor=alliant
+ ;;
+ genix)
+ cpu=ns32k
+ vendor=ns
+ ;;
+ h3050r* | hiux*)
+ cpu=hppa1.1
+ vendor=hitachi
+ basic_os=hiuxwe2
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ cpu=hppa1.0
+ vendor=hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ cpu=m68000
+ vendor=hp
+ ;;
+ hp9k3[2-9][0-9])
+ cpu=m68k
+ vendor=hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ cpu=hppa1.0
+ vendor=hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ cpu=hppa1.0
+ vendor=hp
+ ;;
+ i*86v32)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ basic_os=sysv32
+ ;;
+ i*86v4*)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ basic_os=sysv4
+ ;;
+ i*86v)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ basic_os=sysv
+ ;;
+ i*86sol2)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ basic_os=solaris2
+ ;;
+ j90 | j90-cray)
+ cpu=j90
+ vendor=cray
+ basic_os=${basic_os:-unicos}
+ ;;
+ iris | iris4d)
+ cpu=mips
+ vendor=sgi
+ case $basic_os in
+ irix*)
+ ;;
+ *)
+ basic_os=irix4
+ ;;
+ esac
+ ;;
+ miniframe)
+ cpu=m68000
+ vendor=convergent
+ ;;
+ *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ cpu=m68k
+ vendor=atari
+ basic_os=mint
+ ;;
+ news-3600 | risc-news)
+ cpu=mips
+ vendor=sony
+ basic_os=newsos
+ ;;
+ next | m*-next)
+ cpu=m68k
+ vendor=next
+ ;;
+ np1)
+ cpu=np1
+ vendor=gould
+ ;;
+ op50n-* | op60c-*)
+ cpu=hppa1.1
+ vendor=oki
+ basic_os=proelf
+ ;;
+ pa-hitachi)
+ cpu=hppa1.1
+ vendor=hitachi
+ basic_os=hiuxwe2
+ ;;
+ pbd)
+ cpu=sparc
+ vendor=tti
+ ;;
+ pbb)
+ cpu=m68k
+ vendor=tti
+ ;;
+ pc532)
+ cpu=ns32k
+ vendor=pc532
+ ;;
+ pn)
+ cpu=pn
+ vendor=gould
+ ;;
+ power)
+ cpu=power
+ vendor=ibm
+ ;;
+ ps2)
+ cpu=i386
+ vendor=ibm
+ ;;
+ rm[46]00)
+ cpu=mips
+ vendor=siemens
+ ;;
+ rtpc | rtpc-*)
+ cpu=romp
+ vendor=ibm
+ ;;
+ sde)
+ cpu=mipsisa32
+ vendor=sde
+ basic_os=${basic_os:-elf}
+ ;;
+ simso-wrs)
+ cpu=sparclite
+ vendor=wrs
+ basic_os=vxworks
+ ;;
+ tower | tower-32)
+ cpu=m68k
+ vendor=ncr
+ ;;
+ vpp*|vx|vx-*)
+ cpu=f301
+ vendor=fujitsu
+ ;;
+ w65)
+ cpu=w65
+ vendor=wdc
+ ;;
+ w89k-*)
+ cpu=hppa1.1
+ vendor=winbond
+ basic_os=proelf
+ ;;
+ none)
+ cpu=none
+ vendor=none
+ ;;
+ leon|leon[3-9])
+ cpu=sparc
+ vendor=$basic_machine
+ ;;
+ leon-*|leon[3-9]-*)
+ cpu=sparc
+ vendor=`echo "$basic_machine" | sed 's/-.*//'`
+ ;;
+
+ *-*)
+ saved_IFS=$IFS
+ IFS="-" read cpu vendor <<EOF
+$basic_machine
+EOF
+ IFS=$saved_IFS
+ ;;
+ # We use 'pc' rather than 'unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ cpu=$basic_machine
+ vendor=pc
+ ;;
+ # These rules are duplicated from below for sake of the special case above;
+ # i.e. things that normalized to x86 arches should also default to "pc"
+ pc98)
+ cpu=i386
+ vendor=pc
+ ;;
+ x64 | amd64)
+ cpu=x86_64
+ vendor=pc
+ ;;
+ # Recognize the basic CPU types without company name.
+ *)
+ cpu=$basic_machine
+ vendor=unknown
+ ;;
+esac
+
+unset -v basic_machine
+
+# Decode basic machines in the full and proper CPU-Company form.
+case $cpu-$vendor in
+ # Here we handle the default manufacturer of certain CPU types in canonical form.
+ # It is in some cases the only manufacturer, in others, it is the most popular.
+ c[12]-convex | c[12]-unknown | c3[248]-convex | c3[248]-unknown)
+ vendor=convex
+ basic_os=${basic_os:-bsd}
+ ;;
+ craynv-unknown)
+ vendor=cray
+ basic_os=${basic_os:-unicosmp}
+ ;;
+ c90-unknown | c90-cray)
+ vendor=cray
+ basic_os=${basic_os:-unicos}
+ ;;
+ fx80-unknown)
+ vendor=alliant
+ ;;
+ romp-unknown)
+ vendor=ibm
+ ;;
+ mmix-unknown)
+ vendor=knuth
+ ;;
+ microblaze-unknown | microblazeel-unknown)
+ vendor=xilinx
+ ;;
+ rs6000-unknown)
+ vendor=ibm
+ ;;
+ vax-unknown)
+ vendor=dec
+ ;;
+ pdp11-unknown)
+ vendor=dec
+ ;;
+ we32k-unknown)
+ vendor=att
+ ;;
+ cydra-unknown)
+ vendor=cydrome
+ ;;
+ i370-ibm*)
+ vendor=ibm
+ ;;
+ orion-unknown)
+ vendor=highlevel
+ ;;
+ xps-unknown | xps100-unknown)
+ cpu=xps100
+ vendor=honeywell
+ ;;
+
+ # Here we normalize CPU types with a missing or matching vendor
+ armh-unknown | armh-alt)
+ cpu=armv7l
+ vendor=alt
+ basic_os=${basic_os:-linux-gnueabihf}
+ ;;
+
+ # Normalized CPU+vendor pairs that imply an OS, if not otherwise specified
+ m68k-isi)
+ basic_os=${basic_os:-sysv}
+ ;;
+ m68k-sony)
+ basic_os=${basic_os:-newsos}
+ ;;
+ m68k-tektronix)
+ basic_os=${basic_os:-bsd}
+ ;;
+ m88k-harris)
+ basic_os=${basic_os:-sysv3}
+ ;;
+ i386-bull | m68k-bull)
+ basic_os=${basic_os:-sysv3}
+ ;;
+ rs6000-bull)
+ basic_os=${basic_os:-bosx}
+ ;;
+ mips-sni)
+ basic_os=${basic_os:-sysv4}
+ ;;
+
+ # Here we normalize CPU types irrespective of the vendor
+ amd64-*)
+ cpu=x86_64
+ ;;
+ blackfin-*)
+ cpu=bfin
+ basic_os=${basic_os:-linux}
+ ;;
+ c54x-*)
+ cpu=tic54x
+ ;;
+ c55x-*)
+ cpu=tic55x
+ ;;
+ c6x-*)
+ cpu=tic6x
+ ;;
+ e500v[12]-*)
+ cpu=powerpc
+ basic_os=${basic_os}"spe"
+ ;;
+ mips3*-*)
+ cpu=mips64
+ ;;
+ ms1-*)
+ cpu=mt
+ ;;
+ m68knommu-*)
+ cpu=m68k
+ basic_os=${basic_os:-linux}
+ ;;
+ m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
+ cpu=s12z
+ ;;
+ openrisc-*)
+ cpu=or32
+ ;;
+ parisc-*)
+ cpu=hppa
+ basic_os=${basic_os:-linux}
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ cpu=i586
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
+ cpu=i686
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ cpu=i686
+ ;;
+ pentium4-*)
+ cpu=i786
+ ;;
+ ppc-* | ppcbe-*)
+ cpu=powerpc
+ ;;
+ ppcle-* | powerpclittle-*)
+ cpu=powerpcle
+ ;;
+ ppc64-*)
+ cpu=powerpc64
+ ;;
+ ppc64le-* | powerpc64little-*)
+ cpu=powerpc64le
+ ;;
+ sb1-*)
+ cpu=mipsisa64sb1
+ ;;
+ sb1el-*)
+ cpu=mipsisa64sb1el
+ ;;
+ sh5e[lb]-*)
+ cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
+ ;;
+ spur-*)
+ cpu=spur
+ ;;
+ strongarm-* | thumb-*)
+ cpu=arm
+ ;;
+ tx39-*)
+ cpu=mipstx39
+ ;;
+ tx39el-*)
+ cpu=mipstx39el
+ ;;
+ xscale-* | xscalee[bl]-*)
+ cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
+ ;;
+ arm64-* | aarch64le-* | arm64_32-*)
+ cpu=aarch64
+ ;;
+
+ # Recognize the canonical CPU Types that limit and/or modify the
+ # company names they are paired with.
+ cr16-*)
+ basic_os=${basic_os:-elf}
+ ;;
+ crisv32-* | etraxfs*-*)
+ cpu=crisv32
+ vendor=axis
+ ;;
+ cris-* | etrax*-*)
+ cpu=cris
+ vendor=axis
+ ;;
+ crx-*)
+ basic_os=${basic_os:-elf}
+ ;;
+ neo-tandem)
+ cpu=neo
+ vendor=tandem
+ ;;
+ nse-tandem)
+ cpu=nse
+ vendor=tandem
+ ;;
+ nsr-tandem)
+ cpu=nsr
+ vendor=tandem
+ ;;
+ nsv-tandem)
+ cpu=nsv
+ vendor=tandem
+ ;;
+ nsx-tandem)
+ cpu=nsx
+ vendor=tandem
+ ;;
+ mipsallegrexel-sony)
+ cpu=mipsallegrexel
+ vendor=sony
+ ;;
+ tile*-*)
+ basic_os=${basic_os:-linux-gnu}
+ ;;
+
+ *)
+ # Recognize the canonical CPU types that are allowed with any
+ # company name.
+ case $cpu in
+ 1750a \
+ | 580 \
+ | [cjt]90 \
+ | a29k \
+ | aarch64 \
+ | aarch64_be \
+ | aarch64c \
+ | abacus \
+ | alpha \
+ | alpha64 \
+ | alpha64ev56 \
+ | alpha64ev6[78] \
+ | alpha64ev[4-8] \
+ | alpha64pca5[67] \
+ | alphaev56 \
+ | alphaev6[78] \
+ | alphaev[4-8] \
+ | alphapca5[67] \
+ | am33_2.0 \
+ | amdgcn \
+ | arc \
+ | arc32 \
+ | arc64 \
+ | arceb \
+ | arm \
+ | arm64e \
+ | arm64ec \
+ | arm[lb]e \
+ | arme[lb] \
+ | armv* \
+ | asmjs \
+ | avr \
+ | avr32 \
+ | ba \
+ | be32 \
+ | be64 \
+ | bfin \
+ | bpf \
+ | bs2000 \
+ | c30 \
+ | c4x \
+ | c8051 \
+ | c[123]* \
+ | clipper \
+ | craynv \
+ | csky \
+ | cydra \
+ | d10v \
+ | d30v \
+ | dlx \
+ | dsp16xx \
+ | e2k \
+ | elxsi \
+ | epiphany \
+ | f30[01] \
+ | f700 \
+ | fido \
+ | fr30 \
+ | frv \
+ | ft32 \
+ | fx80 \
+ | h8300 \
+ | h8500 \
+ | hexagon \
+ | hppa \
+ | hppa1.[01] \
+ | hppa2.0 \
+ | hppa2.0[nw] \
+ | hppa64 \
+ | i*86 \
+ | i370 \
+ | i860 \
+ | i960 \
+ | ia16 \
+ | ia64 \
+ | intelgt \
+ | ip2k \
+ | iq2000 \
+ | javascript \
+ | k1om \
+ | kvx \
+ | le32 \
+ | le64 \
+ | lm32 \
+ | loongarch32 \
+ | loongarch64 \
+ | m32c \
+ | m32r \
+ | m32rle \
+ | m5200 \
+ | m68000 \
+ | m680[012346]0 \
+ | m6811 \
+ | m6812 \
+ | m68360 \
+ | m683?2 \
+ | m68hc11 \
+ | m68hc12 \
+ | m68hcs12x \
+ | m68k \
+ | m88110 \
+ | m88k \
+ | maxq \
+ | mb \
+ | mcore \
+ | mep \
+ | metag \
+ | microblaze \
+ | microblazeel \
+ | mips* \
+ | mmix \
+ | mn10200 \
+ | mn10300 \
+ | moxie \
+ | msp430 \
+ | mt \
+ | nanomips* \
+ | nds32 \
+ | nds32be \
+ | nds32le \
+ | nfp \
+ | nios \
+ | nios2 \
+ | nios2eb \
+ | nios2el \
+ | none \
+ | np1 \
+ | ns16k \
+ | ns32k \
+ | nvptx \
+ | open8 \
+ | or1k* \
+ | or32 \
+ | orion \
+ | pdp10 \
+ | pdp11 \
+ | picochip \
+ | pj \
+ | pjl \
+ | pn \
+ | power \
+ | powerpc \
+ | powerpc64 \
+ | powerpc64le \
+ | powerpcle \
+ | powerpcspe \
+ | pru \
+ | pyramid \
+ | riscv \
+ | riscv32 \
+ | riscv32be \
+ | riscv64 \
+ | riscv64be \
+ | rl78 \
+ | romp \
+ | rs6000 \
+ | rx \
+ | s390 \
+ | s390x \
+ | score \
+ | sh \
+ | sh64 \
+ | sh64le \
+ | sh[12345][lb]e \
+ | sh[1234] \
+ | sh[1234]e[lb] \
+ | sh[23]e \
+ | sh[23]ele \
+ | sh[24]a \
+ | sh[24]ae[lb] \
+ | sh[lb]e \
+ | she[lb] \
+ | shl \
+ | sparc \
+ | sparc64 \
+ | sparc64b \
+ | sparc64v \
+ | sparc86x \
+ | sparclet \
+ | sparclite \
+ | sparcv8 \
+ | sparcv9 \
+ | sparcv9b \
+ | sparcv9v \
+ | spu \
+ | sv1 \
+ | sx* \
+ | tahoe \
+ | thumbv7* \
+ | tic30 \
+ | tic4x \
+ | tic54x \
+ | tic55x \
+ | tic6x \
+ | tic80 \
+ | tron \
+ | ubicom32 \
+ | v70 \
+ | v810 \
+ | v850 \
+ | v850e \
+ | v850e1 \
+ | v850e2 \
+ | v850e2v3 \
+ | v850es \
+ | vax \
+ | vc4 \
+ | visium \
+ | w65 \
+ | wasm32 \
+ | wasm64 \
+ | we32k \
+ | x86 \
+ | x86_64 \
+ | xc16x \
+ | xgate \
+ | xps100 \
+ | xstormy16 \
+ | xtensa* \
+ | ymp \
+ | z80 \
+ | z8k)
+ ;;
+
+ *)
+ echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
+ exit 1
+ ;;
+ esac
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $vendor in
+ digital*)
+ vendor=dec
+ ;;
+ commodore*)
+ vendor=cbm
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if test x"$basic_os" != x
+then
+
+# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
+# set os.
+obj=
+case $basic_os in
+ gnu/linux*)
+ kernel=linux
+ os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
+ ;;
+ os2-emx)
+ kernel=os2
+ os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
+ ;;
+ nto-qnx*)
+ kernel=nto
+ os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
+ ;;
+ *-*)
+ saved_IFS=$IFS
+ IFS="-" read kernel os <<EOF
+$basic_os
+EOF
+ IFS=$saved_IFS
+ ;;
+ # Default OS when just kernel was specified
+ nto*)
+ kernel=nto
+ os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
+ ;;
+ orange*)
+ kernel=orange
+ os=`echo "$basic_os" | sed -e 's|orange|mlibc|'`
+ ;;
+ linux*)
+ kernel=linux
+ os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
+ ;;
+ managarm*)
+ kernel=managarm
+ os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
+ ;;
+ *)
+ kernel=
+ os=$basic_os
+ ;;
+esac
+
+# Now, normalize the OS (knowing we just have one component, it's not a kernel,
+# etc.)
+case $os in
+ # First match some system type aliases that might get confused
+ # with valid system types.
+ # solaris* is a basic system type, with this one exception.
+ auroraux)
+ os=auroraux
+ ;;
+ bluegene*)
+ os=cnk
+ ;;
+ solaris1 | solaris1.*)
+ os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
+ ;;
+ solaris)
+ os=solaris2
+ ;;
+ unixware*)
+ os=sysv4.2uw
+ ;;
+ # The marketing names for NeXT's operating systems were
+ # NeXTSTEP, NeXTSTEP 2, OpenSTEP 3, OpenSTEP 4. 'openstep' is
+ # mapped to 'openstep3', but 'openstep1' and 'openstep2' are
+ # mapped to 'nextstep' and 'nextstep2', consistent with the
+ # treatment of SunOS/Solaris.
+ ns | ns1 | nextstep | nextstep1 | openstep1)
+ os=nextstep
+ ;;
+ ns2 | nextstep2 | openstep2)
+ os=nextstep2
+ ;;
+ ns3 | nextstep3 | openstep | openstep3)
+ os=openstep3
+ ;;
+ ns4 | nextstep4 | openstep4)
+ os=openstep4
+ ;;
+ # es1800 is here to avoid being matched by es* (a different OS)
+ es1800*)
+ os=ose
+ ;;
+ # Some version numbers need modification
+ chorusos*)
+ os=chorusos
+ ;;
+ isc)
+ os=isc2.2
+ ;;
+ sco6)
+ os=sco5v6
+ ;;
+ sco5)
+ os=sco3.2v5
+ ;;
+ sco4)
+ os=sco3.2v4
+ ;;
+ sco3.2.[4-9]*)
+ os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
+ ;;
+ sco*v* | scout)
+ # Don't match below
+ ;;
+ sco*)
+ os=sco3.2v2
+ ;;
+ psos*)
+ os=psos
+ ;;
+ qnx*)
+ os=qnx
+ ;;
+ hiux*)
+ os=hiuxwe2
+ ;;
+ lynx*178)
+ os=lynxos178
+ ;;
+ lynx*5)
+ os=lynxos5
+ ;;
+ lynxos*)
+ # don't get caught up in next wildcard
+ ;;
+ lynx*)
+ os=lynxos
+ ;;
+ mac[0-9]*)
+ os=`echo "$os" | sed -e 's|mac|macos|'`
+ ;;
+ opened*)
+ os=openedition
+ ;;
+ os400*)
+ os=os400
+ ;;
+ sunos5*)
+ os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
+ ;;
+ sunos6*)
+ os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
+ ;;
+ wince*)
+ os=wince
+ ;;
+ utek*)
+ os=bsd
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|tektronix|'`
+ ;;
+ dynix*)
+ os=bsd
+ ;;
+ acis*)
+ os=aos
+ ;;
+ atheos*)
+ os=atheos
+ ;;
+ syllable*)
+ os=syllable
+ ;;
+ 386bsd)
+ os=bsd
+ ;;
+ ctix*)
+ os=sysv
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|convergent|'`
+ ;;
+ uts*)
+ os=sysv
+ ;;
+ nova*)
+ kernel=rtmk
+ os=nova
+ ;;
+ # Preserve the version number of sinix5.
+ sinix5.*)
+ os=`echo "$os" | sed -e 's|sinix|sysv|'`
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
+ ;;
+ sinix*)
+ os=sysv4
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
+ ;;
+ tpf*)
+ os=tpf
+ ;;
+ triton*)
+ os=sysv3
+ ;;
+ oss*)
+ os=sysv3
+ ;;
+ svr4*)
+ os=sysv4
+ ;;
+ svr3)
+ os=sysv3
+ ;;
+ sysvr4)
+ os=sysv4
+ ;;
+ ose*)
+ os=ose
+ ;;
+ *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
+ os=mint
+ ;;
+ dicos*)
+ os=dicos
+ ;;
+ pikeos*)
+ # Until real need of OS specific support for
+ # particular features comes up, bare metal
+ # configurations are quite functional.
+ case $cpu in
+ arm*)
+ os=eabi
+ ;;
+ *)
+ os=
+ obj=elf
+ ;;
+ esac
+ ;;
+ aout* | coff* | elf* | pe*)
+ # These are machine code file formats, not OSes
+ obj=$os
+ os=
+ ;;
+ *)
+ # No normalization, but not necessarily accepted, that comes below.
+ ;;
+esac
+
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+kernel=
+obj=
+case $cpu-$vendor in
+ score-*)
+ os=
+ obj=elf
+ ;;
+ spu-*)
+ os=
+ obj=elf
+ ;;
+ *-acorn)
+ os=riscix1.2
+ ;;
+ arm*-rebel)
+ kernel=linux
+ os=gnu
+ ;;
+ arm*-semi)
+ os=
+ obj=aout
+ ;;
+ c4x-* | tic4x-*)
+ os=
+ obj=coff
+ ;;
+ c8051-*)
+ os=
+ obj=elf
+ ;;
+ clipper-intergraph)
+ os=clix
+ ;;
+ hexagon-*)
+ os=
+ obj=elf
+ ;;
+ tic54x-*)
+ os=
+ obj=coff
+ ;;
+ tic55x-*)
+ os=
+ obj=coff
+ ;;
+ tic6x-*)
+ os=
+ obj=coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=tops20
+ ;;
+ pdp11-*)
+ os=none
+ ;;
+ *-dec | vax-*)
+ os=ultrix4.2
+ ;;
+ m68*-apollo)
+ os=domain
+ ;;
+ i386-sun)
+ os=sunos4.0.2
+ ;;
+ m68000-sun)
+ os=sunos3
+ ;;
+ m68*-cisco)
+ os=
+ obj=aout
+ ;;
+ mep-*)
+ os=
+ obj=elf
+ ;;
+ # The -sgi and -siemens entries must be before the mips- entry
+ # or we get the wrong os.
+ *-sgi)
+ os=irix
+ ;;
+ *-siemens)
+ os=sysv4
+ ;;
+ mips*-cisco)
+ os=
+ obj=elf
+ ;;
+ mips*-*|nanomips*-*)
+ os=
+ obj=elf
+ ;;
+ or32-*)
+ os=
+ obj=coff
+ ;;
+ # This must be before the sparc-* entry or we get the wrong os.
+ *-tti)
+ os=sysv3
+ ;;
+ sparc-* | *-sun)
+ os=sunos4.1.1
+ ;;
+ pru-*)
+ os=
+ obj=elf
+ ;;
+ *-be)
+ os=beos
+ ;;
+ *-ibm)
+ os=aix
+ ;;
+ *-knuth)
+ os=mmixware
+ ;;
+ *-wec)
+ os=proelf
+ ;;
+ *-winbond)
+ os=proelf
+ ;;
+ *-oki)
+ os=proelf
+ ;;
+ *-hp)
+ os=hpux
+ ;;
+ *-hitachi)
+ os=hiuxwe2
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=sysv
+ ;;
+ *-cbm)
+ os=amigaos
+ ;;
+ *-dg)
+ os=dgux
+ ;;
+ *-dolphin)
+ os=sysv3
+ ;;
+ m68k-ccur)
+ os=rtu
+ ;;
+ m88k-omron*)
+ os=luna
+ ;;
+ *-next)
+ os=nextstep
+ ;;
+ *-sequent)
+ os=ptx
+ ;;
+ *-crds)
+ os=unos
+ ;;
+ *-ns)
+ os=genix
+ ;;
+ i370-*)
+ os=mvs
+ ;;
+ *-gould)
+ os=sysv
+ ;;
+ *-highlevel)
+ os=bsd
+ ;;
+ *-encore)
+ os=bsd
+ ;;
+ *-masscomp)
+ os=rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=uxpv
+ ;;
+ *-rom68k)
+ os=
+ obj=coff
+ ;;
+ *-*bug)
+ os=
+ obj=coff
+ ;;
+ *-apple)
+ os=macos
+ ;;
+ *-atari*)
+ os=mint
+ ;;
+ *-wrs)
+ os=vxworks
+ ;;
+ *)
+ os=none
+ ;;
+esac
+
+fi
+
+# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
+
+case $os in
+ # Sometimes we do "kernel-libc", so those need to count as OSes.
+ llvm* | musl* | newlib* | relibc* | uclibc*)
+ ;;
+ # Likewise for "kernel-abi"
+ eabi* | gnueabi*)
+ ;;
+ # VxWorks passes extra cpu info in the 4th filed.
+ simlinux | simwindows | spe)
+ ;;
+ # See `case $cpu-$os` validation below
+ ghcjs)
+ ;;
+ # Now accept the basic system types.
+ # Each alternative MUST end in a * to match a version number.
+ abug \
+ | aix* \
+ | amdhsa* \
+ | amigados* \
+ | amigaos* \
+ | android* \
+ | aof* \
+ | aos* \
+ | aros* \
+ | atheos* \
+ | auroraux* \
+ | aux* \
+ | banan_os* \
+ | beos* \
+ | bitrig* \
+ | bme* \
+ | bosx* \
+ | bsd* \
+ | cegcc* \
+ | chorusos* \
+ | chorusrdb* \
+ | clix* \
+ | cloudabi* \
+ | cnk* \
+ | conix* \
+ | cos* \
+ | cxux* \
+ | cygwin* \
+ | darwin* \
+ | dgux* \
+ | dicos* \
+ | dnix* \
+ | domain* \
+ | dragonfly* \
+ | drops* \
+ | ebmon* \
+ | ecoff* \
+ | ekkobsd* \
+ | emscripten* \
+ | emx* \
+ | es* \
+ | fiwix* \
+ | freebsd* \
+ | fuchsia* \
+ | genix* \
+ | genode* \
+ | glidix* \
+ | gnu* \
+ | go32* \
+ | haiku* \
+ | hcos* \
+ | hiux* \
+ | hms* \
+ | hpux* \
+ | ieee* \
+ | interix* \
+ | ios* \
+ | iris* \
+ | irix* \
+ | isc* \
+ | its* \
+ | l4re* \
+ | libertybsd* \
+ | lites* \
+ | lnews* \
+ | luna* \
+ | lynxos* \
+ | mach* \
+ | macos* \
+ | magic* \
+ | mbr* \
+ | midipix* \
+ | midnightbsd* \
+ | mingw32* \
+ | mingw64* \
+ | minix* \
+ | mint* \
+ | mirbsd* \
+ | mks* \
+ | mlibc* \
+ | mmixware* \
+ | mon960* \
+ | morphos* \
+ | moss* \
+ | moxiebox* \
+ | mpeix* \
+ | mpw* \
+ | msdos* \
+ | msys* \
+ | mvs* \
+ | nacl* \
+ | netbsd* \
+ | netware* \
+ | newsos* \
+ | nextstep* \
+ | nindy* \
+ | nonstopux* \
+ | nova* \
+ | nsk* \
+ | nucleus* \
+ | nx6 \
+ | nx7 \
+ | oabi* \
+ | ohos* \
+ | onefs* \
+ | openbsd* \
+ | openedition* \
+ | openstep* \
+ | os108* \
+ | os2* \
+ | os400* \
+ | os68k* \
+ | os9* \
+ | ose* \
+ | osf* \
+ | oskit* \
+ | osx* \
+ | palmos* \
+ | phoenix* \
+ | plan9* \
+ | powermax* \
+ | powerunix* \
+ | proelf* \
+ | psos* \
+ | psp* \
+ | ptx* \
+ | pw32* \
+ | qnx* \
+ | rdos* \
+ | redox* \
+ | rhapsody* \
+ | riscix* \
+ | riscos* \
+ | rtems* \
+ | rtmk* \
+ | rtu* \
+ | scout* \
+ | secbsd* \
+ | sei* \
+ | serenity* \
+ | sim* \
+ | skyos* \
+ | solaris* \
+ | solidbsd* \
+ | sortix* \
+ | storm-chaos* \
+ | sunos \
+ | sunos[34]* \
+ | superux* \
+ | syllable* \
+ | sym* \
+ | sysv* \
+ | tenex* \
+ | tirtos* \
+ | tock* \
+ | toppers* \
+ | tops10* \
+ | tops20* \
+ | tpf* \
+ | tvos* \
+ | twizzler* \
+ | uclinux* \
+ | udi* \
+ | udk* \
+ | ultrix* \
+ | unicos* \
+ | uniplus* \
+ | unleashed* \
+ | unos* \
+ | uwin* \
+ | uxpv* \
+ | v88r* \
+ |*vms* \
+ | vos* \
+ | vsta* \
+ | vxsim* \
+ | vxworks* \
+ | wasi* \
+ | watchos* \
+ | wince* \
+ | windiss* \
+ | windows* \
+ | winnt* \
+ | xenix* \
+ | xray* \
+ | zephyr* \
+ | zvmoe* )
+ ;;
+ # This one is extra strict with allowed versions
+ sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ ;;
+ # This refers to builds using the UEFI calling convention
+ # (which depends on the architecture) and PE file format.
+ # Note that this is both a different calling convention and
+ # different file format than that of GNU-EFI
+ # (x86_64-w64-mingw32).
+ uefi)
+ ;;
+ none)
+ ;;
+ kernel* | msvc* )
+ # Restricted further below
+ ;;
+ '')
+ if test x"$obj" = x
+ then
+ echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
+ fi
+ ;;
+ *)
+ echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
+ exit 1
+ ;;
+esac
+
+case $obj in
+ aout* | coff* | elf* | pe*)
+ ;;
+ '')
+ # empty is fine
+ ;;
+ *)
+ echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we handle the constraint that a (synthetic) cpu and os are
+# valid only in combination with each other and nowhere else.
+case $cpu-$os in
+ # The "javascript-unknown-ghcjs" triple is used by GHC; we
+ # accept it here in order to tolerate that, but reject any
+ # variations.
+ javascript-ghcjs)
+ ;;
+ javascript-* | *-ghcjs)
+ echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
+ exit 1
+ ;;
+esac
+
+# As a final step for OS-related things, validate the OS-kernel combination
+# (given a valid OS), if there is a kernel.
+case $kernel-$os-$obj in
+ linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
+ | linux-mlibc*- | linux-musl*- | linux-newlib*- \
+ | linux-relibc*- | linux-uclibc*- | linux-ohos*- )
+ ;;
+ uclinux-uclibc*- | uclinux-gnu*- )
+ ;;
+ orange-mlibc*-)
+ ;;
+ managarm-mlibc*- | managarm-kernel*- )
+ ;;
+ windows*-msvc*-)
+ ;;
+ -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
+ | -uclibc*- )
+ # These are just libc implementations, not actual OSes, and thus
+ # require a kernel.
+ echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
+ exit 1
+ ;;
+ -kernel*- )
+ echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
+ exit 1
+ ;;
+ *-kernel*- )
+ echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
+ exit 1
+ ;;
+ *-msvc*- )
+ echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
+ exit 1
+ ;;
+ kfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-)
+ ;;
+ vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
+ ;;
+ nto-qnx*-)
+ ;;
+ os2-emx-)
+ ;;
+ rtmk-nova-)
+ ;;
+ *-eabi*- | *-gnueabi*-)
+ ;;
+ ios*-simulator- | tvos*-simulator- | watchos*-simulator- )
+ ;;
+ none--*)
+ # None (no kernel, i.e. freestanding / bare metal),
+ # can be paired with an machine code file format
+ ;;
+ -*-)
+ # Blank kernel with real OS is always fine.
+ ;;
+ --*)
+ # Blank kernel and OS with real machine code file format is always fine.
+ ;;
+ *-*-*)
+ echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+case $vendor in
+ unknown)
+ case $cpu-$os in
+ *-riscix*)
+ vendor=acorn
+ ;;
+ *-sunos* | *-solaris*)
+ vendor=sun
+ ;;
+ *-cnk* | *-aix*)
+ vendor=ibm
+ ;;
+ *-beos*)
+ vendor=be
+ ;;
+ *-hpux*)
+ vendor=hp
+ ;;
+ *-mpeix*)
+ vendor=hp
+ ;;
+ *-hiux*)
+ vendor=hitachi
+ ;;
+ *-unos*)
+ vendor=crds
+ ;;
+ *-dgux*)
+ vendor=dg
+ ;;
+ *-luna*)
+ vendor=omron
+ ;;
+ *-genix*)
+ vendor=ns
+ ;;
+ *-clix*)
+ vendor=intergraph
+ ;;
+ *-mvs* | *-opened*)
+ vendor=ibm
+ ;;
+ *-os400*)
+ vendor=ibm
+ ;;
+ s390-* | s390x-*)
+ vendor=ibm
+ ;;
+ *-ptx*)
+ vendor=sequent
+ ;;
+ *-tpf*)
+ vendor=ibm
+ ;;
+ *-vxsim* | *-vxworks* | *-windiss*)
+ vendor=wrs
+ ;;
+ *-aux*)
+ vendor=apple
+ ;;
+ *-hms*)
+ vendor=hitachi
+ ;;
+ *-mpw* | *-macos*)
+ vendor=apple
+ ;;
+ *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
+ vendor=atari
+ ;;
+ *-vos*)
+ vendor=stratus
+ ;;
+ esac
+ ;;
+esac
+
+echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
+exit
+
+# Local variables:
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%Y-%02m-%02d"
+# time-stamp-end: "'"
+# End: \ No newline at end of file
diff --git a/tools/pkg/pkg-lib.sh b/tools/pkg/pkg-lib.sh
index be29d1c..496cbda 100644
--- a/tools/pkg/pkg-lib.sh
+++ b/tools/pkg/pkg-lib.sh
@@ -2,7 +2,7 @@
GNU_MIRROR=https://mirror.dogado.de/
cachedownload() {
- if [ ! -d "../cached/$1" ]; then
+ if [ ! -f "../cached/$1" ]; then
curl -o ../cached/$1 $2
fi
}
@@ -16,4 +16,136 @@ installgnu() {
diff_patch() {
patch -p1 < "$1"
+}
+
+patch_config_sub() {
+ SRC="$1/tools/pkg/config.sub"
+ find "." -type f -name "config.sub" -exec sudo cp "$SRC" {} \;
+ find "." -type f -name "config.guess" -exec sudo cp "$1/tools/pkg/config.guess" {} \;
+}
+
+fast_install() {
+ old0="$(pwd)"
+ wget "$2"
+ archive_name="$(basename $2)"
+ dir_name=$(tar -tf "$archive_name" | head -1 | cut -f1 -d"/")
+ tar -xvf "$archive_name"
+ cd "$dir_name"
+ autotools_recursive_regen
+ if [ -n "$4" ]; then
+ diff_patch "$4"
+ fi
+ ./configure --prefix="/usr" --host=x86_64-orange-mlibc --disable-static --enable-shared --disable-malloc0returnsnull $3
+ make -j$(nproc)
+ make install DESTDIR="$1"
+
+ old="$(pwd)"
+ cd "$1/usr/lib"
+ rm -rf *.la
+ cd "$old"
+
+ cd "$old0"
+}
+
+fast_install_debug() {
+ old0="$(pwd)"
+ wget "$2"
+ archive_name="$(basename $2)"
+ dir_name=$(tar -tf "$archive_name" | head -1 | cut -f1 -d"/")
+ #tar -xvf "$archive_name"
+ cd "$dir_name"
+ #autotools_recursive_regen
+ # if [ -n "$4" ]; then
+ # diff_patch "$4"
+ # fi
+ ./configure --prefix="/usr" --host=x86_64-orange-mlibc --disable-static --enable-shared --disable-malloc0returnsnull $3
+ make -j$(nproc)
+ sudo make install DESTDIR="$1"
+
+ old="$(pwd)"
+ cd "$1/usr/lib"
+ rm -rf *.la
+ cd "$old"
+
+ cd "$old0"
+}
+
+
+checked_subst() {
+ tmpfile="$2".checked_subst
+ sed -z -E -e "$1" "$2" >"$tmpfile"
+ if cmp -s "$2" "$tmpfile"; then
+ rm -f "$2".checked_subst
+ if [ "$3" = no_die ]; then
+ return 1
+ else
+ die "*** substitution '$1' failed for file '$2'"
+ fi
+ fi
+
+ #diff --color=auto -ur "$2" "$tmpfile" || true
+
+ touch -r "$2" "$2".checked_subst
+ chmod --reference="$2" "$2".checked_subst
+ mv -f "$2".checked_subst "$2"
+}
+
+base_dir="$(realpath ../../../../)"
+
+autotools_recursive_regen() {
+ for f in $(grep -rl 'GNU config.sub ($timestamp)'); do
+ sudo mv "$f" "$f".reference
+ sudo cp -v ${base_dir}/tools/pkg/config.sub "$f"
+ sudo touch -r "$f".reference "$f"
+ sudo rm -f "$f".reference
+ done
+ for f in $(grep -rl 'GNU config.guess ($timestamp)'); do
+ sudo mv "$f" "$f".reference
+ sudo cp -v ${base_dir}/tools/pkg/config.guess "$f"
+ sudo touch -r "$f".reference "$f"
+ sudo rm -f "$f".reference
+ done
+
+ if ! [ -z "$(grep -rl "# No shared lib support for Linux oldld, aout, or coff.")" ]; then
+ if [ -z "$(grep -rl "dynamic_linker='mlibc ld.so'")" ]; then
+ echo "*** Missing libtool support for mlibc - trying to patch support in :3 ***"
+ for f in $(grep -rl "We cannot seem to hardcode it, guess we'll fake it."); do
+ if grep -q 'add_dir="\?-L$lt_sysroot$libdir"\?' "$f"; then
+ continue
+ fi
+ checked_subst 's/add_dir=(")?-L\$libdir(")?/add_dir=\1-L$lt_sysroot$libdir\1/g' "$f"
+ done
+ for f in $(grep -rl "# No shared lib support for Linux oldld, aout, or coff."); do
+ if grep -q 'AC_DEFUN(\[AC_PROG_LIBTOOL\]' "$f"; then
+ continue
+ fi
+ if grep -q 'ltconfig - Create a system-specific libtool' "$f"; then
+ continue
+ fi
+ checked_subst 's/(# This must be (glibc\/|Linux )?ELF.\nlinux\* \| k\*bsd\*-gnu \| kopensolaris\*-gnu( \| gnu\*)?( \| uclinuxfdpiceabi)?)(\)\n lt_cv_deplibs_check_method=pass_all)/\1 | *-mlibc\5/g' "$f"
+ checked_subst 's/(\)\n # FreeBSD uses GNU C)/ | *-mlibc\1/g' "$f" no_die || true
+ checked_subst 's/(lt_prog_compiler_static(_[^=]*)?='"'"'-non_shared'"'"'\n ;;)(\n\n linux\* \| k\*bsd\*-gnu \| kopensolaris\*-gnu( \| gnu\*)?\))/\1\n\n *-mlibc)\n lt_prog_compiler_wl\2='"'"'-Wl,'"'"'\n lt_prog_compiler_pic\2='"'"'-fPIC'"'"'\n lt_prog_compiler_static\2='"'"'-static'"'"'\n ;;\3/g' "$f"
+ checked_subst 's/( (haiku|interix\[3-9\])?\*\)\n (archive_cmds|hardcode_direct)?(_[^=]*)?=)/ *-mlibc)\n archive_cmds\4='"'"'$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'"'"'\n archive_expsym_cmds\4='"'"'$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'"'"'\n ;;\n\n\1/g' "$f"
+ checked_subst 's/(\)\n # FreeBSD 3 and later use GNU C)/ | *-mlibc\1/g' "$f" no_die || true
+ # putting this last to avoid a bug with determining whether the substitutions should be run or not.
+ checked_subst 's/(hardcode_into_libs=yes\n ;;\n\n)(# No shared lib support for Linux oldld, aout, or coff.)/\1*-mlibc)\n version_type=linux\n need_lib_prefix=no\n need_version=no\n library_names_spec='"'"'$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'"'"'\n soname_spec='"'"'$libname$release$shared_ext$major'"'"'\n dynamic_linker='"'"'mlibc ld.so'"'"'\n shlibpath_var=LD_LIBRARY_PATH\n shlibpath_overrides_runpath=no\n hardcode_into_libs=yes\n ;;\n\n\2/g' "$f"
+ done
+ fi
+ fi
+}
+
+#
+
+generate_shared() {
+ echo Generating shared from $2 to $1
+ x86_64-orange-mlibc-gcc -shared -o "$1" -Wl,--whole-archive "$2" -Wl,--no-whole-archive -fPIC
+ rm -f "$2"
+}
+
+kill_libtool_demons() {
+ echo Killing libtool demons
+ old="$(pwd)"
+ cd "$1/usr/lib"
+ rm -rf *.la
+ cd "$old"
} \ No newline at end of file
diff --git a/tools/pkg/toolchain.cmake b/tools/pkg/toolchain.cmake
index 2d1d55f..eca7a3b 100644
--- a/tools/pkg/toolchain.cmake
+++ b/tools/pkg/toolchain.cmake
@@ -2,8 +2,8 @@
set(CMAKE_SYSTEM_NAME Orange)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
-set(CMAKE_C_COMPILER x86_64-orange-gcc)
-set(CMAKE_LINKER x86_64-orange-ld)
+set(CMAKE_C_COMPILER x86_64-orange-mlibc-gcc)
+set(CMAKE_LINKER x86_64-orange-mlibc-ld)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_C_EXTENSIONS ON) \ No newline at end of file
diff --git a/tools/pkg/x86_64-orange.crossfile b/tools/pkg/x86_64-orange.crossfile
new file mode 100644
index 0000000..d32b5ee
--- /dev/null
+++ b/tools/pkg/x86_64-orange.crossfile
@@ -0,0 +1,12 @@
+[binaries]
+c = 'x86_64-orange-mlibc-gcc'
+cpp = 'x86_64-orange-mlibc-g++'
+ar = 'x86_64-orange-mlibc-ar'
+nm = 'x86_64-orange-mlibc-nm'
+pkg-config = 'x86_64-orange-mlibc-pkg-config'
+
+[host_machine]
+system = 'orange'
+cpu_family = 'x86_64'
+cpu = 'x86_64'
+endian = 'little' \ No newline at end of file
diff --git a/tools/toolchain-build.sh b/tools/toolchain-build.sh
index 8b94c70..8c5890c 100644
--- a/tools/toolchain-build.sh
+++ b/tools/toolchain-build.sh
@@ -65,19 +65,27 @@ cd ../../gcc-15.1.0/libstdc++-v3
autoconf
cd ../../
+cd gcc-15.1.0
+cp -rf "$1/tools/pkg/config.sub" "$1/tools/pkg/config.guess" .
+cd ..
+
+cd binutils-2.38
+cp -rf "$1/tools/pkg/config.sub" "$1/tools/pkg/config.guess" .
+cd ..
+
echo Building binutils and gcc
mkdir -p binutils-build
cd binutils-build
mkdir -p $1/initrd
-../binutils-2.38/configure --target=x86_64-orange --prefix="$HOME/opt/cross/orange" --with-sysroot="$(realpath $1)/initrd" --enable-shared
+../binutils-2.38/configure --target=x86_64-orange-mlibc --prefix="$HOME/opt/cross/orange" --with-sysroot="$(realpath $1)/initrd" --enable-shared
make -j$(nproc)
make install -j$(nproc)
cd ..
mkdir -p gcc-build
cd gcc-build
-../gcc-15.1.0/configure --target=x86_64-orange --prefix="$HOME/opt/cross/orange" --with-sysroot="$(realpath $1)/initrd" --enable-languages=c,c++,go --disable-nls --enable-linker-build-id --enable-default-pie --enable-default-ssp --disable-multilib --enable-initfini-array --enable-shared --enable-host-shared CFLAGS=""
+../gcc-15.1.0/configure --target=x86_64-orange-mlibc --prefix="$HOME/opt/cross/orange" --with-sysroot="$(realpath $1)/initrd" --enable-languages=c,c++,go --disable-nls --enable-linker-build-id --enable-default-pie --enable-default-ssp --disable-multilib --enable-initfini-array --enable-shared --enable-host-shared CFLAGS=""
make all-gcc -j$(nproc)
make all-target-libgcc -j$(nproc)