1.4.1 code
[text-to-image.git] / Makefile.common
blob368d60135543e39cc5833a15198c96b2301b3c81
1 # Heavily based on vimperator's makefile and adapted from GameFOX
3 #### configuration
5 TOP           = $(shell pwd)
6 OS            = $(shell uname -s)
7 BUILD_DATE    = $(shell date "+%Y-%m-%d %H:%M:%S")
8 NIGHTLY_DATE  = $(shell date "+%Y%m%d")
9 GIT_VERSION   = $(shell git describe)
11 JAR_TXT_FILES = $(shell find -L content skin locale     \
12                         -type f                         \
13                         -a \(                           \
14                                 -path '*.js'            \
15                              -o -path '*.css'           \
16                              -o -path '*.rdf'           \
17                              -o -path '*.xml'           \
18                              -o -path '*.properties'    \
19                              -o -path '*.xul'           \
20                              -o -path '*.*html'         \
21                              -o -path '*.dtd'           \
22                              -o -path '*/NEWS'          \
23                         \)                              \
24                 )
25 JAR_BIN_FILES = $(shell find content skin               \
26                         -type f                         \
27                         -a \(                           \
28                                 -path '*.png'           \
29                              -o -path '*.gif'           \
30                              -o -path '*.bz2'           \
31                         \)                              \
32                 )
33 JAR_FILES     = ${JAR_BIN_FILES} ${JAR_TXT_FILES}
34 JAR_DIRS      = $(foreach f,${JAR_FILES},$(dir $f))
35 JAR           = chrome/txttoimage.jar
37 XPI_TXT_FILES = install.rdf chrome.manifest defaults/preferences/txttoimage.js
38 XPI_BIN_FILES = ${JAR}
39 XPI_FILES     = ${XPI_BIN_FILES} ${XPI_TXT_FILES}
40 XPI_DIRS      = $(foreach f,${XPI_FILES},$(dir $f))
41 XPI_NAME      = ${NAME}-${VERSION}.xpi
42 XPI           = ${XPI_NAME}
43 MOZXPI        = ${NAME}-${VERSION}_amo.xpi
44 NIGHTLYXPI    = ${NAME}-${VERSION}${NIGHTLY_DATE}.xpi
46 BUILD_DIR     = build.${VERSION}.${OS}
47 BUILD_JAR_DIR = ${BUILD_DIR}/jar
48 BUILD_XPI_DIR = ${BUILD_DIR}/xpi
50 BUILD_JAR_SUBDIRS = $(sort ${JAR_DIRS:%=${BUILD_JAR_DIR}/%})
51 BUILD_XPI_SUBDIRS = $(sort ${XPI_DIRS:%=${BUILD_XPI_DIR}/%})
53 ZIP = zip
54 SED = sed
55 PERL = perl
57 #### rules
59 .PHONY: all help info jar xpi mozxpi install clean distclean nightly upnightly uprelease
60 all: help
62 help:
63         @echo "${NAME} ${VERSION} build"
64         @echo "  make help      - display this help"
65         @echo "  make info      - show some info about the system"
66         @echo "  make jar       - build a JAR (${JAR})"
67         @echo "  make xpi       - build an XPI (${XPI_NAME})"
68         @echo "  make mozxpi    - build an XPI (${MOZXPI}) for Mozilla Addons"
69         @echo "  make nightly   - build a nightly (${NIGHTLYXPI})"
70         @echo "  make upnightly - upload a nightly snapshot and its update RDF (not for you)"
71         @echo "  make uprelease - upload a new release and accompanying files (not for you)"
72         @echo "  make clean     - clean up"
73         @echo "  make distclean - clean up more"
75 info:
76         @echo    "version            ${VERSION}"
77         @echo    "release file       ${XPI}"
78         @echo -e "jar files          $(shell echo ${JAR_FILES} | sed 's/ /\\n                   /g' )"
79         @echo -e "xpi files          $(shell echo ${XPI_FILES} | sed 's/ /\\n                   /g' )"
81 xpi: ${XPI}
82 jar: ${JAR}
84 mozxpi: ${MOZXPI}
85 nightly: ${NIGHTLYXPI}
87 clean:
88         @echo "Cleanup..."
89         ${Q}rm -f ${JAR} ${XPI} ${MOZXPI} ${NIGHTLYXPI}
90         ${Q}find . -name '*~' -exec rm -f {} \;
92 distclean: clean
93         @echo "More cleanup..."
94         ${Q}rm -rf ${BUILD_DIR}
96 upnightly: ${NIGHTLYXPI}
97         ${Q}( cd release/ && ./mknightly.sh ${NIGHTLYXPI} ${VERSION}${NIGHTLY_DATE} ${VERSION} )
99 uprelease: ${XPI}
100         ${Q}( cd release/ && ./mkrelease.py -x ${XPI_NAME} \
101                 --hash "sha1:$(shell sha1sum ${XPI} |cut -d ' ' -f 1)" \
102                 ${VERSION} > release.rdf )
103         ${Q}( cd release/ && ./mknews.py ${VERSION} > ${VERSION}.xhtml )
104         ${Q}( cd release/ && ./put.py ../${XPI} ${XPI_NAME} ${VERSION}.xhtml news/${VERSION}.xhtml)
105         ${Q}( rm -f release/${VERSION}.xhtml )
106         @echo
107         @echo "Sign ./release/release.rdf with McCoy and upload."
109 #### xpi
111 ${BUILD_XPI_SUBDIRS}:
112         ${Q}mkdir -p $@
114 ${XPI}: ${BUILD_XPI_SUBDIRS} ${XPI_FILES}
115         @echo "Building XPI..."
116         ${Q}mkdir -p $(dir ${XPI})
117         ${Q}for f in ${XPI_BIN_FILES} ; do \
118                 cp $$f ${BUILD_XPI_DIR}/$$f ; \
119             done
120         ${Q}for f in ${XPI_TXT_FILES} ; do \
121                 ${SED} -e "s,###VERSION###,${VERSION},g" \
122                        -e "s,###GIT_VERSION###,${GIT_VERSION},g" \
123                        -e "s,###DATE###,${BUILD_DATE},g" \
124                        < $$f > ${BUILD_XPI_DIR}/$$f ; \
125                 ( diff -q $$f ${BUILD_XPI_DIR}/$$f 1>/dev/null ) || \
126                 ( echo "modified: $$f" ; \
127                   diff -u $$f ${BUILD_XPI_DIR}/$$f | grep '^[-+][^-+]' ) ; \
128             done
129         ${Q}${PERL} -pe 's,\s(skin|content|locale)/, jar:${JAR}!/\1/,' \
130                    < chrome.manifest > ${BUILD_XPI_DIR}/chrome.manifest
131         ${Q}( cd ${BUILD_XPI_DIR} && ${ZIP} -r9 ${TOP}/${XPI} ${XPI_FILES} )
132         @echo "SUCCESS: $@"
134 ${MOZXPI}: ${BUILD_XPI_SUBDIRS} ${XPI_FILES}
135         @echo "Building XPI for Mozilla Addons..."
136         ${Q}mkdir -p $(dir ${MOZXPI})
137         ${Q}for f in ${XPI_BIN_FILES} ; do \
138                 cp $$f ${BUILD_XPI_DIR}/$$f ; \
139             done
140         ${Q}for f in ${XPI_TXT_FILES} ; do \
141                 ${SED} -e "s,###VERSION###,${VERSION},g" \
142                        -e "s,###GIT_VERSION###,${GIT_VERSION},g" \
143                        -e "s,###DATE###,${BUILD_DATE},g" \
144                            -e "s,<em:updateURL>.*</em:updateURL>,,g" \
145                            -e "s,<em:updateKey>.*</em:updateKey>,,g" \
146                        < $$f > ${BUILD_XPI_DIR}/$$f ; \
147                 ( diff -q $$f ${BUILD_XPI_DIR}/$$f 1>/dev/null ) || \
148                 ( echo "modified: $$f" ; \
149                   diff -u $$f ${BUILD_XPI_DIR}/$$f | grep '^[-+][^-+]' ) ; \
150             done
151         ${Q}${PERL} -pe 's,\s(skin|content|locale)/, jar:${JAR}!/\1/,' \
152                    < chrome.manifest > ${BUILD_XPI_DIR}/chrome.manifest
153         ${Q}( cd ${BUILD_XPI_DIR} && ${ZIP} -r9 ${TOP}/${MOZXPI} ${XPI_FILES} )
154         @echo "SUCCESS: $@"
156 ${NIGHTLYXPI}: ${BUILD_XPI_SUBDIRS} ${XPI_FILES}
157         @echo "Building nightly XPI..."
158         ${Q}mkdir -p $(dir ${NIGHTLYXPI})
159         ${Q}for f in ${XPI_BIN_FILES} ; do \
160                 cp $$f ${BUILD_XPI_DIR}/$$f ; \
161             done
162         ${Q}for f in ${XPI_TXT_FILES} ; do \
163                 ${SED} -e "s,###VERSION###,${VERSION},g" \
164                        -e "s,###GIT_VERSION###,${GIT_VERSION},g" \
165                        -e "s,###DATE###,${BUILD_DATE},g" \
166                            -e "s,<em:version>\([0-9.]\+\)pre</em:version>,<em:version>\1pre${NIGHTLY_DATE}</em:version>,g" \
167                            -e "s,<em:updateURL>.*</em:updateURL>,<em:updateURL>http://beyondboredom.net/gfox/nightly.rdf</em:updateURL>,g" \
168                            -e "s,<em:updateKey>.*</em:updateKey>,<em:updateKey>MIGfMA0GCSqGSIb3DQEB\
169 AQUAA4GNADCBiQKBgQC7eAy22UWonorb/WB+eeDeE6eMDgRB9gjRt4LGzoOB+jgxc1ZkOMuLwbU599zu+GvW038T\
170 LCyUgpvEC6Nh5NoOryFCKbPNM/Hun+GPITbSl59ZqpRj9mFie5ASlPnU3xI+FG5czTJLsBSAZF6pfhnCNzfcVD9mH\
171 gvy+qXLl73fXQIDAQAB</em:updateKey>,g" \
172                        < $$f > ${BUILD_XPI_DIR}/$$f ; \
173                 ( diff -q $$f ${BUILD_XPI_DIR}/$$f 1>/dev/null ) || \
174                 ( echo "modified: $$f" ; \
175                   diff -u $$f ${BUILD_XPI_DIR}/$$f | grep '^[-+][^-+]' ) ; \
176             done
177         ${Q}${PERL} -pe 's,\s(skin|content|locale)/, jar:${JAR}!/\1/,' \
178                    < chrome.manifest > ${BUILD_XPI_DIR}/chrome.manifest
179         ${Q}( cd ${BUILD_XPI_DIR} && ${ZIP} -r9 ${TOP}/${NIGHTLYXPI} ${XPI_FILES} )
180         @echo "SUCCESS: $@"
183 #### jar
185 ${BUILD_JAR_SUBDIRS}:
186         ${Q}mkdir -p $@
188 ${JAR}: ${BUILD_JAR_SUBDIRS} ${JAR_FILES}
189         @echo "Building JAR..."
190         ${Q}mkdir -p $(dir ${JAR})
191         ${Q}for f in ${JAR_BIN_FILES} ; do \
192                 cp $$f ${BUILD_JAR_DIR}/$$f ; \
193             done
194         ${Q}for f in ${JAR_TXT_FILES} ; do \
195                 ${SED} -e "s,###VERSION###,${VERSION},g" \
196                        -e "s,###DATE###,${BUILD_DATE},g" \
197                        < $$f > ${BUILD_JAR_DIR}/$$f ; \
198                 ( diff -q $$f ${BUILD_JAR_DIR}/$$f 1>/dev/null ) || \
199                 ( echo "modified: $$f" ; \
200                   diff -u $$f ${BUILD_JAR_DIR}/$$f | grep '^[-+][^-+]' ) ; \
201             done
202         ${Q}( cd ${BUILD_JAR_DIR} && ${ZIP} -r0 ${TOP}/${JAR} ${JAR_FILES} )
203         @echo "SUCCESS: $@"