2020-02-08 10:48:41 +01:00
|
|
|
VERSION ?= $(shell cat VERSION)
|
2020-02-07 14:56:50 +01:00
|
|
|
PREFIX ?= /usr/local
|
2020-02-27 05:59:43 +01:00
|
|
|
includedir ?= /include
|
2020-02-07 14:56:50 +01:00
|
|
|
bindir ?= /bin
|
|
|
|
libdir ?= /lib
|
|
|
|
mandir ?= /share/man/man1
|
2022-08-23 21:42:15 +02:00
|
|
|
PKG_CONFIG ?= pkg-config
|
2020-02-07 14:56:50 +01:00
|
|
|
|
2020-02-08 11:05:41 +01:00
|
|
|
GIT_SHA1 = $(shell git rev-parse HEAD 2>/dev/null || printf 'nogit')
|
2021-05-20 03:35:18 +02:00
|
|
|
GIT_TAG = $(shell git tag --points-at HEAD 2>/dev/null || cat VERSION)
|
2020-02-07 14:56:50 +01:00
|
|
|
MAKEFLAGS += --no-builtin-rules
|
|
|
|
|
|
|
|
WARNINGS = -Wall -Wextra -Wpedantic -Wformat=2 -Wstrict-aliasing=3 -Wstrict-overflow=5 -Wstack-usage=12500 \
|
2021-12-26 17:38:11 +01:00
|
|
|
-Wcast-align -Wpointer-arith -Wchar-subscripts -Warray-bounds=2 -Wno-unknown-warning-option
|
2022-02-18 23:28:55 +01:00
|
|
|
VISIBILITY ?= -fvisibility=hidden
|
2020-02-07 14:56:50 +01:00
|
|
|
|
2021-05-20 03:35:18 +02:00
|
|
|
override CFLAGS ?= -g -O2 $(WARNINGS) $(EXTRA_WARNINGS)
|
2022-02-18 23:28:55 +01:00
|
|
|
override CFLAGS += -std=c99 $(VISIBILITY)
|
2020-02-07 17:32:22 +01:00
|
|
|
override CPPFLAGS ?= -D_FORTIFY_SOURCE=2
|
2020-02-07 14:56:50 +01:00
|
|
|
override CPPFLAGS += -DBM_VERSION=\"$(VERSION)\" -DBM_PLUGIN_VERSION=\"$(VERSION)-$(GIT_SHA1)\" -DINSTALL_LIBDIR=\"$(PREFIX)$(libdir)\"
|
2020-02-07 17:32:22 +01:00
|
|
|
override CPPFLAGS += -D_DEFAULT_SOURCE -Ilib
|
2020-02-07 14:56:50 +01:00
|
|
|
|
|
|
|
libs = libbemenu.so
|
2020-02-08 09:49:22 +01:00
|
|
|
pkgconfigs = bemenu.pc
|
2020-02-07 14:56:50 +01:00
|
|
|
bins = bemenu bemenu-run
|
2021-03-30 08:48:54 +02:00
|
|
|
mans = bemenu.1
|
2020-02-07 14:56:50 +01:00
|
|
|
renderers = bemenu-renderer-x11.so bemenu-renderer-curses.so bemenu-renderer-wayland.so
|
2021-03-30 08:48:54 +02:00
|
|
|
all: $(bins) $(renderers) $(mans)
|
2020-02-07 14:56:50 +01:00
|
|
|
clients: $(bins)
|
|
|
|
curses: bemenu-renderer-curses.so
|
|
|
|
x11: bemenu-renderer-x11.so
|
|
|
|
wayland: bemenu-renderer-wayland.so
|
|
|
|
|
2020-02-08 11:05:41 +01:00
|
|
|
# support non git builds
|
|
|
|
.git/index:
|
2023-02-18 10:33:20 +01:00
|
|
|
[ -f .git ] && exit; \
|
|
|
|
mkdir -p .git; \
|
2020-02-08 11:05:41 +01:00
|
|
|
touch .git/index
|
|
|
|
|
2020-02-07 14:56:50 +01:00
|
|
|
%.a:
|
|
|
|
$(LINK.c) -c $(filter %.c,$^) $(LDLIBS) -o $@
|
|
|
|
|
2020-03-17 11:03:53 +01:00
|
|
|
$(libs): private override full=$(addsuffix .$(VERSION), $@)
|
|
|
|
$(libs): private override major=$(addsuffix .$(firstword $(subst ., ,$(VERSION))), $@)
|
2020-02-08 10:48:41 +01:00
|
|
|
$(libs): %: VERSION .git/index
|
2020-05-07 07:47:42 +02:00
|
|
|
$(LINK.c) -shared -fPIC $(filter %.c %.a,$^) $(LDLIBS) -o $(full) -Wl,-soname,$(major)
|
2020-03-17 11:03:53 +01:00
|
|
|
ln -fs $(full) $(major)
|
|
|
|
ln -fs $(full) $@
|
2020-02-07 14:56:50 +01:00
|
|
|
|
2020-02-08 10:48:41 +01:00
|
|
|
$(pkgconfigs): %: VERSION %.in
|
2021-05-25 10:32:01 +02:00
|
|
|
sed "s/@VERSION@/$(VERSION)/;s,@PREFIX@,$(PREFIX),;s,@LIBDIR@,$(libdir),;s,@INCLUDEDIR@,$(includedir)," $(addsuffix .in, $@) > $@
|
2020-02-08 09:49:22 +01:00
|
|
|
|
2021-12-27 17:53:57 +01:00
|
|
|
bemenu.1: man/bemenu.1.scd.in
|
2022-02-18 23:36:47 +01:00
|
|
|
-sed 's,@LIBDIR@,$(PREFIX)$(libdir),' $< | scdoc > $@
|
2021-03-30 08:48:54 +02:00
|
|
|
|
2020-02-08 10:48:41 +01:00
|
|
|
$(renderers): %: VERSION .git/index | $(libs)
|
2020-02-07 14:56:50 +01:00
|
|
|
$(LINK.c) -shared -fPIC $(filter %.c %.a,$^) $(LDLIBS) -L. -lbemenu -o $@
|
|
|
|
|
|
|
|
$(bins): %: | $(libs)
|
|
|
|
$(LINK.c) $(filter %.c %.a,$^) $(LDLIBS) -L. -lbemenu -o $@
|
|
|
|
|
2021-06-09 02:12:57 +02:00
|
|
|
cdl.a: private override LDFLAGS += -fPIC
|
2020-02-07 14:56:50 +01:00
|
|
|
cdl.a: lib/3rdparty/cdl.c lib/3rdparty/cdl.h
|
|
|
|
|
2022-02-19 00:00:26 +01:00
|
|
|
util.a: private override LDFLAGS += -fPIC
|
|
|
|
util.a: lib/util.c lib/internal.h
|
|
|
|
|
2020-02-07 14:56:50 +01:00
|
|
|
libbemenu.so: private override LDLIBS += -ldl
|
2022-10-20 03:18:17 +02:00
|
|
|
libbemenu.so: lib/bemenu.h lib/internal.h lib/filter.c lib/item.c lib/library.c lib/list.c lib/menu.c lib/vim.c util.a cdl.a
|
2020-02-07 14:56:50 +01:00
|
|
|
|
2022-08-23 21:42:15 +02:00
|
|
|
bemenu-renderer-curses.so: private override LDLIBS += $(shell $(PKG_CONFIG) --libs ncursesw) -lm
|
|
|
|
bemenu-renderer-curses.so: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I ncursesw)
|
2022-02-19 00:00:26 +01:00
|
|
|
bemenu-renderer-curses.so: lib/renderers/curses/curses.c util.a
|
2020-02-07 14:56:50 +01:00
|
|
|
|
2022-08-23 21:42:15 +02:00
|
|
|
bemenu-renderer-x11.so: private override LDLIBS += $(shell $(PKG_CONFIG) --libs x11 xinerama cairo pango pangocairo)
|
|
|
|
bemenu-renderer-x11.so: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I x11 xinerama cairo pango pangocairo)
|
2022-02-19 00:00:26 +01:00
|
|
|
bemenu-renderer-x11.so: lib/renderers/cairo_renderer.h lib/renderers/x11/x11.c lib/renderers/x11/x11.h lib/renderers/x11/window.c lib/renderers/x11/xkb_unicode.c lib/renderers/x11/xkb_unicode.h util.a
|
2020-02-07 14:56:50 +01:00
|
|
|
|
2020-02-09 17:51:55 +01:00
|
|
|
lib/renderers/wayland/xdg-shell.c:
|
2022-08-23 21:42:15 +02:00
|
|
|
wayland-scanner private-code < "$$($(PKG_CONFIG) --variable=pkgdatadir wayland-protocols)/stable/xdg-shell/xdg-shell.xml" > $@
|
2020-02-07 16:27:40 +01:00
|
|
|
|
2020-02-08 09:48:07 +01:00
|
|
|
lib/renderers/wayland/wlr-layer-shell-unstable-v1.h: lib/renderers/wayland/wlr-layer-shell-unstable-v1.xml
|
|
|
|
wayland-scanner client-header < $^ > $@
|
2020-02-07 14:56:50 +01:00
|
|
|
|
2020-02-08 09:48:07 +01:00
|
|
|
lib/renderers/wayland/wlr-layer-shell-unstable-v1.c: lib/renderers/wayland/wlr-layer-shell-unstable-v1.xml
|
|
|
|
wayland-scanner private-code < $^ > $@
|
2020-02-07 14:56:50 +01:00
|
|
|
|
2024-02-02 08:51:10 +01:00
|
|
|
lib/renderers/wayland/fractional-scale-v1.h: lib/renderers/wayland/fractional-scale-v1.xml
|
|
|
|
wayland-scanner client-header < $^ > $@
|
|
|
|
|
|
|
|
lib/renderers/wayland/fractional-scale-v1.c: lib/renderers/wayland/fractional-scale-v1.xml
|
|
|
|
wayland-scanner private-code < $^ > $@
|
|
|
|
|
|
|
|
lib/renderers/wayland/viewporter.h: lib/renderers/wayland/viewporter.xml
|
|
|
|
wayland-scanner client-header < $^ > $@
|
|
|
|
|
|
|
|
lib/renderers/wayland/viewporter.c: lib/renderers/wayland/viewporter.xml
|
|
|
|
wayland-scanner private-code < $^ > $@
|
|
|
|
|
2021-06-09 02:12:57 +02:00
|
|
|
xdg-shell.a: private override LDFLAGS += -fPIC
|
2022-08-23 21:42:15 +02:00
|
|
|
xdg-shell.a: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I wayland-client)
|
2020-02-07 16:27:40 +01:00
|
|
|
xdg-shell.a: lib/renderers/wayland/xdg-shell.c
|
2021-06-09 02:12:57 +02:00
|
|
|
wlr-layer-shell.a: private override LDFLAGS += -fPIC
|
2022-08-23 21:42:15 +02:00
|
|
|
wlr-layer-shell.a: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I wayland-client)
|
2020-02-07 14:56:50 +01:00
|
|
|
wlr-layer-shell.a: lib/renderers/wayland/wlr-layer-shell-unstable-v1.c lib/renderers/wayland/wlr-layer-shell-unstable-v1.h
|
2024-02-02 08:51:10 +01:00
|
|
|
fractional-scale.a: private override LDFLAGS += -fPIC
|
|
|
|
fractional-scale.a: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I wayland-client)
|
|
|
|
fractional-scale.a: lib/renderers/wayland/fractional-scale-v1.c lib/renderers/wayland/fractional-scale-v1.h
|
|
|
|
viewporter.a: private override LDFLAGS += -fPIC
|
|
|
|
viewporter.a: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I wayland-client)
|
|
|
|
viewporter.a: lib/renderers/wayland/viewporter.c lib/renderers/wayland/viewporter.h
|
2022-08-23 21:42:15 +02:00
|
|
|
bemenu-renderer-wayland.so: private override LDLIBS += $(shell $(PKG_CONFIG) --libs wayland-client cairo pango pangocairo xkbcommon)
|
|
|
|
bemenu-renderer-wayland.so: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I wayland-client cairo pango pangocairo xkbcommon)
|
2024-02-02 08:51:10 +01:00
|
|
|
bemenu-renderer-wayland.so: lib/renderers/cairo_renderer.h lib/renderers/wayland/wayland.c lib/renderers/wayland/wayland.h lib/renderers/wayland/registry.c lib/renderers/wayland/window.c xdg-shell.a wlr-layer-shell.a fractional-scale.a viewporter.a util.a
|
2020-02-07 14:56:50 +01:00
|
|
|
|
|
|
|
common.a: client/common/common.c client/common/common.h
|
|
|
|
bemenu: common.a client/bemenu.c
|
|
|
|
bemenu-run: common.a client/bemenu-run.c
|
|
|
|
|
2020-02-08 09:49:22 +01:00
|
|
|
install-pkgconfig: $(pkgconfigs)
|
|
|
|
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/pkgconfig"
|
|
|
|
cp $^ "$(DESTDIR)$(PREFIX)$(libdir)/pkgconfig"
|
|
|
|
|
2020-02-27 05:59:43 +01:00
|
|
|
install-include: lib/bemenu.h
|
|
|
|
mkdir -p "$(DESTDIR)$(PREFIX)$(includedir)"
|
|
|
|
cp $^ "$(DESTDIR)$(PREFIX)$(includedir)"
|
|
|
|
|
2020-02-07 14:56:50 +01:00
|
|
|
install-libs: $(libs)
|
2020-02-07 18:31:49 +01:00
|
|
|
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)"
|
|
|
|
cp $(addsuffix .$(VERSION), $^) "$(DESTDIR)$(PREFIX)$(libdir)"
|
2020-02-07 14:56:50 +01:00
|
|
|
|
|
|
|
install-lib-symlinks: $(libs) | install-libs
|
2020-02-07 18:31:49 +01:00
|
|
|
cp -RP $^ $(addsuffix .$(firstword $(subst ., ,$(VERSION))), $^) "$(DESTDIR)$(PREFIX)$(libdir)"
|
2020-02-07 14:56:50 +01:00
|
|
|
|
|
|
|
install-bins:
|
2020-02-07 18:31:49 +01:00
|
|
|
mkdir -p "$(DESTDIR)$(PREFIX)$(bindir)"
|
|
|
|
-cp $(bins) "$(DESTDIR)$(PREFIX)$(bindir)"
|
2020-02-09 19:13:48 +01:00
|
|
|
-chmod 0755 $(addprefix "$(DESTDIR)$(PREFIX)$(bindir)"/,$(bins))
|
2020-02-09 19:16:03 +01:00
|
|
|
|
2021-03-30 08:48:54 +02:00
|
|
|
install-man: bemenu.1
|
2022-02-19 01:34:56 +01:00
|
|
|
-hash scdoc && mkdir -p "$(DESTDIR)$(PREFIX)$(mandir)"
|
|
|
|
-hash scdoc && cp $< "$(DESTDIR)$(PREFIX)$(mandir)"
|
2020-02-07 14:56:50 +01:00
|
|
|
|
2020-05-07 01:56:45 +02:00
|
|
|
install-renderers: install-curses install-wayland install-x11
|
|
|
|
|
2020-05-07 07:54:09 +02:00
|
|
|
install-curses:
|
|
|
|
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
|
|
|
-cp bemenu-renderer-curses.so "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
2020-05-07 01:56:45 +02:00
|
|
|
|
2020-05-07 07:54:09 +02:00
|
|
|
install-wayland:
|
|
|
|
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
|
|
|
-cp bemenu-renderer-wayland.so "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
2020-05-07 01:56:45 +02:00
|
|
|
|
2020-05-07 07:54:09 +02:00
|
|
|
install-x11:
|
|
|
|
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
|
|
|
-cp bemenu-renderer-x11.so "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
2020-05-07 01:56:45 +02:00
|
|
|
|
2022-02-08 12:08:41 +01:00
|
|
|
install-docs: install-man
|
2020-05-07 01:56:45 +02:00
|
|
|
|
2022-02-08 12:08:41 +01:00
|
|
|
install-base: install-pkgconfig install-include install-lib-symlinks install-bins
|
|
|
|
|
|
|
|
install: install-base install-renderers install-docs
|
2020-02-07 14:56:50 +01:00
|
|
|
@echo "Install OK!"
|
|
|
|
|
|
|
|
doxygen:
|
|
|
|
BM_VERSION=$(VERSION) doxygen doxygen/Doxyfile
|
2020-02-07 18:31:49 +01:00
|
|
|
cp -R doxygen/doxygen-qmi-style/navtree html
|
|
|
|
cp -R doxygen/doxygen-qmi-style/search html/search
|
2020-02-07 14:56:50 +01:00
|
|
|
|
2021-05-20 03:35:18 +02:00
|
|
|
sign:
|
|
|
|
test "x$(GIT_TAG)" = "x$(VERSION)"
|
2021-05-23 07:11:47 +02:00
|
|
|
git archive --prefix="bemenu-$(VERSION)/" -o "bemenu-$(VERSION).tar.gz" "$(GIT_TAG)"
|
2021-05-20 03:35:18 +02:00
|
|
|
gpg --default-key "$(GPG_KEY_ID)" --armor --detach-sign "bemenu-$(VERSION).tar.gz"
|
|
|
|
|
2022-02-19 01:00:56 +01:00
|
|
|
check-symbols: libbemenu.so lib/bemenu.h
|
|
|
|
sh scripts/check-symbols.sh $^ bemenu-renderer-*.so
|
|
|
|
|
2020-02-07 14:56:50 +01:00
|
|
|
clean:
|
2020-02-09 06:22:16 +01:00
|
|
|
$(RM) -r *.dSYM # OSX generates .dSYM dirs with -g ...
|
2021-03-30 08:48:54 +02:00
|
|
|
$(RM) $(pkgconfigs) $(libs) $(bins) $(renderers) $(mans) *.a *.so.*
|
2020-02-07 16:29:35 +01:00
|
|
|
$(RM) lib/renderers/wayland/wlr-*.h lib/renderers/wayland/wlr-*.c lib/renderers/wayland/xdg-shell.c
|
2020-02-07 14:56:50 +01:00
|
|
|
$(RM) -r html
|
|
|
|
|
2022-02-09 18:41:11 +01:00
|
|
|
uninstall:
|
|
|
|
$(RM) -r "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
|
|
|
$(RM) "$(DESTDIR)$(PREFIX)$(mandir)/bemenu.1"
|
|
|
|
$(RM) "$(DESTDIR)$(PREFIX)$(bindir)/bemenu"
|
|
|
|
$(RM) "$(DESTDIR)$(PREFIX)$(bindir)/bemenu-run"
|
|
|
|
$(RM) "$(DESTDIR)$(PREFIX)$(libdir)"/libbemenu.so*
|
|
|
|
$(RM) "$(DESTDIR)$(PREFIX)$(includedir)/bemenu.h"
|
|
|
|
|
2020-02-07 18:31:49 +01:00
|
|
|
.DELETE_ON_ERROR:
|
2022-02-09 18:41:11 +01:00
|
|
|
.PHONY: all clean uninstall install install-base install-pkgconfig install-include install-libs install-lib-symlinks \
|
2022-02-08 12:08:41 +01:00
|
|
|
install-man install-bins install-docs install-renderers install-curses install-wayland install-x11 \
|
2022-02-19 01:00:56 +01:00
|
|
|
doxygen sign check-symbols clients curses x11 wayland
|