Merged default into xdg-dirs
[pidgin-git.git] / Makefile.mingw
blob9c380eb5e04e7580e7ab420f61e49ac85bc5fffa
1 # Makefile.mingw
3 # Author: hermanator12002@yahoo.com
4 # Date 9/11/02
5 # Description: Top Makefile for win32 (mingw) port of Pidgin and libpurple
8 PIDGIN_TREE_TOP := .
9 include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
11 # Generate a X.X.X.X version for the installer file versioning header
12 # The last digit will be 99 for a final release, 0 for dev or unknown, or the beta number
13 PIDGIN_PRODUCT_VERSION = $(shell \
14 awk 'BEGIN {FS="."} { \
15     if (int($$3) == $$3) { \
16         $$4 = "99"; \
17     } else { \
18         $$5 = $$3; \
19         sub(int($$3), "", $$5); \
20         if ($$5 == "dev") { \
21             $$4 = "0"; \
22         } else { \
23             if (sub("beta", "", $$5) > 0) { \
24                 $$4 = $$5; \
25             } else { \
26                 $$4 = "0"; \
27             } \
28         } \
29     } \
30     printf("%s.%s.%s.%s", $$1, $$2, int($$3), $$4); \
31     exit; \
32 }' VERSION)
34 GTK_INSTALL_VERSION = 2.24.18.0
36 ifdef SIGNTOOL
37 authenticode_sign = $(SIGNTOOL) sign \
38                     /fd SHA256 \
39                     /f "$(SIGNTOOL_PFX)" /p "$(SIGNTOOL_PASSWORD)" \
40                     /d $(2) /du "https://pidgin.im" \
41                     /tr "http://timestamp.comodoca.com/rfc3161" /td SHA256 \
42                     $(1)
43 else
44 authenticode_sign = $(MONO_SIGNCODE) \
45                     -spc "$(SIGNCODE_SPC)" -v "$(SIGNCODE_PVK)" \
46                     -a sha1 -$$ commercial \
47                     -n "$(2)" -i "https://pidgin.im" \
48                     -t "http://timestamp.verisign.com/scripts/timstamp.dll" -tr 10 \
49                     $(1) && rm -f $(1).bak
50 endif
52 gpg_sign = $(GPG_SIGN) -ab $(1) && $(GPG_SIGN) --verify $(1).asc
54 STRIPPED_RELEASE_DIR = $(PIDGIN_TREE_TOP)/pidgin-$(PIDGIN_VERSION)-win32bin
55 DEBUG_SYMBOLS_DIR = $(PIDGIN_TREE_TOP)/pidgin-$(PIDGIN_VERSION)-dbgsym
57 PIDGIN_INST_DEP_DIR="$(WIN32_DEV_TOP)/pidgin-inst-deps-20130214"
59 # Any *.dll or *.exe files included in win32-install-dir that we don't compile
60 # should be included in this list so they don't get stripped
61 EXTERNAL_DLLS = \
62         exchndl.dll
64 #build an expression for `find` to use to ignore the above files
65 EXTERNAL_DLLS_FIND_EXP = $(patsubst %,-o -name %,$(EXTERNAL_DLLS))
67 include $(PIDGIN_COMMON_RULES)
69 .PHONY: all install installer installer_offline installer_zip debug_symbols_zip installers clean uninstall create_release_install_dir generate_installer_includes $(PIDGIN_REVISION_H) $(PIDGIN_REVISION_RAW_TXT) gtk_runtime_zip
71 all: $(PIDGIN_CONFIG_H) $(PIDGIN_REVISION_H)
72         $(MAKE_at) $(MAKE) -C $(PURPLE_TOP) -f $(MINGW_MAKEFILE)
73         $(MAKE_at) $(MAKE) -C $(PIDGIN_TOP) -f $(MINGW_MAKEFILE)
74 ifndef DISABLE_NLS
75         $(MAKE_at) $(MAKE) -C $(PURPLE_PO_TOP) -f $(MINGW_MAKEFILE)
76 endif
78 install: all $(PIDGIN_INSTALL_DIR)
79         $(MAKE_at) $(MAKE) -C $(PURPLE_TOP) -f $(MINGW_MAKEFILE) install
80         $(MAKE_at) $(MAKE) -C $(PIDGIN_TOP) -f $(MINGW_MAKEFILE) install
81 ifndef DISABLE_NLS
82         $(MAKE_at) $(MAKE) -C $(PURPLE_PO_TOP) -f $(MINGW_MAKEFILE) install
83 endif
84         $(MAKE_at) $(MAKE) -C share/ca-certs -f $(MINGW_MAKEFILE) install
85         $(MAKE_at) $(MAKE) -C share/sounds -f $(MINGW_MAKEFILE) install
86         cp $(PIDGIN_INST_DEP_DIR)/exchndl.dll $(PIDGIN_INSTALL_DIR)
87         chmod -R 777 $(PIDGIN_INSTALL_DIR)
89 gtk_runtime_zip:
90         cd pidgin/win32/nsis/ ; ./generate_gtk_zip.sh "$(GPG_SIGN)"
92 generate_installer_includes: create_release_install_dir gtk_runtime_zip debug_symbols_zip $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/nsis_translations.desktop
93         rm -f pidgin/win32/nsis/pidgin-translations.nsh pidgin/win32/nsis/pidgin-spellcheck.nsh pidgin/win32/nsis/pidgin-spellcheck-preselect.nsh
94         find $(STRIPPED_RELEASE_DIR)/locale -maxdepth 1 -mindepth 1 \
95          -exec basename {} ';' \
96          | LC_ALL=C sort | sed -e s/^/\!insertmacro\ LANG_SECTION\ \"/ -e s/$$/\"/ \
97          > pidgin/win32/nsis/pidgin-translations.nsh
98         #Convert the available.lst lines to "!insertmacro SPELLCHECK_SECTION lang lang_name lang_file"
99         sed -e "/^#/d" -e "s/^[^,]\{1,\},[^,]\{1,\},/\"/" \
100          -e "s/,/\"\ \"/" -e "s/,/\"\ \"/" -e "s/[\ \t]*$$/\"/" \
101          -e "s/^/\!insertmacro\ SPELLCHECK_SECTION\ /" \
102          pidgin/win32/nsis/available.lst \
103          > pidgin/win32/nsis/pidgin-spellcheck.nsh
104         #Convert the lines to "!insertmacro CHECK_SPELLCHECK_SECTION lang"
105         iconv -f latin1 -t utf-8 pidgin/win32/nsis/pidgin-spellcheck.nsh | \
106          sed -e "s/SPELLCHECK_SECTION/CHECK_SPELLCHECK_SECTION/" \
107          -e "s/ \"[^\"]*\"\ \"[^\"]*\"[\t\ ]*$$//" | \
108          iconv -f utf-8 -t latin1 \
109         > pidgin/win32/nsis/pidgin-spellcheck-preselect.nsh
110         #Generate the Installer translations
111         echo "!define GCOMPRIS_NSIS_INCLUDE_PATH \".\"" > $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/langmacros.nsh
112         echo "@INSERT_TRANSLATIONS@" >> $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/langmacros.nsh
113         $(PERL) $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/create_nsis_translations.pl \
114                 $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/nsis_translations.desktop \
115                 $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/langmacros.nsh \
116                 $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/translations
118 create_release_install_dir: install
119         rm -rf $(STRIPPED_RELEASE_DIR)
120         mkdir $(STRIPPED_RELEASE_DIR)
121         tar -cf - $(PIDGIN_INSTALL_DIR) --exclude=Gtk --exclude=spellcheck/share \
122          | tar --strip 2 -xC $(STRIPPED_RELEASE_DIR) -f -
123         find $(STRIPPED_RELEASE_DIR) \( -name '*.dll' -o -name '*.exe' \) \
124          -not \( -false $(EXTERNAL_DLLS_FIND_EXP) \) \
125          -exec $(STRIP) --strip-unneeded {} ';'
126 ifdef SIGN_EXECUTABLES
127         $(call authenticode_sign, $(STRIPPED_RELEASE_DIR)/pidgin.exe, "Pidgin $(PIDGIN_VERSION)")
128 endif
130 installer: generate_installer_includes
131         $(eval $@_DEBUG_SYMBOLS_SHA1SUM := $(shell sha1sum $(DEBUG_SYMBOLS_DIR).zip | sed -e "s/\ .*$$//"))
132         $(eval $@_GTK_SHA1SUM := $(shell sha1sum pidgin/win32/nsis/gtk-runtime-$(GTK_INSTALL_VERSION).zip | sed -e "s/\ .*$$//"))
133         $(MAKENSIS) -V3 -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_PRODUCT_VERSION="$(PIDGIN_PRODUCT_VERSION)" \
134                 -DPIDGIN_INSTALL_DIR="$(STRIPPED_RELEASE_DIR)" -DGTK_INSTALL_VERSION="$(GTK_INSTALL_VERSION)" \
135                 -DDEBUG_SYMBOLS_SHA1SUM="$($@_DEBUG_SYMBOLS_SHA1SUM)" -DGTK_SHA1SUM="$($@_GTK_SHA1SUM)"\
136                 pidgin/win32/nsis/pidgin-installer.nsi
137 ifdef SIGN_EXECUTABLES
138         $(call authenticode_sign, pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION).exe, "Pidgin Installer")
139 endif
140         mv pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION).exe ./
141 ifdef SIGN_EXECUTABLES
142         $(call gpg_sign, pidgin-$(PIDGIN_VERSION).exe)
143 endif
145 installer_offline: generate_installer_includes
146         $(MAKENSIS) -V3 -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_PRODUCT_VERSION="$(PIDGIN_PRODUCT_VERSION)" \
147                 -DPIDGIN_INSTALL_DIR="$(STRIPPED_RELEASE_DIR)" -DGTK_INSTALL_VERSION="$(GTK_INSTALL_VERSION)" \
148                 -DOFFLINE_INSTALLER \
149                 pidgin/win32/nsis/pidgin-installer.nsi
150 ifdef SIGN_EXECUTABLES
151         $(call authenticode_sign, pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION)-offline.exe, "Pidgin Installer")
152 endif
153         mv pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION)-offline.exe ./
154 ifdef SIGN_EXECUTABLES
155         $(call gpg_sign, pidgin-$(PIDGIN_VERSION)-offline.exe)
156 endif
158 installer_zip: create_release_install_dir
159         rm -f pidgin-$(PIDGIN_VERSION)-win32-bin.zip
160         zip -9 -r pidgin-$(PIDGIN_VERSION)-win32-bin.zip $(STRIPPED_RELEASE_DIR)
161 ifdef SIGN_EXECUTABLES
162         $(call gpg_sign, pidgin-$(PIDGIN_VERSION)-win32-bin.zip)
163 endif
165 debug_symbols_zip: install
166         rm -rf $(DEBUG_SYMBOLS_DIR) $(DEBUG_SYMBOLS_DIR).zip
167         mkdir $(DEBUG_SYMBOLS_DIR)
168         tar -cf - `find $(PIDGIN_INSTALL_DIR) \( -name '*.dll' -o -name '*.exe' \) \
169          -not \( -false $(EXTERNAL_DLLS_FIND_EXP) \) -print` \
170          | tar --strip 2 --xform s/$$/.dbgsym/ -xC $(DEBUG_SYMBOLS_DIR) -f -
171         cp $(MEANWHILE_TOP)/bin/libmeanwhile-1.dll.debug $(DEBUG_SYMBOLS_DIR)/libmeanwhile-1.dll.dbgsym
172         zip -9 -r $(DEBUG_SYMBOLS_DIR).zip $(DEBUG_SYMBOLS_DIR) 
173 ifdef SIGN_EXECUTABLES
174         $(call gpg_sign, $(DEBUG_SYMBOLS_DIR).zip)
175 endif
177 installers: installer installer_offline debug_symbols_zip installer_zip
179 clean:
180         $(MAKE_at) $(MAKE) -C $(PURPLE_PO_TOP) -f $(MINGW_MAKEFILE) clean
181         $(MAKE_at) $(MAKE) -C $(PIDGIN_TOP) -f $(MINGW_MAKEFILE) clean
182         $(MAKE_at) $(MAKE) -C $(PURPLE_TOP) -f $(MINGW_MAKEFILE) clean
183         $(MAKE_at) $(MAKE) -C share/ca-certs -f $(MINGW_MAKEFILE) clean
184         rm -f $(PIDGIN_CONFIG_H) $(PIDGIN_REVISION_H) $(PIDGIN_REVISION_RAW_TXT) ./VERSION pidgin-$(PIDGIN_VERSION)*.exe pidgin-$(PIDGIN_VERSION)-win32-bin.zip $(DEBUG_SYMBOLS_DIR).zip
186 uninstall:
187         rm -rf $(PURPLE_INSTALL_PERL_DIR) $(PIDGIN_INSTALL_PLUGINS_DIR) $(PURPLE_INSTALL_PO_DIR) $(PIDGIN_INSTALL_DIR) $(STRIPPED_RELEASE_DIR) $(DEBUG_SYMBOLS_DIR)
188         rm -f ./VERSION
190 include $(PIDGIN_COMMON_TARGETS)