aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElse <else@localhost>2026-03-18 11:01:36 +0100
committerfrosty <gabriel@bwaaa.monster>2026-03-18 06:26:07 -0400
commit3b17d8a766ce93bdba1b9f19c22018c010d8a780 (patch)
tree812b02e0a010dddd5226155f2663362be33a05b7
parent39184b8a7975eb141ffa2dc11ed87e90113a95c3 (diff)
downloadomnisearch-3b17d8a766ce93bdba1b9f19c22018c010d8a780.tar.gz
Add macOS build and launchd install support
-rw-r--r--Makefile62
-rw-r--r--README.md21
-rw-r--r--init/launchd/omnisearch.plist.in28
3 files changed, 100 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 8f2cf29..d15a104 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,19 @@
CC := cc
+UNAME_S := $(shell uname -s)
+PKG_CONFIG ?= pkg-config
+PKG_DEPS := libxml-2.0 libcurl openssl
+
+ifeq ($(UNAME_S),Darwin)
+DEP_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PKG_DEPS) 2>/dev/null)
+DEP_LIBS := $(shell $(PKG_CONFIG) --libs $(PKG_DEPS) 2>/dev/null)
+CFLAGS := -Wall -Wextra -O2 -Isrc $(DEP_CFLAGS)
+LIBS := -lbeaker $(DEP_LIBS) -lpthread -lm
+else
CFLAGS := -Wall -Wextra -O2 -Isrc -I/usr/include/libxml2
-LDFLAGS :=
-
LIBS := -lbeaker -lcurl -lxml2 -lpthread -lm -lssl -lcrypto
+endif
+
+LDFLAGS :=
SRC_DIR := src
BIN_DIR := bin
@@ -44,19 +55,32 @@ info:
@echo "Object files to generate:"
@echo "$(OBJS)" | tr ' ' '\n'
+ifeq ($(UNAME_S),Darwin)
+PREFIX ?= /usr/local
+DATA_DIR ?= $(PREFIX)/etc/omnisearch
+CONF_DIR ?= $(DATA_DIR)
+VAR_DIR ?= $(PREFIX)/var/lib/omnisearch
+LOG_DIR ?= $(PREFIX)/var/log/omnisearch
+CACHE_DIR ?= $(PREFIX)/var/cache/omnisearch
+else
PREFIX ?= /usr
+DATA_DIR ?= /etc/omnisearch
+CONF_DIR ?= /etc/omnisearch
+VAR_DIR ?= /var/lib/omnisearch
+LOG_DIR ?= /var/log/omnisearch
+CACHE_DIR ?= /var/cache/omnisearch
+endif
+
INSTALL_BIN_DIR := $(PREFIX)/bin
-DATA_DIR := /etc/omnisearch
-CONF_DIR := /etc/omnisearch
-VAR_DIR := /var/lib/omnisearch
-LOG_DIR := /var/log/omnisearch
-CACHE_DIR := /var/cache/omnisearch
USER := omnisearch
GROUP := omnisearch
SYSTEMD_DIR := /etc/systemd/system
OPENRC_DIR := /etc/init.d
DINIT_DIR := /etc/dinit.d
+LAUNCHD_DIR ?= /Library/LaunchDaemons
+LAUNCHD_LABEL ?= monster.bwaaa.omnisearch
+LAUNCHD_PLIST := $(LAUNCHD_DIR)/$(LAUNCHD_LABEL).plist
install:
@echo "Available install targets:"
@@ -65,9 +89,31 @@ install:
@echo " make install-runit"
@echo " make install-s6"
@echo " make install-dinit"
+ @if [ "$(UNAME_S)" = "Darwin" ]; then echo " make install-launchd"; fi
@echo ""
@echo "Example: doas/sudo make install-openrc"
+install-launchd: $(TARGET)
+ @mkdir -p $(DATA_DIR)/templates $(DATA_DIR)/static $(INSTALL_BIN_DIR) $(LOG_DIR)
+ @cp -rf templates/* $(DATA_DIR)/templates/
+ @cp -rf static/* $(DATA_DIR)/static/
+ @cp -n example-config.ini $(DATA_DIR)/config.ini || true
+ install -m 755 $(TARGET) $(INSTALL_BIN_DIR)/omnisearch
+ @mkdir -p $(LAUNCHD_DIR)
+ @sed \
+ -e 's|@INSTALL_BIN_DIR@|$(INSTALL_BIN_DIR)|g' \
+ -e 's|@DATA_DIR@|$(DATA_DIR)|g' \
+ -e 's|@LOG_DIR@|$(LOG_DIR)|g' \
+ -e 's|@LAUNCHD_LABEL@|$(LAUNCHD_LABEL)|g' \
+ init/launchd/omnisearch.plist.in > $(LAUNCHD_PLIST)
+ @chmod 644 $(LAUNCHD_PLIST)
+ @echo ""
+ @echo "Config: $(DATA_DIR)/config.ini"
+ @echo "Installed launchd plist to $(LAUNCHD_PLIST)"
+ @echo "Load with: sudo launchctl bootstrap system $(LAUNCHD_PLIST)"
+ @echo "Enable with: sudo launchctl enable system/$(LAUNCHD_LABEL)"
+ @echo "Start with: sudo launchctl kickstart -k system/$(LAUNCHD_LABEL)"
+
install-systemd: $(TARGET)
@mkdir -p $(DATA_DIR)/templates $(DATA_DIR)/static $(LOG_DIR) $(CACHE_DIR)
@cp -rf templates/* $(DATA_DIR)/templates/
@@ -176,4 +222,4 @@ uninstall:
@grep -q '^$(GROUP):' /etc/group 2>/dev/null && groupdel $(GROUP) 2>/dev/null || true
@echo "Uninstalled omnisearch"
-.PHONY: all run clean rebuild info install install-systemd install-openrc install-runit install-s6 install-dinit uninstall
+.PHONY: all run clean rebuild info install install-launchd install-systemd install-openrc install-runit install-s6 install-dinit uninstall
diff --git a/README.md b/README.md
index a7cfce4..164ab8e 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ A modern lightweight metasearch engine with a clean design written in C.
I request that none of this code, in part or in full, be hosted on GitHub, SourceForge, or any other proprietary platform. This request is made out of respect for both me, the developer and for you, the user.
## Configuration
-Create a config.ini, there is an example included in the root. Or if you installed omnisearch, edit the config file at `/etc/omnisearch/config.ini`.
+Create a config.ini, there is an example included in the root. Or if you installed omnisearch, edit the installed config file.
## Dependencies
- libxml2
@@ -46,13 +46,27 @@ Depending on your system, you may first need to install libcurl and libxml2.
# xbps-install -S libxml2-devel libcurl-devel
```
+### macOS (Homebrew)
+```
+$ brew install libxml2 curl openssl pkg-config
+```
+
+### macOS (MacPorts)
+```
+# port install libxml2 curl openssl3 pkgconfig
+```
+
+On macOS the build uses `pkg-config` to discover `libxml2`, `libcurl` and OpenSSL flags.
+
Install libbeaker:
```
$ git clone https://git.bwaaa.monster/beaker
$ cd beaker
-$ make
# make install
```
+
+On macOS `beaker` installs to `/usr/local/` by default and installs `libbeaker.dylib`.
+
And then install omnisearch:
```
$ git clone https://git.bwaaa.monster/omnisearch
@@ -60,7 +74,8 @@ $ cd omnisearch
$ make
# make install-<init>
```
-Replace `<init>` with your init system (openrc,systemd,runit,s6,dinit)
+Replace `<init>` with your init system (`openrc`, `systemd`, `runit`, `s6`, `dinit`, `launchd`).
+On macOS, use `install-launchd`.
## Hosting
Run it normally behind a reverse proxy (like nginx)
diff --git a/init/launchd/omnisearch.plist.in b/init/launchd/omnisearch.plist.in
new file mode 100644
index 0000000..f939738
--- /dev/null
+++ b/init/launchd/omnisearch.plist.in
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Label</key>
+ <string>@LAUNCHD_LABEL@</string>
+
+ <key>ProgramArguments</key>
+ <array>
+ <string>@INSTALL_BIN_DIR@/omnisearch</string>
+ </array>
+
+ <key>WorkingDirectory</key>
+ <string>@DATA_DIR@</string>
+
+ <key>RunAtLoad</key>
+ <true/>
+
+ <key>KeepAlive</key>
+ <true/>
+
+ <key>StandardOutPath</key>
+ <string>@LOG_DIR@/omnisearch.log</string>
+
+ <key>StandardErrorPath</key>
+ <string>@LOG_DIR@/omnisearch.err</string>
+</dict>
+</plist>