5 BUILD_DATE = $(shell date "+%Y/%m/%d %H:%M:%S")
6 BASE = $(TOP)/../common
8 GOOGLE = https://$(GOOGLE_PROJ).googlecode.com/files
9 VERSION ?= $(shell sed -n 's/.*em:version\(>\|="\)\(.*\)["<].*/\2/p' $(TOP)/install.rdf | sed 1q)
10 UUID := $(shell sed -n 's/.*em:id\(>\|="\)\(.*\)["<].*/\2/p' $(TOP)/install.rdf | sed 1q)
11 MANGLE := $(shell date '+%s' | awk '{ printf "%x", $$1 }')
13 HOSTAPP_PATH = $(shell which $(HOSTAPP))
14 TEST_DIR = $(BASE)/tests/functional
15 TEST_LOG = $(TEST_DIR)/log
17 IDNAME := $(shell echo "$(NAME)" | tr a-z A-Z)
20 DOC_FILES = $(wildcard $(LOCALEDIR)/*/*.xml)
22 export VERSION BUILD_DATE
23 MAKE_JAR = sh $(BASE)/make_jar.sh
25 # TODO: specify source files manually?
26 JAR_BASES = $(TOP) $(BASE)
27 JAR_DIRS = content skin locale modules
28 JAR_TEXTS = js jsm css dtd xml xul html xhtml xsl properties
32 JAR = $(CHROME)$(NAME).jar
34 XPI_BASES = $(JAR_BASES) $(TOP)/..
35 XPI_FILES = bootstrap.js TODO AUTHORS Donors NEWS LICENSE.txt
36 XPI_DIRS = components $(MANGLE) defaults
37 XPI_TEXTS = js jsm $(JAR_TEXTS)
38 XPI_BINS = $(JAR_BINS)
40 XPI_NAME = $(NAME)-$(VERSION)
41 XPI = ../downloads/$(XPI_NAME).xpi
42 XPI_PATH = $(TOP)/$(XPI:%.xpi=%)
44 RDF = ../downloads/update.rdf
47 BUILD_DIR = build.$(VERSION).$(OS)
52 SED := $(shell if [ "xoo" = x$$(echo foo | sed -E 's/f(o)/\1/' 2>/dev/null) ]; \
53 then echo sed -E; else echo sed -r; \
60 TARGETS = all help info jar xpi install clean distclean install installxpi test $(CHROME) $(JAR)
62 echo MAKE $* $(@:$*.%=%)
63 $(MAKE) -C $* $(@:$*.%=%)
69 @echo "$(NAME) $(VERSION) build"
71 @echo " make help - display this help"
72 @echo " make info - show some info about the system"
73 @echo " make jar - build a JAR ($(JAR))"
74 @echo " make xpi - build an XPI ($(XPI_NAME))"
75 @echo " make installxpi - build an XPI and install it to your profile"
76 @echo " make install - installs this source tree directly to your $(HOSTAPP) profile"
77 @echo ' set $$PROFILE to select a profile by name and $$PROFILEPATHS'
78 @echo ' to change the directory where profiles are searched'
79 @echo " make release - updates update.rdf (this is not for you)"
80 @echo " make dist - uploads to Google Code (this is not for you)"
81 @echo " make clean - clean up"
82 @echo " make distclean - clean up more"
83 @echo " make test - run functional tests"
85 @echo "running some commands with V=1 will show more build details"
88 @echo "version $(VERSION)"
89 @echo "release file $(XPI)"
90 @echo "doc files $(DOC_FILES)"
91 @echo "xpi files $(XPI_FILES)"
95 release: $(XPI) $(RDF)
97 # This is not for you!
99 @echo DIST $(XPI) $(GOOGLE)
102 proj=$$(echo -n $(NAME) | sed 's/\(.\).*/\1/' | tr a-z A-Z); \
103 proj="$$proj$$(echo $(NAME) | sed 's/.//')"; \
104 [ -z "$$summary" ] && summary="$$proj $(VERSION) Release"; \
105 labels="Project-$$proj,$(labels)"; \
106 [ -n "$(featured)" ] && labels="$$labels,Featured"; \
108 IFS=,; for l in $$labels; do \
109 set -- "$$@" --form-string "label=$$l"; \
111 auth=$$(echo -n "$(GOOGLE_USER):$(GOOGLE_PASS)" | $(B64ENCODE)); \
112 $(CURL) "$$@" --form-string "summary=$$summary" \
113 -F "filename=@$(XPI)" \
114 -H "Authorization: Basic $$auth" \
115 -i "$(GOOGLE)" | sed -n '/^Location/{p;q;}'
119 for dir in $(PROFILEPATHS); do \
120 test -f "$$dir/profiles.ini" && break; \
123 profile=$$(sed 's/^$$/\#/' "$$dir/profiles.ini" | \
124 awk -v"profile=$(PROFILE)" \
126 index($$0, "\nName=" profile "\n") { print; exit } \
127 !profile && /\nName=default\n/ { args["name=default"] = $$0 } \
128 !profile && /\nDefault=1/ { args["default=1"] = $$0 } \
130 if (args["default=1"]) print args["default=1"]; \
131 else print args["name=default"] \
133 awk -F= '{ args[$$1] = $$2 } \
135 if (args["IsRelative"]) print ENVIRON["dir"] "/" args["Path"]; \
136 else print args["Path"] \
139 if ! test -d "$$profile"; then \
140 echo >&2 "Can't locate profile directory"; \
144 ext="$$profile/extensions/$(UUID)"; \
145 mkdir -p "$$(dirname "$$ext")"; \
146 rm -rf "$$ext.xpi" "$$ext"; \
147 echo "Installing to $$ext"; \
148 if which cygpath >/dev/null 2>&1; \
149 then cygpath -wa .; \
155 $(RDF): $(RDF_IN) Makefile
156 @echo "Preparing release..."
157 $(SED) -e "s,@VERSION@,$(VERSION),g" \
158 -e "s,@DATE@,$(BUILD_DATE),g" \
163 @echo "General $(NAME) cleanup..."
167 @echo "More $(NAME) cleanup..."
171 @echo "Running $(NAME) functional tests..."
172 $(IDNAME)_INIT="set loadplugins=" \
173 $(MOZMILL) --show-all -l $(TEST_LOG) -b $(HOSTAPP_PATH) --addons $(XPI) -t $(TEST_DIR)
178 @echo "Building XPI..."
179 mkdir -p "$(XPI_PATH)"
181 $(AWK) -v 'name=$(NAME)' -v 'suffix=$(MANGLE)' \
182 -f $(BASE)/process_manifest.awk \
183 "$(TOP)/chrome.manifest" >"$(XPI_PATH)/chrome.manifest"
185 version="$(VERSION)"; \
186 hg root >/dev/null 2>&1 && \
187 case "$$version" in \
188 *pre) version="$$version-hg$$(hg log -r . --template '{rev}')-$$(hg branch)";; \
190 $(SED) -e 's/(em:version(>|="))([^"<]+)/\1'"$$version/" \
191 <"$(TOP)/install.rdf" >"$(XPI_PATH)/install.rdf"
193 $(MAKE_JAR) "$(XPI)" "$(XPI_BASES)" "$(XPI_DIRS)" "$(XPI_TEXTS)" "$(XPI_BINS)" "$(XPI_FILES)"
195 @echo "Built XPI: $(XPI)"
200 @echo "Packaging chrome..."
201 $(MAKE_JAR) -r "$(@)" "$(JAR_BASES)" "$(JAR_DIRS)" "$(JAR_TEXTS)" "$(JAR_BINS)" "$(JAR_FILES)"