seamonkey/seamonkey-GNUmakefile

190 lines
5.1 KiB
Plaintext

#
# Front-end based on GNU make, intended for a more friendly
# integration of the build system with Linux/UNIX distributions,
# as well as for those who still allergy using mach command.
#
# Place it as `mozilla/GNUmakefile' (instead of the existing stub),
# and work under `mozilla/' dir.
#
#
# For build, just use
#
# make
#
# (If you want to separate config stage, use "make configure" and then "make",
# but normally it is done automatically).
#
# For install, use
#
# make install DESTDIR=where_you_want_to_install
#
#
# Additionally, before install you can use:
#
# make locales
#
# to provide all the shipped locales (will appear in a form of langpack extensions).
# If irc and/or calendar are built, their data will be included too.
# (See below for more details about locales target).
#
#
# For clarity, some comparison with the other build methods
# (assume `-jN' is the option for parallel builds, ie. `-j4' for 4-cpu system):
#
# Build stage:
#
# client.mk: make -f client.mk build MOZ_MAKE_FLAGS=-jN
# mach: ./mach build -jN
# THIS: make -jN
#
# Install stage:
#
# client.mk: DESTDIR=where... make -f client.mk install
# mach: DESTDIR=where... make -C $OBJDIR... install
# THIS: make install DESTDIR=where...
#
ifeq (,$(wildcard .mozconfig))
$(error Cannot find .mozconfig file in the current directory)
endif
MACH_CMD = ./mach --log-no-times
OBJDIR := $(shell $(MACH_CMD) environment --format=json | sed -e 's/.*"topobjdir": "//' -e 's/".*//')
OBJDIR_TARGETS = install distribution source-package package clobber
.PHONY: all configure build clean distclean $(OBJDIR_TARGETS)
all: build
configure: $(OBJDIR)/Makefile
$(OBJDIR)/Makefile: .mozconfig
$(MACH_CMD) configure
build: $(OBJDIR)/Makefile
$(MAKE) -C $(OBJDIR)
$(OBJDIR_TARGETS):
$(MAKE) -C $(OBJDIR) $@
clean:
$(MACH_CMD) clobber
distclean: clean
rm -f configure js/src/configure
rm -rf $(OBJDIR)
#
# LOCALES
#
#
# The target `locales' creates all the needed langpacks.
#
# By default, all available locales will be used. You can change it
# by overriding SHIPPED_LOCALES variable on the command line.
#
# Additionally, you can use `make locale-LANG' to create one (or several)
# langpack separately.
#
# For example, to build `fr' and 'it' only, use:
#
# make locales SHIPPED_LOCALES="fr it"
#
# to create just `ru' langpack:
#
# make locale-ru
#
# Use `clear-locales' for clearing.
#
#
# NOTE! NOTE! NOTE!
#
# Do NOT use parallel builds (-jN) for locale targets!
#
# It is better to use `-j1' explicitly (`make -j1 locales') to avoid issues.
#
.PHONY: locales clear-locales dictionaries clear-dictionaries
drop_extra := $(if $(or $(filter Windows_NT,$(OS)),$(filter-out Darwin,$(shell uname))),ja-JP-mac,ja)
SHIPPED_LOCALES := $(shell while read loc rest; do echo $$loc; done <comm/suite/locales/shipped-locales)
SHIPPED_LOCALES := $(filter-out en-US $(drop_extra),$(sort $(SHIPPED_LOCALES)))
locales: $(SHIPPED_LOCALES:%=locale-%)
PACKAGE_MANIFEST = $(OBJDIR)/comm/suite/installer/package-manifest
$(PACKAGE_MANIFEST):
cp comm/suite/installer/package-manifest.in $@
sed -i '/MOZ_PKG_MANIFEST =/ s,.*,MOZ_PKG_MANIFEST = $$(topobjdir)/comm/suite/installer/package-manifest,' \
$(OBJDIR)/comm/suite/installer/Makefile
stage := $(OBJDIR)/dist/xpi-stage/locale
.PRECIOUS: $(stage)-%
$(stage)-%:
$(MAKE) -C $(OBJDIR)/comm/suite/locales langpack-$*
# Cleanup of old manifest files
find $@ -name "*.manifest" -print | xargs rm -f
find $@ -name ".mkdir.done" -print | xargs rm -f
find $@/extensions -name "defaults" -type d -print | xargs rm -rf
# Spanish locales other than es-ES are from Latam, where the es-AR langpack is most preferred
[ $* = es-AR ] && sed -i '/"es-AR": {/ s/es-AR/es/' $@/manifest.json || :
locale-%: REL_NAME = extensions/langpack-$*@seamonkey.mozilla.org.xpi
locale-%: DEST_NAME = $(OBJDIR)/dist/bin/$(REL_NAME)
locale-%: manifest_entry = @RESPATH@/$(REL_NAME)
# To avoid performance issues in multi-locale installs, put manifest.json file
# into the beginning of the archive, and do not compress them.
locale-%: $(stage)-% $(PACKAGE_MANIFEST)
rm -f $(DEST_NAME)
cd $<; zip -0 -D -X $(DEST_NAME) manifest.json
cd $<; zip -g -r -9 -D -X $(DEST_NAME) chrome extensions
fgrep $(manifest_entry) $(PACKAGE_MANIFEST) || echo $(manifest_entry) >>$(PACKAGE_MANIFEST)
clear-locales:
sed -i '/langpack-.*@seamonkey.mozilla.org.xpi/ d' $(PACKAGE_MANIFEST)
rm -f $(OBJDIR)/dist/bin/extensions/langpack-*@seamonkey.mozilla.org.xpi
#
# Dictionaries
#
# It is better to use system dictionaries, specifying directory path for them
# by "spellchecker.dictionary_path" preference (or even use symlink when possible).
#
DICT_DEST := $(OBJDIR)/dist/bin/dictionaries
dictionaries: $(SHIPPED_LOCALES:%=$(stage)-%)
cp -f -d $(wildcard $(foreach loc,$(SHIPPED_LOCALES),$(stage)-$(loc)/dictionaries/$(loc).aff $(stage)-$(loc)/dictionaries/$(loc).dic)) $(DICT_DEST)
clear-dictionaries:
rm -f $(filter-out $(DICT_DEST)/en-US.%,$(wildcard $(DICT_DEST)/*.aff $(DICT_DEST)/*.dic))