From 97fa6ede7a9cec6e2a3cc6c32ef38363552c6dc4 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 15 Jul 2021 15:23:06 +0200 Subject: Makefile: Add EXTRA_CFLAGS --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2ec3a80..4349593 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ DATADIR ?= $(PREFIX)/share/badwolf APPSDIR ?= $(PREFIX)/share/applications CC ?= cc -CFLAGS ?= -g -O2 -pie -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -O2 -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla +CFLAGS ?= -g -O2 -pie -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -O2 -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla $(EXTRA_CFLAGS) DBG ?= PKGCONFIG ?= pkg-config MSGFMT ?= msgfmt -- cgit v1.3.1-23-gd82d From 3c8aa19036086624029f314cc6f0d75b9c757171 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 15 Jul 2021 18:51:20 +0200 Subject: Makefile: Force some cflags, bump _XOPEN_SOURCE to 700 --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4349593..10bd767 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,8 @@ DATADIR ?= $(PREFIX)/share/badwolf APPSDIR ?= $(PREFIX)/share/applications CC ?= cc -CFLAGS ?= -g -O2 -pie -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -O2 -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla $(EXTRA_CFLAGS) +CFLAGS ?= -g -O2 -pie -fPIE +CFLAGS += -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla $(EXTRA_CFLAGS) DBG ?= PKGCONFIG ?= pkg-config MSGFMT ?= msgfmt @@ -33,7 +34,7 @@ EXE_test = uri_test TRANS = fr.mo pt_BR.mo tr.mo de.mo DOCS = usr.bin.badwolf README.md KnowledgeBase.md interface.txt -CDEPS = -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION_FULL)\" +CDEPS = -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION_FULL)\" CDEPS += `$(PKGCONFIG) --cflags $(DEPS)` LIBS = `$(PKGCONFIG) --libs $(DEPS)` -- cgit v1.3.1-23-gd82d From c5fca92a08a8a63ad4d746b4d3a44a9cf724ea61 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 7 Sep 2021 02:46:07 +0200 Subject: Change buildsystem to use a ./configure script This is done to support webkit2gtk-4.1 (libsoup3) vs. webkit2gtk-4.0 (libsoup2). It will also be useful once WebKitGTK with support for GTK4 lands in badwolf. --- .gitignore | 1 + Makefile | 39 +++++----------------- README.md | 4 +-- configure | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ version.sh | 13 +++++--- 5 files changed, 130 insertions(+), 37 deletions(-) create mode 100755 configure (limited to 'Makefile') diff --git a/.gitignore b/.gitignore index fba98ae..b1e22a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /badwolf /locale +/config.mk *.o *.mo diff --git a/Makefile b/Makefile index 10bd767..b8d8e3e 100644 --- a/Makefile +++ b/Makefile @@ -3,29 +3,8 @@ # - Usage of ?= for defining variables when not already defined # - Usage of += for appending to a variable -PACKAGE = Badwolf -VERSION = 1.1.0 -VERSION_FULL = $(VERSION)`./version.sh` - -PREFIX ?= /usr/local -BINDIR ?= $(PREFIX)/bin -MANDIR ?= $(PREFIX)/share/man -DOCDIR ?= $(PREFIX)/share/doc/badwolf-$(VERSION) -DATADIR ?= $(PREFIX)/share/badwolf -APPSDIR ?= $(PREFIX)/share/applications - -CC ?= cc -CFLAGS ?= -g -O2 -pie -fPIE -CFLAGS += -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla $(EXTRA_CFLAGS) -DBG ?= -PKGCONFIG ?= pkg-config -MSGFMT ?= msgfmt -INKSCAPE ?= inkscape - -# for i in 24 32 48 64 128 256; do echo icons/hicolor/${i}x${i}/apps/badwolf.png; done | tr '\n' ' ' -ICON_SIZES = icons/hicolor/24x24/apps/badwolf.png icons/hicolor/32x32/apps/badwolf.png icons/hicolor/48x48/apps/badwolf.png icons/hicolor/64x64/apps/badwolf.png icons/hicolor/128x128/apps/badwolf.png icons/hicolor/256x256/apps/badwolf.png - -DEPS = gtk+-3.0 webkit2gtk-4.0 libsoup-2.4 libxml-2.0 +include config.mk + SRCS = bookmarks.c uri.c uri_test.c keybindings.c downloads.c badwolf.c OBJS = bookmarks.o uri.o keybindings.o downloads.o badwolf.o OBJS_test = uri_test.o @@ -34,11 +13,11 @@ EXE_test = uri_test TRANS = fr.mo pt_BR.mo tr.mo de.mo DOCS = usr.bin.badwolf README.md KnowledgeBase.md interface.txt -CDEPS = -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION_FULL)\" -CDEPS += `$(PKGCONFIG) --cflags $(DEPS)` -LIBS = `$(PKGCONFIG) --libs $(DEPS)` +all: config.mk $(EXE) $(TRANS) po/messages.pot -all: $(EXE) $(TRANS) po/messages.pot +config.mk: configure + @echo "Error: You need to execute ./configure before running make" + @exit 1 icons: $(ICON_SIZES) @@ -64,10 +43,10 @@ badwolf: $(OBJS) $(CC) -std=c11 -o $@ $(OBJS) $(LDFLAGS) $(LIBS) .c: - $(CC) -std=c11 $(CFLAGS) $(CDEPS) $(LDFLAGS) $(LIBS) -o $@ $< + $(CC) -std=c11 $(CFLAGS) $(LDFLAGS) $(LIBS) -o $@ $< .c.o: - $(CC) -std=c11 $(CFLAGS) $(CDEPS) -c -o $@ $< + $(CC) -std=c11 $(CFLAGS) -c -o $@ $< uri_test: uri.o uri_test.o $(CC) -std=c11 -o $@ uri.o uri_test.o $(LDFLAGS) $(LIBS) @@ -95,7 +74,7 @@ install: all .PHONY: clean clean: - rm -fr locale $(OBJS) $(OBJS_test) $(EXE) $(EXE_test) + rm -fr locale config.mk $(OBJS) $(OBJS_test) $(EXE) $(EXE_test) format: *.c *.h clang-format -style=file -assume-filename=.clang-format -i *.c *.h diff --git a/README.md b/README.md index d99da03..5f61b0a 100644 --- a/README.md +++ b/README.md @@ -54,13 +54,13 @@ You need to have gettext installed. If you want a GUI, poedit exists and Weblate Dependencies are: - C11 Compiler (such as clang or gcc) -- [WebKitGTK](https://webkitgtk.org/), only the latest stable is supported +- [WebKitGTK](https://webkitgtk.org/), only the latest stable(2.32.0+) is supported - [libxml-2.0](http://www.xmlsoft.org/), no known version limitation - POSIX make with extension for shell in variables (works with GNU, {Net,Free,Open}BSD) - A pkg-config implementation (pkgconf is recommended) - (optionnal) gettext implementation (such as GNU Gettext) -Compilation is done with `make`, install with `make install` (`DESTDIR` and `PREFIX` environment variables are supported, amongs other common ones). An example AppArmor profile is provided at `usr.bin.badwolf`, please do some long runtime checks before shipping it or a modified version, help can be provided but with no support. +Compilation is done with `./configure && make`, install with `make install` (`DESTDIR` and `PREFIX` environment variables are supported, amongs other common ones). An example AppArmor profile is provided at `usr.bin.badwolf`, please do some long runtime checks before shipping it or a modified version, help can be provided but with no support. You'll also need inkscape (command line only) if you want to regenerate the icons, for example after modifying them or adding a new size. These aren't needed for normal installation as it is bundled. diff --git a/configure b/configure new file mode 100755 index 0000000..17510a0 --- /dev/null +++ b/configure @@ -0,0 +1,110 @@ +#!/bin/sh +VERSION=1.1.0 +VERSION_FULL=${VERSION}$(./version.sh) +PREFIX="${PREFIX:-/usr/local}" +BINDIR="${BINDIR:-${PREFIX}/bin}" +MANDIR="${MANDIR:-${PREFIX}/share/man}" +DOCDIR="${DOCDIR:-${PREFIX}/share/doc/badwolf-${VERSION}}" +DATADIR="${DATADIR:-${PREFIX}/share/badwolf}" +APPSDIR="${APPSDIR:-${PREFIX}/share/applications}" + +PKGCONFIG="${PKGCONFIG:-pkg-config}" +MSGFMT="${MSGFMT:-msgfmt}" +INKSCAPE="${INKSCAPE:-inkscape}" +CC="${CC:-cc}" +CFLAGS="${CFLAGS:--g -O2 -pie -fPIE} -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla ${EXTRA_CFLAGS}" + +DEPS="gtk+-3.0 libxml-2.0" + +is_ok() { + status="$?" + + if test "$status" == 0; then + printf " OK\n" + else + printf " FAIL\n" + fi + + return $status +} + +required() { + is_ok || exit 1 +} + +pkg_config_check() { + printf 'Checking: %s %s ...' "${PKGCONFIG}" "$*" + "${PKGCONFIG}" "$@" + is_ok +} + +printf 'Checking %s command existance ...' "${PKGCONFIG}" +command -v "${PKGCONFIG}" >/dev/null ; required + +printf 'Checking %s command existance ...' "${CC}" +command -v "${CC}" >/dev/null ; required + +for dep in ${DEPS} +do + pkg_config_check --exists "$dep" || exit 1 +done + +case "${WITH_WEBKITGTK}n" in + 4.1n) + pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.1 || exit 1 + DEPS="${DEPS} webkit2gtk-4.1 libsoup-3.0" + ;; + 4.0n) + pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.0 || exit 1 + DEPS="${DEPS} webkit2gtk-4.0 libsoup-2.4" + ;; + n) + echo "warning: Packagers should specify the ABI version (4.0 or 4.1) in WITH_WEBKITGTK" >&2 + if pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.1 + then + DEPS="${DEPS} webkit2gtk-4.1 libsoup-3.0" + else + pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.0 || exit 1 + DEPS="${DEPS} webkit2gtk-4.0 libsoup-2.4" + fi + ;; + *) + echo "error: invalid webkit2gtk version in WITH_WEBKITGTK environment variable, must be 4.0 or 4.1" >&2 + exit 1 + ;; +esac + +get_cflags() { "${PKGCONFIG}" --cflags "${DEPS}"; } +DEPS_cflags="$(get_cflags)" +get_libs() { "${PKGCONFIG}" --libs "${DEPS}"; } +DEPS_libs="$(get_libs)" + +ICON_SIZES="$(for i in 24 32 48 64 128 256; do printf 'icons/hicolor/%sx%s/apps/badwolf.png ' $i $i ; done)" + +printf 'Writing to config.mk ...' +cat >config.mk </dev/null) -branch=$(git --git-dir="$(dirname $0)/.git" rev-parse --abbrev-ref HEAD | sed -r 's/.*[^0-9A-Za-z-]([0-9A-Za-z-]*)$/\1/g') - -if [ -n "$hash" ] || [ -n "$branch" ] +if command -v git 2>/dev/null >/dev/null then - printf '+g%s.%s' "$hash" "$branch" + hash=$(git --git-dir="$(dirname $0)/.git" rev-parse --short HEAD 2>/dev/null) + branch=$(git --git-dir="$(dirname $0)/.git" rev-parse --abbrev-ref HEAD 2>/dev/null | sed -r 's/.*[^0-9A-Za-z-]([0-9A-Za-z-]*)$/\1/g') + + if [ -n "$hash" ] || [ -n "$branch" ] + then + printf '+g%s.%s' "$hash" "$branch" + fi fi echo -- cgit v1.3.1-23-gd82d From 7e0b7516625bc94bf0734890ba07c5b2f7bc36f2 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Wed, 29 Sep 2021 07:06:42 +0200 Subject: Hook and fixup Vietnamese translation $ make [...] msgfmt -o locale/vi/LC_MESSAGES/Badwolf.mo po/vi.po po/vi.po:106: 'msgid' and 'msgstr' entries do not both end with '\n' po/vi.po:162: 'msgid' and 'msgstr' entries do not both end with '\n' msgfmt: found 2 fatal errors $ --- Makefile | 2 +- po/vi.po | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b8d8e3e..328da17 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ OBJS = bookmarks.o uri.o keybindings.o downloads.o badwolf.o OBJS_test = uri_test.o EXE = badwolf EXE_test = uri_test -TRANS = fr.mo pt_BR.mo tr.mo de.mo +TRANS = fr.mo pt_BR.mo tr.mo de.mo vi.mo DOCS = usr.bin.badwolf README.md KnowledgeBase.md interface.txt all: config.mk $(EXE) $(TRANS) po/messages.pot diff --git a/po/vi.po b/po/vi.po index ecbb253..b4e4ed8 100644 --- a/po/vi.po +++ b/po/vi.po @@ -103,7 +103,7 @@ msgstr "Bắt đầu tải xuống…" #: badwolf.c:413 msgid "Error: Some unknown error occurred validating the certificate.\n" -msgstr "Lỗi: Có một lỗi không xác định đã xảy ra khi đang hợp lệ hoá chứng thực." +msgstr "Lỗi: Có một lỗi không xác định đã xảy ra khi đang hợp lệ hoá chứng thực.\n" #: badwolf.c:394 msgid "Error: The X509 Certificate Authority is unknown.\n" @@ -159,7 +159,7 @@ msgstr "Phiên bản Badwolf đang chạy: %s\n" #: badwolf.c:1039 #, c-format msgid "Runtime WebKit version: %d.%d.%d\n" -msgstr "Phiên bản WebKit tại thời điểm chạy: %d.%d.%d" +msgstr "Phiên bản WebKit tại thời điểm chạy: %d.%d.%d\n" #: badwolf.c:437 #, c-format -- cgit v1.3.1-23-gd82d From dd3e46487b980fd0f2b9aa017b27e1af2f2bd07a Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 1 Oct 2021 21:19:58 +0200 Subject: Make: Add manpage linting mandb / GNU groff seems to have less tolerance than mandoc for rendering slightly broken manpages, which is rather annoying in my case. --- Makefile | 1 + README.md | 4 +++- configure | 11 +++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 328da17..0ff8b3d 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ uri_test: uri.o uri_test.o .PHONY: test test: $(EXE_test) + $(MANDOC) -Tlint -Wunsupp,error,warning ./badwolf.1 .PHONY: install install: all diff --git a/README.md b/README.md index 5f61b0a..e5205e1 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,14 @@ You need to have gettext installed. If you want a GUI, poedit exists and Weblate ## Manual Installation Dependencies are: +- POSIX-compatible Shell (ie. mrsh, dash, lksh) - C11 Compiler (such as clang or gcc) - [WebKitGTK](https://webkitgtk.org/), only the latest stable(2.32.0+) is supported - [libxml-2.0](http://www.xmlsoft.org/), no known version limitation - POSIX make with extension for shell in variables (works with GNU, {Net,Free,Open}BSD) - A pkg-config implementation (pkgconf is recommended) -- (optionnal) gettext implementation (such as GNU Gettext) +- (optional) gettext implementation (such as GNU Gettext) +- (optional, test) [mandoc](https://mdocml.bsd.lv/) (the command) for linting the manpage Compilation is done with `./configure && make`, install with `make install` (`DESTDIR` and `PREFIX` environment variables are supported, amongs other common ones). An example AppArmor profile is provided at `usr.bin.badwolf`, please do some long runtime checks before shipping it or a modified version, help can be provided but with no support. diff --git a/configure b/configure index c5fe4a8..b3e179a 100755 --- a/configure +++ b/configure @@ -13,6 +13,7 @@ MSGFMT="${MSGFMT:-msgfmt}" INKSCAPE="${INKSCAPE:-inkscape}" CC="${CC:-cc}" CFLAGS="${CFLAGS:--g -O2 -pie -fPIE} -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla ${EXTRA_CFLAGS}" +MANDOC="mandoc" DEPS="gtk+-3.0 libxml-2.0" @@ -44,6 +45,15 @@ command -v "${PKGCONFIG}" >/dev/null ; required printf 'Checking %s command existance ...' "${CC}" command -v "${CC}" >/dev/null ; required +printf 'Checking %s command existance ...' "${MANDOC}" +if command -v "${CC}" >/dev/null ; is_ok +then + : +else + MANDOC="true" +fi + + for dep in ${DEPS} do pkg_config_check --exists "$dep" || exit 1 @@ -100,6 +110,7 @@ CC = ${CC} INKSCAPE = ${INKSCAPE} MSGFMT = ${MSGFMT} DBG = ${DBG} +MANDOC = ${MANDOC} CFLAGS = ${CFLAGS} -DDATADIR=\"\${DATADIR}\" -DPACKAGE=\"\${PACKAGE}\" -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"\${VERSION_FULL}\" ${DEPS_cflags} LIBS = ${DEPS_libs} -- cgit v1.3.1-23-gd82d