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_FILES = config.json
36 JAR_DIRS = content skin locale modules
37 JAR_TEXTS = js jsm css dtd xml xul html xhtml xsl properties json
41 JAR = $(CHROME)$(NAME).jar
43 XPI_BASES = $(JAR_BASES) $(TOP)/..
44 XPI_FILES = icon.png icon64.png bootstrap.js TODO AUTHORS Donors NEWS LICENSE.txt
45 XPI_DIRS = components $(MANGLE) defaults
46 XPI_TEXTS = js jsm $(JAR_TEXTS)
47 XPI_BINS = $(JAR_BINS)
49 XPI_NAME = $(NAME)-$(VERSION)
50 XPI = ../downloads/$(XPI_NAME).xpi
51 XPI_PATH = $(TOP)/$(XPI:%.xpi=%)
53 RDF = ../downloads/update.rdf
56 BUILD_DIR = build.$(VERSION).$(OS)
62 TARGETS = all help info jar xpi install clean distclean install installxpi test $(CHROME) $(JAR)
64 echo MAKE $* $(@:$*.%=%)
65 $(MAKE) -C $* $(@:$*.%=%)
71 @echo "$(NAME) $(VERSION) build"
73 @echo " make help - display this help"
74 @echo " make info - show some info about the system"
75 @echo " make jar - build a JAR ($(JAR))"
76 @echo " make xpi - build an XPI ($(XPI_NAME))"
77 @echo " make installxpi - build an XPI and install it to your profile"
78 @echo " make install - installs this source tree directly to your $(HOSTAPP) profile"
79 @echo ' set $$PROFILE to select a profile by name and $$PROFILEPATHS'
80 @echo ' to change the directory where profiles are searched'
81 @echo " make release - updates update.rdf (this is not for you)"
82 @echo " make dist - uploads to Google Code (this is not for you)"
83 @echo " make clean - clean up"
84 @echo " make distclean - clean up more"
85 @echo " make test - run functional tests"
87 @echo "running some commands with V=1 will show more build details"
90 @echo "version $(VERSION)"
91 @echo "release file $(XPI)"
92 @echo "doc files $(DOC_FILES)"
93 @echo "xpi files $(XPI_FILES)"
97 release: $(XPI) $(RDF)
99 # This is not for you!
101 @echo DIST $(XPI) $(GOOGLE)
104 proj=$$(echo -n $(NAME) | sed 's/\(.\).*/\1/' | tr a-z A-Z); \
105 proj="$$proj$$(echo $(NAME) | sed 's/.//')"; \
106 [ -z "$$summary" ] && summary="$$proj $(VERSION) Release"; \
107 labels="Project-$$proj,$(labels)"; \
108 [ -n "$(featured)" ] && labels="$$labels,Featured"; \
110 IFS=,; for l in $$labels; do \
111 set -- "$$@" --form-string "label=$$l"; \
113 auth=$$(echo -n "$(GOOGLE_USER):$(GOOGLE_PASS)" | $(B64ENCODE)); \
114 $(CURL) "$$@" --form-string "summary=$$summary" \
115 -F "filename=@$(XPI)" \
116 -H "Authorization: Basic $$auth" \
117 -i "$(GOOGLE)" | sed -n '/^Location/{p;q;}'
121 for dir in $(PROFILEPATHS); do \
122 test -f "$$dir/profiles.ini" && break; \
125 profile=$$(sed 's/^$$/\#/' "$$dir/profiles.ini" | \
126 awk -v "profile=$(PROFILE)" \
128 index($$0, "\nName=" profile "\n") { print; exit } \
129 !profile && /\nName=default\n/ { args["name=default"] = $$0 } \
130 !profile && /\nDefault=1/ { args["default=1"] = $$0 } \
132 if (args["default=1"]) print args["default=1"]; \
133 else print args["name=default"] \
135 awk -F= '{ args[$$1] = $$2 } \
137 if (args["IsRelative"]) print ENVIRON["dir"] "/" args["Path"]; \
138 else print args["Path"] \
141 if ! test -d "$$profile"; then \
142 echo >&2 "Can't locate profile directory"; \
147 ext="$$profile/extensions/$$2"; \
148 mkdir -p "$$(dirname "$$ext")"; \
149 rm -rf "$$ext.xpi" "$$ext"; \
151 echo "Installing $$2 to $$ext"; \
152 if which cygpath >/dev/null 2>&1; \
153 then cygpath -wa $$1; \
154 else (cd $$1; pwd); \
158 install ../binary binary@dactyl.googlecode.com; \
163 $(RDF): $(RDF_IN) Makefile
164 @echo "Preparing release..."
165 $(SED) -e "s,@VERSION@,$(VERSION),g" \
166 -e "s,@DATE@,$(BUILD_DATE),g" \
171 @echo "General $(NAME) cleanup..."
175 @echo "More $(NAME) cleanup..."
179 @echo "Running $(NAME) functional tests..."
180 $(IDNAME)_INIT="set loadplugins=" \
181 $(MOZMILL) --show-all -l $(TEST_LOG) -b $(HOSTAPP_PATH) --addons $(XPI) -t $(TEST_DIR)
186 @echo "Building XPI..."
187 mkdir -p "$(XPI_PATH)"
189 $(AWK) -v 'name=$(NAME)' -v 'suffix=$(MANGLE)' \
190 -f $(BASE)/process_manifest.awk \
191 "$(TOP)/chrome.manifest" >"$(XPI_PATH)/chrome.manifest"
193 version="$(VERSION)"; \
194 hg root >/dev/null 2>&1 && \
195 case "$$version" in \
196 *pre) version="$$version-hg$$(hg log -r . --template '{rev}')-$$(hg branch)";; \
198 $(SED) -e 's/(em:version(>|="))([^"<]+)/\1'"$$version/" \
199 <"$(TOP)/install.rdf" >"$(XPI_PATH)/install.rdf"
201 $(MAKE_JAR) "$(XPI)" "$(XPI_BASES)" "$(XPI_DIRS)" "$(XPI_TEXTS)" "$(XPI_BINS)" "$(XPI_FILES)"
203 @echo "Built XPI: $(XPI)"
208 @echo "Packaging chrome..."
209 $(MAKE_JAR) -r "$(@)" "$(JAR_BASES)" "$(JAR_DIRS)" "$(JAR_TEXTS)" "$(JAR_BINS)" "$(JAR_FILES)"