aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2022-05-14 14:31:34 -0400
committerBruce Hill <bruce@bruce-hill.com>2022-05-14 14:31:34 -0400
commitd62fd1eb968cebe75acdbcc43ccd33b24d6f163d (patch)
treea1448a132a9ed7a77e9e2ad1ba7f14f46a7c611b
parent56da250d69615d70774dbc361fa2693cca1e3df4 (diff)
Lib install stuff
-rw-r--r--Makefile14
-rw-r--r--match.h1
-rw-r--r--pattern.h1
3 files changed, 14 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 2afb00d..8c8e472 100644
--- a/Makefile
+++ b/Makefile
@@ -22,13 +22,18 @@ G=
O=-O3
ALL_FLAGS=$(CFLAGS) $(OSFLAGS) -DBP_NAME="\"$(NAME)\"" $(EXTRA) $(CWARN) $(G) $(O)
+LIBFILE=lib$(NAME).so
CFILES=pattern.c utils.c match.c files.c printmatch.c json.c utf8.c
+HFILES=files.h json.h match.h pattern.h printmatch.h utf8.h utils.h
OBJFILES=$(CFILES:.c=.o)
$(NAME): $(OBJFILES) bp.c
$(CC) $(ALL_FLAGS) -o $@ $(OBJFILES) bp.c
-all: $(NAME) bp.1 lua
+$(LIBFILE): $(OBJFILES)
+ $(CC) $^ $(ALL_FLAGS) -Wl,-soname,$(LIBFILE) -shared -o $@
+
+all: $(NAME) $(LIBFILE) bp.1 lua
%.o: %.c %.h utf8.h
$(CC) -c $(ALL_FLAGS) -o $@ $<
@@ -76,6 +81,11 @@ install: $(NAME) bp.1
rm -f "$(PREFIX)/bin/$(NAME)"
cp $(NAME) "$(PREFIX)/bin/"
+install-lib: $(LIBFILE) bp.1
+ mkdir -p -m 755 "$(PREFIX)/lib" "$(PREFIX)/include/$(NAME)"
+ cp $(LIBFILE) "$(PREFIX)/lib"
+ cp $(HFILES) "$(PREFIX)/include/$(NAME)"
+
uninstall:
rm -rf "$(PREFIX)/bin/$(NAME)" "$(PREFIX)/man/man1/$(NAME).1" "$(SYSCONFDIR)/$(NAME)"
@if [ -d ~/.config/$(NAME) ]; then \
@@ -84,4 +94,4 @@ uninstall:
[ "$$confirm" != n ] && rm -rf ~/.config/$(NAME); \
fi
-.PHONY: all clean install uninstall leaktest splint test tutorial lua
+.PHONY: all clean install install-lib uninstall leaktest splint test tutorial lua
diff --git a/match.h b/match.h
index 5209977..6c875c4 100644
--- a/match.h
+++ b/match.h
@@ -6,6 +6,7 @@
#include <stdbool.h>
#include <stdio.h>
+#include <sys/types.h>
#include "pattern.h"
diff --git a/pattern.h b/pattern.h
index 16b9654..7569849 100644
--- a/pattern.h
+++ b/pattern.h
@@ -5,6 +5,7 @@
#define PATTERN__H
#include <stdbool.h>
+#include <sys/types.h>
#define UNBOUNDED(pat) ((pat)->max_matchlen == -1)