diff --git a/.gitignore b/.gitignore index d56a6b60..8ed74fc7 100644 --- a/.gitignore +++ b/.gitignore @@ -54,55 +54,13 @@ Module.symvers Mkfile.old dkms.conf -## From: https://github.com/github/gitignore/blob/master/Autotools.gitignore -# http://www.gnu.org/software/automake - -Makefile.in -/ar-lib -/mdate-sh -/py-compile -/test-driver -/ylwrap - -# http://www.gnu.org/software/autoconf - -autom4te.cache -/autoscan.log -/autoscan-*.log -/aclocal.m4 -/compile -/config.guess -/config.h.in -/config.log -/config.status -/config.sub -/configure -/configure.scan -/depcomp -/install-sh -/missing -/stamp-h1 - -# https://www.gnu.org/software/libtool/ - -/ltmain.sh - # http://www.gnu.org/software/texinfo /texinfo.tex -# http://www.gnu.org/software/m4/ - -m4/libtool.m4 -m4/ltoptions.m4 -m4/ltsugar.m4 -m4/ltversion.m4 -m4/lt~obsolete.m4 - ## Redshift specific: # generated files /ABOUT-NLS -/config.rpath /contrib/redshift.spec /data/apparmor/usr.bin.redshift /data/appdata/redshift-gtk.appdata.xml @@ -110,23 +68,7 @@ m4/lt~obsolete.m4 /data/applications/redshift-gtk.desktop /data/systemd/redshift.service /data/systemd/redshift-gtk.service -/m4 /src/redshift /src/redshift-gtk/defs.py /src/redshift-gtk/redshift-gtk /src/redshift-gtk/__pycache__/ - -# gettext -/po/POTFILES -/po/stamp-po -/po/stamp-it -/po/*.gmo -/po/Makefile.in.in -/po/Rules-quot -/po/boldquot.sed -/po/Makevars.template -/po/en@boldquot.header -/po/en@quot.header -/po/insert-header.sin -/po/quot.sed -/po/remove-potcdate.sin diff --git a/.travis.yml b/.travis.yml index cc0d35d3..b1298fbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,17 +4,14 @@ language: c matrix: include: - os: linux + dist: xenial compiler: gcc - dist: trusty - sudo: false - os: osx compiler: clang addons: apt: packages: - - autopoint - - intltool # DRM - libdrm-dev # RANDR @@ -25,30 +22,50 @@ addons: - libxxf86vm-dev # GeoClue2 - libglib2.0-dev - # GUI - - python3 - -before_install: | - if [ "$TRAVIS_OS_NAME" == "osx" ]; then - brew update - brew install gettext - brew link --force gettext - brew install intltool - fi install: - - ./bootstrap - - mkdir "$TRAVIS_BUILD_DIR/root" + - | + if [ "$TRAVIS_OS_NAME" == "osx" ]; then + # Enable gettext + export PATH=/usr/local/opt/gettext/bin:$PATH + fi - | if [ "$TRAVIS_OS_NAME" == "linux" ]; then - ./configure --prefix="$TRAVIS_BUILD_DIR/root" --enable-drm --enable-vidmode --enable-randr --enable-geoclue2 --enable-gui --enable-apparmor - elif [ "$TRAVIS_OS_NAME" == "osx" ]; then - ./configure --prefix="$TRAVIS_BUILD_DIR/root" --enable-corelocation --enable-quartz --enable-gui + # Set PATH to use Python 3.7 (already installed) and Meson + export PATH=~/virtualenv/python3.7/bin:$PATH + fi + # This version of Meson is already tested. + - pip3 install ninja meson==0.54.2 + +before_script: + - | + if [ "$TRAVIS_OS_NAME" == "linux" ]; then + CONF_FLAGS="--prefix=$TRAVIS_BUILD_DIR/root" + CONF_FLAGS="$CONF_FLAGS -Ddrm=enabled -Drandr=enabled" + CONF_FLAGS="$CONF_FLAGS -Dvidmode=enabled -Dquartz=disabled" + CONF_FLAGS="$CONF_FLAGS -Dwingdi=disabled -Dgeoclue2=enabled" + CONF_FLAGS="$CONF_FLAGS -Dcorelocation=disabled -Dgui=enabled" + CONF_FLAGS="$CONF_FLAGS -Dubuntu=disabled -Dapparmor=enabled" + CONF_FLAGS="$CONF_FLAGS -Dsystemduserunitdir=$TRAVIS_BUILD_DIR/root/lib/systemd/user" + export CONF_FLAGS + fi + - | + if [ "$TRAVIS_OS_NAME" == "osx" ]; then + CONF_FLAGS="--prefix=$TRAVIS_BUILD_DIR/root" + CONF_FLAGS="$CONF_FLAGS -Ddrm=disabled -Drandr=disabled" + CONF_FLAGS="$CONF_FLAGS -Dvidmode=disabled -Dquartz=enabled" + CONF_FLAGS="$CONF_FLAGS -Dwingdi=disabled -Dgeoclue2=disabled" + CONF_FLAGS="$CONF_FLAGS -Dcorelocation=enabled -Dgui=disabled" + CONF_FLAGS="$CONF_FLAGS -Dubuntu=disabled -Dapparmor=disabled" + export CONF_FLAGS fi - - make -j2 install - - make -j2 distcheck script: + - meson $CONF_FLAGS _build + - ninja -v -C _build install + - ninja -v -C _build test + - ninja -v -C _build dist + # redshift tests - | "$TRAVIS_BUILD_DIR"/root/bin/redshift -l 12:-34 -pv - | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c8a29e75..55714fbd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,39 +3,37 @@ Building from git clone ----------------------- ``` shell -$ ./bootstrap -$ ./configure +$ meson ([options...]) _build ``` -The bootstrap script will use autotools to set up the build environment -and create the `configure` script. +Meson sets up the build environment and create a build directory named `_build`. -Use `./configure --help` for options. Use `--prefix` to make an install in +See `meson_options.txt` for options. Use `--prefix` to make an install in your home directory. This is necessary to test python scripts. The systemd user unit directory should be set to avoid writing to the system location. Systemd will look for the unit files in `~/.config/systemd/user` so this directory can be used as a target if the unit files will be used. Otherwise -the location can be set to `no` to disable the systemd files. +the location can be set to `disabled` to disable the systemd files. Example: ``` shell -$ ./configure --prefix=$HOME/redshift/root \ - --with-systemduserunitdir=$HOME/.config/systemd/user +$ meson --prefix=$HOME/redshift/root \ + -Dsystemduserunitdir=$HOME/.config/systemd/user ``` Now, build the files: ``` shell -$ make +$ ninja -C _build ``` The main redshift program can be run at this point. To install to the prefix directory run: ``` shell -$ make install +$ ninja -C _build install ``` You can now run the python script. Example: @@ -48,8 +46,9 @@ $ $HOME/redshift/root/bin/redshift-gtk Dependencies ------------ -* autotools, gettext -* intltool, libtool +* Meson (>= 0.47.0) +* gettext (>= 0.19.7) +* Ninja (>= 1.5) * libdrm (Optional, for DRM support) * libxcb, libxcb-randr (Optional, for RandR support) * libX11, libXxf86vm (Optional, for VidMode support) @@ -138,8 +137,8 @@ Creating a new release 3. Apply any bugfixes for release 4. Import updated translations from launchpad and commit. Remember to update `po/LINGUAS` if new languages were added -5. Update version in `configure.ac` and create entry in NEWS -6. Run `make distcheck` +5. Update version in `meson.build` and create entry in NEWS +6. Run `ninja -C _build dist` 7. Commit and tag release (`vX.Y` or `vX.Y.Z`) 8. Push tag to Github and also upload source dist file to Github @@ -152,7 +151,7 @@ Also remember to check before release that Build Fedora RPMs ----------------- -Run `make dist-xz` and copy the `.tar.xz` file to `~/rpmbuild/SOURCES`. Then run +Run `ninja -C _build dist` and copy the `.tar.xz` file to `~/rpmbuild/SOURCES`. Then run ``` shell $ rpmbuild -ba contrib/redshift.spec @@ -164,13 +163,14 @@ If successful this will place RPMs in `~/rpmbuild/RPMS`. Cross-compile for Windows ------------------------- -Install MinGW and run `configure` using the following command line. Use -`i686-w64-mingw32` as host for 32-bit builds. +Install mingw-w64 and run `meson` using the following command line. ``` shell -$ ./configure --disable-drm --disable-randr --disable-vidmode --enable-wingdi \ - --disable-quartz --disable-geoclue2 --disable-corelocation --disable-gui \ - --disable-ubuntu --host=x86_64-w64-mingw32 +(Win64) +$ meson --cross-file build-win64.txt _build + +(Win32) +$ meson --cross-file build-win32.txt _build ``` diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 7e58f082..00000000 --- a/Makefile.am +++ /dev/null @@ -1,141 +0,0 @@ - -SUBDIRS = src po -ACLOCAL_AMFLAGS = -I m4 - -# Install systemd user unit files locally for distcheck -DISTCHECK_CONFIGURE_FLAGS = \ - --with-systemduserunitdir=$$dc_install_base/$(systemduserunitdir) - -UPDATE_ICON_CACHE = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor || : - -EXTRA_ROOTDOC_FILES = \ - CONTRIBUTING.md \ - DESIGN \ - README \ - README-colorramp \ - redshift.conf.sample - -_HICOLOR_FILES = \ - data/icons/hicolor/scalable/apps/redshift.svg \ - data/icons/hicolor/scalable/apps/redshift-status-on.svg \ - data/icons/hicolor/scalable/apps/redshift-status-off.svg - -_UBUNTU_MONO_DARK_FILES = \ - data/icons/ubuntu-mono-dark/scalable/apps/redshift-status-on.svg \ - data/icons/ubuntu-mono-dark/scalable/apps/redshift-status-off.svg - -_UBUNTU_MONO_LIGHT_FILES = \ - data/icons/ubuntu-mono-light/scalable/apps/redshift-status-on.svg \ - data/icons/ubuntu-mono-light/scalable/apps/redshift-status-off.svg - -DESKTOP_IN_FILES = \ - data/applications/redshift.desktop.in \ - data/applications/redshift-gtk.desktop.in - -SYSTEMD_USER_UNIT_IN_FILES = \ - data/systemd/redshift.service.in \ - data/systemd/redshift-gtk.service.in - -APPDATA_IN_FILES = \ - data/appdata/redshift-gtk.appdata.xml.in - -APPARMOR_IN_FILES = \ - data/apparmor/usr.bin.redshift.in - - -# Icons -if ENABLE_GUI -hicolor_icondir = @datadir@/icons/hicolor/scalable/apps -hicolor_icon_DATA = $(_HICOLOR_FILES) - -if ENABLE_UBUNTU -ubuntu_mono_dark_icondir = @datadir@/icons/ubuntu-mono-dark/scalable/apps -ubuntu_mono_dark_icon_DATA = $(_UBUNTU_MONO_DARK_FILES) - -ubuntu_mono_light_icondir = @datadir@/icons/ubuntu-mono-light/scalable/apps -ubuntu_mono_light_icon_DATA = $(_UBUNTU_MONO_LIGHT_FILES) -endif -endif - - -# Desktop file -if ENABLE_GUI -desktopdir = @datadir@/applications -desktop_DATA = $(DESKTOP_IN_FILES:.desktop.in=.desktop) -endif - -if ENABLE_GUI -install-data-hook: - $(UPDATE_ICON_CACHE); - -uninstall-hook: - $(UPDATE_ICON_CACHE); - -# We would preferable use @INTLTOOL_DESKTOP_RULE@ here but -# sadly it is broken for out-of-tree builds. -%.desktop: %.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) - $(AM_V_GEN)$(MKDIR_P) $(@D); - $(INTLTOOL_V_MERGE)LC_ALL=C $(INTLTOOL_MERGE) $(INTLTOOL_V_MERGE_OPTIONS) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@ -endif - - -# man page -dist_man1_MANS = redshift.1 - - -# Systemd service files -if ENABLE_SYSTEMD -systemduserunit_DATA = $(SYSTEMD_USER_UNIT_IN_FILES:.service.in=.service) -endif - -$(systemduserunit_DATA): $(SYSTEMD_USER_UNIT_IN_FILES) Makefile - $(AM_V_GEN)$(MKDIR_P) $(@D) && \ - sed -e "s|\@bindir\@|$(bindir)|g" "$(srcdir)/$(@:.service=.service.in)" > $@ - - -# Appdata file -if ENABLE_GUI -appdatadir = @datadir@/appdata -appdata_DATA = $(APPDATA_IN_FILES:.xml.in=.xml) - -# We would preferable use @INTLTOOL_XML_RULE@ here but -# sadly it is broken for out-of-tree builds. -%.xml: %.xml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) - $(AM_V_GEN)$(MKDIR_P) $(@D); - $(INTLTOOL_V_MERGE)LC_ALL=C $(INTLTOOL_MERGE) $(INTLTOOL_V_MERGE_OPTIONS) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@ -endif - - -# AppArmor profile -if ENABLE_APPARMOR -apparmordir = @sysconfdir@/apparmor.d -apparmor_DATA = $(APPARMOR_IN_FILES:.in=) - -$(apparmor_DATA): $(APPARMOR_IN_FILES) Makefile - $(AM_V_GEN)$(MKDIR_P) $(@D) && \ - sed -e "s|\@bindir\@|$(bindir)|g" "$(srcdir)/$(@:=.in)" > $@ -endif - - - -EXTRA_DIST = \ - $(EXTRA_ROOTDOC_FILES) \ - $(_HICOLOR_FILES) \ - $(_UBUNTU_MONO_DARK_FILES) \ - $(_UBUNTU_MONO_LIGHT_FILES) \ - $(DESKTOP_IN_FILES) \ - $(SYSTEMD_USER_UNIT_IN_FILES) \ - $(APPDATA_IN_FILES) \ - $(APPARMOR_IN_FILES) - -CLEANFILES = \ - $(desktop_DATA) \ - $(systemduserunit_DATA) \ - $(appdata_DATA) \ - $(apparmor_DATA) - - -# Update PO translations -.PHONY: update-po -update-po: - cd po && $(MAKE) POTFILES redshift.pot update-po diff --git a/appveyor.yml b/appveyor.yml index 0ac39835..73f5b61d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,26 +4,36 @@ image: environment: matrix: - arch: x86_64 + PATH: C:\Python37;C:\Python37\scripts;C:\msys64\mingw64\bin;%PATH%; - arch: i686 + PATH: C:\Python37;C:\Python37\scripts;C:\msys64\mingw32\bin;%PATH%; build: verbosity: detailed -build_script: +install: +- ps: | + Start-FileDownload "https://raw.githubusercontent.com/mesonbuild/cidata/e5ea5b021d8144515a1b8f576cda327e45a81235/ninja.exe" + # This version of Meson is already tested. +- pip3 install meson==0.54.2 + +before_build: - ps: | - If ($env:arch -Match "x86_64") { - $env:MSYSTEM = "MINGW64" - } Else { - $env:MSYSTEM = "MINGW32" - } + $env:CONF_FLAGS = "--prefix=${env:APPVEYOR_BUILD_FOLDER}\root" + $env:CONF_FLAGS += " -Ddrm=disabled -Drandr=disabled -Dvidmode=disabled" + $env:CONF_FLAGS += " -Dwingdi=enabled -Dquartz=disabled" + $env:CONF_FLAGS += " -Dgeoclue2=disabled -Dcorelocation=disabled" + $env:CONF_FLAGS += " -Dgui=disabled -Dubuntu=disabled -Dnls=disabled" - $env:CONFIGURE_FLAGS = "--disable-drm --disable-randr --disable-vidmode --enable-wingdi --disable-quartz --disable-geoclue2 --disable-corelocation --disable-gui --disable-ubuntu --disable-nls --host=$env:arch-w64-mingw32" + # For Ninja + $env:PATH = "${env:APPVEYOR_BUILD_FOLDER};${env:PATH};" +build_script: - ps: md (Join-Path $env:APPVEYOR_BUILD_FOLDER root) -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./bootstrap" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./configure --prefix=\"$APPVEYOR_BUILD_FOLDER/root\" $CONFIGURE_FLAGS" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && make distcheck DISTCHECK_CONFIGURE_FLAGS=\"$CONFIGURE_FLAGS\"" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && make install" +- meson %CONF_FLAGS% _build && + ninja -C _build install && + ninja -C _build test && + ninja -C _build dist test_script: - | diff --git a/bootstrap b/bootstrap deleted file mode 100755 index 0599cf5f..00000000 --- a/bootstrap +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# change to root directory -cd $(dirname "$0") - -autopoint --force && \ - AUTOPOINT="intltoolize --automake --copy" autoreconf --force --install --verbose diff --git a/build-win32.txt b/build-win32.txt new file mode 100644 index 00000000..e1155330 --- /dev/null +++ b/build-win32.txt @@ -0,0 +1,15 @@ +[binaries] +c = 'i686-w64-mingw32-gcc' +ar = 'i686-w64-mingw32-ar' +strip = 'i686-w64-mingw32-strip' +windres = 'i686-w64-mingw32-windres' +exe_wrapper = 'wine' + +[properties] +c_link_args = ['-static', '-static-libgcc'] + +[host_machine] +system = 'windows' +cpu_family = 'x86' +cpu = 'x86' +endian = 'little' diff --git a/build-win64.txt b/build-win64.txt new file mode 100644 index 00000000..9ea2c5dc --- /dev/null +++ b/build-win64.txt @@ -0,0 +1,15 @@ +[binaries] +c = 'x86_64-w64-mingw32-gcc' +ar = 'x86_64-w64-mingw32-ar' +strip = 'x86_64-w64-mingw32-strip' +windres = 'x86_64-w64-mingw32-windres' +exe_wrapper = 'wine' + +[properties] +c_link_args = ['-static', '-static-libgcc'] + +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' diff --git a/configure.ac b/configure.ac deleted file mode 100644 index b4116262..00000000 --- a/configure.ac +++ /dev/null @@ -1,392 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.69]) -AC_INIT([redshift], [1.12], [https://github.com/jonls/redshift/issues]) -AC_CONFIG_SRCDIR([src/redshift.c]) -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([foreign subdir-objects dist-xz]) - -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -# Checks for programs. -AC_PROG_CC_C99 -AC_PROG_LIBTOOL -AC_PROG_OBJC # For macOS support modules -AC_LANG([C]) - -AC_PROG_INTLTOOL([0.50]) - -AC_CANONICAL_HOST - -# Test host platform -build_windows=no -case "${host_os}" in - mingw*) - build_windows=yes - ;; -esac - -# Test whether to compile Windows resources -AC_CHECK_TOOL([WINDRES], [windres], []) -AS_IF([test "x$build_windows" = "xyes" -a -n "x$WINDRES"], [ - enable_windows_resource=yes -], [ - enable_windows_resource=no -]) -AM_CONDITIONAL([ENABLE_WINDOWS_RESOURCE], - [test "x$enable_windows_resource" = xyes]) - - -# Test whether Objective C compiler works -AC_MSG_CHECKING([whether Objective C compiler works]) -AC_LANG_PUSH([Objective C]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [ - AC_MSG_RESULT([yes]) - have_objc_compiler=yes -], [ - AC_MSG_RESULT([no]) - have_objc_compiler=no -]) -AC_LANG_POP([Objective C]) - -# Checks for libraries. -AM_GNU_GETTEXT_VERSION([0.17]) -AM_GNU_GETTEXT([external]) - -GETTEXT_PACKAGE=redshift -AC_SUBST(GETTEXT_PACKAGE) -AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Package name for gettext]) - - -PKG_CHECK_MODULES([DRM], [libdrm], [have_drm=yes], [have_drm=no]) - -PKG_CHECK_MODULES([X11], [x11], [have_x11=yes], [have_x11=no]) -PKG_CHECK_MODULES([XF86VM], [xxf86vm], [have_xf86vm=yes], [have_xf86vm=no]) -PKG_CHECK_MODULES([XCB], [xcb], [have_xcb=yes], [have_xcb=no]) -PKG_CHECK_MODULES([XCB_RANDR], [xcb-randr], - [have_xcb_randr=yes], [have_xcb_randr=no]) - -PKG_CHECK_MODULES([GLIB], [glib-2.0 gobject-2.0], [have_glib=yes], [have_glib=no]) -PKG_CHECK_MODULES([GEOCLUE2], [glib-2.0 gio-2.0 >= 2.26], [have_geoclue2=yes], [have_geoclue2=no]) - -# macOS headers -AC_CHECK_HEADER([ApplicationServices/ApplicationServices.h], [have_appserv_h=yes], [have_appserv_h=no]) - -# CoreLocation.h is an Objective C header. Only test if -# Objective C compiler works. AC_CHECK_HEADER does not -# appear to work if the Ojective C compiler is not -# available so we need a custom test. -AC_MSG_CHECKING([whether CoreLocation/CoreLocation.h is usable]) -AS_IF([test "x$have_objc_compiler" = xyes], [ - AC_LANG_PUSH([Objective C]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#import ]],[[]])], [ - AC_MSG_RESULT([yes]) - have_corelocation_h=yes - ], [ - AC_MSG_RESULT([no]) - have_corelocation_h=no - ]) - AC_LANG_POP([Objective C]) -], [ - AC_MSG_RESULT([no Objective C compiler available]) - have_corelocation_h=no -]) - -# Windows header -AC_CHECK_HEADER([windows.h], [have_windows_h=yes], [have_windows_h=no]) - -# Check for Python -AM_PATH_PYTHON([3.2], [have_python=yes], [have_python=no]) - -# Check DRM method -AC_MSG_CHECKING([whether to enable DRM method]) -AC_ARG_ENABLE([drm], [AC_HELP_STRING([--enable-drm], - [enable DRM method])], - [enable_drm=$enableval],[enable_drm=maybe]) -AS_IF([test "x$enable_drm" != xno], [ - AS_IF([test $have_drm = yes], [ - AC_DEFINE([ENABLE_DRM], 1, - [Define to 1 to enable DRM method]) - AC_MSG_RESULT([yes]) - enable_drm=yes - ], [ - AC_MSG_RESULT([missing dependencies]) - AS_IF([test "x$enable_drm" = xyes], [ - AC_MSG_ERROR([missing dependencies for DRM method]) - ]) - enable_drm=no - ]) -], [ - AC_MSG_RESULT([no]) - enable_drm=no -]) -AM_CONDITIONAL([ENABLE_DRM], [test "x$enable_drm" = xyes]) - -# Check RANDR method -AC_MSG_CHECKING([whether to enable RANDR method]) -AC_ARG_ENABLE([randr], [AC_HELP_STRING([--enable-randr], - [enable RANDR method])], - [enable_randr=$enableval],[enable_randr=maybe]) -AS_IF([test "x$enable_randr" != xno], [ - AS_IF([test $have_xcb = yes -a $have_xcb_randr = yes], [ - AC_DEFINE([ENABLE_RANDR], 1, - [Define to 1 to enable RANDR method]) - AC_MSG_RESULT([yes]) - enable_randr=yes - ], [ - AC_MSG_RESULT([missing dependencies]) - AS_IF([test "x$enable_randr" = xyes], [ - AC_MSG_ERROR([missing dependencies for RANDR method]) - ]) - enable_randr=no - ]) -], [ - AC_MSG_RESULT([no]) - enable_randr=no -]) -AM_CONDITIONAL([ENABLE_RANDR], [test "x$enable_randr" = xyes]) - -# Check VidMode method -AC_MSG_CHECKING([whether to enable VidMode method]) -AC_ARG_ENABLE([vidmode], [AC_HELP_STRING([--enable-vidmode], - [enable VidMode method])], - [enable_vidmode=$enableval],[enable_vidmode=maybe]) -AS_IF([test "x$enable_vidmode" != xno], [ - AS_IF([test $have_x11 = yes -a $have_xf86vm = yes], [ - AC_DEFINE([ENABLE_VIDMODE], 1, - [Define to 1 to enable VidMode method]) - AC_MSG_RESULT([yes]) - enable_vidmode=yes - ], [ - AC_MSG_RESULT([missing dependencies]) - AS_IF([test "x$enable_vidmode" = xyes], [ - AC_MSG_ERROR([missing dependencies for VidMode method]) - ]) - enable_vidmode=no - ]) -], [ - AC_MSG_RESULT([no]) - enable_vidmode=no -]) -AM_CONDITIONAL([ENABLE_VIDMODE], [test "x$enable_vidmode" = xyes]) - -# Check Quartz (macOS) method -AC_MSG_CHECKING([whether to enable Quartz method]) -AC_ARG_ENABLE([quartz], [AC_HELP_STRING([--enable-quartz], - [enable Quartz (macOS) method])], - [enable_quartz=$enableval],[enable_quartz=maybe]) -AS_IF([test "x$enable_quartz" != xno], [ - AS_IF([test $have_appserv_h = yes], [ - QUARTZ_CFLAGS="" - QUARTZ_LIBS="-framework ApplicationServices" - AC_DEFINE([ENABLE_QUARTZ], 1, - [Define to 1 to enable Quartz method]) - AC_MSG_RESULT([yes]) - enable_quartz=yes - ], [ - AC_MSG_RESULT([missing dependencies]) - AS_IF([test "x$enable_quartz" = xyes], [ - AC_MSG_ERROR([missing Quartz headers]) - ]) - enable_quartz=no - ]) -], [ - AC_MSG_RESULT([no]) - enable_quartz=no -]) -AM_CONDITIONAL([ENABLE_QUARTZ], [test "x$enable_quartz" = xyes]) -AC_SUBST([QUARTZ_CFLAGS]) -AC_SUBST([QUARTZ_LIBS]) - -# Check Windows GDI method -AC_MSG_CHECKING([whether to enable WinGDI method]) -AC_ARG_ENABLE([wingdi], [AC_HELP_STRING([--enable-wingdi], - [enable WinGDI method])], - [enable_wingdi=$enableval],[enable_wingdi=maybe]) -AS_IF([test "x$enable_wingdi" != xno], [ - AS_IF([test $have_windows_h = yes], [ - AC_DEFINE([ENABLE_WINGDI], 1, - [Define to 1 to enable WinGDI method]) - AC_MSG_RESULT([yes]) - enable_wingdi=yes - ], [ - AC_MSG_RESULT([missing dependencies]) - AS_IF([test "x$enable_wingdi" = xyes], [ - AC_MSG_ERROR([missing Windows API headers for WinGDI method]) - ]) - enable_wingdi=no - ]) -], [ - AC_MSG_RESULT([no]) - enable_wingdi=no -]) -AM_CONDITIONAL([ENABLE_WINGDI], [test "x$enable_wingdi" = xyes]) - - -# Check Geoclue2 location provider -AC_MSG_CHECKING([whether to enable Geoclue2 location provider]) -AC_ARG_ENABLE([geoclue2], [AC_HELP_STRING([--enable-geoclue2], - [enable Geoclue2 location provider])], - [enable_geoclue2=$enableval],[enable_geoclue2=maybe]) -AS_IF([test "x$enable_geoclue2" != xno], [ - AS_IF([test "x$have_geoclue2" = xyes], [ - AC_DEFINE([ENABLE_GEOCLUE2], 1, - [Define to 1 to enable Geoclue2 location provider]) - AC_MSG_RESULT([yes]) - enable_geoclue2=yes - ], [ - AC_MSG_RESULT([missing dependencies]) - AS_IF([test "x$enable_geoclue2" = xyes], [ - AC_MSG_ERROR([missing dependencies for Geoclue2 location provider]) - ]) - enable_geoclue2=no - ]) -], [ - AC_MSG_RESULT([no]) - enable_geoclue2=no -]) -AM_CONDITIONAL([ENABLE_GEOCLUE2], [test "x$enable_geoclue2" = xyes]) - -# Check CoreLocation (macOS) provider -AC_MSG_CHECKING([whether to enable CoreLocation method]) -AC_ARG_ENABLE([corelocation], [AC_HELP_STRING([--enable-corelocation], - [enable CoreLocation (macOS) provider])], - [enable_corelocation=$enableval],[enable_corelocation=maybe]) -AS_IF([test "x$enable_corelocation" != xno], [ - AS_IF([test "x$have_corelocation_h" = xyes], [ - CORELOCATION_CFLAGS="" - CORELOCATION_LIBS="-framework Foundation -framework Cocoa -framework CoreLocation" - AC_DEFINE([ENABLE_CORELOCATION], 1, - [Define to 1 to enable CoreLocation provider]) - AC_MSG_RESULT([yes]) - enable_corelocation=yes - ], [ - AC_MSG_RESULT([missing dependencies]) - AS_IF([test "x$enable_corelocation" = xyes], [ - AC_MSG_ERROR([missing CoreLocation headers]) - ]) - enable_corelocation=no - ]) -], [ - AC_MSG_RESULT([no]) - enable_corelocation=no -]) -AM_CONDITIONAL([ENABLE_CORELOCATION], [test "x$enable_corelocation" = xyes]) -AC_SUBST([CORELOCATION_CFLAGS]) -AC_SUBST([CORELOCATION_LIBS]) - - -# Check for GUI status icon -AC_MSG_CHECKING([whether to enable GUI status icon]) -AC_ARG_ENABLE([gui], [AC_HELP_STRING([--enable-gui], - [enable GUI status icon])], - [enable_gui=$enableval],[enable_gui=maybe]) -AS_IF([test "x$enable_gui" != xno], [ - AS_IF([test $have_python = yes], [ - AC_MSG_RESULT([yes]) - enable_gui=yes - ], [ - AC_MSG_RESULT([missing dependencies]) - AS_IF([test "x$enable_gui" = xyes], [ - AC_MSG_ERROR([GUI status icon script requires Python]) - ]) - enable_gui=no - ]) -], [ - AC_MSG_RESULT([no]) - enable_gui=no -]) -AM_CONDITIONAL([ENABLE_GUI], [test "x$enable_gui" != xno]) - -# Check for Ubuntu icons -AC_MSG_CHECKING([whether to enable Ubuntu icons]) -AC_ARG_ENABLE([ubuntu], [AC_HELP_STRING([--enable-ubuntu], - [enable Ubuntu icons])], - [enable_ubuntu=$enableval],[enable_ubuntu=no]) -AS_IF([test "x$enable_ubuntu" != xno], [ - AC_MSG_RESULT([yes]) -], [ - AC_MSG_RESULT([no]) -]) -AM_CONDITIONAL([ENABLE_UBUNTU], [test "x$enable_ubuntu" != xno]) - - -# Check for systemd -PKG_PROG_PKG_CONFIG -AC_MSG_CHECKING([Directory to install systemd user unit files]) -AC_ARG_WITH([systemduserunitdir], - [AS_HELP_STRING([--with-systemduserunitdir=], - [Directory for systemd user unit files])], - [], [with_systemduserunitdir=$($PKG_CONFIG --variable=systemduserunitdir systemd)]) -AS_IF([test -n "$with_systemduserunitdir" -a "x$with_systemduserunitdir" != xno], [ - AC_SUBST([systemduserunitdir], [$with_systemduserunitdir]) - AC_MSG_RESULT([$systemduserunitdir]) - enable_systemd=yes -], [ - AC_MSG_RESULT([not enabled]) - enable_systemd=no -]) -AM_CONDITIONAL([ENABLE_SYSTEMD], [test "x$enable_systemd" != xno]) - - -# Check for AppArmor -AC_MSG_CHECKING([whether to enable AppArmor profile]) -AC_ARG_ENABLE([apparmor], [AC_HELP_STRING([--enable-apparmor], - [enable AppArmor profile])], - [enable_apparmor=$enableval],[enable_apparmor=no]) -AS_IF([test "x$enable_apparmor" != xno], [ - AC_MSG_RESULT([yes]) - enable_apparmor=yes -], [ - AC_MSG_RESULT([no]) - enable_apparmor=no -]) -AM_CONDITIONAL([ENABLE_APPARMOR], [test "x$enable_apparmor" != xno]) - - -# Checks for header files. -AC_CHECK_HEADERS([locale.h stdint.h stdlib.h string.h unistd.h signal.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_TYPE_UINT16_T - -# Checks for library functions. -AC_SEARCH_LIBS([clock_gettime], [rt]) -AC_SEARCH_LIBS([floor], [m]) -AC_CHECK_FUNCS([setlocale strchr floor pow]) - -AC_CONFIG_FILES([ - Makefile - po/Makefile.in - src/Makefile - src/redshift-gtk/Makefile -]) -AC_OUTPUT - - -echo " - $PACKAGE_NAME $VERSION - - prefix: ${prefix} - compiler: ${CC} - cflags: ${CFLAGS} - ldflags: ${LDFLAGS} - - Adjustment methods: - DRM: ${enable_drm} - RANDR: ${enable_randr} - VidMode: ${enable_vidmode} - Quartz (macOS): ${enable_quartz} - WinGDI (Windows): ${enable_wingdi} - - Location providers: - Geoclue2: ${enable_geoclue2} - CoreLocation (macOS): ${enable_corelocation} - - GUI: ${enable_gui} - Ubuntu icons: ${enable_ubuntu} - systemd units: ${enable_systemd} ${systemduserunitdir} - AppArmor profile: ${enable_apparmor} -" diff --git a/contrib/redshift.spec b/contrib/redshift.spec index 475aa66b..1c7c12cc 100644 --- a/contrib/redshift.spec +++ b/contrib/redshift.spec @@ -6,6 +6,7 @@ Group: Applications/System License: GPLv3+ URL: http://jonls.dk/redshift/ Source0: http://launchpad.net/redshift/trunk/%{version}/+download/%{name}-%{version}.tar.xz +BuildRequires: meson BuildRequires: gettext-devel BuildRequires: libX11-devel BuildRequires: libXxf86vm-devel @@ -29,6 +30,7 @@ This package provides the base program. %package -n %{name}-gtk Summary: GTK integration for Redshift Group: Applications/System +BuildArch: noarch BuildRequires: python3-devel >= 3.2 BuildRequires: desktop-file-utils Requires: python3-gobject @@ -44,12 +46,16 @@ temperature adjustment program. %setup -q %build -%configure --enable-gui --disable-geoclue --enable-geoclue2 --enable-randr --enable-vidmode --with-systemduserunitdir=%{_userunitdir} -make %{?_smp_mflags} V=1 +# This macro adds "--auto-features=enabled" option and +# tries to enable all features in "meson_options.txt". +%meson -Dquartz=disabled -Dcorelocation=disabled -Dwingdi=disabled -Dsystemduserunitdir=%{_userunitdir} +%meson_build %install rm -rf %{buildroot} -make DESTDIR=%{buildroot} install INSTALL="install -p" +%meson_install +# Some files are incorrectly installed into "/usr/lib64/python3.X" on x86_64. +find %{buildroot}/usr/lib64 -name "*.py*" -exec mv {} %{buildroot}/usr/lib/python*/*/*/ \; %find_lang %{name} desktop-file-validate %{buildroot}%{_datadir}/applications/redshift.desktop desktop-file-validate %{buildroot}%{_datadir}/applications/redshift-gtk.desktop diff --git a/data/apparmor/meson.build b/data/apparmor/meson.build new file mode 100644 index 00000000..6049b822 --- /dev/null +++ b/data/apparmor/meson.build @@ -0,0 +1,11 @@ +if config_build.has('ENABLE_APPARMOR') + usr_bin_redshift = configure_file( + input : 'usr.bin.redshift.in', + output : 'usr.bin.redshift', + configuration : in_substs, + ) + install_data( + usr_bin_redshift, + install_dir : get_option('sysconfdir') / 'apparmor.d', + ) +endif diff --git a/data/appdata/meson.build b/data/appdata/meson.build new file mode 100644 index 00000000..2ffa6eb6 --- /dev/null +++ b/data/appdata/meson.build @@ -0,0 +1,11 @@ +if host_machine.system() != 'windows' + if config_build.has('ENABLE_GUI') + i18n.merge_file( + input : 'redshift-gtk.appdata.xml.in', + output : 'redshift-gtk.appdata.xml', + po_dir : po_dir, + install : true, + install_dir : get_option('datadir') / 'appdata', + ) + endif +endif diff --git a/data/appdata/redshift-gtk.appdata.xml.in b/data/appdata/redshift-gtk.appdata.xml.in index 36399843..daecb25e 100644 --- a/data/appdata/redshift-gtk.appdata.xml.in +++ b/data/appdata/redshift-gtk.appdata.xml.in @@ -1,20 +1,20 @@ - - redshift-gtk.desktop + + redshift-gtk.desktop CC0 GPL-3.0+ - <_p>Redshift adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night. - <_p>The color temperature is set according to the position of the sun. A different color temperature is set during night and daytime. During twilight and early morning, the color temperature transitions smoothly from night to daytime temperature to allow your eyes to slowly adapt. - <_p>This program provides a status icon that allows the user to control Redshift. +

Redshift adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night.

+

The color temperature is set according to the position of the sun. A different color temperature is set during night and daytime. During twilight and early morning, the color temperature transitions smoothly from night to daytime temperature to allow your eyes to slowly adapt.

+

This program provides a status icon that allows the user to control Redshift.

http://jonls.dk/assets/screenshot1.png - <_caption>The Redshift information window overlaid with an example of the redness effect + The Redshift information window overlaid with an example of the redness effect http://jonls.dk/redshift/ jonlst@gmail.com -
+ diff --git a/data/applications/meson.build b/data/applications/meson.build new file mode 100644 index 00000000..7973a7a1 --- /dev/null +++ b/data/applications/meson.build @@ -0,0 +1,23 @@ +if host_machine.system() != 'windows' + desktop_dir = get_option('datadir') / 'applications' + + i18n.merge_file( + input : 'redshift.desktop.in', + output : 'redshift.desktop', + type : 'desktop', + po_dir : po_dir, + install : true, + install_dir : desktop_dir, + ) + + if config_build.has('ENABLE_GUI') + i18n.merge_file( + input : 'redshift-gtk.desktop.in', + output : 'redshift-gtk.desktop', + type : 'desktop', + po_dir : po_dir, + install : true, + install_dir : desktop_dir, + ) + endif +endif diff --git a/data/applications/redshift-gtk.desktop.in b/data/applications/redshift-gtk.desktop.in old mode 100755 new mode 100644 index f68bef67..ed6a3d05 --- a/data/applications/redshift-gtk.desktop.in +++ b/data/applications/redshift-gtk.desktop.in @@ -1,9 +1,10 @@ [Desktop Entry] Version=1.0 -_Name=Redshift -_GenericName=Color temperature adjustment -_Comment=Color temperature adjustment tool +Name=Redshift +GenericName=Color temperature adjustment +Comment=Color temperature adjustment tool Exec=redshift-gtk +# TRANSLATORS: Icon name, please set to "redshift" Icon=redshift Terminal=false Type=Application diff --git a/data/applications/redshift.desktop.in b/data/applications/redshift.desktop.in old mode 100755 new mode 100644 index 74ca416c..c7a28e5c --- a/data/applications/redshift.desktop.in +++ b/data/applications/redshift.desktop.in @@ -1,9 +1,10 @@ [Desktop Entry] Version=1.0 -_Name=Redshift -_GenericName=Color temperature adjustment -_Comment=Color temperature adjustment tool +Name=Redshift +GenericName=Color temperature adjustment +Comment=Color temperature adjustment tool Exec=redshift +# TRANSLATORS: Icon name, please set to "redshift" Icon=redshift Terminal=true Type=Application diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 00000000..33b99722 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,14 @@ +# Icons +icons_dir = get_option('datadir') / 'icons' +install_subdir('icons' / 'hicolor', install_dir : icons_dir) +if config_build.has('ENABLE_UBUNTU') + install_subdir( + 'icons' / 'ubuntu-mono-dark', install_dir : icons_dir) + install_subdir( + 'icons' / 'ubuntu-mono-light', install_dir : icons_dir) +endif + +subdir('apparmor') +subdir('appdata') +subdir('applications') +subdir('systemd') diff --git a/data/systemd/meson.build b/data/systemd/meson.build new file mode 100644 index 00000000..5fb421e0 --- /dev/null +++ b/data/systemd/meson.build @@ -0,0 +1,16 @@ +if config_build.has('ENABLE_SYSTEMD') + redshift_service = configure_file( + input : 'redshift.service.in', + output : 'redshift.service', + configuration : in_substs, + ) + install_data(redshift_service, install_dir : systemd_userunitdir) + if config_build.has('ENABLE_GUI') + redshift_gtk_service = configure_file( + input : 'redshift-gtk.service.in', + output : 'redshift-gtk.service', + configuration : in_substs, + ) + install_data(redshift_gtk_service, install_dir : systemd_userunitdir) + endif +endif diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..1f3c42f4 --- /dev/null +++ b/meson.build @@ -0,0 +1,239 @@ +project( + 'redshift', + 'c', + default_options : ['buildtype=debugoptimized', 'c_std=gnu99'], + license : 'GPL3+', + meson_version : '>= 0.53', + version : '1.12', +) +proj_name = meson.project_name() +proj_version = meson.project_version() +proj_bugreport = 'https://github.com/jonls/redshift/issues' + +# TODO: Currently unity build fails due to redefinition error. +# (hooks.c and redshift.c have "static" variable "period_names") +if meson.is_unity() + error('Sorry, unity build is currently broken.') +endif + +cc = meson.get_compiler('c') + +# Directories +full_bindir = get_option('prefix') / get_option('bindir') +full_localedir = get_option('prefix') / get_option('localedir') +po_dir = meson.source_root() / 'po' +in_substs = configuration_data() +in_substs.set('bindir', full_bindir) +in_substs.set('localedir', full_localedir) + +# config.h +configuration_inc = include_directories('.') +add_project_arguments('-DHAVE_CONFIG_H', language : ['c', 'objc']) +config_h = configuration_data() +config_h.set_quoted('GETTEXT_PACKAGE', proj_name) +config_h.set_quoted('PACKAGE', proj_name) +config_h.set_quoted('PACKAGE_BUGREPORT', proj_bugreport) +config_h.set_quoted('PACKAGE_NAME', proj_name) +config_h.set_quoted('PACKAGE_STRING', '@0@ @1@'.format(proj_name, proj_version)) +config_h.set_quoted('PACKAGE_TARNAME', proj_name) +config_h.set_quoted('PACKAGE_VERSION', proj_version) +config_h.set_quoted('LOCALEDIR', full_localedir) + +# Check for library functions +intl_dep = cc.find_library('intl', required : false) +m_dep = cc.find_library('m', required : false) +if cc.sizeof('uint16_t', prefix : '#include ') == -1 + error('uint16_t is not defined.') +endif +foreach f : ['setlocale', 'strchr', 'floor', 'pow'] + if not cc.has_function(f, dependencies : m_dep) + error('Function "@0@" is not available.'.format(f)) + endif +endforeach + +# NLS +opt_nls = get_option('nls') +if not opt_nls.disabled() + have_gettext_func = cc.has_function('gettext', dependencies : intl_dep) + if not have_gettext_func and opt_nls.enabled() + error('Function gettext() is not available.') + endif + have_libintl_h = cc.has_header('libintl.h') + if not have_libintl_h and opt_nls.enabled() + error('libintl.h is not installed.') + endif + if have_gettext_func and have_libintl_h + config_h.set('ENABLE_NLS', 1) + endif +endif + +# Check for header files +system_headers = [ + 'locale.h', + 'signal.h', + 'stdint.h', + 'stdlib.h', + 'string.h', + 'unistd.h', +] +foreach h : system_headers + if cc.has_header(h) + config_h.set('HAVE_@0@'.format(h.to_upper().underscorify()), 1) + endif +endforeach + +# Build configuration +config_build = configuration_data() + +null_dep = disabler() + +# Check DRM method +drm_dep = dependency('libdrm', required : get_option('drm')) +if drm_dep.found() + config_h.set('ENABLE_DRM', 1) +endif + +# Check RANDR method +xcb_dep = null_dep +xcb_randr_dep = dependency('xcb-randr', required : get_option('randr')) +if xcb_randr_dep.found() + xcb_dep = dependency('xcb') +endif +if xcb_dep.found() + config_h.set('ENABLE_RANDR', 1) +endif + +# Check VidMode method +x11_dep = null_dep +xxf86vm_dep = dependency('xxf86vm', required : get_option('vidmode')) +if xxf86vm_dep.found() + x11_dep = dependency('x11') +endif +if x11_dep.found() + config_h.set('ENABLE_VIDMODE', 1) +endif + +# Check Quartz (macOS) method +appservices_dep = dependency('appleframeworks', + modules : 'applicationservices', required : get_option('quartz')) +if appservices_dep.found() and cc.has_header( + 'ApplicationServices/ApplicationServices.h') + config_h.set('ENABLE_QUARTZ', 1) +endif + +# Check Windows GDI method +gdi32_dep = cc.find_library('gdi32', required : get_option('wingdi')) +if gdi32_dep.found() and cc.has_header('windows.h') + config_h.set('ENABLE_WINGDI', 1) +endif + +# Check Geoclue2 location provider +gio_dep = dependency( + 'gio-2.0', version : '>= 2.26', required : get_option('geoclue2')) +if gio_dep.found() + config_h.set('ENABLE_GEOCLUE2', 1) +endif + +# Check CoreLocation (macOS) provider +foundation_dep = null_dep +cocoa_dep = null_dep +corelocation_dep = dependency('appleframeworks', + modules : 'corelocation', required : get_option('corelocation')) +if corelocation_dep.found() + foundation_dep = dependency('appleframeworks', modules : 'foundation') + cocoa_dep = dependency('appleframeworks', modules : 'cocoa') +endif +if foundation_dep.found() and cocoa_dep.found() + add_languages('objc') + objc = meson.get_compiler('objc') + if objc.has_header('CoreLocation/CoreLocation.h') + config_h.set('ENABLE_CORELOCATION', 1) + endif +endif + +# Check for GUI status icon +pymod = import('python') +py_installation = pymod.find_installation('python3', required : get_option('gui')) +if py_installation.found() + config_build.set('ENABLE_GUI', 1) +endif + +# Check for Ubuntu icons +if get_option('ubuntu').enabled() + config_build.set('ENABLE_UBUNTU', 1) +endif + +# Check for systemd +systemd_userunitdir = '' +opt_systemd_userunitdir = get_option('systemduserunitdir') +if opt_systemd_userunitdir != 'disabled' + if opt_systemd_userunitdir == 'auto' + if host_machine.system() == 'linux' + pkgconfig = find_program('pkg-config', required : false) + if pkgconfig.found() + cmd = run_command(pkgconfig, '--variable=systemduserunitdir', 'systemd') + if cmd.returncode() == 0 + systemd_userunitdir = cmd.stdout().strip() + config_build.set('ENABLE_SYSTEMD', 1) + endif + endif + endif + else + systemd_userunitdir = opt_systemd_userunitdir + config_build.set('ENABLE_SYSTEMD', 1) + endif +endif + +# Check for AppArmor +if get_option('apparmor').enabled() + config_build.set('ENABLE_APPARMOR', 1) +endif + +# i18n (used in subdirs) +i18n = import('i18n') + +# Man +install_man('redshift.1') + +# Subdirectories +subdir('src') +subdir('po') +subdir('data') + +# Generate config.h +configure_file(output : 'config.h', configuration : config_h) + +# Summary +summary( + { + 'prefix': get_option('prefix'), + }, + section: 'Directories', +) +summary( + { + 'DRM': config_h.has('ENABLE_DRM'), + 'RANDR': config_h.has('ENABLE_RANDR'), + 'VidMode': config_h.has('ENABLE_VIDMODE'), + 'Quartz (macOS)': config_h.has('ENABLE_QUARTZ'), + 'WinGDI (Windows)': config_h.has('ENABLE_WINGDI'), + }, + section: 'Adjustment methods', +) +summary( + { + 'Geoclue2': config_h.has('ENABLE_GEOCLUE2'), + 'CoreLocation (macOS)': config_h.has('ENABLE_CORELOCATION'), + }, + section: 'Location providers', +) +summary( + { + 'GUI': config_build.has('ENABLE_GUI'), + 'Ubuntu icons': config_build.has('ENABLE_UBUNTU'), + 'systemd units': config_build.has('ENABLE_SYSTEMD') + ? systemd_userunitdir : 'None', + 'AppArmor profile': config_build.has('ENABLE_APPARMOR'), + }, + section: 'Miscellaneous', +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..17ca79ed --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,72 @@ +option( + 'nls', + type : 'feature', + value : 'auto', + description : 'NLS support' +) +option( + 'drm', + type : 'feature', + value : 'auto', + description : 'DRM method' +) +option( + 'randr', + type : 'feature', + value : 'auto', + description : 'RANDR method' +) +option( + 'vidmode', + type : 'feature', + value : 'auto', + description : 'VidMode method' +) +option( + 'quartz', + type : 'feature', + value : 'auto', + description : 'Quartz (macOS) method' +) +option( + 'wingdi', + type : 'feature', + value : 'auto', + description : 'WinGDI method' +) +option( + 'corelocation', + type : 'feature', + value : 'auto', + description : 'CoreLocation (macOS) provider' +) +option( + 'geoclue2', + type : 'feature', + value : 'auto', + description : 'Geoclue2 provider' +) +option( + 'gui', + type : 'feature', + value : 'auto', + description : 'GUI status icon' +) +option( + 'ubuntu', + type : 'feature', + value : 'disabled', + description : 'Ubuntu icons' +) +option( + 'apparmor', + type : 'feature', + value : 'disabled', + description : 'AppArmor profile' +) +option( + 'systemduserunitdir', + type : 'string', + value : 'auto', + description : 'Directory for systemd user unit files (or, "auto" / "disabled")' +) diff --git a/po/Makevars b/po/Makevars deleted file mode 100644 index 33980f1b..00000000 --- a/po/Makevars +++ /dev/null @@ -1,41 +0,0 @@ -# Makefile variables for PO directory in any package using GNU gettext. - -# Usually the message domain is the same as the package name. -DOMAIN = $(PACKAGE) - -# These two variables depend on the location of this directory. -subdir = po -top_builddir = .. - -# These options get passed to xgettext. -XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --add-comments=TRANSLATORS - -# This is the copyright holder that gets inserted into the header of the -# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding -# package. (Note that the msgstr strings, extracted from the package's -# sources, belong to the copyright holder of the package.) Translators are -# expected to transfer the copyright for their translations to this person -# or entity, or to disclaim their copyright. The empty string stands for -# the public domain; in this case the translators are expected to disclaim -# their copyright. -COPYRIGHT_HOLDER = Jon Lund Steffensen - -# This is the email address or URL to which the translators shall report -# bugs in the untranslated strings: -# - Strings which are not entire sentences, see the maintainer guidelines -# in the GNU gettext documentation, section 'Preparing Strings'. -# - Strings which use unclear terms or require additional context to be -# understood. -# - Strings which make invalid assumptions about notation of date, time or -# money. -# - Pluralisation problems. -# - Incorrect English spelling. -# - Incorrect formatting. -# It can be your email address, or a mailing list address where translators -# can write to without being subscribed, or the URL of a web page through -# which the translators can contact you. -MSGID_BUGS_ADDRESS = https://github.com/jonls/redshift/issues - -# This is the list of locale categories, beyond LC_MESSAGES, for which the -# message catalogs shall be used. It is usually empty. -EXTRA_LOCALE_CATEGORIES = diff --git a/po/POTFILES.in b/po/POTFILES similarity index 100% rename from po/POTFILES.in rename to po/POTFILES diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 00000000..416a338f --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext(proj_name, preset : 'glib') diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 8aa96ead..00000000 --- a/src/Makefile.am +++ /dev/null @@ -1,105 +0,0 @@ - -SUBDIRS = redshift-gtk - -# I18n -localedir = $(datadir)/locale -AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" - -# redshift Program -bin_PROGRAMS = redshift - -redshift_SOURCES = \ - colorramp.c colorramp.h \ - config-ini.c config-ini.h \ - gamma-dummy.c gamma-dummy.h \ - hooks.c hooks.h \ - location-manual.c location-manual.h \ - options.c options.h \ - pipeutils.c pipeutils.h \ - redshift.c redshift.h \ - signals.c signals.h \ - solar.c solar.h \ - systemtime.c systemtime.h - -EXTRA_redshift_SOURCES = \ - gamma-drm.c gamma-drm.h \ - gamma-randr.c gamma-randr.h \ - gamma-vidmode.c gamma-vidmode.h \ - gamma-quartz.c gamma-quartz.h \ - gamma-w32gdi.c gamma-w32gdi.h \ - location-geoclue2.c location-geoclue2.h \ - location-corelocation.m location-corelocation.h \ - windows/appicon.rc \ - windows/versioninfo.rc - -AM_CFLAGS = -redshift_LDADD = @LIBINTL@ -EXTRA_DIST = windows/redshift.ico - -if ENABLE_DRM -redshift_SOURCES += gamma-drm.c gamma-drm.h -AM_CFLAGS += $(DRM_CFLAGS) -redshift_LDADD += \ - $(DRM_LIBS) $(DRM_CFLAGS) -endif - -if ENABLE_RANDR -redshift_SOURCES += gamma-randr.c gamma-randr.h -AM_CFLAGS += $(XCB_CFLAGS) $(XCB_RANDR_CFLAGS) -redshift_LDADD += \ - $(XCB_LIBS) $(XCB_CFLAGS) \ - $(XCB_RANDR_LIBS) $(XCB_RANDR_CFLAGS) -endif - -if ENABLE_VIDMODE -redshift_SOURCES += gamma-vidmode.c gamma-vidmode.h -AM_CFLAGS += $(X11_CFLAGS) $(XF86VM_CFLAGS) -redshift_LDADD += \ - $(X11_LIBS) $(X11_CFLAGS) \ - $(XF86VM_LIBS) $(XF86VM_CFLAGS) -endif - -if ENABLE_QUARTZ -redshift_SOURCES += gamma-quartz.c gamma-quartz.h -AM_CFLAGS += $(QUARTZ_CFLAGS) -redshift_LDADD += \ - $(QUARTZ_LIBS) $(QUARTZ_CFLAGS) -endif - -if ENABLE_WINGDI -redshift_SOURCES += gamma-w32gdi.c gamma-w32gdi.h -redshift_LDADD += -lgdi32 -endif - - -if ENABLE_GEOCLUE2 -redshift_SOURCES += location-geoclue2.c location-geoclue2.h -AM_CFLAGS += \ - $(GEOCLUE2_CFLAGS) -redshift_LDADD += \ - $(GEOCLUE2_LIBS) $(GEOCLUE2_CFLAGS) -endif - -# Build CoreLocation module as a separate convenience -# library since it is using a separate compiler -# (Objective C). - -if ENABLE_CORELOCATION -noinst_LTLIBRARIES = liblocation-corelocation.la -liblocation_corelocation_la_SOURCES = \ - location-corelocation.m location-corelocation.h -liblocation_corelocation_la_OBJCFLAGS = \ - $(CORELOCATION_CFLAGS) -liblocation_corelocation_la_LIBADD = \ - $(CORELOCATION_CFLAGS) $(CORELOCATION_LIBS) -redshift_LDADD += liblocation-corelocation.la -endif - - -# Windows resources -if ENABLE_WINDOWS_RESOURCE -redshift_SOURCES += windows/appicon.rc windows/versioninfo.rc -endif - -.rc.o: - $(AM_V_GEN)$(WINDRES) -I$(top_builddir) -i $< -o $@ diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 00000000..22ab8ce7 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,99 @@ +redshift_libs = [] +redshift_deps = [m_dep, intl_dep] +include_dirs = [configuration_inc] + +libredshift_common_sources = files( + 'colorramp.c', + 'colorramp.h', + 'config-ini.c', + 'config-ini.h', + 'gamma-dummy.c', + 'gamma-dummy.h', + 'location-manual.c', + 'location-manual.h', + 'options.c', + 'options.h', + 'pipeutils.c', + 'pipeutils.h', +) + +redshift_sources = files( + 'hooks.c', + 'hooks.h', + 'redshift.c', + 'redshift.h', + 'signals.c', + 'signals.h', + 'solar.c', + 'solar.h', + 'systemtime.c', + 'systemtime.h', +) + +if config_h.has('ENABLE_DRM') + libredshift_common_sources += files('gamma-drm.c', 'gamma-drm.h') + redshift_deps += drm_dep +endif + +if config_h.has('ENABLE_RANDR') + libredshift_common_sources += files('gamma-randr.c', 'gamma-randr.h') + redshift_deps += [xcb_randr_dep, xcb_dep] +endif + +if config_h.has('ENABLE_VIDMODE') + libredshift_common_sources += files('gamma-vidmode.c', 'gamma-vidmode.h') + redshift_deps += [xxf86vm_dep, x11_dep] +endif + +if config_h.has('ENABLE_QUARTZ') + libredshift_common_sources += files('gamma-quartz.c', 'gamma-quartz.h') + redshift_deps += appservices_dep +endif + +if config_h.has('ENABLE_WINGDI') + libredshift_common_sources += files('gamma-w32gdi.c', 'gamma-w32gdi.h') + redshift_deps += gdi32_dep +endif + +if config_h.has('ENABLE_GEOCLUE2') + libredshift_common_sources += files('location-geoclue2.c', 'location-geoclue2.h') + redshift_deps += gio_dep +endif + +# Build CoreLocation module as a separate convenience +# library since it is using a separate compiler +# (Objective C). +if config_h.has('ENABLE_CORELOCATION') + redshift_libs += static_library('libredshift_corelocation', + ['location-corelocation.m', 'location-corelocation.h'], + include_directories : include_dirs, + ) + redshift_deps += [corelocation_dep, foundation_dep, cocoa_dep] +endif + +if host_machine.system() == 'windows' + windows = import('windows') + # Windows resources + win_resources = windows.compile_resources( + ['windows/appicon.rc', 'windows/versioninfo.rc'], + include_directories : include_dirs, + ) + redshift_sources += win_resources +endif + +libredshift_common = static_library('libredshift_common', + libredshift_common_sources, + dependencies : redshift_deps, + include_directories : include_dirs, +) +redshift_libs += libredshift_common + +executable('redshift', + redshift_sources, + dependencies : redshift_deps, + include_directories : include_dirs, + link_with : redshift_libs, + install : true, +) + +subdir('redshift-gtk') diff --git a/src/redshift-gtk/Makefile.am b/src/redshift-gtk/Makefile.am deleted file mode 100644 index b7303a26..00000000 --- a/src/redshift-gtk/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ - -if ENABLE_GUI -redshift_gtk_PYTHON = \ - __init__.py \ - controller.py \ - statusicon.py \ - utils.py -nodist_redshift_gtk_PYTHON = \ - defs.py -redshift_gtkdir = $(pythondir)/redshift_gtk - -bin_SCRIPTS = redshift-gtk -endif - -EXTRA_DIST = defs.py.in redshift-gtk.in -CLEANFILES = defs.py redshift-gtk - - -# Local python definitions -defs.py: defs.py.in - $(AM_V_GEN)sed -e "s|\@bindir\@|$(bindir)|g" \ - -e "s|\@localedir\@|$(localedir)|g" $< > $@ - -redshift-gtk: redshift-gtk.in - $(AM_V_GEN)sed -e "s|\@pythondir\@|$(pythondir)|g" $< > $@ diff --git a/src/redshift-gtk/meson.build b/src/redshift-gtk/meson.build new file mode 100644 index 00000000..892729ff --- /dev/null +++ b/src/redshift-gtk/meson.build @@ -0,0 +1,29 @@ +if config_build.has('ENABLE_GUI') + py_installdir = py_installation.get_install_dir() / 'redshift_gtk' + in_substs.set('pythondir', py_installdir) + + defs_py = configure_file( + input : 'defs.py.in', + output : 'defs.py', + configuration : in_substs, + ) + redshift_gtk = configure_file( + input : 'redshift-gtk.in', + output : 'redshift-gtk', + configuration : in_substs, + ) + redshift_gtk_sources = files( + '__init__.py', + 'controller.py', + 'statusicon.py', + 'utils.py', + ) + + py_installation.install_sources(redshift_gtk_sources, subdir : 'redshift_gtk') + install_data(defs_py, install_dir : py_installdir) + install_data(redshift_gtk, + install_dir : full_bindir, + install_mode : 'rwxr-xr-x', + ) + meson.add_install_script('meson_compile_py.py', py_installdir) +endif diff --git a/src/redshift-gtk/meson_compile_py.py b/src/redshift-gtk/meson_compile_py.py new file mode 100755 index 00000000..3bd1d3e7 --- /dev/null +++ b/src/redshift-gtk/meson_compile_py.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +from mesonbuild.scripts import destdir_join +import compileall, sys, os + +compileall.compile_dir( + destdir_join(os.environ.get('DESTDIR', ''), sys.argv[1]))