Initial Commit, project structure and build system.
This commit is contained in:
6
.clang-format
Normal file
6
.clang-format
Normal file
@@ -0,0 +1,6 @@
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
ColumnLimit: 90
|
||||
Cpp11BracedListStyle: true
|
||||
AlignArrayOfStructures: Left
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
19
LICENSE
Normal file
19
LICENSE
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2025 omicron <omicron.me@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
17
Makefile
Normal file
17
Makefile
Normal file
@@ -0,0 +1,17 @@
|
||||
.PHONY: all loader runtime test clean
|
||||
|
||||
include make/include/defaults.mk
|
||||
|
||||
all: loader runtime
|
||||
|
||||
loader:
|
||||
$(MAKE) -rRf make/loader.mk
|
||||
|
||||
runtime:
|
||||
$(MAKE) -rRf make/runtime.mk
|
||||
|
||||
test:
|
||||
$(MAKE) -rRf make/test.mk test
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)
|
||||
21
make/include/defaults.mk
Normal file
21
make/include/defaults.mk
Normal file
@@ -0,0 +1,21 @@
|
||||
CC ?= i686-w64-mingw32-gcc
|
||||
CFLAGS = -Wall -Wextra -pedantic -Werror -std=c23
|
||||
|
||||
SRC_DIR = src
|
||||
SRC_DIR_COMMON = $(SRC_DIR)/common
|
||||
SRC_DIR_RUNTIME = $(SRC_DIR)/runtime
|
||||
SRC_DIR_LOADER = $(SRC_DIR)/loader
|
||||
|
||||
SOURCES_COMMON := $(shell find $(SRC_DIR_COMMON) -name '*.c')
|
||||
SOURCES_RUNTIME := $(shell find $(SRC_DIR_RUNTIME) -name '*.c')
|
||||
SOURCES_LOADER := $(shell find $(SRC_DIR_LOADER) -name '*.c')
|
||||
|
||||
BUILD_DIR ?= build
|
||||
|
||||
OBJECTS_COMMON = $(SOURCES_COMMON:%.c=$(BUILD_DIR)/%.o)
|
||||
OBJECTS_RUNTIME = $(SOURCES_RUNTIME:%.c=$(BUILD_DIR)/%.o)
|
||||
OBJECTS_LOADER = $(SOURCES_LOADER:%.c=$(BUILD_DIR)/%.o)
|
||||
|
||||
DEPS_COMMON = $(SOURCES_COMMON:%.c=$(BUILD_DIR)/%.d)
|
||||
DEPS_RUNTIME = $(SOURCES_RUNTIME:%.c=$(BUILD_DIR)/%.d)
|
||||
DEPS_LOADER = $(SOURCES_LOADER:%.c=$(BUILD_DIR)/%.d)
|
||||
9
make/include/shared.mk
Normal file
9
make/include/shared.mk
Normal file
@@ -0,0 +1,9 @@
|
||||
$(TARGET): $(OBJECTS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: %.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
|
||||
|
||||
-include $(DEPS)
|
||||
19
make/loader.mk
Normal file
19
make/loader.mk
Normal file
@@ -0,0 +1,19 @@
|
||||
.PHONY: all
|
||||
|
||||
include make/include/defaults.mk
|
||||
|
||||
CFLAGS += -I$(BUILD_DIR)/stub
|
||||
LDFLAGS +=
|
||||
TARGET = $(BUILD_DIR)/loader.exe
|
||||
OBJECTS = $(OBJECTS_COMMON) $(OBJECTS_LOADER)
|
||||
DEPS = $(DEPS_COMMON) $(DEPS_LOADER)
|
||||
STUB = $(BUILD_DIR)/stub/stub.bin
|
||||
|
||||
all: $(STUB) $(TARGET)
|
||||
|
||||
$(STUB): $(SRC_DIR)/stub/stub.asm
|
||||
@mkdir -p $(dir $@)
|
||||
nasm -f bin $< -o $@
|
||||
|
||||
include make/include/shared.mk
|
||||
$(OBJECTS_LOADER): $(STUB)
|
||||
9
make/runtime.mk
Normal file
9
make/runtime.mk
Normal file
@@ -0,0 +1,9 @@
|
||||
include make/include/defaults.mk
|
||||
|
||||
CFLAGS +=
|
||||
LDFLAGS += -shared
|
||||
TARGET = $(BUILD_DIR)/runtime.dll
|
||||
OBJECTS = $(OBJECTS_COMMON) $(OBJECTS_RUNTIME)
|
||||
DEPS = $(DEPS_COMMON) $(DEPS_RUNTIME)
|
||||
|
||||
include make/include/shared.mk
|
||||
20
make/test.mk
Normal file
20
make/test.mk
Normal file
@@ -0,0 +1,20 @@
|
||||
.PHONY: all test
|
||||
|
||||
include make/include/defaults.mk
|
||||
|
||||
SOURCES_TEST := $(shell find tests/ -name '*.c')
|
||||
OBJECTS_TEST = $(SOURCES_TEST:%.c=$(BUILD_DIR)/%.o)
|
||||
DEPS_TEST = $(SOURCES_TEST:%.c=$(BUILD_DIR)/%.d)
|
||||
|
||||
CFLAGS += -Isrc -D__STDC_NO_ATOMICS__ -DMUNIT_TEST_NAME_LEN=45
|
||||
LDFLAGS +=
|
||||
TARGET = $(BUILD_DIR)/binprobe-tests.exe
|
||||
OBJECTS = $(OBJECTS_COMMON) $(OBJECTS_TEST)
|
||||
DEPS = $(DEPS_COMMON) $(DEPS_TEST)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
test: $(TARGET)
|
||||
WINEDEBUG=-all wine $(TARGET)
|
||||
|
||||
include make/include/shared.mk
|
||||
Reference in New Issue
Block a user