aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorfrosty <frosty@illegalfirearms.store>2025-12-28 03:26:05 -0500
committerfrosty <frosty@illegalfirearms.store>2025-12-28 03:26:05 -0500
commit4af132cf6adeeeeb5d6764c378bec2d05cad042f (patch)
treee422cff2831424775ba5c20196064f94cbe1e5c3 /Makefile
Migrated from GitHub
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile56
1 files changed, 56 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..66e5016
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,56 @@
+CC = gcc
+AR = ar
+CFLAGS = -Wall -fPIC -I. -Isrc
+LDFLAGS = -shared
+BUILD_DIR ?= build
+OBJ_DIR = $(BUILD_DIR)/obj
+INSTALL_PREFIX ?= /usr/
+
+SRCS = $(wildcard src/*.c)
+OBJS = $(patsubst src/%.c,$(OBJ_DIR)/%.o,$(SRCS))
+
+LIB = $(BUILD_DIR)/libbeaker
+HEADER = beaker.h
+
+.PHONY: all clean install uninstall
+
+all: $(LIB).so $(LIB).a
+
+
+$(OBJ_DIR):
+ @mkdir -p $(OBJ_DIR)
+
+$(LIB).a: $(OBJS)
+ @echo "Linking shared library $@..."
+ $(AR) rcs $@ $^
+ @echo "Successfully built $@"
+
+$(LIB).so: $(OBJS)
+ @echo "Linking shared library $@..."
+ $(CC) $(LDFLAGS) $(OBJS) -o $@ -lm
+ @echo "Successfully built $@"
+
+$(OBJ_DIR)/%.o: src/%.c | $(OBJ_DIR)
+ @echo "Compiling $<..."
+ $(CC) $(CFLAGS) -c $< -o $@
+
+clean:
+ @echo "Cleaning up object files and shared library..."
+ @rm -rf $(OBJ_DIR) $(LIB)
+ @echo "Clean complete."
+
+install: all
+ @echo "Installing $(LIB) to $(INSTALL_PREFIX)/lib"
+ @cp $(LIB).so $(INSTALL_PREFIX)/lib/
+ @ldconfig
+ @echo "Installing $(HEADER) to $(INSTALL_PREFIX)/include"
+ @cp $(HEADER) $(INSTALL_PREFIX)/include
+ @echo "Installation complete."
+
+uninstall:
+ @echo "Uninstalling $(LIB) from $(INSTALL_PREFIX)/lib..."
+ @rm -f $(INSTALL_PREFIX)/lib/$(LIB)
+ @ldconfig
+ @echo "Removing $(HEADER) from $(INSTALL_PREFIX)/include"
+ @rm -f $(INSTALL_PREFIX)/include/$(HEADER)
+ @echo "Uninstallation complete."