Improve build on Windows via llvm-mingw
This commit is contained in:
parent
74f78a60de
commit
5eb6770760
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.ref.log text eol=auto
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -34,3 +34,5 @@ covpreproc
|
|||||||
*.aml
|
*.aml
|
||||||
ignore.*
|
ignore.*
|
||||||
t.d
|
t.d
|
||||||
|
*~
|
||||||
|
*.exe
|
||||||
|
15
isatty.c
15
isatty.c
@ -1,15 +0,0 @@
|
|||||||
#include "isatty.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
int isatty(int fd) {
|
|
||||||
// TODO: Make it work for win32
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fileno(FILE *fp) {
|
|
||||||
// TODO: Make it work for win32
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // _WIN32
|
|
6
isatty.h
6
isatty.h
@ -1,6 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int isatty(int fd);
|
|
||||||
int fileno(FILE *fp);
|
|
52
makefile
52
makefile
@ -2,32 +2,56 @@ ifndef KOLIBRIOS
|
|||||||
$(error "Set KOLIBRIOS environment variable to KolibriOS root")
|
$(error "Set KOLIBRIOS environment variable to KolibriOS root")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
FASM ?= fasm -dUEFI=1 -dextended_primary_loader=1 -dUMKA=1
|
ifndef HOST
|
||||||
|
$(error "Set HOST variable to linux/windows")
|
||||||
|
endif
|
||||||
|
|
||||||
|
FASM_EXE ?= fasm
|
||||||
|
FASM_INCLUDE=$(KOLIBRIOS)/kernel/trunk;$(KOLIBRIOS)/programs/develop/libraries/libcrash/hash
|
||||||
|
FASM_FLAGS=-dUEFI=1 -dextended_primary_loader=1 -dUMKA=1 -dHOST=$(HOST)
|
||||||
|
|
||||||
CC ?= gcc
|
CC ?= gcc
|
||||||
WARNINGS_COMMON=-Wall -Wextra \
|
WARNINGS_COMMON=-Wall -Wextra \
|
||||||
-Wnull-dereference -Wshadow -Wformat=2 -Wswitch -Wswitch-enum \
|
-Wnull-dereference -Wshadow -Wformat=2 -Wswitch -Wswitch-enum \
|
||||||
-Wpedantic \
|
-Wpedantic \
|
||||||
#-Wconversion -Wsign-conversion
|
#-Wconversion -Wsign-conversion
|
||||||
NOWARNINGS_COMMON=-Wno-address-of-packed-member -Wno-missing-prototype-for-cc
|
NOWARNINGS_COMMON=-Wno-address-of-packed-member
|
||||||
|
|
||||||
ifeq ($(CC),gcc)
|
ifneq (,$(findstring gcc,$(CC)))
|
||||||
WARNINGS=$(WARNINGS_COMMON) -Wduplicated-cond -Wduplicated-branches -Wrestrict -Wlogical-op -Wjump-misses-init
|
WARNINGS=$(WARNINGS_COMMON) -Wduplicated-cond -Wduplicated-branches -Wrestrict -Wlogical-op -Wjump-misses-init
|
||||||
NOWARNINGS=$(NOWARNINGS_COMMON)
|
NOWARNINGS=$(NOWARNINGS_COMMON)
|
||||||
else ifeq ($(CC),clang)
|
else ifneq (,$(findstring clang,$(CC)))
|
||||||
WARNINGS=$(WARNINGS_COMMON)
|
WARNINGS=$(WARNINGS_COMMON)
|
||||||
NOWARNINGS=$(NOWARNINGS_COMMON)
|
NOWARNINGS=$(NOWARNINGS_COMMON) -Wno-missing-prototype-for-cc
|
||||||
else
|
else
|
||||||
$(error compiler $(CC) is not supported)
|
$(error your compiler is not supported)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS=$(WARNINGS) $(NOWARNINGS) -std=c11 -g -O0 -D_FILE_OFFSET_BITS=64 \
|
CFLAGS=$(WARNINGS) $(NOWARNINGS) -std=c11 -g -O0 -D_FILE_OFFSET_BITS=64 \
|
||||||
-DNDEBUG -masm=intel -D_POSIX_C_SOURCE=200809L -Ilinux -fno-pie
|
-DNDEBUG -masm=intel -D_POSIX_C_SOURCE=200809L -I$(HOST) -fno-pie
|
||||||
CFLAGS_32=$(CFLAGS) -m32
|
CFLAGS_32=$(CFLAGS) -m32
|
||||||
LDFLAGS=-no-pie
|
LDFLAGS=-no-pie
|
||||||
LDFLAGS_32=$(LDFLAGS) -m32
|
LDFLAGS_32=$(LDFLAGS) -m32
|
||||||
|
|
||||||
|
ifeq ($(HOST),linux)
|
||||||
|
FASM_INCLUDE=$(KOLIBRIOS)/kernel/trunk;$(KOLIBRIOS)/programs/develop/libraries/libcrash/hash
|
||||||
|
FASM=INCLUDE="$(FASM_INCLUDE)" $(FASM_EXE) $(FASM_FLAGS)
|
||||||
|
else ifeq ($(HOST),windows)
|
||||||
|
FASM_INCLUDE=$(KOLIBRIOS)\kernel\trunk;$(KOLIBRIOS)\programs\develop\libraries\libcrash\hash
|
||||||
|
FASM=set INCLUDE=$(FASM_INCLUDE)&&$(FASM_EXE) $(FASM_FLAGS)
|
||||||
|
else
|
||||||
|
$(error your OS is not supported)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(HOST),linux)
|
||||||
all: umka_shell umka_fuse umka_os umka_gen_devices_dat umka.sym umka.prp \
|
all: umka_shell umka_fuse umka_os umka_gen_devices_dat umka.sym umka.prp \
|
||||||
umka.lst tags covpreproc default.skn skin.skn
|
umka.lst tags covpreproc default.skn skin.skn
|
||||||
|
else ifeq ($(HOST),windows)
|
||||||
|
all: umka_shell umka.sym umka.prp \
|
||||||
|
umka.lst default.skn skin.skn
|
||||||
|
else
|
||||||
|
$(error your OS is not supported)
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
|
|
||||||
@ -38,7 +62,7 @@ covpreproc: covpreproc.c
|
|||||||
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
|
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
|
||||||
|
|
||||||
umka_shell: umka_shell.o umka.o shell.o trace.o trace_lbr.o vdisk.o vnet.o \
|
umka_shell: umka_shell.o umka.o shell.o trace.o trace_lbr.o vdisk.o vnet.o \
|
||||||
lodepng.o pci.o thread.o util.o getopt.o isatty.o
|
lodepng.o pci.o thread.o util.o getopt.o
|
||||||
$(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld
|
$(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld
|
||||||
|
|
||||||
umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o pci.o thread.o
|
umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o pci.o thread.o
|
||||||
@ -52,17 +76,16 @@ umka_gen_devices_dat: umka_gen_devices_dat.o umka.o pci.o thread.o util.o
|
|||||||
$(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld
|
$(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld
|
||||||
|
|
||||||
umka.o umka.fas: umka.asm
|
umka.o umka.fas: umka.asm
|
||||||
INCLUDE="$(KOLIBRIOS)/kernel/trunk;$(KOLIBRIOS)/programs/develop/libraries/libcrash/hash" \
|
$(FASM) $< umka.o -s umka.fas
|
||||||
$(FASM) $< umka.o -s umka.fas -m 2000000
|
|
||||||
|
|
||||||
shell.o: shell.c
|
shell.o: shell.c
|
||||||
$(CC) $(CFLAGS_32) -c $<
|
$(CC) $(CFLAGS_32) -c $<
|
||||||
|
|
||||||
thread.o: linux/thread.c
|
thread.o: $(HOST)/thread.c
|
||||||
$(CC) $(CFLAGS_32) -c $<
|
$(CC) $(CFLAGS_32) -c $<
|
||||||
|
|
||||||
pci.o: linux/pci.c
|
pci.o: $(HOST)/pci.c
|
||||||
$(CC) $(CFLAGS_32) -c $<
|
$(CC) $(CFLAGS_32) -std=gnu11 -c $<
|
||||||
|
|
||||||
lodepng.o: lodepng.c lodepng.h
|
lodepng.o: lodepng.c lodepng.h
|
||||||
$(CC) $(CFLAGS_32) -c $<
|
$(CC) $(CFLAGS_32) -c $<
|
||||||
@ -70,9 +93,6 @@ lodepng.o: lodepng.c lodepng.h
|
|||||||
getopt.o: getopt.c getopt.h
|
getopt.o: getopt.c getopt.h
|
||||||
$(CC) $(CFLAGS_32) -c $<
|
$(CC) $(CFLAGS_32) -c $<
|
||||||
|
|
||||||
isatty.o: isatty.c isatty.h
|
|
||||||
$(CC) $(CFLAGS_32) -c $<
|
|
||||||
|
|
||||||
util.o: util.c util.h umka.h
|
util.o: util.c util.h umka.h
|
||||||
$(CC) $(CFLAGS_32) -c $<
|
$(CC) $(CFLAGS_32) -c $<
|
||||||
|
|
||||||
|
3
shell.c
3
shell.c
@ -35,7 +35,6 @@
|
|||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "isatty.h"
|
|
||||||
#include "getopt.h"
|
#include "getopt.h"
|
||||||
#include "vdisk.h"
|
#include "vdisk.h"
|
||||||
#include "vnet.h"
|
#include "vnet.h"
|
||||||
@ -45,7 +44,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "lodepng.h"
|
#include "lodepng.h"
|
||||||
|
|
||||||
#define PATH_MAX 4096
|
//#define PATH_MAX 4096
|
||||||
#define FGETS_BUF_LEN 4096
|
#define FGETS_BUF_LEN 4096
|
||||||
#define MAX_COMMAND_ARGS 42
|
#define MAX_COMMAND_ARGS 42
|
||||||
#define PRINT_BYTES_PER_LINE 32
|
#define PRINT_BYTES_PER_LINE 32
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
ifndef COVERAGE
|
ifndef COVERAGE
|
||||||
UMKA_SHELL=../umka_shell
|
UMKA_SHELL ?= ../umka_shell
|
||||||
else
|
else
|
||||||
UMKA_SHELL=sudo taskset 1 ../umka_shell -c
|
UMKA_SHELL ?= sudo taskset 1 ../umka_shell -c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
xfs_tests := $(addsuffix .out.log, $(basename $(wildcard *\#xfs_*.t)))
|
xfs_tests := $(addsuffix .out.log, $(basename $(wildcard *\#xfs_*.t)))
|
||||||
@ -48,9 +48,14 @@ arp: $(arp_tests)
|
|||||||
acpi: $(acpi_tests)
|
acpi: $(acpi_tests)
|
||||||
|
|
||||||
%.out.log: %.t
|
%.out.log: %.t
|
||||||
$(UMKA_SHELL) < $*.t > $@
|
$(UMKA_SHELL) -i $*.t
|
||||||
|
ifeq ($(HOST),linux)
|
||||||
@ cmp $*.out.log $*.ref.log
|
@ cmp $*.out.log $*.ref.log
|
||||||
@ if [ -f "$*.ref.png" ]; then cmp $*.out.png $*.ref.png; fi
|
@ if [ -f "$*.ref.png" ]; then cmp $*.out.png $*.ref.png; fi
|
||||||
|
else
|
||||||
|
@ comp /M $*.out.log $*.ref.log
|
||||||
|
# @ if [ -f "$*.ref.png" ]; then cmp $*.out.png $*.ref.png; fi
|
||||||
|
endif
|
||||||
|
|
||||||
collect_coverage:
|
collect_coverage:
|
||||||
../covpreproc ../umka.lst 0x34 coverage.* > ../umka.cov
|
../covpreproc ../umka.lst 0x34 coverage.* > ../umka.cov
|
||||||
|
36
umka.asm
36
umka.asm
@ -1,9 +1,11 @@
|
|||||||
; TODO: SPDX
|
; TODO: SPDX
|
||||||
|
|
||||||
if defined WIN32
|
if HOST eq windows
|
||||||
format MS COFF
|
format MS COFF
|
||||||
else
|
else if HOST eq linux
|
||||||
format ELF
|
format ELF
|
||||||
|
else
|
||||||
|
error "Your OS is not supported"
|
||||||
end if
|
end if
|
||||||
|
|
||||||
; win32:
|
; win32:
|
||||||
@ -21,7 +23,7 @@ end if
|
|||||||
; pubsym name, "name", 20 -> public name as "name"
|
; pubsym name, "name", 20 -> public name as "name"
|
||||||
; pubsym name, "name", no_mangle -> public name as "name"
|
; pubsym name, "name", no_mangle -> public name as "name"
|
||||||
macro pubsym name, marg1, marg2 {
|
macro pubsym name, marg1, marg2 {
|
||||||
if defined WIN32
|
if HOST eq windows
|
||||||
if marg1 eq no_mangle
|
if marg1 eq no_mangle
|
||||||
public name
|
public name
|
||||||
else if marg1 eqtype 20
|
else if marg1 eqtype 20
|
||||||
@ -37,12 +39,14 @@ macro pubsym name, marg1, marg2 {
|
|||||||
else
|
else
|
||||||
public name as '_' # `name
|
public name as '_' # `name
|
||||||
end if
|
end if
|
||||||
else
|
else if HOST eq linux
|
||||||
if marg1 eqtype 'string'
|
if marg1 eqtype 'string'
|
||||||
public name as marg1
|
public name as marg1
|
||||||
else
|
else
|
||||||
public name
|
public name
|
||||||
end if
|
end if
|
||||||
|
else
|
||||||
|
error "Your OS is not supported"
|
||||||
end if
|
end if
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,14 +57,16 @@ macro pubsym name, marg1, marg2 {
|
|||||||
; extrn name -> extrn name
|
; extrn name -> extrn name
|
||||||
; extrn name, 20 -> extrn name
|
; extrn name, 20 -> extrn name
|
||||||
macro extrn name, [argsize] {
|
macro extrn name, [argsize] {
|
||||||
if defined WIN32
|
if HOST eq windows
|
||||||
if argsize eqtype 20
|
if argsize eqtype 20
|
||||||
extrn '_' # `name # '@' # `argsize as name
|
extrn '_' # `name # '@' # `argsize as name
|
||||||
else
|
else
|
||||||
extrn '_' # `name as name
|
extrn '_' # `name as name
|
||||||
end if
|
end if
|
||||||
else
|
else if HOST eq linux
|
||||||
extrn name
|
extrn name
|
||||||
|
else
|
||||||
|
error "Your OS is not supported"
|
||||||
end if
|
end if
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,11 +198,13 @@ include 'macros.inc'
|
|||||||
|
|
||||||
macro diff16 msg,blah2,blah3 {
|
macro diff16 msg,blah2,blah3 {
|
||||||
if msg eq "end of .data segment"
|
if msg eq "end of .data segment"
|
||||||
if defined WIN32
|
if HOST eq windows
|
||||||
section '.bss.8k' writeable align 8192
|
section '.bss.8k' writeable align 8192
|
||||||
else
|
else if HOST eq linux
|
||||||
; fasm doesn't align on 65536, but ld script does
|
; fasm doesn't align on 65536, but ld script does
|
||||||
section '.bss.aligned65k' writeable align 65536
|
section '.bss.aligned65k' writeable align 65536
|
||||||
|
else
|
||||||
|
error "Your OS is not supported"
|
||||||
end if
|
end if
|
||||||
bss_base:
|
bss_base:
|
||||||
end if
|
end if
|
||||||
@ -683,14 +691,14 @@ endp
|
|||||||
proc sys_msg_board
|
proc sys_msg_board
|
||||||
cmp cl, 0x0d
|
cmp cl, 0x0d
|
||||||
jz @f
|
jz @f
|
||||||
if defined WIN32
|
if HOST eq windows
|
||||||
extrn putchar
|
extrn putchar
|
||||||
pushad
|
pushad
|
||||||
push ecx
|
push ecx
|
||||||
call putchar
|
call putchar
|
||||||
pop ecx
|
pop ecx
|
||||||
popad
|
popad
|
||||||
else
|
else if HOST eq linux
|
||||||
pushad
|
pushad
|
||||||
mov eax, SYS_WRITE
|
mov eax, SYS_WRITE
|
||||||
mov ebx, STDOUT
|
mov ebx, STDOUT
|
||||||
@ -700,6 +708,8 @@ else
|
|||||||
int 0x80
|
int 0x80
|
||||||
pop ecx
|
pop ecx
|
||||||
popad
|
popad
|
||||||
|
else
|
||||||
|
error "Your OS is not supported"
|
||||||
end if
|
end if
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -888,11 +898,13 @@ restore sys_msg_board,delay_ms
|
|||||||
|
|
||||||
coverage_end:
|
coverage_end:
|
||||||
|
|
||||||
if defined WIN32
|
if HOST eq windows
|
||||||
section '.data.8k' writeable align 8192
|
section '.data.8k' writeable align 8192
|
||||||
else
|
else if HOST eq linux
|
||||||
; fasm doesn't align on 65536, but ld script does
|
; fasm doesn't align on 65536, but ld script does
|
||||||
section '.data.aligned65k' writeable align 65536
|
section '.data.aligned65k' writeable align 65536
|
||||||
|
else
|
||||||
|
error "Your OS is not supported"
|
||||||
end if
|
end if
|
||||||
pubsym umka_tool
|
pubsym umka_tool
|
||||||
umka_tool dd ?
|
umka_tool dd ?
|
||||||
|
9
umka.h
9
umka.h
@ -3,15 +3,16 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#define UMKA_PATH_MAX 4096
|
||||||
// TODO: Cleanup
|
// TODO: Cleanup
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <signal.h> // for irq0: siginfo_t
|
#include <signal.h> // for irq0: siginfo_t
|
||||||
#else
|
#else
|
||||||
typedef int32_t ssize_t;
|
//typedef int32_t ssize_t;
|
||||||
typedef int64_t off_t;
|
//typedef int64_t off_t;
|
||||||
#define PATH_MAX 255
|
typedef void siginfo_t;
|
||||||
typedef void siginfo_t
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STDCALL __attribute__((__stdcall__))
|
#define STDCALL __attribute__((__stdcall__))
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include "pci.h"
|
#include "pci.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "../umka.h"
|
||||||
|
|
||||||
char pci_path[PATH_MAX] = ".";
|
char pci_path[UMKA_PATH_MAX] = ".";
|
||||||
|
|
||||||
__attribute__((stdcall)) uint32_t pci_read(uint32_t bus, uint32_t dev,
|
__attribute__((stdcall)) uint32_t pci_read(uint32_t bus, uint32_t dev,
|
||||||
uint32_t fun, uint32_t offset,
|
uint32_t fun, uint32_t offset,
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef PCI_H_INCLUDED
|
#ifndef PCI_H_INCLUDED
|
||||||
#define PCI_H_INCLUDED
|
#define PCI_H_INCLUDED
|
||||||
|
|
||||||
#define PATH_MAX 255
|
#include "../umka.h"
|
||||||
|
|
||||||
extern char pci_path[PATH_MAX];
|
extern char pci_path[UMKA_PATH_MAX];
|
||||||
|
|
||||||
#endif // PCI_H_INCLUDED
|
#endif // PCI_H_INCLUDED
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
void reset_procmask(void) {
|
void reset_procmask(void) {
|
||||||
printf("STUB: %s:%d", __FILE__, __LINE__);
|
printf("STUB: %s:%d", __FILE__, __LINE__);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user