11# ### configuration
22
3- TOP = $(shell pwd)
4- OS = $(shell uname -s)
53BUILD_DATE = $(shell date "+% Y/% m/% d % H:% M:% S")
64COMMON_DIR = ../common
7- GOOGLE_PROJ = vimperator-labs
8- GOOGLE = https://$(GOOGLE_PROJ ) .googlecode.com/files
95
106LOCALEDIR = locale
117ifeq ($(LOCALE ) ,)
1511endif
1612DOC_FILES = $(foreach dir,$(LOCALEDIR ) ,$(wildcard $(dir ) /* .xml) )
1713
18- # TODO: only add these file types?
19- # JAR_TEXTS = js css dtd xml xul html xhtml xsl
20- # JAR_BINS = png
21- # XPI_TEXTS = js jsm
22-
2314XPI_FILES = install.rdf TODO AUTHORS NEWS chrome.manifest ../License.txt
2415XPI_DIRS = components $(COMMON_DIR ) /components
25- CHROME_DIRS = content skin $( LOCALEDIR )
26- COMMON_CHROME_DIRS = content skin modules $( LOCALEDIR )
16+ CHROME_DIRS = content skin
17+ COMMON_CHROME_DIRS = content skin modules
2718
2819XPI_NAME = $(NAME ) -$(VERSION )
2920XPI_PATH = ../downloads/$(XPI_NAME )
3021XPI = $(XPI_PATH ) .xpi
3122
32- AWK = awk
33- CURL = curl
34- B64ENCODE = base64
35- # Mac OS X's sed and cp is not run because BSD's syntax
36- # use make -e SED=gsed CP=gcp ...
37- SED ?= sed
38- CP ?= cp
23+ ifeq ($(TOPLEVEL ) ,)
24+ XPI_FILE = $(XPI)
25+ else
26+ XPI_FILE = downloads/$(XPI_NAME).xpi
27+ endif
3928
4029.SILENT :
4130
4231# ### rules
4332
4433TARGETS = all help info xpi clean
4534$(TARGETS:% =\%.%):
46- echo MAKE $* $(@:$*.%=%)
35+ @ echo MAKE $* $(@:$*.%=%)
4736 $(MAKE) -C $* $(@:$*.%=%)
4837
4938.PHONY : $(TARGETS )
5544 @echo " make help - display this help"
5645 @echo " make info - show some info about the system"
5746 @echo " make xpi - build an XPI ($( XPI_NAME) )"
58- @echo " make dist - uploads to Google Code (this is not for you)"
5947 @echo " make clean - clean up"
6048 @echo
6149 @echo " running some commands with V=1 will show more build details"
@@ -66,52 +54,74 @@ info:
6654 @echo " doc files $( DOC_FILES) "
6755 @echo " xpi files $( XPI_FILES) "
6856
69- # This is not for you!
70- dist : $(XPI )
71- @echo DIST $(XPI ) $(GOOGLE )
72- set -e; \
73- which $$(echo $(B64ENCODE ) | $(AWK ) '{print $1}' ) > /dev/null; \
74- \
75- proj=$$(echo -n $(NAME ) | $(SED ) 's/\(.\ ) .* /\1 /' | tr a-z A-Z); \
76- proj=" $$ proj$$ (echo $( NAME) | $( SED) 's/.//')" ; \
77- [ -z " $$ summary" ] && summary=" $$ proj $( VERSION) Release" ; \
78- labels=" Project-$$ proj,$( labels) " ; \
79- [ -n " $( featured) " ] && labels=" $$ labels,Featured" ; \
80- \
81- IFS=,; for l in $$ labels; do \
82- set -- " $$ @" --form-string " label=$$ l" ; \
83- done ; \
84- $(CURL ) " $$ @" --form-string " summary=$$ summary" \
85- -F " filename=@$( XPI) " \
86- -H " Authorization: Basic $$ (echo -n " $(GOOGLE_USER ) :$(GOOGLE_PASS ) " | $( B64ENCODE) )" \
87- -i " $( GOOGLE) " | $(SED ) -n ' /^Location/{p;q;}'
88-
8957clean :
9058 @echo " General $( NAME) cleanup..."
9159 rm -f $(XPI )
9260
9361xpi :
9462 @echo " Building XPI..."
9563 # Create folder structure
96- mkdir -p $(XPI_PATH ) /common
64+ mkdir -p $(XPI_PATH ) /common/locale
65+ mkdir -p $(XPI_PATH ) /locale
66+
9767 # Copy top level files
98- $(CP ) -L $(XPI_FILES ) -t $(XPI_PATH ) || true
68+ cp -L $(XPI_FILES) $(XPI_PATH)
69+
9970 @echo "Update chrome.manifest for paths used inside the XPI..."
100- $(SED ) -i -e ' s#../common/#common/#' $(XPI_PATH ) /chrome.manifest
71+ sed -i -e 's# ../common/#common/#' $(XPI_PATH)/chrome.manifest
72+
10173 if [ "x$(LOCALE)" != "x" ]; then \
10274 echo "locale $(NAME) $(LOCALE) locale/$(LOCALE)/" >> $(XPI_PATH)/chrome.manifest; \
10375 echo "locale liberator $(LOCALE) common/locale/$(LOCALE)/" >> $(XPI_PATH)/chrome.manifest; \
10476 fi
77+
10578 # Copy components and modules directories
106- find $(XPI_DIRS ) -follow -type f ! -name " .*" -print0 | xargs -0i $(CP ) --parents {} -t $(XPI_PATH ) || true
107- # Copy all chrome files, from both commmon/ and vimperator/ folders
108- cd $(COMMON_DIR ) && find $(COMMON_CHROME_DIRS ) -follow -type f ! -name " .*" -print0 | xargs -0i $(CP ) --parents {} -t $(XPI_PATH ) /common || true
109- find $(CHROME_DIRS ) -follow -type f ! -name " .*" -print0 | xargs -0i $(CP ) --parents {} -t $(XPI_PATH ) || true
110- # TODO: Replace ###VERSION### tags
79+ cp -LR $(XPI_DIRS) $(XPI_PATH)
80+
81+ # Copy all chrome files from commmon/ folder
82+ cd $(COMMON_DIR) && \
83+ cp -LR $(COMMON_CHROME_DIRS) $(XPI_PATH)/common && \
84+ cp -LR $(LOCALEDIR) $(XPI_PATH)/common/locale || true
85+
86+ # Copy all chrome files from vimperator|muttator folder
87+ cp -LR $(CHROME_DIRS) $(XPI_PATH)
88+ cp -LR $(LOCALEDIR) $(XPI_PATH)/locale || true
89+
11190 @echo "Replacing # ##VERSION### and ###DATE### tags"
112- find $(XPI_PATH ) -type f ! -name " *.png" -exec $(SED ) -i -e " s,###VERSION###,$( VERSION) ,g" -e " s,###DATE###,$( BUILD_DATE) ,g" {} \;
91+ for file in `grep -rl -e "# ##VERSION###" -e "###DATE###" $(XPI_PATH)`; do \
92+ sed -i -e "s,###VERSION###,$(VERSION),g" $${file}; \
93+ sed -i -e "s,###DATE###,$(BUILD_DATE),g" $${file}; \
94+ done
95+
96+ # Delete unknown file types
97+ find $(XPI_PATH) -type f \
98+ ! -name 'AUTHORS' \
99+ -a ! -name 'TODO' \
100+ -a ! -name 'NEWS' \
101+ -a ! -name 'install.rdf' \
102+ -a ! -name 'chrome.manifest' \
103+ -a ! -name 'License.txt' \
104+ -a ! -name 'Makefile' \
105+ -a ! -name '*.css' \
106+ -a ! -name '*.dtd' \
107+ -a ! -name '*.xml' \
108+ -a ! -name '*.xul' \
109+ -a ! -name '*.html' \
110+ -a ! -name '*.xhtml' \
111+ -a ! -name '*.xsl' \
112+ -a ! -name '*.png' \
113+ -a ! -name '*.svg' \
114+ -a ! -name '*.js' \
115+ -a ! -name '*.jsm' \
116+ -delete
117+
113118 # Zip the whole directory and remove dist folder
114- cd $(XPI_PATH ) && zip -9r ../$(XPI_NAME ) .xpi *
119+ @echo Packaging up $(XPI_NAME).xpi
120+ cd $(XPI_PATH) && zip -q -9r ../$(XPI_NAME).xpi *
121+
122+ # Clean out build files
115123 rm -rf $(XPI_PATH)
116- @echo " SUCCESS: $( XPI_PATH) .xpi"
124+ rm -rf ../downloads/common
125+
126+ @echo "SUCCESS: $(XPI_FILE)"
117127
0 commit comments