7 SED := $(shell if [ "xoo" = x$$(echo foo | sed -E 's/f(o)/\1/' 2>/dev/null) ]; \
8 then echo sed -E; else echo sed -r; \
12 OS = $(shell uname -s)
13 BUILD_DATE = $(shell date "+%Y/%m/%d %H:%M:%S")
14 BASE = $(TOP)/../common
16 GOOGLE = https://$(GOOGLE_PROJ).googlecode.com/files
17 VERSION ?= $(shell $(SED) -n 's/.*em:version(>|=")(.*)["<].*/\2/p' $(TOP)/install.rdf | sed 1q)
18 UUID := $(shell $(SED) -n 's/.*em:id(>|=")(.*)["<].*/\2/p' $(TOP)/install.rdf | sed 1q)
19 MANGLE := $(shell date '+%s' | awk '{ printf "%x", $$1 }')
21 HOSTAPP_PATH = $(shell which $(HOSTAPP))
22 TEST_DIR = $(BASE)/tests/functional
23 TEST_LOG = $(TEST_DIR)/log
25 IDNAME := $(shell echo "$(NAME)" | tr a-z A-Z)
28 DOC_FILES = $(wildcard $(LOCALEDIR)/*/*.xml)
30 export VERSION BUILD_DATE
31 MAKE_JAR = sh $(BASE)/make_jar.sh
33 # TODO: specify source files manually?
34 JAR_BASES = $(TOP) $(BASE)
35 JAR_DIRS = content skin locale modules
36 JAR_TEXTS = js jsm css dtd xml xul html xhtml xsl properties
40 JAR = $(CHROME)$(NAME).jar
42 XPI_BASES = $(JAR_BASES) $(TOP)/..
43 XPI_FILES = bootstrap.js TODO AUTHORS Donors NEWS LICENSE.txt
44 XPI_DIRS = components $(MANGLE) defaults
45 XPI_TEXTS = js jsm $(JAR_TEXTS)
46 XPI_BINS = $(JAR_BINS)
48 XPI_NAME = $(NAME)-$(VERSION)
49 XPI = ../downloads/$(XPI_NAME).xpi
50 XPI_PATH = $(TOP)/$(XPI:%.xpi=%)
52 RDF = ../downloads/update.rdf
55 BUILD_DIR = build.$(VERSION).$(OS)
61 TARGETS = all help info jar xpi install clean distclean install installxpi test $(CHROME) $(JAR)
63 echo MAKE $* $(@:$*.%=%)
64 $(MAKE) -C $* $(@:$*.%=%)
70 @echo "$(NAME) $(VERSION) build"
72 @echo " make help - display this help"
73 @echo " make info - show some info about the system"
74 @echo " make jar - build a JAR ($(JAR))"
75 @echo " make xpi - build an XPI ($(XPI_NAME))"
76 @echo " make installxpi - build an XPI and install it to your profile"
77 @echo " make install - installs this source tree directly to your $(HOSTAPP) profile"
78 @echo ' set $$PROFILE to select a profile by name and $$PROFILEPATHS'
79 @echo ' to change the directory where profiles are searched'
80 @echo " make release - updates update.rdf (this is not for you)"
81 @echo " make dist - uploads to Google Code (this is not for you)"
82 @echo " make clean - clean up"
83 @echo " make distclean - clean up more"
84 @echo " make test - run functional tests"
86 @echo "running some commands with V=1 will show more build details"
89 @echo "version $(VERSION)"
90 @echo "release file $(XPI)"
91 @echo "doc files $(DOC_FILES)"
92 @echo "xpi files $(XPI_FILES)"
96 release: $(XPI) $(RDF)
98 # This is not for you!
100 @echo DIST $(XPI) $(GOOGLE)
103 proj=$$(echo -n $(NAME) | sed 's/\(.\).*/\1/' | tr a-z A-Z); \
104 proj="$$proj$$(echo $(NAME) | sed 's/.//')"; \
105 [ -z "$$summary" ] && summary="$$proj $(VERSION) Release"; \
106 labels="Project-$$proj,$(labels)"; \
107 [ -n "$(featured)" ] && labels="$$labels,Featured"; \
109 IFS=,; for l in $$labels; do \
110 set -- "$$@" --form-string "label=$$l"; \
112 auth=$$(echo -n "$(GOOGLE_USER):$(GOOGLE_PASS)" | $(B64ENCODE)); \
113 $(CURL) "$$@" --form-string "summary=$$summary" \
114 -F "filename=@$(XPI)" \
115 -H "Authorization: Basic $$auth" \
116 -i "$(GOOGLE)" | sed -n '/^Location/{p;q;}'
120 for dir in $(PROFILEPATHS); do \
121 test -f "$$dir/profiles.ini" && break; \
124 profile=$$(sed 's/^$$/\#/' "$$dir/profiles.ini" | \
125 awk -v "profile=$(PROFILE)" \
127 index($$0, "\nName=" profile "\n") { print; exit } \
128 !profile && /\nName=default\n/ { args["name=default"] = $$0 } \
129 !profile && /\nDefault=1/ { args["default=1"] = $$0 } \
131 if (args["default=1"]) print args["default=1"]; \
132 else print args["name=default"] \
134 awk -F= '{ args[$$1] = $$2 } \
136 if (args["IsRelative"]) print ENVIRON["dir"] "/" args["Path"]; \
137 else print args["Path"] \
140 if ! test -d "$$profile"; then \
141 echo >&2 "Can't locate profile directory"; \
145 ext="$$profile/extensions/$(UUID)"; \
146 mkdir -p "$$(dirname "$$ext")"; \
147 rm -rf "$$ext.xpi" "$$ext"; \
148 echo "Installing to $$ext"; \
149 if which cygpath >/dev/null 2>&1; \
150 then cygpath -wa .; \
156 $(RDF): $(RDF_IN) Makefile
157 @echo "Preparing release..."
158 $(SED) -e "s,@VERSION@,$(VERSION),g" \
159 -e "s,@DATE@,$(BUILD_DATE),g" \
164 @echo "General $(NAME) cleanup..."
168 @echo "More $(NAME) cleanup..."
172 @echo "Running $(NAME) functional tests..."
173 $(IDNAME)_INIT="set loadplugins=" \
174 $(MOZMILL) --show-all -l $(TEST_LOG) -b $(HOSTAPP_PATH) --addons $(XPI) -t $(TEST_DIR)
179 @echo "Building XPI..."
180 mkdir -p "$(XPI_PATH)"
182 $(AWK) -v 'name=$(NAME)' -v 'suffix=$(MANGLE)' \
183 -f $(BASE)/process_manifest.awk \
184 "$(TOP)/chrome.manifest" >"$(XPI_PATH)/chrome.manifest"
186 version="$(VERSION)"; \
187 hg root >/dev/null 2>&1 && \
188 case "$$version" in \
189 *pre) version="$$version-hg$$(hg log -r . --template '{rev}')-$$(hg branch)";; \
191 $(SED) -e 's/(em:version(>|="))([^"<]+)/\1'"$$version/" \
192 <"$(TOP)/install.rdf" >"$(XPI_PATH)/install.rdf"
194 $(MAKE_JAR) "$(XPI)" "$(XPI_BASES)" "$(XPI_DIRS)" "$(XPI_TEXTS)" "$(XPI_BINS)" "$(XPI_FILES)"
196 @echo "Built XPI: $(XPI)"
201 @echo "Packaging chrome..."
202 $(MAKE_JAR) -r "$(@)" "$(JAR_BASES)" "$(JAR_DIRS)" "$(JAR_TEXTS)" "$(JAR_BINS)" "$(JAR_FILES)"