1
0
mirror of https://github.com/Cloudef/bemenu synced 2024-11-24 01:44:16 +01:00
bemenu/GNUmakefile

168 lines
7.2 KiB
Makefile
Raw Normal View History

VERSION ?= $(shell cat VERSION)
PREFIX ?= /usr/local
2020-02-27 05:59:43 +01:00
includedir ?= /include
bindir ?= /bin
libdir ?= /lib
mandir ?= /share/man/man1
GIT_SHA1 = $(shell git rev-parse HEAD 2>/dev/null || printf 'nogit')
GIT_TAG = $(shell git tag --points-at HEAD 2>/dev/null || cat VERSION)
MAKEFLAGS += --no-builtin-rules
WARNINGS = -Wall -Wextra -Wpedantic -Wformat=2 -Wstrict-aliasing=3 -Wstrict-overflow=5 -Wstack-usage=12500 \
2020-02-07 15:35:01 +01:00
-Wfloat-equal -Wcast-align -Wpointer-arith -Wchar-subscripts -Warray-bounds=2 -Wno-unknown-warning-option
override CFLAGS ?= -g -O2 $(WARNINGS) $(EXTRA_WARNINGS)
override CFLAGS += -std=c99
2020-02-07 17:32:22 +01:00
override CPPFLAGS ?= -D_FORTIFY_SOURCE=2
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
libs = libbemenu.so
2020-02-08 09:49:22 +01:00
pkgconfigs = bemenu.pc
bins = bemenu bemenu-run
mans = bemenu.1
renderers = bemenu-renderer-x11.so bemenu-renderer-curses.so bemenu-renderer-wayland.so
all: $(bins) $(renderers) $(mans)
clients: $(bins)
curses: bemenu-renderer-curses.so
x11: bemenu-renderer-x11.so
wayland: bemenu-renderer-wayland.so
# support non git builds
.git/index:
mkdir -p .git
touch .git/index
%.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))), $@)
$(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) $@
$(pkgconfigs): %: VERSION %.in
sed "s/@VERSION@/$(VERSION)/;s,@PREFIX@,$(PREFIX),;s,@LIBDIR@,$(libdir),;s,@INCLUDEDIR@,$(includedir)," $(addsuffix .in, $@) > $@
2020-02-08 09:49:22 +01:00
bemenu.1: man/bemenu.1.in
sed 's,@LIBDIR@,$(PREFIX)$(libdir),' $< > $@
$(renderers): %: VERSION .git/index | $(libs)
$(LINK.c) -shared -fPIC $(filter %.c %.a,$^) $(LDLIBS) -L. -lbemenu -o $@
$(bins): %: | $(libs)
$(LINK.c) $(filter %.c %.a,$^) $(LDLIBS) -L. -lbemenu -o $@
cdl.a: private override LDFLAGS += -fPIC
cdl.a: lib/3rdparty/cdl.c lib/3rdparty/cdl.h
libbemenu.so: private override LDLIBS += -ldl
libbemenu.so: lib/bemenu.h lib/internal.h lib/filter.c lib/item.c lib/library.c lib/list.c lib/menu.c lib/util.c cdl.a
2020-02-08 09:53:35 +01: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)
bemenu-renderer-curses.so: lib/renderers/curses/curses.c
2020-02-07 18:31:49 +01: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)
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
lib/renderers/wayland/xdg-shell.c:
wayland-scanner private-code < "$$(pkg-config --variable=pkgdatadir wayland-protocols)/stable/xdg-shell/xdg-shell.xml" > $@
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-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 < $^ > $@
lib/renderers/wayland/xdg-output-unstable-v1.h: lib/renderers/wayland/xdg-output-unstable-v1.xml
wayland-scanner client-header < $^ > $@
lib/renderers/wayland/xdg-output-unstable-v1.c: lib/renderers/wayland/xdg-output-unstable-v1.xml
wayland-scanner private-code < $^ > $@
xdg-shell.a: private override LDFLAGS += -fPIC
xdg-shell.a: private override CPPFLAGS += $(shell pkg-config --cflags-only-I wayland-client)
xdg-shell.a: lib/renderers/wayland/xdg-shell.c
wlr-layer-shell.a: private override LDFLAGS += -fPIC
wlr-layer-shell.a: private override CPPFLAGS += $(shell pkg-config --cflags-only-I wayland-client)
wlr-layer-shell.a: lib/renderers/wayland/wlr-layer-shell-unstable-v1.c lib/renderers/wayland/wlr-layer-shell-unstable-v1.h
xdg-output.a: private override LDFLAGS += -fPIC
xdg-output.a: private override CPPFLAGS += $(shell pkg-config --cflags-only-I wayland-client)
xdg-output.a: lib/renderers/wayland/xdg-output-unstable-v1.c lib/renderers/wayland/xdg-output-unstable-v1.h
2020-02-07 18:31:49 +01: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)
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 xdg-output.a
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)"
install-libs: $(libs)
2020-02-07 18:31:49 +01:00
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)"
cp $(addsuffix .$(VERSION), $^) "$(DESTDIR)$(PREFIX)$(libdir)"
install-lib-symlinks: $(libs) | install-libs
2020-02-07 18:31:49 +01:00
cp -RP $^ $(addsuffix .$(firstword $(subst ., ,$(VERSION))), $^) "$(DESTDIR)$(PREFIX)$(libdir)"
install-bins:
2020-02-07 18:31:49 +01:00
mkdir -p "$(DESTDIR)$(PREFIX)$(bindir)"
-cp $(bins) "$(DESTDIR)$(PREFIX)$(bindir)"
-chmod 0755 $(addprefix "$(DESTDIR)$(PREFIX)$(bindir)"/,$(bins))
2020-02-09 19:16:03 +01:00
install-man: bemenu.1
2020-02-07 18:31:49 +01:00
mkdir -p "$(DESTDIR)$(PREFIX)$(mandir)"
cp $< "$(DESTDIR)$(PREFIX)$(mandir)"
install-renderers: install-curses install-wayland install-x11
install-curses:
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
-cp bemenu-renderer-curses.so "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
install-wayland:
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
-cp bemenu-renderer-wayland.so "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
install-x11:
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
-cp bemenu-renderer-x11.so "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
install-base: install-pkgconfig install-include install-lib-symlinks install-bins install-man
install: install-base install-renderers
@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
sign:
test "x$(GIT_TAG)" = "x$(VERSION)"
git archive --prefix="bemenu-$(VERSION)/" -o "bemenu-$(VERSION).tar.gz" "$(GIT_TAG)"
gpg --default-key "$(GPG_KEY_ID)" --armor --detach-sign "bemenu-$(VERSION).tar.gz"
clean:
2020-02-09 06:22:16 +01:00
$(RM) -r *.dSYM # OSX generates .dSYM dirs with -g ...
$(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
$(RM) -r html
2020-02-07 18:31:49 +01:00
.DELETE_ON_ERROR:
.PHONY: all clean install install-base install-pkgconfig install-include install-libs install-lib-symlinks \
install-man install-bins install-renderers install-curses install-wayland install-x11 \
doxygen sign clients curses x11 wayland