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)
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 BUILD_DIR = build.$(VERSION).$(OS)
59 TARGETS = all help info jar xpi install clean distclean install installxpi test $(CHROME) $(JAR)
61 echo MAKE $* $(@:$*.%=%)
62 $(MAKE) -C $* $(@:$*.%=%)
68 @echo "$(NAME) $(VERSION) build"
70 @echo " make help - display this help"
71 @echo " make info - show some info about the system"
72 @echo " make jar - build a JAR ($(JAR))"
73 @echo " make xpi - build an XPI ($(XPI_NAME))"
74 @echo " make installxpi - build an XPI and install it to your profile"
75 @echo " make install - installs this source tree directly to your $(HOSTAPP) profile"
76 @echo ' set $$PROFILE to select a profile by name and $$PROFILEPATHS'
77 @echo ' to change the directory where profiles are searched'
78 @echo " make dist - uploads to Google Code (this is not for you)"
79 @echo " make clean - clean up"
80 @echo " make distclean - clean up more"
81 @echo " make test - run functional tests"
83 @echo "running some commands with V=1 will show more build details"
86 @echo "version $(VERSION)"
87 @echo "release file $(XPI)"
88 @echo "doc files $(DOC_FILES)"
89 @echo "xpi files $(XPI_FILES)"
93 # This is not for you!
95 @echo DIST $(XPI) $(GOOGLE)
98 proj=$$(echo -n $(NAME) | sed 's/\(.\).*/\1/' | tr a-z A-Z); \
99 proj="$$proj$$(echo $(NAME) | sed 's/.//')"; \
100 [ -z "$$summary" ] && summary="$$proj $(VERSION) Release"; \
101 labels="Project-$$proj,$(labels)"; \
102 [ -n "$(featured)" ] && labels="$$labels,Featured"; \
104 IFS=,; for l in $$labels; do \
105 set -- "$$@" --form-string "label=$$l"; \
107 auth=$$(echo -n "$(GOOGLE_USER):$(GOOGLE_PASS)" | $(B64ENCODE)); \
108 $(CURL) "$$@" --form-string "summary=$$summary" \
109 -F "filename=@$(XPI)" \
110 -H "Authorization: Basic $$auth" \
111 -i "$(GOOGLE)" | sed -n '/^Location/{p;q;}'
115 for dir in $(PROFILEPATHS); do \
116 test -f "$$dir/profiles.ini" && break; \
119 profile=$$(sed 's/^$$/\#/' "$$dir/profiles.ini" | \
120 awk -v "profile=$(PROFILE)" \
122 index($$0, "\nName=" profile "\n") { print; exit } \
123 !profile && /\nName=default\n/ { args["name=default"] = $$0 } \
124 !profile && /\nDefault=1/ { args["default=1"] = $$0 } \
126 if (args["default=1"]) print args["default=1"]; \
127 else print args["name=default"] \
129 awk -F= '{ args[$$1] = $$2 } \
131 if (args["IsRelative"]) print ENVIRON["dir"] "/" args["Path"]; \
132 else print args["Path"] \
135 if ! test -d "$$profile"; then \
136 echo >&2 "Can't locate profile directory"; \
141 ext="$$profile/extensions/$$2"; \
142 mkdir -p "$$(dirname "$$ext")"; \
143 rm -rf "$$ext.xpi" "$$ext"; \
145 echo "Installing $$2 to $$ext"; \
146 if which cygpath >/dev/null 2>&1; \
147 then cygpath -wa $$1; \
148 else (cd $$1; pwd); \
152 install ../binary binary@dactyl.googlecode.com; \
158 @echo "General $(NAME) cleanup..."
162 @echo "More $(NAME) cleanup..."
166 @echo "Running $(NAME) functional tests..."
167 $(IDNAME)_INIT="set loadplugins=" \
168 $(MOZMILL) --show-all -l $(TEST_LOG) -b $(HOSTAPP_PATH) --addons $(XPI) -t $(TEST_DIR)
173 @echo "Building XPI..."
174 mkdir -p "$(XPI_PATH)"
176 $(AWK) -v 'name=$(NAME)' -v 'suffix=$(MANGLE)' \
177 -f $(BASE)/process_manifest.awk \
178 "$(TOP)/chrome.manifest" >"$(XPI_PATH)/chrome.manifest"
180 version="$(VERSION)"; \
181 hg root >/dev/null 2>&1 && \
182 case "$$version" in \
183 *pre) version="$$version-hg$$(hg log -r . --template '{rev}')-$$(hg branch)";; \
185 $(SED) -e 's/(em:version(>|="))([^"<]+)/\1'"$$version/" \
186 <"$(TOP)/install.rdf" >"$(XPI_PATH)/install.rdf"
188 $(MAKE_JAR) "$(XPI)" "$(XPI_BASES)" "$(XPI_DIRS)" "$(XPI_TEXTS)" "$(XPI_BINS)" "$(XPI_FILES)"
190 @echo "Built XPI: $(XPI)"
195 @echo "Packaging chrome..."
196 $(MAKE_JAR) -r "$(@)" "$(JAR_BASES)" "$(JAR_DIRS)" "$(JAR_TEXTS)" "$(JAR_BINS)" "$(JAR_FILES)"