Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 179 lines (146 sloc) 5.36 KB
.PHONY: help
help:
@echo "BUILD/INSTALL INSTRUCTIONS"
@echo
@echo "to build Firetray, just:"
@echo " make build"
@echo
@echo "by default, debug calls are stripped from js files and DEBUG_MODE"
@echo "is off (performance). If you want to keep debug calls:"
@echo " DEBUG=on make build"
@echo
@echo "to create the dev profile:"
@echo " firefox -no-remote -P # then create '$(profile_id)'"
@echo " thunderbird -no-remote -P # then create '$(profile_id)'"
@echo
@echo "to test the extension with the dev profile:"
@echo " cd ~/.mozilla/firefox/mozilla-dev/extensions"
@echo " ln -s ../../path/to/firetray/src '{9533f794-00b4-4354-aa15-c2bbda6989f8}'"
@echo " cd ~/.thunderbird/mozilla-dev/extensions"
@echo " ln -s ../path/to/firetray/src '{9533f794-00b4-4354-aa15-c2bbda6989f8}'"
@echo
@echo "to test with dev profile:"
@echo " firefox -no-remote -P mozilla-dev"
@echo " thunderbird -no-remote -P mozilla-dev"
@echo
@echo "Have fun !"
# The UUID of the extension.
extension_name := firetray
# The name of the profile dir where the extension can be installed.
profile_id := mozilla-dev
# The zip application to be used. NOTE: symlinks seem not supported in XPI
# ("could not be installed because Firefox cannot modify the needed file")
ZIP := zip # --symlinks
# The target location of the build and build files.
build_dir := ../build
# The location of the extension profile. (this extension is intended for Linux only)
profile_locations := \
~/.mozilla/firefox/$(profile_id)/extensions \
~/.thunderbird/$(profile_id)/extensions
# The license file
license := LICENSE
# The install.rdf file.
install_rdf := install.rdf
# Version fetched from install.rdf
VERSION := $(shell awk '/<em:version>/ { version=$$1; \
version=gensub(/<em:version>(.+)<\/em:version>/, "\\1", "g", version); \
print version }' $(install_rdf))
# The target XPI files.
xpi_file := $(extension_name)-$(VERSION).xpi
xpi_built := $(build_dir)/$(xpi_file)
# Since we use <em:unpack>false, we need the same name across versions
xpi_deployed := $(extension_name).xpi
# The chrome.manifest file.
chrome_manifest := chrome.manifest
# The preferences dir.
preferences_dir := defaults/preferences
# The root of the chrome sources.
chrome_source_root := chrome
# The chrome sources.
chrome_sources_js := $(wildcard $(chrome_source_root)/content/*.js)
chrome_sources := $(chrome_sources_js) \
$(wildcard $(chrome_source_root)/content/*.xul) \
$(wildcard $(chrome_source_root)/content/*.xml) \
$(wildcard $(chrome_source_root)/content/*.css) \
$(wildcard $(chrome_source_root)/skin/*.css) \
$(wildcard $(chrome_source_root)/skin/*.png) \
$(wildcard $(chrome_source_root)/skin/*.gif) \
$(wildcard $(chrome_source_root)/skin/linux/icons/hicolor/22x22/apps/*.png) \
$(wildcard $(chrome_source_root)/skin/linux/icons/hicolor/32x32/apps/*.png) \
$(wildcard $(chrome_source_root)/locale/*/*.dtd) \
$(wildcard $(chrome_source_root)/locale/*/*.properties)
# The modules (JSM) dir.
modules_dir := modules
# The sources for the module files.
modules_sources := $(wildcard $(modules_dir)/*.js) \
$(wildcard $(modules_dir)/*.jsm) \
$(wildcard $(modules_dir)/ctypes/*.jsm) \
$(wildcard $(modules_dir)/ctypes/linux/*.jsm) \
$(wildcard $(modules_dir)/linux/*.jsm)
# The components (JSM) dir.
components_dir := components
# The JS component source files
components_sources := $(wildcard $(components_dir)/*.js)
# The sources for the XPI file. Uses variables defined in the included
# Makefiles.
xpi_includes := $(license) \
$(install_rdf) \
$(chrome_manifest) \
$(preferences_dir)/prefs.js \
$(chrome_sources) \
$(modules_sources) \
$(components_sources)
# Destination files
build_includes := $(foreach f,$(xpi_includes),$(build_dir)/$(f))
$(xpi_built): $(build_dir) $(build_includes)
@echo "Creating XPI file."
@cd $(build_dir); $(ZIP) $(xpi_file) $(xpi_includes)
@echo "Creating XPI file. Done!"
# This builds the extension XPI file.
.PHONY: build
build: $(xpi_built)
@echo
@echo "Build finished successfully."
@echo
# This cleans all temporary files and directories created by 'make'.
.PHONY: clean
clean: clean_build
@echo "Cleanup is done."
# Regex for 'no'
YES_RE := yes|y|Y|true|on
# called via $(build_includes)
$(build_dir)/%: %
@mkdir -p $(dir $@)
@cp -f $< $@ # -d for symlinks
copy_and_strip_maybe = \
@mkdir -p $(dir $(1)); \
if [[ "$(DEBUG)" =~ $(YES_RE) ]]; then \
cp -f $(2) $(1); \
else \
echo "Stripping debug calls from JS file $<"; \
sed '/F.LOG(/d' $(2) > $(1); \
fi
# Debug calls are removed for performance.
# NOTE: we could also use m4 for filtering source files...
$(build_dir)/$(chrome_source_root)/%.js: $(chrome_source_root)/%.js
$(call copy_and_strip_maybe,$@,$<)
$(build_dir)/$(modules_dir)/%: $(modules_dir)/%
$(call copy_and_strip_maybe,$@,$<)
$(build_dir)/$(components_dir)/%.js: $(components_dir)/%.js
$(call copy_and_strip_maybe,$@,$<)
$(build_dir):
@if [ ! -x $(build_dir) ]; \
then \
mkdir -p $(build_dir); \
fi
$(profile_locations):
@echo "Creating extension folder: $(profile_locations)"
@for p in $(profile_locations) ; do \
if [ ! -x "$$p" ]; \
then \
mkdir -p $$p; \
fi; \
done
clean_build:
@echo "Removing build dir: $(build_dir)"
@rm -rf $(build_dir)
Something went wrong with that request. Please try again.