diff --git a/README.md b/README.md index 0143fd07..96f38781 100644 --- a/README.md +++ b/README.md @@ -12,17 +12,16 @@ License: ISC, see [COPYING](./COPYING) for details. ## Dependencies * All configurations and builds: + - C compiler, linker etc. + - [Python](http://python.org/) + - [Meson](https://en.wikipedia.org/wiki/Meson_(software)) and [ninja](https://en.wikipedia.org/wiki/Ninja_(build_system)) + - Alternately, Autotools can be used instead but they are now considered deprecated. - [json-c](https://github.com/json-c/json-c/wiki) (>= 0.11) - - C compiler, `make` etc. -* Most configurations (all except `--disable-introspection --without-glib`): + - [gettext](https://www.gnu.org/software/gettext/gettext.html) (unless `-Di18n=disabled`) +* Most configurations (all except `-Dintrospection=disabled -Dglib=disabled`): - [GObject-Introspection](https://live.gnome.org/GObjectIntrospection) - [GLib](https://wiki.gnome.org/Projects/GLib) -* When building from `git` (developer package names vary by distribution): - - [Python](http://python.org/) - - [autotools](https://en.wikipedia.org/wiki/GNU_Build_System) - - [intltool](https://freedesktop.org/wiki/Software/intltool/) - - [gettext](https://www.gnu.org/software/gettext/gettext.html) -* For `--enable-gegl` (GIMP *does not* require this): +* For `-Dgegl=enabled` (GIMP *does not* require this): - [GEGL + BABL](http://gegl.org/) ### Install dependencies (Debian and derivatives) @@ -30,10 +29,10 @@ License: ISC, see [COPYING](./COPYING) for details. On recent Debian-like systems, you can type the following to get started with a standard configuration: - # apt install -y build-essential + # apt install -y build-essential meson # apt install -y libjson-c-dev libgirepository1.0-dev libglib2.0-dev -When building from git: +Additionally, when using the deprecated Autotools build system: # apt install -y python autotools-dev intltool gettext libtool @@ -44,11 +43,11 @@ You might also try using your package manager: ### Install dependencies (Red Hat and derivatives) -The following works on a minimal CentOS 7 installation: +The following should works on a minimal CentOS 7 installation: - # yum install -y gcc gobject-introspection-devel json-c-devel glib2-devel + # yum install -y gcc meson gobject-introspection-devel json-c-devel glib2-devel -When building from git, you'll want to add: +Additionally, when using the deprecated Autotools build system: # yum install -y git python autoconf intltool gettext libtool @@ -60,9 +59,9 @@ You might also try your package manager: Works with a fresh OpenSUSE Tumbleweed Docker image: - # zypper install gcc13 gobject-introspection-devel libjson-c-devel glib2-devel + # zypper install gcc13 meson gobject-introspection-devel libjson-c-devel glib2-devel -When building from git: +Additionally, when using the deprecated Autotools build system: # zypper install git python311 autoconf intltool gettext-tools libtool @@ -72,61 +71,53 @@ Package manager: ## Build and install +You can use [Meson](https://mesonbuild.com/) build system. + + $ meson setup _build --prefix=/usr + $ meson compile -C _build + # meson install -C _build + # ldconfig + MyPaint and libmypaint benefit dramatically from autovectorization and other compiler optimizations. -You may want to set your CFLAGS before compiling (for gcc): +You may want to set your CFLAGS before compiling (for gcc) by passing something like the following as an argument to `meson setup`: - $ export CFLAGS='-Ofast -ftree-vectorize -fopt-info-vec-optimized -march=native -mtune=native -funsafe-math-optimizations -funsafe-loop-optimizations' + -Dc_args='-Ofast -ftree-vectorize -fopt-info-vec-optimized -march=native -mtune=native -funsafe-math-optimizations -funsafe-loop-optimizations' -The traditional setup works just fine. +Alternately, you can use the traditional Autotools build system for now (it is deprecated and will be eventually removed): - $ ./autogen.sh # Only needed when building from git. + $ ./autogen.sh $ ./configure # make install # ldconfig -### Maintainer mode - -We don't ship a `configure` script in our git repository. If you're -building from git, you have to kickstart the build environment with: - - $ git clone https://github.com/mypaint/libmypaint.git - $ cd libmypaint - $ ./autogen.sh - -This script generates `configure` from `configure.ac`, after running a -few checks to make sure your build environment is broadly OK. It also -regenerates certain important generated headers if they need it. - -Folks building from a release tarball don't need to do this: they will -have a `configure` script from the start. - ### Configure - $ ./configure - $ ./configure --prefix=/tmp/junk/example +Meson requires out-of-tree builds so you need to specify a build directory. -There are several MyPaint-specific options. -These can be shown by running + $ meson setup _build + $ meson setup _build --prefix=/tmp/junk/example - $ ./configure --help +In addition to to [Meson options](https://mesonbuild.com/Builtin-options.html#compiler-options), there are several libmypaint-specific options, see `meson_options.txt` file for details. + + $ meson setup _build -Dgegl=disabled -Ddocs=true -Di18n=enabled ### Build - $ make + $ meson compile -C _build Once MyPaint is built, you can run the test suite and/or install it. ### Test - $ make check + $ meson test -C _build This runs all the unit tests. ### Install - # make install + # meson install -C _build -Uninstall libmypaint with `make uninstall`. +Uninstall libmypaint with `meson uninstall -C _build`. ### Check availability @@ -172,11 +163,7 @@ for details of how you can begin contributing. The distribution release can be generated with: - $ make dist - -And it should be checked before public release with: - - $ make distcheck + $ meson dist -C _build ## Localization @@ -198,7 +185,7 @@ in `po/POTFILES.in`. You can update the .po files when translated strings in the code change using: - $ cd po && make update-po + $ meson compile -C _build update-po When the results of this are pushed, Weblate translators will see the new strings immediately. diff --git a/po/README.md b/po/README.md index aca2d611..66366acd 100644 --- a/po/README.md +++ b/po/README.md @@ -16,7 +16,7 @@ We use [GNU gettext][gettext] for runtime translation of program text. ## After updating program strings After changing any string in the source text which makes use of the -gettext macros, you will need to run `./po/update_translation.sh` +gettext macros, you will need to run `meson compile -C _build update-po` and then commit the modified `po/libmypaint.pot` and `po/*.po` files along with your changes. Keeping this generated template file in the distribution @@ -26,7 +26,7 @@ without having to ask us. if all you want to do is compare diffs, the `.pot` file alone can be updated by running: ``` -./po/update_translations.sh --only-template +meson compile -C _build libmypaint.pot ``` # Information for translators @@ -63,18 +63,16 @@ Before working on a translation, update the `.po` file for your language. For example, for the French translation, run: - ./po/update_translations.sh fr + meson compile -C _build update-po-fr ## Use/Test the translation After modifying the translation, you need to rebuild and reinstall libmypaint to see the effect in MyPaint, or in other apps that use `libmypaint`. -If you have already built it, and `make install` does what you want, -you can just use: +If you have already built it, you can just use: - make - make install + meson install -C _build To run MyPaint with a specific translation on Linux, you can use the LANG environment variable diff --git a/po/update_translations.sh b/po/update_translations.sh deleted file mode 100755 index 1d0b919b..00000000 --- a/po/update_translations.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env bash - -update_translations() -{ - cd $(dirname "$1") - local HELP - HELP="\ -==== -Update translation files: generated sources / po template / po language files -Usage: $1 [--force] [[--only-template] | [LANG...]] - -If no languages are specified, and --only-template is not set, all .po files in -the directory will be updated, same as running: $1 *.po -==== -" - shift - - sec() { date -r "$1" "+%s"; } - err() { >&2 echo -e "\e[91m""Error: $@""\e[0m"; } - print_errors() - { - for e in "$@" - do - err "$e" - done - } - - local ORIG GEN_SRC ENUM GEN TEMPLATE FORCE ONLY_TEMPLATE - ORIG=../brushsettings.json - GEN_SRC=../brushsettings-gen.h - ENUM=../mypaint-brush-settings-gen.h - GEN_SCRIPT=../generate.py - TEMPLATE=libmypaint.pot - - local langs errors - langs=() - errors=() - - while [ -n "$1" ] - do - case "$1" in - --help) - echo "$HELP" && exit 0 - ;; - --force) - FORCE=1 - ;; - --only-template) - ONLY_TEMPLATE=1 - ;; - -*) - errors+=("Unrecognized option: $1") - ;; - *) - local f - f="${1%%.po}.po" - if [ ! -e "$f" ] - then - errors+=("Not found: $f - LANG must be the code or .po file for an existing language") - else - langs+=("$f") - fi - ;; - esac - shift - done - - # Sanity check - if [ -n "$ONLY_TEMPLATE" -a -n "$langs" ] - then - errors+=("Don't specify languages when using ``--only-template``") - fi - # Print usage instructions followed by error message(s) - [ -n "$errors" ] && >&2 echo "$HELP" && print_errors "${errors[@]}" && exit 1 - - # Check if the message source file needs to be (re)generated. - # ( generated source: not present,older than basis, older than script ) - if [ -n "$FORCE" -o ! -e "$GEN_SRC" -o \ - $(sec "$GEN_SRC") -lt $(sec "$ORIG") -o \ - $(sec "$GEN_SRC") -lt $(sec "$GEN_SCRIPT") ] - then - [ -z "$FORCE" ] && - echo "Generated file missing or out of date, generating..." || - echo "Generating (forced)..." - python "$GEN_SCRIPT" "$ENUM" "$GEN_SRC" || - (echo "Failed to generate source file!" && exit 1) - fi - - # Check if the template file appears up to date - if [ -z "$FORCE" -a -e "$TEMPLATE" -a $(sec "$GEN_SRC") -lt $(sec "$TEMPLATE") ] - then - echo "$TEMPLATE up to date, skipping extraction (use --force to override)." - else - local temp_template temp_diff - temp_template=$(mktemp) - temp_diff=$(mktemp) - # Omit locations from the generated file, and instead... - xgettext --no-location -c -kN_:1 -o - "$GEN_SRC" | - # ...transform special generated comments into accurate source locations. - sed -E "s@^#\. (: $ORIG:.*)@#\1@" > "$temp_template" - # Don't update template if the only change is the creation date - diff --suppress-common-lines -y "$TEMPLATE" "$temp_template" > "$temp_diff" - if [ $(wc -l < "$temp_diff") -eq 1 -a - $(grep -i -o "POT-Creation-Date" "$temp_diff" | wc -l) -eq 2 ] - then - echo "$TEMPLATE unchanged" - else - mv "$temp_template" "$TEMPLATE" && echo "$TEMPLATE updated." - fi - fi - - # If requested, don't update any languages - [ -n "$ONLY_TEMPLATE" ] && exit 0 - - # If no languages are specified, try to update all of them - if [ -z "${langs[*]}" ] - then - langs=($(ls *.po)) - fi - - local failed_updates - failed_updates=() - - # Update the language files based on the template - for lang in "${langs[@]}" - do - msgmerge -q -U "$lang" "$TEMPLATE" || failed_updates+=("$lang") - done - - echo "Successfully processed $((${#langs[@]} - ${#failed_updates[@]})) language files." - if [ -n "${failed_updates[*]}" ] - then - err "Failed to update ${#failed_updates[@]} language files:" - for f in "${failed_updates[@]}" - do - err "$f" - done - exit 1 - fi -} - -update_translations "$0" "$@"