summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-04-23 02:08:30 -0400
committerLLLL Colonq <llll@colonq>2026-04-23 02:08:30 -0400
commit2850670124e5d5398aca6290558317a24291b219 (patch)
tree16523ff7f234813a20ae434080e9f3d3f451fdc7
parent2e0091cef23bd8eef5bc0c32b60bbeff7a832de2 (diff)
Add WASM build to flake.nix
-rw-r--r--Makefile23
-rw-r--r--flake.nix14
2 files changed, 32 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index d92724a..e9da313 100644
--- a/Makefile
+++ b/Makefile
@@ -21,9 +21,9 @@ bindir ?= $(exec_prefix)/bin
includedir ?= $(prefix)/include
libdir ?= $(exec_prefix)/lib
-.PHONY: all clean install check-syntax
+.PHONY: all clean install install-bin install-headers install-core install-native check-syntax
-all: $(EXE) $(LIB) $(LIB_NATIVE)
+all: $(EXE) $(LIB_CORE) $(LIB_NATIVE)
$(EXE): $(BUILD)/main.o $(LIB_NATIVE) $(LIB_CORE)
$(CC) -o $@ $^ $(LDFLAGS)
@@ -42,18 +42,31 @@ $(BUILD)/%.o: src/%.c | $(BUILD)
clean:
-rm $(EXE)
- -rm $(LIB)
+ -rm $(LIB_CORE)
+ -rm $(LIB_NATIVE)
-rm -r $(BUILD)/
TAGS: $(SRCS)
ctags --output-format=etags $^
-install: $(EXE) $(LIB)
+install: install-bin install-headers install-core install-native
+
+install-bin: $(EXE)
mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
install $(EXE) $(DESTDIR)$(bindir)/$(EXE)
- install $(LIB) $(DESTDIR)$(libdir)/$(LIB)
+
+install-headers:
+ mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
cp -r include/* $(DESTDIR)$(includedir)
+install-core: $(LIB_CORE)
+ mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
+ install $(LIB_CORE) $(DESTDIR)$(libdir)/$(LIB_CORE)
+
+install-native: $(LIB_NATIVE)
+ mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
+ install $(LIB_NATIVE) $(DESTDIR)$(libdir)/$(LIB_NATIVE)
+
check-syntax: TAGS
gcc $(CFLAGS) -fsyntax-only $(CHK_SOURCES)
diff --git a/flake.nix b/flake.nix
index f944dc4..8312ec9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -21,10 +21,24 @@
wasm32-clang = pkgs.writeShellScriptBin "wasm32-clang" ''
${pkgs.llvmPackages.clang-unwrapped}/bin/clang -I${pkgs.llvmPackages.clang}/resource-root/include --target=wasm32-unknown-unknown "$@"
'';
+ pit-wasm = pkgs.stdenv.mkDerivation {
+ pname = "pit";
+ version = "git";
+ src = ./.;
+ hardeningDisable = ["all"];
+ buildInputs = [ wasm32-clang ];
+ buildPhase = ''
+ make CC=wasm32-clang libcolonq-pit.a
+ '';
+ installPhase = ''
+ make CC=wasm32-clang prefix=$out install-core
+ '';
+ };
in {
packages = {
inherit pit;
default = pit;
+ wasm = pit-wasm;
};
devShells.default = pkgs.mkShell {
hardeningDisable = ["all"];