Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cc9e897c1 | ||
|
|
ee5e46b050 | ||
|
|
9462006028 | ||
|
|
270808e602 | ||
|
|
053f8a14c8 | ||
|
|
6429e29084 | ||
|
|
5509c18b17 | ||
|
|
cc39200917 | ||
|
|
95d7191fdd | ||
|
|
eb4b4c1f80 |
No files matched your search
+29
-1
@@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `build.sh`: install/uninstall no longer requires `doas`/`sudo` under MSYS2, where neither exists and `id -u` never reports root
|
||||||
|
- `build.bat`: now builds `release` before `install`, no separate manual build step needed
|
||||||
|
|
||||||
|
## [1.0.1] - 2026-11-09
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `build.sh`/`module_template/build.sh`: detect MSYS2 (`MINGW64_NT`/`MINGW32_NT`/`MSYS_NT`/`UCRT64_NT`/`CLANG64_NT` etc.) and route to `gmake.mk` instead of `bmake.mk`; `uname -s` result exported once and reused by make instead of being re-run
|
||||||
|
- `gmake.mk`/`test/gmake.mk`/`module_template/gmake.mk`: stopped relying on the `OS` env var (unset under MSYS2), now detect Windows via `uname -s` with the native-Windows `cmd.exe`/batch-command path reserved for environments without a POSIX shell; fixes MSYS2 builds failing to link with `cannot find -ldl`
|
||||||
|
|
||||||
|
## [1.0.0] - 2026-09-29
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `module_template/`: copyable starting point for a native stk module, builds cross-platform out of the box
|
||||||
|
|
||||||
|
## [1.0.0-pre.12] - 2026-03-29
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `gmake.mk`: changed static library extension on Windows from `.lib` to `.a` for MinGW compatibility
|
||||||
|
- `module_loader`: use `RTLD_GLOBAL` when loading modules to correctly expose host symbols to dynamic libraries
|
||||||
|
|
||||||
|
## [1.0.0-pre.11] - 2026-03-15
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `gmake.mk`: `PREFIX` now defaults to `/usr` on Linux instead of `/usr/local`
|
||||||
|
|
||||||
## [1.0.0-pre.10] - 2026-03-14
|
## [1.0.0-pre.10] - 2026-03-14
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -207,7 +233,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Dependency management and versioning not yet implemented
|
- Dependency management and versioning not yet implemented
|
||||||
- API is unstable and subject to change in future releases
|
- API is unstable and subject to change in future releases
|
||||||
|
|
||||||
[Unreleased]: https://github.com/anth64/stk/compare/v1.0.0-pre.10...HEAD
|
[Unreleased]: https://github.com/anth64/stk/compare/v1.0.0-pre.12...HEAD
|
||||||
|
[1.0.0-pre.12]: https://github.com/anth64/stk/compare/v1.0.0-pre.11...v1.0.0-pre.12
|
||||||
|
[1.0.0-pre.11]: https://github.com/anth64/stk/compare/v1.0.0-pre.10...v1.0.0-pre.11
|
||||||
[1.0.0-pre.10]: https://github.com/anth64/stk/compare/v1.0.0-pre.9...v1.0.0-pre.10
|
[1.0.0-pre.10]: https://github.com/anth64/stk/compare/v1.0.0-pre.9...v1.0.0-pre.10
|
||||||
[1.0.0-pre.9]: https://github.com/anth64/stk/compare/v1.0.0-pre.8...v1.0.0-pre.9
|
[1.0.0-pre.9]: https://github.com/anth64/stk/compare/v1.0.0-pre.8...v1.0.0-pre.9
|
||||||
[1.0.0-pre.8]: https://github.com/anth64/stk/compare/v1.0.0-pre.7...v1.0.0-pre.8
|
[1.0.0-pre.8]: https://github.com/anth64/stk/compare/v1.0.0-pre.7...v1.0.0-pre.8
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ build.bat debug release
|
|||||||
./build.sh install
|
./build.sh install
|
||||||
```
|
```
|
||||||
|
|
||||||
Installs to `/usr/local` by default. Use `PREFIX` to customize:
|
Installs to `/usr` on Linux, `/usr/local` on BSD/macOS by default. Use `PREFIX` to customize:
|
||||||
```bash
|
```bash
|
||||||
./build.sh PREFIX=$HOME/.local install
|
./build.sh PREFIX=$HOME/.local install
|
||||||
```
|
```
|
||||||
@@ -131,6 +131,8 @@ cc -shared -o my_module.dll my_module.c
|
|||||||
|
|
||||||
Place the compiled module in the `mods/` directory (default), and `stk` will automatically load it and watch for changes.
|
Place the compiled module in the `mods/` directory (default), and `stk` will automatically load it and watch for changes.
|
||||||
|
|
||||||
|
Copy `module_template/` as a starting point, it builds cross-platform out of the box.
|
||||||
|
|
||||||
### Module Metadata
|
### Module Metadata
|
||||||
|
|
||||||
Modules can optionally export metadata functions:
|
Modules can optionally export metadata functions:
|
||||||
@@ -234,7 +236,7 @@ stk_init();
|
|||||||
|
|
||||||
## Project Status
|
## Project Status
|
||||||
|
|
||||||
**Current Version:** 1.0.0-pre.10
|
**Current Version:** 1.0.1
|
||||||
|
|
||||||
### What Works
|
### What Works
|
||||||
- Cross-platform module loading and hot-reloading
|
- Cross-platform module loading and hot-reloading
|
||||||
|
|||||||
@@ -1,2 +1,14 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
set HAS_INSTALL=0
|
||||||
|
for %%a in (%*) do (
|
||||||
|
if "%%a"=="install" set HAS_INSTALL=1
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%HAS_INSTALL%"=="1" (
|
||||||
|
make -f gmake.mk release
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
make -f gmake.mk %*
|
make -f gmake.mk %*
|
||||||
@@ -1,12 +1,19 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
UNAME_S=$(uname -s)
|
||||||
|
export UNAME_S
|
||||||
|
|
||||||
if [ "$OS" = "linux" ]; then
|
OS=$(echo "$UNAME_S" | tr '[:upper:]' '[:lower:]')
|
||||||
MK_FILE="gmake.mk"
|
|
||||||
else
|
case "$OS" in
|
||||||
MK_FILE="bmake.mk"
|
linux|mingw*|msys*|ucrt*|clang*) MK_FILE="gmake.mk" ;;
|
||||||
fi
|
*) MK_FILE="bmake.mk" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$OS" in
|
||||||
|
mingw*|msys*|ucrt*|clang*) IS_WIN=1 ;;
|
||||||
|
*) IS_WIN=0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
HAS_INSTALL=0
|
HAS_INSTALL=0
|
||||||
HAS_UNINSTALL=0
|
HAS_UNINSTALL=0
|
||||||
@@ -22,7 +29,7 @@ if [ "$HAS_INSTALL" = "1" ] || [ "$HAS_UNINSTALL" = "1" ]; then
|
|||||||
make -f "$MK_FILE" release
|
make -f "$MK_FILE" release
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(id -u)" = "0" ]; then
|
if [ "$IS_WIN" = "1" ] || [ "$(id -u)" = "0" ]; then
|
||||||
PRIV=""
|
PRIV=""
|
||||||
elif command -v doas > /dev/null 2>&1; then
|
elif command -v doas > /dev/null 2>&1; then
|
||||||
PRIV="doas"
|
PRIV="doas"
|
||||||
|
|||||||
@@ -1,28 +1,46 @@
|
|||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(UNAME_S),)
|
||||||
SHELL := cmd.exe
|
UNAME_S := $(shell uname -s)
|
||||||
|
endif
|
||||||
|
ifneq (,$(filter MINGW% MSYS% UCRT% CLANG% CYGWIN%,$(UNAME_S)))
|
||||||
|
IS_WINDOWS := 1
|
||||||
|
IS_POSIX_SHELL := 1
|
||||||
|
else ifeq ($(OS),Windows_NT)
|
||||||
|
IS_WINDOWS := 1
|
||||||
|
IS_POSIX_SHELL :=
|
||||||
|
else
|
||||||
|
IS_WINDOWS :=
|
||||||
|
IS_POSIX_SHELL := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(IS_WINDOWS),1)
|
||||||
FULL_LIB := $(LIB_NAME).dll
|
FULL_LIB := $(LIB_NAME).dll
|
||||||
STATIC_LIB := $(LIB_NAME).lib
|
STATIC_LIB := lib$(LIB_NAME).a
|
||||||
LDFLAGS_PLAT :=
|
LDFLAGS_PLAT :=
|
||||||
CFLAGS_PLAT :=
|
CFLAGS_PLAT :=
|
||||||
CFLAGS_STATIC :=
|
CFLAGS_STATIC :=
|
||||||
MKDIR = if not exist $(subst /,\,$(1)) mkdir $(subst /,\,$(1))
|
|
||||||
RMDIR = if exist $(subst /,\,$(1)) rd /s /q $(subst /,\,$(1))
|
|
||||||
else
|
else
|
||||||
FULL_LIB := lib$(LIB_NAME).so
|
FULL_LIB := lib$(LIB_NAME).so
|
||||||
STATIC_LIB := lib$(LIB_NAME).a
|
STATIC_LIB := lib$(LIB_NAME).a
|
||||||
LDFLAGS_PLAT := -ldl
|
LDFLAGS_PLAT := -ldl
|
||||||
CFLAGS_PLAT := -fPIC
|
CFLAGS_PLAT := -fPIC
|
||||||
CFLAGS_STATIC :=
|
CFLAGS_STATIC :=
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(IS_POSIX_SHELL),1)
|
||||||
MKDIR = mkdir -p $(1)
|
MKDIR = mkdir -p $(1)
|
||||||
RMDIR = rm -rf $(1)
|
RMDIR = rm -rf $(1)
|
||||||
|
else
|
||||||
|
SHELL := cmd.exe
|
||||||
|
MKDIR = if not exist $(subst /,\,$(1)) mkdir $(subst /,\,$(1))
|
||||||
|
RMDIR = if exist $(subst /,\,$(1)) rd /s /q $(subst /,\,$(1))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
RELEASE_LDFLAGS := -s
|
RELEASE_LDFLAGS := -s
|
||||||
CFLAGS_BASE := -Wall -Wpedantic -I$(INC_DIR) -std=c89 $(CFLAGS_PLAT)
|
CFLAGS_BASE := -Wall -Wpedantic -I$(INC_DIR) -std=c89 $(CFLAGS_PLAT)
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr
|
||||||
LIBDIR ?= $(PREFIX)/lib
|
LIBDIR ?= $(PREFIX)/lib
|
||||||
INCDIR ?= $(PREFIX)/include
|
INCDIR ?= $(PREFIX)/include
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Build directories
|
||||||
|
obj/
|
||||||
|
bin/
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# my_module
|
||||||
|
|
||||||
|
TODO: one-line description.
|
||||||
|
|
||||||
|
An stk module.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./build.sh debug release # Linux/BSD/macOS
|
||||||
|
build.bat debug release # Windows
|
||||||
|
```
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Copy `bin/release/my_module.so`/`.dylib`/`.dll` into the game's `mods/` directory.
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
TODO: list any, or delete this section.
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
.include "config.mk"
|
||||||
|
|
||||||
|
UNAME_S != uname -s
|
||||||
|
|
||||||
|
.if ${UNAME_S} == "Darwin"
|
||||||
|
MODULE_EXT = .dylib
|
||||||
|
.else
|
||||||
|
MODULE_EXT = .so
|
||||||
|
.endif
|
||||||
|
|
||||||
|
CC ?= cc
|
||||||
|
CFLAGS_BASE = -Wall -Wpedantic -I${.CURDIR}/${INC_DIR} -fPIC
|
||||||
|
|
||||||
|
.PHONY: all debug release clean
|
||||||
|
|
||||||
|
all: debug
|
||||||
|
|
||||||
|
OBJS_DEBUG = ${SRCS:S|^src/|${.CURDIR}/obj/debug/|:S/.c$/.o/}
|
||||||
|
OBJS_RELEASE = ${SRCS:S|^src/|${.CURDIR}/obj/release/|:S/.c$/.o/}
|
||||||
|
|
||||||
|
debug: ${.CURDIR}/${BIN_DIR}/debug/${MODULE_NAME}${MODULE_EXT}
|
||||||
|
release: ${.CURDIR}/${BIN_DIR}/release/${MODULE_NAME}${MODULE_EXT}
|
||||||
|
|
||||||
|
${.CURDIR}/${BIN_DIR}/debug/${MODULE_NAME}${MODULE_EXT}: ${OBJS_DEBUG}
|
||||||
|
@mkdir -p ${.TARGET:H}
|
||||||
|
${CC} -shared -o ${.TARGET} ${.ALLSRC}
|
||||||
|
|
||||||
|
${.CURDIR}/${BIN_DIR}/release/${MODULE_NAME}${MODULE_EXT}: ${OBJS_RELEASE}
|
||||||
|
@mkdir -p ${.TARGET:H}
|
||||||
|
${CC} -shared -s -o ${.TARGET} ${.ALLSRC}
|
||||||
|
|
||||||
|
.for _src in ${SRCS}
|
||||||
|
${.CURDIR}/obj/debug/${_src:S|^src/||:S/.c$/.o/}: ${.CURDIR}/${_src}
|
||||||
|
@mkdir -p ${.TARGET:H}
|
||||||
|
${CC} ${CFLAGS_BASE} -g -O0 -MMD -MP -MT ${.TARGET} -MF ${.TARGET:S/.o$/.d/} -c ${.ALLSRC} -o ${.TARGET}
|
||||||
|
|
||||||
|
${.CURDIR}/obj/release/${_src:S|^src/||:S/.c$/.o/}: ${.CURDIR}/${_src}
|
||||||
|
@mkdir -p ${.TARGET:H}
|
||||||
|
${CC} ${CFLAGS_BASE} -O2 -MMD -MP -MT ${.TARGET} -MF ${.TARGET:S/.o$/.d/} -c ${.ALLSRC} -o ${.TARGET}
|
||||||
|
.endfor
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf ${.CURDIR}/${OBJ_DIR} ${.CURDIR}/${BIN_DIR}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
@echo off
|
||||||
|
make -f gmake.mk %*
|
||||||
Executable
+13
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
UNAME_S=$(uname -s)
|
||||||
|
export UNAME_S
|
||||||
|
|
||||||
|
OS=$(echo "$UNAME_S" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
case "$OS" in
|
||||||
|
linux|mingw*|msys*|ucrt*|clang*) MK_FILE="gmake.mk" ;;
|
||||||
|
*) MK_FILE="bmake.mk" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
make -f "$MK_FILE" "$@"
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-xc
|
||||||
|
-Wall
|
||||||
|
-Wpedantic
|
||||||
|
-Iinclude
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
SRC_DIR = src
|
||||||
|
INC_DIR = include
|
||||||
|
OBJ_DIR = obj
|
||||||
|
BIN_DIR = bin
|
||||||
|
|
||||||
|
MODULE_NAME = my_module
|
||||||
|
|
||||||
|
SRCS = src/module.c
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
include config.mk
|
||||||
|
|
||||||
|
ifeq ($(UNAME_S),)
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
endif
|
||||||
|
ifneq (,$(filter MINGW% MSYS% UCRT% CLANG% CYGWIN%,$(UNAME_S)))
|
||||||
|
IS_WINDOWS := 1
|
||||||
|
IS_POSIX_SHELL := 1
|
||||||
|
else ifeq ($(OS),Windows_NT)
|
||||||
|
IS_WINDOWS := 1
|
||||||
|
IS_POSIX_SHELL :=
|
||||||
|
else
|
||||||
|
IS_WINDOWS :=
|
||||||
|
IS_POSIX_SHELL := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(IS_WINDOWS),1)
|
||||||
|
MODULE_EXT = .dll
|
||||||
|
else
|
||||||
|
MODULE_EXT = .so
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(IS_POSIX_SHELL),1)
|
||||||
|
MKDIR = mkdir -p $(1)
|
||||||
|
RMDIR = rm -rf $(1)
|
||||||
|
else
|
||||||
|
SHELL := cmd.exe
|
||||||
|
MKDIR = if not exist $(subst /,\,$(1)) mkdir $(subst /,\,$(1))
|
||||||
|
RMDIR = if exist $(subst /,\,$(1)) rd /s /q $(subst /,\,$(1))
|
||||||
|
endif
|
||||||
|
|
||||||
|
CC = cc
|
||||||
|
CFLAGS_BASE = -Wall -Wpedantic -I$(INC_DIR) -fPIC
|
||||||
|
|
||||||
|
.PHONY: all debug release clean
|
||||||
|
|
||||||
|
all: debug
|
||||||
|
|
||||||
|
debug: $(BIN_DIR)/debug/$(MODULE_NAME)$(MODULE_EXT)
|
||||||
|
release: $(BIN_DIR)/release/$(MODULE_NAME)$(MODULE_EXT)
|
||||||
|
|
||||||
|
$(BIN_DIR)/debug/$(MODULE_NAME)$(MODULE_EXT): $(SRCS:src/%.c=obj/debug/%.o)
|
||||||
|
@$(call MKDIR,$(@D))
|
||||||
|
$(CC) -shared -o $@ $^
|
||||||
|
|
||||||
|
obj/debug/%.o: src/%.c
|
||||||
|
@$(call MKDIR,$(@D))
|
||||||
|
$(CC) $(CFLAGS_BASE) -g -O0 -MMD -MP -c $< -o $@
|
||||||
|
|
||||||
|
$(BIN_DIR)/release/$(MODULE_NAME)$(MODULE_EXT): $(SRCS:src/%.c=obj/release/%.o)
|
||||||
|
@$(call MKDIR,$(@D))
|
||||||
|
$(CC) -shared -s -o $@ $^
|
||||||
|
|
||||||
|
obj/release/%.o: src/%.c
|
||||||
|
@$(call MKDIR,$(@D))
|
||||||
|
$(CC) $(CFLAGS_BASE) -O2 -MMD -MP -c $< -o $@
|
||||||
|
|
||||||
|
-include $(wildcard obj/debug/*.d)
|
||||||
|
-include $(wildcard obj/release/*.d)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@$(call RMDIR,$(OBJ_DIR))
|
||||||
|
@$(call RMDIR,$(BIN_DIR))
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef MODULE_VERSION_H
|
||||||
|
#define MODULE_VERSION_H
|
||||||
|
|
||||||
|
#define MY_MODULE_VERSION_MAJOR 0
|
||||||
|
#define MY_MODULE_VERSION_MINOR 1
|
||||||
|
#define MY_MODULE_VERSION_PATCH 0
|
||||||
|
|
||||||
|
#define MY_MODULE_STRINGIFY_HELPER(x) #x
|
||||||
|
#define MY_MODULE_STRINGIFY(x) MY_MODULE_STRINGIFY_HELPER(x)
|
||||||
|
|
||||||
|
#define MY_MODULE_VERSION_STRING \
|
||||||
|
MY_MODULE_STRINGIFY(MY_MODULE_VERSION_MAJOR) \
|
||||||
|
"." MY_MODULE_STRINGIFY(MY_MODULE_VERSION_MINOR) "." MY_MODULE_STRINGIFY( \
|
||||||
|
MY_MODULE_VERSION_PATCH)
|
||||||
|
|
||||||
|
#endif /* MODULE_VERSION_H */
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#include "module_version.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* on load */
|
||||||
|
int stk_mod_init(void)
|
||||||
|
{
|
||||||
|
printf("my_module initialized!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* on unload/reload */
|
||||||
|
void stk_mod_shutdown(void) { printf("my_module shut down.\n"); }
|
||||||
|
|
||||||
|
const char *stk_mod_name(void) { return "my_module"; }
|
||||||
|
const char *stk_mod_version(void) { return MY_MODULE_VERSION_STRING; }
|
||||||
|
const char *stk_mod_description(void) { return "TODO: describe this module"; }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* declares which other modules must be loaded first.
|
||||||
|
* id = dependency's filename, minus extension.
|
||||||
|
* layout must match stk_dep_t: id[64], version[32].
|
||||||
|
* sentinel ("","") required, always last.
|
||||||
|
*
|
||||||
|
* =1.0.0 exact
|
||||||
|
* >=1.0.0 minimum (default)
|
||||||
|
* ^1.0.0 same major
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
typedef struct {
|
||||||
|
char id[64];
|
||||||
|
char version[32];
|
||||||
|
} dep_t;
|
||||||
|
|
||||||
|
dep_t stk_mod_deps[] = {
|
||||||
|
{ "physics", ">=2.0.0" },
|
||||||
|
{ "", "" }
|
||||||
|
};
|
||||||
|
*/
|
||||||
+1
-1
@@ -278,7 +278,7 @@ void *platform_load_library(const char *path)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return (void *)LoadLibraryA(path);
|
return (void *)LoadLibraryA(path);
|
||||||
#else
|
#else
|
||||||
return dlopen(path, RTLD_NOW);
|
return dlopen(path, RTLD_NOW | RTLD_GLOBAL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+32
-15
@@ -2,9 +2,21 @@ CC := cc
|
|||||||
CFLAGS = -Wall -Wpedantic -I../include -std=c89
|
CFLAGS = -Wall -Wpedantic -I../include -std=c89
|
||||||
LDFLAGS = -L../bin/debug -lstk
|
LDFLAGS = -L../bin/debug -lstk
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(UNAME_S),)
|
||||||
SHELL := cmd.exe
|
UNAME_S := $(shell uname -s)
|
||||||
.SHELLFLAGS := /c
|
endif
|
||||||
|
ifneq (,$(filter MINGW% MSYS% UCRT% CLANG% CYGWIN%,$(UNAME_S)))
|
||||||
|
IS_WINDOWS := 1
|
||||||
|
IS_POSIX_SHELL := 1
|
||||||
|
else ifeq ($(OS),Windows_NT)
|
||||||
|
IS_WINDOWS := 1
|
||||||
|
IS_POSIX_SHELL :=
|
||||||
|
else
|
||||||
|
IS_WINDOWS :=
|
||||||
|
IS_POSIX_SHELL := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(IS_WINDOWS),1)
|
||||||
MODULE_EXT = .dll
|
MODULE_EXT = .dll
|
||||||
EXE_EXT = .exe
|
EXE_EXT = .exe
|
||||||
else
|
else
|
||||||
@@ -13,6 +25,11 @@ else
|
|||||||
LDFLAGS += -Wl,-rpath,../bin/debug
|
LDFLAGS += -Wl,-rpath,../bin/debug
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(IS_POSIX_SHELL),1)
|
||||||
|
SHELL := cmd.exe
|
||||||
|
.SHELLFLAGS := /c
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: all test clean
|
.PHONY: all test clean
|
||||||
|
|
||||||
all: test
|
all: test
|
||||||
@@ -27,28 +44,28 @@ test_mod_dep$(MODULE_EXT): test_mod_dep.c
|
|||||||
$(CC) $(CFLAGS) -fPIC -shared -o $@ test_mod_dep.c
|
$(CC) $(CFLAGS) -fPIC -shared -o $@ test_mod_dep.c
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(IS_POSIX_SHELL),1)
|
||||||
|
@mkdir -p mods
|
||||||
|
@cp -f test_mod$(MODULE_EXT) mods/ 2>/dev/null || true
|
||||||
|
@cp -f test_mod_dep$(MODULE_EXT) mods/ 2>/dev/null || true
|
||||||
|
else
|
||||||
@if not exist mods mkdir mods
|
@if not exist mods mkdir mods
|
||||||
@if exist test_mod.dll copy /Y test_mod.dll mods\ >nul 2>&1
|
@if exist test_mod.dll copy /Y test_mod.dll mods\ >nul 2>&1
|
||||||
@if exist test_mod_dep.dll copy /Y test_mod_dep.dll mods\ >nul 2>&1
|
@if exist test_mod_dep.dll copy /Y test_mod_dep.dll mods\ >nul 2>&1
|
||||||
else
|
|
||||||
@mkdir -p mods
|
|
||||||
@cp -f test_mod.so mods/ 2>/dev/null || true
|
|
||||||
@cp -f test_mod_dep.so mods/ 2>/dev/null || true
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
test: test_program$(EXE_EXT) test_mod$(MODULE_EXT) test_mod_dep$(MODULE_EXT) setup
|
test: test_program$(EXE_EXT) test_mod$(MODULE_EXT) test_mod_dep$(MODULE_EXT) setup
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(IS_POSIX_SHELL),1)
|
||||||
@set PATH=../bin/debug;%PATH% && cmd /C "test_program.exe"
|
@./test_program$(EXE_EXT)
|
||||||
else
|
else
|
||||||
@./test_program
|
@set PATH=../bin/debug;%PATH% && cmd /C "test_program.exe"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(IS_POSIX_SHELL),1)
|
||||||
|
@rm -f test_program$(EXE_EXT) test_mod$(MODULE_EXT) test_mod_dep$(MODULE_EXT)
|
||||||
|
@rm -rf mods
|
||||||
|
else
|
||||||
@del /Q test_program.exe test_mod.dll test_mod_dep.dll 2>nul || true
|
@del /Q test_program.exe test_mod.dll test_mod_dep.dll 2>nul || true
|
||||||
@rmdir /S /Q mods 2>nul || true
|
@rmdir /S /Q mods 2>nul || true
|
||||||
else
|
|
||||||
@rm -f test_program test_mod.so test_mod_dep.so
|
|
||||||
@rm -rf mods
|
|
||||||
endif
|
endif
|
||||||
Reference in new issue
Block a user