1
1
# ### configuration
2
2
3
- TOP = $(shell pwd)
4
- OS = $(shell uname -s)
5
3
BUILD_DATE = $(shell date "+% Y/% m/% d % H:% M:% S")
6
4
COMMON_DIR = ../common
7
- GOOGLE_PROJ = vimperator-labs
8
- GOOGLE = https://$(GOOGLE_PROJ ) .googlecode.com/files
9
5
10
6
LOCALEDIR = locale
11
7
ifeq ($(LOCALE ) ,)
15
11
endif
16
12
DOC_FILES = $(foreach dir,$(LOCALEDIR ) ,$(wildcard $(dir ) /* .xml) )
17
13
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
-
23
14
XPI_FILES = install.rdf TODO AUTHORS NEWS chrome.manifest ../License.txt
24
15
XPI_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
27
18
28
19
XPI_NAME = $(NAME ) -$(VERSION )
29
20
XPI_PATH = ../downloads/$(XPI_NAME )
30
21
XPI = $(XPI_PATH ) .xpi
31
22
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
39
28
40
29
.SILENT :
41
30
42
31
# ### rules
43
32
44
33
TARGETS = all help info xpi clean
45
34
$(TARGETS:% =\%.%):
46
- echo MAKE $* $(@:$*.%=%)
35
+ @ echo MAKE $* $(@:$*.%=%)
47
36
$(MAKE) -C $* $(@:$*.%=%)
48
37
49
38
.PHONY : $(TARGETS )
55
44
@echo " make help - display this help"
56
45
@echo " make info - show some info about the system"
57
46
@echo " make xpi - build an XPI ($( XPI_NAME) )"
58
- @echo " make dist - uploads to Google Code (this is not for you)"
59
47
@echo " make clean - clean up"
60
48
@echo
61
49
@echo " running some commands with V=1 will show more build details"
@@ -66,52 +54,74 @@ info:
66
54
@echo " doc files $( DOC_FILES) "
67
55
@echo " xpi files $( XPI_FILES) "
68
56
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
-
89
57
clean :
90
58
@echo " General $( NAME) cleanup..."
91
59
rm -f $(XPI )
92
60
93
61
xpi :
94
62
@echo " Building XPI..."
95
63
# Create folder structure
96
- mkdir -p $(XPI_PATH ) /common
64
+ mkdir -p $(XPI_PATH ) /common/locale
65
+ mkdir -p $(XPI_PATH ) /locale
66
+
97
67
# Copy top level files
98
- $(CP ) -L $(XPI_FILES ) -t $(XPI_PATH ) || true
68
+ cp -L $(XPI_FILES) $(XPI_PATH)
69
+
99
70
@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
+
101
73
if [ "x$(LOCALE)" != "x" ]; then \
102
74
echo "locale $(NAME) $(LOCALE) locale/$(LOCALE)/" >> $(XPI_PATH)/chrome.manifest; \
103
75
echo "locale liberator $(LOCALE) common/locale/$(LOCALE)/" >> $(XPI_PATH)/chrome.manifest; \
104
76
fi
77
+
105
78
# 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
+
111
90
@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
+
113
118
# 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
115
123
rm -rf $(XPI_PATH)
116
- @echo " SUCCESS: $( XPI_PATH) .xpi"
124
+ rm -rf ../downloads/common
125
+
126
+ @echo "SUCCESS: $(XPI_FILE)"
117
127
0 commit comments