# OpenWrt package feed Makefile for quicprochat server.
#
# Usage:
#   1. Add this directory as a custom feed in feeds.conf:
#      src-link quicprochat /path/to/quicprochat/packaging/openwrt
#   2. ./scripts/feeds update quicprochat && ./scripts/feeds install quicprochat
#   3. make menuconfig  (select Network -> quicprochat)
#   4. make package/quicprochat/compile V=s
#
# The binary is pre-built via cross-compilation (see scripts/cross-compile.sh)
# and the Makefile simply installs it into the ipkg.

include $(TOPDIR)/rules.mk

PKG_NAME:=quicprochat
PKG_VERSION:=0.1.0
PKG_RELEASE:=1
PKG_MAINTAINER:=quicprochat team
PKG_LICENSE:=MIT

include $(INCLUDE_DIR)/package.mk

define Package/quicprochat
  SECTION:=net
  CATEGORY:=Network
  TITLE:=End-to-end encrypted group messenger (server)
  DEPENDS:=+libpthread +librt
  URL:=https://github.com/nicholasgasior/quicprochat
endef

define Package/quicprochat/description
  Production-grade end-to-end encrypted group messenger using QUIC transport,
  MLS (RFC 9420), ML-KEM-768 hybrid post-quantum KEM, and OPAQUE authentication.
  This package installs the qpc-server daemon.
endef

define Package/quicprochat/conffiles
/etc/config/quicprochat
endef

# Skip standard build — we use pre-compiled static musl binaries.
define Build/Compile
endef

define Package/quicprochat/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/qpc-server $(1)/usr/bin/qpc-server

	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) ./files/quicprochat.init $(1)/etc/init.d/quicprochat

	$(INSTALL_DIR) $(1)/etc/config
	$(INSTALL_CONF) ./files/quicprochat.uci $(1)/etc/config/quicprochat

	$(INSTALL_DIR) $(1)/var/lib/quicprochat
endef

$(eval $(call BuildPackage,quicprochat))
