4 _SH := $(shell if which dash >/dev/null 2>&1; \
12 SED := $(shell if [ "xoo" = x$$(echo foo | sed -E 's/f(o)/\1/' 2>/dev/null) ]; \
18 OS = $(shell uname -s)
19 BUILD_DATE = $(shell date "+%Y/%m/%d %H:%M:%S")
20 BASE = $(TOP)/../common
22 GOOGLE = https://$(GOOGLE_PROJ).googlecode.com/files
23 VERSION ?= $(shell $(SED) -n 's/.*em:version(>|=")(.*)["<].*/\2/p' $(TOP)/install.rdf | sed 1q)
24 UUID := $(shell $(SED) -n 's/.*em:id(>|=")(.*)["<].*/\2/p' $(TOP)/install.rdf | sed 1q)
27 HOSTAPP_PATH = $(shell which $(HOSTAPP))
28 TEST_DIR = $(BASE)/tests/functional
29 TEST_LOG = $(TEST_DIR)/log
31 IDNAME := $(shell echo "$(NAME)" | tr a-z A-Z)
34 DOC_FILES = $(wildcard $(LOCALEDIR)/*/*.xml)
36 export VERSION BUILD_DATE
37 MAKE_JAR = $(SH) $(BASE)/make_jar.sh
39 # TODO: specify source files manually?
40 JAR_BASES = $(TOP) $(BASE)
41 JAR_FILES = config.json
42 JAR_DIRS = content skin locale modules
43 JAR_TEXTS = js jsm css dtd xml xul html xhtml xsl properties json
47 JAR = $(CHROME)$(NAME).jar
49 XPI_BASES = $(JAR_BASES) $(TOP)/..
50 XPI_FILES = icon.png icon64.png bootstrap.js TODO AUTHORS Donors NEWS LICENSE.txt
51 XPI_DIRS = components $(MANGLE) defaults
52 XPI_TEXTS = js jsm $(JAR_TEXTS)
53 XPI_BINS = $(JAR_BINS)
55 XPI_NAME = $(NAME)-$(VERSION)
56 XPI = ../downloads/$(XPI_NAME).xpi
57 XPI_PATH = $(TOP)/$(XPI:%.xpi=%)
59 BUILD_DIR = build.$(VERSION).$(OS)
65 TARGETS = all help info jar xpi install clean distclean install installxpi test $(CHROME) $(JAR)
67 echo MAKE $* $(@:$*.%=%)
68 $(MAKE) -C $* $(@:$*.%=%)
74 @echo "$(NAME) $(VERSION) build"
76 @echo " make help - display this help"
77 @echo " make info - show some info about the system"
78 @echo " make jar - build a JAR ($(JAR))"
79 @echo " make xpi - build an XPI ($(XPI_NAME))"
80 @echo " make installxpi - build an XPI and install it to your profile"
81 @echo " make install - installs this source tree directly to your $(HOSTAPP) profile"
82 @echo ' set $$PROFILE to select a profile by name and $$PROFILEPATHS'
83 @echo ' to change the directory where profiles are searched'
84 @echo " make dist - uploads to Google Code (this is not for you)"
85 @echo " make clean - clean up"
86 @echo " make distclean - clean up more"
87 @echo " make test - run functional tests"
89 @echo "running some commands with V=1 will show more build details"
92 @echo "version $(VERSION)"
93 @echo "release file $(XPI)"
94 @echo "doc files $(DOC_FILES)"
95 @echo "xpi files $(XPI_FILES)"
101 for dir in $(PROFILEPATHS); do \
102 test -f "$$dir/profiles.ini" && break; \
105 profile=$$(sed 's/^$$/\#/' "$$dir/profiles.ini" | \
106 awk -v "profile=$(PROFILE)" \
108 index($$0, "\nName=" profile "\n") { print; exit } \
109 !profile && /\nName=default\n/ { args["name=default"] = $$0 } \
110 !profile && /\nDefault=1/ { args["default=1"] = $$0 } \
112 if (args["default=1"]) print args["default=1"]; \
113 else print args["name=default"] \
115 awk -F= '{ args[$$1] = $$2 } \
117 if (args["IsRelative"]) print ENVIRON["dir"] "/" args["Path"]; \
118 else print args["Path"] \
121 if ! test -d "$$profile"; then \
122 echo >&2 "Can't locate profile directory"; \
127 ext="$$profile/extensions/$$2"; \
128 mkdir -p "$$(dirname "$$ext")"; \
129 rm -rf "$$ext.xpi" "$$ext"; \
131 echo "Installing $$2 to $$ext"; \
132 if which cygpath >/dev/null 2>&1; \
133 then cygpath -wa $$1; \
134 else (cd $$1; pwd); \
138 install ../binary binary@dactyl.googlecode.com; \
144 @echo "General $(NAME) cleanup..."
148 @echo "More $(NAME) cleanup..."
152 @echo "Running $(NAME) functional tests..."
153 $(IDNAME)_INIT="set loadplugins=" \
154 $(MOZMILL) --show-all -l $(TEST_LOG) -b $(HOSTAPP_PATH) --addons $(XPI) -t $(TEST_DIR)
159 @echo "Building XPI..."
160 mkdir -p "$(XPI_PATH)"
162 $(AWK) -v 'name=$(NAME)' -v 'suffix=$(MANGLE)' \
163 -f $(BASE)/process_manifest.awk \
164 "$(TOP)/chrome.manifest" >"$(XPI_PATH)/chrome.manifest"
166 $(AWK) -v 'name=$(NAME)' -v 'suffix=$(MANGLE)' \
167 -f $(BASE)/process_config.awk \
168 "$(TOP)/config.json" >"$(XPI_PATH)/config.json"
170 version="$(VERSION)"; \
171 hg root >/dev/null 2>&1 && \
172 case "$$version" in \
173 *pre) version="$$version-hg$$(hg log -r . --template '{rev}')-$$(hg branch)";; \
175 $(SED) -e 's/(em:version(>|="))([^"<]+)/\1'"$$version/" \
176 <"$(TOP)/install.rdf" >"$(XPI_PATH)/install.rdf"
178 $(MAKE_JAR) "$(XPI)" "$(XPI_BASES)" "$(XPI_DIRS)" "$(XPI_TEXTS)" "$(XPI_BINS)" "$(XPI_FILES)"
180 @echo "Built XPI: $(XPI)"
185 @echo "Packaging chrome..."
186 $(MAKE_JAR) -r "$(@)" "$(JAR_BASES)" "$(JAR_DIRS)" "$(JAR_TEXTS)" "$(JAR_BINS)" "$(JAR_FILES)"