From d39fe358143fc4e36c87803fb1c9112ae2248dd5 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 15 Jan 2016 23:12:46 +0000 Subject: [PATCH] Proper gnome-shell-extension build environment --- .gitignore | 21 ++ Makefile.am | 63 +++++ autogen.sh | 20 ++ build.sh | 3 - configure.ac | 102 ++++++++ po/LINGUAS | 0 po/Makefile.in.in | 222 ++++++++++++++++++ po/POTFILES.in | 2 + extension.js => src/extension.js | 0 {icons => src/icons}/tor-connected.svg | 0 {icons => src/icons}/tor-disconnected.svg | 0 log.js => src/log.js | 0 metadata.json => src/metadata.json | 0 .../tor_control_client.js | 0 {ui => src/ui}/tor_button.js | 0 {ui => src/ui}/tor_popup_menu.js | 0 16 files changed, 430 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile.am create mode 100755 autogen.sh delete mode 100755 build.sh create mode 100644 configure.ac create mode 100644 po/LINGUAS create mode 100644 po/Makefile.in.in create mode 100644 po/POTFILES.in rename extension.js => src/extension.js (100%) rename {icons => src/icons}/tor-connected.svg (100%) rename {icons => src/icons}/tor-disconnected.svg (100%) rename log.js => src/log.js (100%) rename metadata.json => src/metadata.json (100%) rename tor_control_client.js => src/tor_control_client.js (100%) rename {ui => src/ui}/tor_button.js (100%) rename {ui => src/ui}/tor_popup_menu.js (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8be76e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +*~ +op/*.mo +TODOs.txt +gschemas.compiled +*.zip +messages.pot +Makefile.in +aclocal +automate.cache* +config.log +config.status +configure +install-sh +missing +aclocal.m4 +compile +Makefile +autom4te.cache +po/Makefile +po/POTFILES +po/stamp-it diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..3a11609 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,63 @@ +#additional_files = src/redshift-prefs.ui + + +uuid = @PACKAGE_NAME@ + +# blatantly stolen from http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html +rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) + +extension_files_pattern := *.js *.css *.png *.svg *.jpg *.wav *.mp3 +extension_files = $(foreach ext,$(extension_files_pattern),$(call rwildcard,src/,$(ext))) + +opt_files_pattern := README.rst README.md README.mdwn README COPYING AUTHORS LICENSE ChangeLog +opt_files = $(foreach file,$(opt_files_pattern),$(wildcard $(file))) + +extensionbase = $(datadir)/gnome-shell/extensions +extensiondir = $(extensionbase)/$(uuid) + + +nobase_dist_extension_DATA = src/metadata.json $(extension_files) $(additional_files) $(opt_files) + +.PHONY: zip local-install local-helper + +zip: + $(MAKE) local-helper DESTDIR=$(abs_builddir)/_build + (cd $(abs_builddir)/_build/$(uuid)/ && \ + zip -qr $(abs_builddir)/$(uuid).zip . \ + ) + -rm -rf $(abs_builddir)/_build + +CLEANFILES = $(abs_builddir)/$(uuid).zip +DISTCLEANFILES = $(uuid).zip + +local-install: + $(MAKE) local-helper DESTDIR=$(HOME)/.local/share/gnome-shell/extensions + +local-helper: all + $(MAKE) install prefix='' DATADIRNAME='$(uuid)' extensionbase='' + +install-data-hook: + -mv $(DESTDIR)$(extensiondir)/src/* $(DESTDIR)$(extensiondir) + -rmdir $(DESTDIR)$(extensiondir)/src + +if HAVE_GSETTINGS +schemasdir = $(extensiondir)/schemas +schemas_DATA = src/schemas/gschemas.compiled + +CLEANFILES += $(schemas_DATA) +DISTCLEANFILES += $(sort $(GSETTINGS_SCHEMAS_CONFIGURE)) + +.SECONDARY: $(GSETTINGS_SCHEMAS) + +%gschemas.compiled: $(sort $(GSETTINGS_SCHEMAS)) + $(GLIB_COMPILE_SCHEMAS) $(dir $@) +endif + + +if HAVE_I18N +# until intltool plays nicely with non-recursive make +SUBDIRS = @CONFIGURE_SUBDIRS@ + +@INTLTOOL_XML_NOMERGE_RULE@ +endif + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..4494dbf --- /dev/null +++ b/autogen.sh @@ -0,0 +1,20 @@ +#!/bin/sh +srcdir=`dirname $0` +[ -z "$srcdir" ] && srcdir=. + +PKG_NAME=mypackage + +if [ ! -f "$srcdir/configure.ac" ]; then + echo "$srcdir doesn't look like source directory for $PKG_NAME" >&2 + exit 1 +fi + +which gnome-autogen.sh || { + echo "You need to install gnome-common from GNOME Git (or from" + echo "your OS vendor's package manager)." + exit 1 +} + +NOCONFIGURE=true +. gnome-autogen.sh + diff --git a/build.sh b/build.sh deleted file mode 100755 index dda9f9f..0000000 --- a/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -git archive --format=zip HEAD -o tor-gnome-shell-extension.zip diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..c042dbb --- /dev/null +++ b/configure.ac @@ -0,0 +1,102 @@ + +AC_PREREQ([2.69]) +AC_INIT(m4_esyscmd_s([(grep -o -E '"uuid"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*"\([^"]*\)"$/\1/') < src/metadata.json]), [0]) + +AM_INIT_AUTOMAKE([1.10 foreign dist-xz tar-ustar subdir-objects]) + +# every extension has this file +AC_CONFIG_SRCDIR([src/metadata.json]) + +# read some of the config stuff from metadata.json +# uuid, gsettings, gettext +PACKAGE_GETTEXT_DOMAIN=[$((grep -o -E '"gettext-domain"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*"\([^"]*\)"$/\1/') < src/metadata.json)] +PACKAGE_GSETTINGS_SCHEMA=[$((grep -o -E '"settings-schema"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*"\([^"]*\)"$/\1/') < src/metadata.json)] + +AC_SUBST([UUID], [$PACKAGE_NAME]) +AC_SUBST([GETTEXT_DOMAIN], [$PACKAGE_GETTEXT_DOMAIN]) +AC_SUBST([GSETTINGS_SCHEMA], [$PACKAGE_GSETTINGS_SCHEMA]) + + +AC_MSG_NOTICE([checking if we want internationalization (i18n) support]) +AC_CHECK_FILES([./po/Makefile.in.in], [HAVE_I18N=yes], [HAVE_I18N=no]) +AM_CONDITIONAL([HAVE_I18N], [test "$HAVE_I18N" = "yes"]) +AC_MSG_WARN([$HAVE_I18N]) +AM_COND_IF([HAVE_I18N], [ + AC_CONFIG_FILES([po/Makefile.in]) + GETTEXT_PACKAGE=$PACKAGE_GETTEXT_DOMAIN + AC_SUBST([GETTEXT_PACKAGE]) + AC_SUBST([CONFIGURE_SUBDIRS], [po ]) +]) + + +# this is a bad bad bad workaround that should be removed as soon +# as IT_PROG_INTLTOOL behaves and does not fail while checking +# or until I can replace it by a better macro that also has fewer dependencies +AC_CONFIG_COMMANDS_PRE( + [AC_CONFIG_COMMANDS([po/fake-it], + [AS_IF([test "$MY_HAVE_I18N" = "no"], + [mkdir -p po + AC_MSG_NOTICE([tricking intltool into working]) + touch po/POTFILES.in + echo '# INTLTOOL_MAKEFILE' > po/Makefile.in])], + [MY_HAVE_I18N=$HAVE_I18N])]) +# space at the beginning to hide it from gnome-autogen.sh + IT_PROG_INTLTOOL([0.26]) + +AC_CONFIG_COMMANDS_PRE( + [AC_CONFIG_COMMANDS([po/clean-it], + [AS_IF([test "$MY_HAVE_I18N" = "no"], + [rm -rf po])], + [MY_HAVE_I18N=$HAVE_I18N])]) + + + +# when i18n is enabled, intltool looks for xml.in files, so the configuration +# input should be xml.in.in +# see if we have gsettings schemas to configure and compile +AM_COND_IF([HAVE_I18N], [ + # when i18n support is enabled, intltool will process xml.in files, + # so configured files should be .in.in + GSETTINGS_SCHEMAS_SUFFIX=".gschema.xml.in" +], [ + # i18n support disabled, so look for .in files only + GSETTINGS_SCHEMAS_SUFFIX=".gschema.xml" +]) + +HAVE_SCHEMAS=no +AC_MSG_NOTICE([checking what to do with schemas]) +GSETTINGS_SCHEMAS_CONFIGURE=$(find src/schemas/ -name "*${GSETTINGS_SCHEMAS_SUFFIX}.in" 2>/dev/null | tr '\n' ' ') +GSETTINGS_SCHEMAS_CONFIGURE=${GSETTINGS_SCHEMAS_CONFIGURE//${GSETTINGS_SCHEMAS_SUFFIX}.in/${GSETTINGS_SCHEMAS_SUFFIX}} + +# let's see if we found any in the previous step +AS_IF([test -n "$GSETTINGS_SCHEMAS_CONFIGURE"], [ + # add processed schemas + HAVE_SCHEMAS=yes + # in either case (i18n or not) we have to strip one + # level of .in on each file + AC_CONFIG_FILES([$GSETTINGS_SCHEMAS_CONFIGURE]) + AC_SUBST([GSETTINGS_SCHEMAS_CONFIGURE]) + AC_MSG_NOTICE([will configure schemas]) +]) + +# finally, we can have schema files that shall neither be translated, +# nor configured +GSETTINGS_SCHEMAS=$(find src/schemas/ -name '*.gschema.xml' 2>/dev/null | tr '\n' ' ') +AS_IF([test -n "${GSETTINGS_SCHEMAS}"], [ + HAVE_SCHEMAS=yes +]) + +AM_CONDITIONAL([HAVE_GSETTINGS], [test "$HAVE_SCHEMAS" = "yes"]) +AM_COND_IF([HAVE_GSETTINGS], [ + AC_MSG_NOTICE([will compile schemas]) + GSETTINGS_SCHEMAS="$GSETTINGS_SCHEMAS ${GSETTINGS_SCHEMAS_CONFIGURE//$GSETTINGS_SCHEMAS_SUFFIX/.gschema.xml}" + AC_SUBST([GSETTINGS_SCHEMAS]) + GLIB_GSETTINGS +]) + + +AC_CONFIG_FILES([ + Makefile +]) + +AC_OUTPUT diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..e69de29 diff --git a/po/Makefile.in.in b/po/Makefile.in.in new file mode 100644 index 0000000..06a8cfe --- /dev/null +++ b/po/Makefile.in.in @@ -0,0 +1,222 @@ +# Makefile for program source directory in GNU NLS utilities package. +# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper +# Copyright (C) 2004-2008 Rodney Dawes +# +# This file may be copied and used freely without restrictions. It may +# be used in projects which are not available under a GNU Public License, +# but which still want to provide support for the GNU gettext functionality. +# +# - Modified by Owen Taylor to use GETTEXT_PACKAGE +# instead of PACKAGE and to look for po2tbl in ./ not in intl/ +# +# - Modified by jacob berkman to install +# Makefile.in.in and po2tbl.sed.in for use with glib-gettextize +# +# - Modified by Rodney Dawes for use with intltool +# +# We have the following line for use by intltoolize: +# INTLTOOL_MAKEFILE + +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datadir = @datadir@ +datarootdir = @datarootdir@ +libdir = @libdir@ +DATADIRNAME = @DATADIRNAME@ +itlocaledir = $(prefix)/$(DATADIRNAME)/locale +subdir = po +install_sh = @install_sh@ +# Automake >= 1.8 provides @mkdir_p@. +# Until it can be supposed, use the safe fallback: +mkdir_p = $(install_sh) -d + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +GMSGFMT = @GMSGFMT@ +MSGFMT = @MSGFMT@ +XGETTEXT = @XGETTEXT@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +MSGMERGE = INTLTOOL_EXTRACT="$(INTLTOOL_EXTRACT)" XGETTEXT="$(XGETTEXT)" srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist +GENPOT = INTLTOOL_EXTRACT="$(INTLTOOL_EXTRACT)" XGETTEXT="$(XGETTEXT)" srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot + +ALL_LINGUAS = @ALL_LINGUAS@ + +PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; else echo "$(ALL_LINGUAS)"; fi) + +USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for lang in $$LLINGUAS; do if test -n "`grep \^$$lang$$ $(srcdir)/LINGUAS 2>/dev/null`" -o -n "`echo $$ALINGUAS|tr ' ' '\n'|grep \^$$lang$$`"; then printf "$$lang "; fi; done; fi) + +USE_LINGUAS=$(shell if test -n "$(USER_LINGUAS)" -o -n "$(LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else if test -n "$(PO_LINGUAS)"; then LLINGUAS="$(PO_LINGUAS)"; else LLINGUAS="$(ALL_LINGUAS)"; fi; fi; for lang in $$LLINGUAS; do printf "$$lang "; done) + +POFILES=$(shell LINGUAS="$(PO_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done) + +DISTFILES = Makefile.in.in POTFILES.in $(POFILES) +EXTRA_DISTFILES = ChangeLog POTFILES.skip Makevars LINGUAS + +POTFILES = \ +# This comment gets stripped out + +CATALOGS=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.gmo "; done) + +.SUFFIXES: +.SUFFIXES: .po .pox .gmo .mo .msg .cat + +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +INTLTOOL_V_MSGFMT = $(INTLTOOL__v_MSGFMT_$(V)) +INTLTOOL__v_MSGFMT_= $(INTLTOOL__v_MSGFMT_$(AM_DEFAULT_VERBOSITY)) +INTLTOOL__v_MSGFMT_0 = @echo " MSGFMT" $@; + +.po.pox: + $(MAKE) $(GETTEXT_PACKAGE).pot + $(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox + +.po.mo: + $(INTLTOOL_V_MSGFMT)$(MSGFMT) -o $@ $< + +.po.gmo: + $(INTLTOOL_V_MSGFMT)file=`echo $* | sed 's,.*/,,'`.gmo \ + && rm -f $$file && $(GMSGFMT) -o $$file $< + +.po.cat: + sed -f ../intl/po2msg.sed < $< > $*.msg \ + && rm -f $@ && gencat $@ $*.msg + + +all: all-@USE_NLS@ + +all-yes: $(CATALOGS) +all-no: + +$(GETTEXT_PACKAGE).pot: $(POTFILES) + $(GENPOT) + +install: install-data +install-data: install-data-@USE_NLS@ +install-data-no: all +install-data-yes: all + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \ + $(mkdir_p) $$dir; \ + if test -r $$lang.gmo; then \ + $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ + echo "installing $$lang.gmo as $$dir/$(GETTEXT_PACKAGE).mo"; \ + else \ + $(INSTALL_DATA) $(srcdir)/$$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ + echo "installing $(srcdir)/$$lang.gmo as" \ + "$$dir/$(GETTEXT_PACKAGE).mo"; \ + fi; \ + if test -r $$lang.gmo.m; then \ + $(INSTALL_DATA) $$lang.gmo.m $$dir/$(GETTEXT_PACKAGE).mo.m; \ + echo "installing $$lang.gmo.m as $$dir/$(GETTEXT_PACKAGE).mo.m"; \ + else \ + if test -r $(srcdir)/$$lang.gmo.m ; then \ + $(INSTALL_DATA) $(srcdir)/$$lang.gmo.m \ + $$dir/$(GETTEXT_PACKAGE).mo.m; \ + echo "installing $(srcdir)/$$lang.gmo.m as" \ + "$$dir/$(GETTEXT_PACKAGE).mo.m"; \ + else \ + true; \ + fi; \ + fi; \ + done + +# Empty stubs to satisfy archaic automake needs +dvi info ctags tags CTAGS TAGS ID: + +# Define this as empty until I found a useful application. +install-exec installcheck: + +uninstall: + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \ + rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \ + done + +check: all $(GETTEXT_PACKAGE).pot + rm -f missing notexist + srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m + if [ -r missing -o -r notexist ]; then \ + exit 1; \ + fi + +mostlyclean: + rm -f *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp + rm -f .intltool-merge-cache + +clean: mostlyclean + +distclean: clean + rm -f Makefile Makefile.in POTFILES stamp-it + rm -f *.mo *.msg *.cat *.cat.m *.gmo + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f Makefile.in.in + +distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: $(DISTFILES) + dists="$(DISTFILES)"; \ + extra_dists="$(EXTRA_DISTFILES)"; \ + for file in $$extra_dists; do \ + test -f $(srcdir)/$$file && dists="$$dists $(srcdir)/$$file"; \ + done; \ + for file in $$dists; do \ + test -f $$file || file="$(srcdir)/$$file"; \ + ln $$file $(distdir) 2> /dev/null \ + || cp -p $$file $(distdir); \ + done + +update-po: Makefile + $(MAKE) $(GETTEXT_PACKAGE).pot + tmpdir=`pwd`; \ + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + echo "$$lang:"; \ + result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \ + if $$result; then \ + if cmp $(srcdir)/$$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "msgmerge for $$lang.gmo failed!"; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi; \ + done + +Makefile POTFILES: stamp-it + @if test ! -f $@; then \ + rm -f stamp-it; \ + $(MAKE) stamp-it; \ + fi + +stamp-it: Makefile.in.in $(top_builddir)/config.status POTFILES.in + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/Makefile.in CONFIG_HEADERS= CONFIG_LINKS= \ + $(SHELL) ./config.status + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..0ab8861 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,2 @@ +src/*.js +src/schemas/*.xml.in diff --git a/extension.js b/src/extension.js similarity index 100% rename from extension.js rename to src/extension.js diff --git a/icons/tor-connected.svg b/src/icons/tor-connected.svg similarity index 100% rename from icons/tor-connected.svg rename to src/icons/tor-connected.svg diff --git a/icons/tor-disconnected.svg b/src/icons/tor-disconnected.svg similarity index 100% rename from icons/tor-disconnected.svg rename to src/icons/tor-disconnected.svg diff --git a/log.js b/src/log.js similarity index 100% rename from log.js rename to src/log.js diff --git a/metadata.json b/src/metadata.json similarity index 100% rename from metadata.json rename to src/metadata.json diff --git a/tor_control_client.js b/src/tor_control_client.js similarity index 100% rename from tor_control_client.js rename to src/tor_control_client.js diff --git a/ui/tor_button.js b/src/ui/tor_button.js similarity index 100% rename from ui/tor_button.js rename to src/ui/tor_button.js diff --git a/ui/tor_popup_menu.js b/src/ui/tor_popup_menu.js similarity index 100% rename from ui/tor_popup_menu.js rename to src/ui/tor_popup_menu.js