about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorlatex <latex@disroot.org>2023-01-31 23:52:48 +0100
committerlatex <latex@disroot.org>2023-01-31 23:52:48 +0100
commitc7b869f661475903ef5e656dfbf9f30915d2ff50 (patch)
tree6a659d1db7ae0bee4b0231d6844c2e85c7fb55e4
parentb3ae0767c8f5f72bfc381b935866f384205d912b (diff)
downloaduv_link_t-c7b869f661475903ef5e656dfbf9f30915d2ff50.tar.gz
Replace stupid gypkg build system with simple Makefile
-rw-r--r--.gitignore3
-rw-r--r--Makefile44
-rw-r--r--config.mk11
3 files changed, 51 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index 7ce373b..4f23168 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,6 @@ out/
 gypkg_deps/
 node_modules/
 npm-debug.log
+*.a
+*.so
+*.dll
diff --git a/Makefile b/Makefile
index eb86aee..613771b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,40 @@
-test: dist
-	./out/Release/uv_link_t-test
+include config.mk
 
-example: dist
-	./out/Release/uv_link_t-example
+SRC = $(shell find src/ -type f -name '*.c')
+OBJ = $(SRC:%=$(BUILD_DIR)/%.o)
+H = include/uv_link_t.h
 
-dist:
-	gypkg build uv_link_t.gyp
+.PHONY: all static shared clean install-static install-shared install
 
-.PHONY: test example dist
+all: static shared
+
+static: $(SNAME)
+
+shared: $(DNAME)
+
+$(OBJ): config.mk
+
+$(SNAME): $(OBJ)
+	ar rcs $@ $?
+
+$(DNAME): LDFLAGS += -shared
+$(DNAME): $(OBJ)
+	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
+
+$(BUILD_DIR)/%.c.o: %.c
+	mkdir -p '$(@D)'
+	$(CC) -c -o $@ $(INCLUDES) $(CFLAGS) $<
+
+clean:
+	rm -rf $(SNAME) $(DNAME) $(BUILD_DIR)
+
+install-header:
+	install -m 644 $(H) $(PREFIX)/include
+
+install-static: $(SNAME)
+	install -m 755 $(SNAME) $(PREFIX)/lib64
+
+install-shared: $(DNAME)
+	install -m 755 $(DNAME) $(PREFIX)/lib64
+
+install: install-header install-static install-shared
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..8de5d81
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,11 @@
+PREFIX = /usr/local
+BUILD_DIR = build
+NAME = libuv_link_t
+SNAME = $(NAME).a
+DNAME = $(NAME).so
+
+CFLAGS = -W -Wall -Wvla -std=gnu99 -g -fPIC
+CFLAGS += $(shell pkg-config --cflags libuv)
+LDLIBS = $(shell pkg-config --libs libuv)
+
+INCLUDES = -I.