root/middleware-offline/trunk/_src/eidmw/_Builds/Makefile_mac @ 5

Revision 5, 30.0 KB (checked in by vsilva, 9 years ago)

Initial comit

Line 
1####################################################################################
2## Makefile for the preparation of the release and the package on Mac.
3##
4## This Makefile should be used after having built the package:
5##       
6## on the ppc:
7##   make -f Makefile_mac    (this will also call the configure script)
8##   sudo make -f Makefile_mac release
9## on the macIntel:
10##   make -f Makefile_mac    (this will also call the configure script)
11##   sudo make -f Makefile_mac release
12## copy one of the /release_build dirs on the other machine in the directory /other
13##   sudo make -f Makefile_mac universal
14##
15## .. voila', the package with the universal binaries is there.
16##
17## To build the SDK:
18##   make -f Makefile_mac sdk
19##
20## To build a release without the 3rd party libs (so this release can
21## be safely installed on your test machine):
22##   make -f Makefile_mac    (this will also call the configure script)
23##   sudo make -f Makefile_mac testrelease
24##
25## If you want to add or remove files from the release, please edit the following variables:
26## BASE_LIBS --> implicit names of the libraries (as from the definition file *versions.mak)
27## ETC --> implicit names of the config file(s)
28## OLD_LIBS --> names of the old (V2.6) libs
29## OLD_ETC --> names of the old (V2.6) config (are already universal binaries)
30## BASE_SISPLUGINS --> implicit names of the libraries (as from the definition file *versions.mak)
31## BASE_BINS --> names to the executables
32## APP_BINS --> paths to the executables
33## TRANSLATIONS --> language files for the GUI
34## HEADERS --> header files needed to use the SDK
35## CONFIG --> configuration files, e.g. for the GUI
36## DOCS --> documentation files, man pages
37## SCRIPTS --> script files
38## ...
39####################################################################################
40# check if the QTBASEDIR is set. If so, use this as a bas directory to copy the Qt libraries
41# to the pkg.
42# The environment variable is used to indicate which Qt libraries have to be taken.
43ifdef QTBASEDIR
44        QTFRAMEWORKSDIR:=$(QTBASEDIR)/lib/
45        QTPLUGINDIR=$(QTBASEDIR)/plugins
46else
47        QTFRAMEWORKSDIR=/Library/Frameworks/
48        QTPLUGINDIR=/Developer/Applications/Qt/plugins/
49endif
50QT4VERSION=$(shell otool -L $(QTFRAMEWORKSDIR)/QtCore.framework/QtCore)
51VERSIONSTR=$(shell expr "$(QT4VERSION)" : '.*current version \(4\.[0-9]\.[0-9]\)')
52QT_VERSION=pteid_$(VERSIONSTR)
53
54
55
56## If you want to build the release for another country,
57## substitute pteidversions.mak with the country-specific one (e.g. pteidversions.mak for Portugal)
58## Other things to change:
59## - value of REL_NAME
60## - value of APPS_DIR
61
62include pteidversions.mak
63
64REL_NAME=pteid
65PKCS11_BUNDLE = pteid-pkcs11.bundle
66
67## For Qt4 we will try to figure out the version starting from 'qmake -v'
68## Sometimes qmake is link to the real qmake executable, therefore we first
69## do a 'readlink' and then use the directory of it to find the libs etc.
70#QT_VERSION=pteid_4.3.4
71
72#QT4=$(shell which qmake)
73#LINKPATH=$(shell readlink $(QT4))
74#QMAKEPATH=$(shell which $(LINKPATH))
75#THEPATH=$(dir $(QMAKEPATH))
76#QT4VERSION=`$(THEPATH)/moc -v 2>&1`
77#VERSIONSTR=$(shell expr "$(QT4VERSION)" : '.*\([1-9]\.[0-9]\.[0-9]\)')
78
79#QT_VERSION=pteid_$(VERSIONSTR)
80#QT_BASEPATH=$(THEPATH)/..
81ifdef UNIVERSAL
82        PATH_TO_QTCORE:=$(shell otool -L ../bin/pteiddialogsQTsrv | grep QtCore  | sed s/\(.*\)//)
83        PATH_TO_QTGUI:=$(shell otool -L ../bin/pteiddialogsQTsrv | grep QtGui  | sed s/\(.*\)//)
84else
85        PATH_TO_QTCORE:=$(shell otool -L ../bin/pteiddialogsQTsrv.app/Contents/MacOS/pteiddialogsQTsrv | grep QtCore  | sed s/\(.*\)//)
86        PATH_TO_QTGUI:=$(shell otool -L ../bin/pteiddialogsQTsrv.app/Contents/MacOS/pteiddialogsQTsrv | grep QtGui  | sed s/\(.*\)//)
87endif
88
89UDIR=/univ
90REL_DIR=/release_build
91
92PKG_MAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
93
94REL_VERSION=$(REL_MAJ).$(REL_MIN).$(REL_REV)
95BUILD_NR=$(shell cat ../svn_revision | tr -d "\r")
96
97PKG_NAME =   $(REL_DIR)/$(REL_NAME).pkg
98DMG_NAME =   $(REL_NAME)_$(REL_VERSION).dmg
99DMG_NAME_u = $(REL_NAME)_u_$(REL_VERSION).dmg
100DMG_NAME_SDK = $(REL_NAME)_SDK_$(REL_VERSION)_$(BUILD_NR).dmg
101VOL_NAME =   $(REL_NAME)_MacOSX_$(REL_VERSION)
102VOL_NAME_SDK = $(REL_NAME)_SDK_MacOSX_$(REL_VERSION)
103
104ROOT_DIR =  $(REL_DIR)/root
105INST_DIR =  /usr/local
106MAN_DIR  =  /usr/share/man/man1
107SDK_DIR  = sdk
108
109## Make interpretes spaces as separator. So we specify 2 names:
110## the one that will be installed and the one to which this
111## name will be renamed into in the postflight script at the end
112## of the installation.
113APPS_DIR =  /Applications/PortugalIdentityCard
114APPS_DIR_NAME = "/Applications/Portugal\ Identity\ Card"
115EIDGUI_NAME = eID-Viewer
116
117## List of the implicit names of the libraries. This is convenient
118## when we want to substitue "x_y_z" with "x_y" to obtain e.g.
119## DLGLIB_NAME_x_y_dylib and then use its value, resulting in libdialogsQT_1.0.dylib
120
121BASE_LIBS =  DLGLIB_NAME_x_y_z_dylib \
122        EIDLIB_NAME_x_y_z_dylib \
123        CARDLAYERLIB_NAME_x_y_z_dylib \
124        COMMONLIB_NAME_x_y_z_dylib \
125        APPLAYERLIB_NAME_x_y_z_dylib \
126        PKCS11LIB_NAME_x_y_z_dylib \
127        JAVALIB_NAME_x_y_z_dylib
128
129ETC = pteid.conf
130
131OLD_LIBS = pteidlib.jar libpteidlibjni.2.7.2.dylib libpteid.2.7.4.dylib \
132        libpteidlibopensc.2.2.0.dylib libpteidcommon.1.0.0.dylib \
133        libpteidlibopenscinternal.2.2.0.dylib libpteidgui.1.5.0.dylib \
134        libqt-mt.3.3.8.dylib
135
136OLD_ETC = pteidbase.conf pteidgui.conf
137
138BASE_SISPLUGINS = CARDPLUGINSIS_ACR38U_NAME_dylib
139#BASE_SISPLUGINS =
140LATEST_XPI:=$(shell readlink ../xpi/builds/portugaleid-CURRENT.xpi)
141XPI_107 = /Applications/Firefox.app/Contents/MacOS/extensions/portugaleid-1.0.7.xpi
142XPI_PLUGIN = xpi/builds/$(LATEST_XPI)
143XPI_PLUGIN_DIR = "/Library/Application\ Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/portugaleid@eid.portugal.be"
144#XPI_PLUGIN = xpi/builds/portugaleid-CURRENT.xpi
145
146## This foreach command loops over the content of BASE_LIBS and substitute
147## to each element $(element) --> LIBS contains $(DLGLIB_NAME_x_y_z_dylib),
148## $(EIDLIB_NAME_x_y_z_dylib), etc. These variables are defined in pteidversions.mak,
149## therefore LIBS contains libdialogsQT_1.0.0.dylib, lipteidlib_1.0.0.dylib, etc.
150
151LIBS = $(foreach var,$(BASE_LIBS), lib/$($(var)) )
152
153SISPLUGINS = $(foreach var,$(BASE_SISPLUGINS), lib/$($(var)) )
154SISPLUGINS_BARE = $(foreach var,$(BASE_SISPLUGINS), $($(var)) )
155
156
157BASE_BINS = $(DLGSRV)
158#       $(CARDLAYERTOOL)
159ifdef UNIVERSAL
160        APP_BINS =  $(DLGSRV)
161else
162        APP_BINS =  $(DLGSRV).app/Contents/MacOS/$(DLGSRV)
163endif
164#       $(CARDLAYERTOOL)/Contents/MacOS/$(CARDLAYERTOOL)
165
166
167## prepends 'bin/' to all the elements of BASE_BINS
168BINS = $(APP_BINS:%= bin/%)
169
170## to be put in the APPS_DIR
171APP_FILES = $(XPI_PLUGIN)
172
173
174## Language files for the GUI
175TRANSLATIONS = bin/$(EIDGUI).app/Contents/MacOS/eidmw_de.qm \
176               bin/$(EIDGUI).app/Contents/MacOS/eidmw_en.qm \
177               bin/$(EIDGUI).app/Contents/MacOS/eidmw_fr.qm \
178               bin/$(EIDGUI).app/Contents/MacOS/eidmw_nl.qm
179
180## SDK files to be included in the release
181SDK_HEADERS_CPP = ../eidlib/eidlibdefines.h ../eidlib/eidlib.h ../common/eidErrors.h \
182        ../eidlib/eidlibException.h
183SDK_SAMPLES1_CPP = ../sdk/samples/read_eid/C++/main.cpp
184SDK_SAMPLES1_JAVA = ../sdk/samples/read_eid/Java/main.java
185SDK_SAMPLES2_CPP = ../sdk/samples/wait_card/C++/main.cpp
186SDK_SAMPLES2_JAVA = ../sdk/samples/wait_card/Java/main.java
187SDK_SAMPLES3_CPP = ../sdk/samples/pin_eid/C++/main.cpp
188SDK_SAMPLES3_JAVA = ../sdk/samples/pin_eid/Java/main.java
189SDK_SAMPLES4_CPP = ../sdk/samples/exception/C++/main.cpp
190SDK_SAMPLES4_JAVA = ../sdk/samples/exception/Java/get_exception.java
191SDK_SAMPLES5_CPP = ../sdk/samples/events/C++/main.cpp
192SDK_SAMPLES5_JAVA = ../sdk/samples/events/Java/main.java ../sdk/samples/events/Java/EventCallback.java \
193                ../sdk/samples/events/Java/EventData.java ../sdk/samples/events/Java/ReaderRef.java
194SDK_SAMPLES6_CPP = ../sdk/samples/sign_p11/C++/main.cpp ../sdk/samples/sign_p11/C++/Makefile
195SDK_SAMPLES6_JAVA = ../sdk/samples/sign_p11/java/sign_p11.java ../sdk/samples/sign_p11/java/*.sh
196SDK_BASE_APPLET = ../eidlibJava_Applet/PTEID_Applet.java ../jar/PTEID_reader.html \
197                ../sdk/samples/misc/Applet/Basic/java/pteid35test.store \
198                ../sdk/samples/misc/Applet/Basic/java/*.sh \
199                ../sdk/samples/misc/Applet/Basic/java/Readme.txt ../jar/*.rtf
200SDK_IMAGE_APPLET = ../sdk/samples/misc/Applet/Image/java/excanvas.js \
201                ../sdk/samples/misc/Applet/Image/java/*.java \
202                ../sdk/samples/misc/Applet/Image/java/PTEID_sample_base64.html \
203                ../sdk/samples/misc/Applet/Image/java/pteid35test.store \
204                ../sdk/samples/misc/Applet/Image/java/*.sh ../jar/*.rtf
205SDK_JAVA_BIN  = ../../ThirdParty/pteid_sdk/3.5/Java/SignedJar/*.jar ../jar/*License.rtf \
206                ../jar/pteid.jnlp ../jar/PTEID_reader.html
207SDK_JAVA_UNSIGNED = ../jar/PTEID_Applet.jar ../jar/pteid35libJava.jar ../jar/applet-launcher.jar \
208                ../../ThirdParty/pteid_sdk/3.5/Java/*libJava_Wrapper* ../jar/*License.rtf
209SDK_PKCS11_FILES = ../sdk/pkcs11/C++/include/*.h
210SDK_COMMON_FILES = ../sdk/readme.txt ../misc/licenses_files/License*
211
212## Man pages to be included in the release.
213## Will be copied to $(ROOT_DIR)/$(MAN_DIR)
214DOCS =
215
216## Scripts to be included in the release.
217## Will be copied to $(ROOT_DIR)/$(INST_DIR)/bin
218SCRIPTS =
219
220
221## directories that the package installer should create
222## on the user's machine in case they are absent
223DIRS_TO_CREATE = $(INST_DIR) $(APPS_DIR) /usr/local/lib/pkcs11
224
225INSTALLER_DIR = misc/mac/mw_installer
226
227
228## directories which will be created by the release rule
229DIRS =  $(ROOT_DIR)/$(INST_DIR)/lib/siscardplugins \
230        $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/plugins \
231        $(ROOT_DIR)/$(INST_DIR)/bin \
232        $(ROOT_DIR)/$(INST_DIR)/etc \
233        $(ROOT_DIR)/$(INST_DIR)/include/$(REL_NAME) \
234        $(ROOT_DIR)/usr/bin \
235        $(ROOT_DIR)/$(MAN_DIR) \
236        $(ROOT_DIR)/$(APPS_DIR) \
237        $(ROOT_DIR)/$(APPS_DIR)/licenses
238       
239SDK_DIRS = $(SDK_DIR)/pteidlib/C++/include \
240           $(SDK_DIR)/pteidlib/Java/bin \
241           $(SDK_DIR)/pteidlib/Java/unsigned \
242           $(SDK_DIR)/doc \
243           $(SDK_DIR)/samples/read_eid/C++ \
244           $(SDK_DIR)/samples/read_eid/Java \
245           $(SDK_DIR)/samples/wait_card/C++ \
246           $(SDK_DIR)/samples/wait_card/Java \
247           $(SDK_DIR)/samples/pin_eid/C++ \
248           $(SDK_DIR)/samples/pin_eid/Java \
249           $(SDK_DIR)/samples/exception/C++ \
250           $(SDK_DIR)/samples/exception/Java \
251           $(SDK_DIR)/samples/events/C++ \
252           $(SDK_DIR)/samples/events/Java \
253           $(SDK_DIR)/samples/sign_p11/C++ \
254           $(SDK_DIR)/samples/sign_p11/Java \
255           $(SDK_DIR)/pkcs11/C++/include \
256           $(SDK_DIR)/samples/misc/Applet/Image/Java \
257           $(SDK_DIR)/samples/misc/Applet/Basic/Java
258           
259
260## The source file (or directories) and the destination are
261## separated by 5 '_'. These will be parsed in copy_command
262
263FILES_TO_COPY := $(LIBS:%=%_____$(ROOT_DIR)/$(INST_DIR)/lib/) \
264                 $(OLD_LIBS:%=../pteid-2.6/mac/lib/%_____$(ROOT_DIR)/$(INST_DIR)/lib/) \
265                 $(ETC:%=misc/mac/%_____$(ROOT_DIR)/$(INST_DIR)/etc/) \
266                 $(OLD_ETC:%=../pteid-2.6/mac/etc/%_____$(ROOT_DIR)/$(INST_DIR)/etc/) \
267                 $(SISPLUGINS:%=%_____$(ROOT_DIR)/$(INST_DIR)/lib/siscardplugins) \
268                 $(TRANSLATIONS:%=%_____$(ROOT_DIR)/$(APPS_DIR)/$(EIDGUI).app/Contents/MacOS/) \
269                 $(DOCS:%=%_____$(ROOT_DIR)/$(MAN_DIR)) \
270                 $(SCRIPTS:%=%_____$(ROOT_DIR)/$(INST_DIR)/bin) \
271                 $(BINS:%=%_____$(ROOT_DIR)/usr/bin) \
272                 $(APP_FILES:%=%_____$(ROOT_DIR)/$(APPS_DIR))
273
274
275SDK_FILES_TO_COPY := $(SDK_HEADERS_CPP:%=%_____$(SDK_DIR)/pteidlib/C++/include) \
276                     $(SDK_SAMPLES1_CPP:%=%_____$(SDK_DIR)/samples/read_eid/C++) \
277                     $(SDK_SAMPLES1_JAVA:%=%_____$(SDK_DIR)/samples/read_eid/Java) \
278                     $(SDK_SAMPLES2_CPP:%=%_____$(SDK_DIR)/samples/wait_card/C++) \
279                     $(SDK_SAMPLES2_JAVA:%=%_____$(SDK_DIR)/samples/wait_card/Java) \
280                     $(SDK_SAMPLES3_CPP:%=%_____$(SDK_DIR)/samples/pin_eid/C++) \
281                     $(SDK_SAMPLES3_JAVA:%=%_____$(SDK_DIR)/samples/pin_eid/Java) \
282                     $(SDK_SAMPLES4_CPP:%=%_____$(SDK_DIR)/samples/exception/C++) \
283                     $(SDK_SAMPLES4_JAVA:%=%_____$(SDK_DIR)/samples/exception/Java) \
284                     $(SDK_SAMPLES5_CPP:%=%_____$(SDK_DIR)/samples/events/C++) \
285                     $(SDK_SAMPLES5_JAVA:%=%_____$(SDK_DIR)/samples/events/Java) \
286                     $(SDK_SAMPLES6_CPP:%=%_____$(SDK_DIR)/samples/sign_p11/C++) \
287                     $(SDK_SAMPLES6_JAVA:%=%_____$(SDK_DIR)/samples/sign_p11/Java) \
288                     $(SDK_IMAGE_APPLET:%=%_____$(SDK_DIR)/samples/misc/Applet/Image/java) \
289                     $(SDK_BASE_APPLET:%=%_____$(SDK_DIR)/samples/misc/Applet/Basic/java) \
290                     $(SDK_JAVA_BIN:%=%_____$(SDK_DIR)/pteidlib/Java/bin) \
291                     $(SDK_JAVA_UNSIGNED:%=%_____$(SDK_DIR)/pteidlib/Java/unsigned) \
292                     $(SDK_PKCS11_FILES:%=%_____$(SDK_DIR)/pkcs11/C++/include) \
293                     $(SDK_COMMON_FILES:%=%_____$(SDK_DIR))
294
295DIRS_TO_COPY := bin/$(EIDGUI).app_____$(ROOT_DIR)/$(APPS_DIR) \
296                misc/mac/OOoRegister/OpenOffice_Register.pkg_____$(ROOT_DIR)/$(APPS_DIR) \
297                misc/mac/OOo.default_____$(ROOT_DIR)/$(INST_DIR)/lib \
298                bin/PTEID.tokend_____$(ROOT_DIR)/$(APPS_DIR) \
299                ../pteid-2.6/mac/share/_____$(ROOT_DIR)/$(INST_DIR)/share
300
301r1=$(ROOT_DIR)
302r2=/other/$(ROOT_DIR)
303r3=$(UDIR)/$(ROOT_DIR)
304 
305## List of binaries for which we have to run the lipo command.
306## The substitution command prepends $(r3)/$(INST_DIR)/ to all the elements of LIBS and
307## $(r3)/$(APPS_DIR)/ to all the elements of BASE_BINS
308UNIVERSAL = $(LIBS:%=$(r3)/$(INST_DIR)/%) \
309            $(SISPLUGINS_BARE:%=$(r3)/$(INST_DIR)/lib/siscardplugins/%) \
310            $(BASE_BINS:%=$(r3)/usr/bin/%) \
311            $(r3)/$(APPS_DIR)/$(EIDGUI).app/Contents/MacOS/$(EIDGUI)
312
313
314#####################################################################
315# Rules                                                             #
316#####################################################################
317all:
318        cd .. && ./configure BUILD_TESTS=y CONFIG+=release && $(MAKE) && cd -
319        cd ../tokend && ./buildtokend.sh && cd -
320        cd ../misc/mac/OOoRegister && make && cd -
321
322################################################################
323clean:
324        cd .. && $(MAKE) clean && cd -
325
326################################################################
327install:
328        cd .. && $(MAKE) install && cd -
329
330################################################################
331uninstall:
332        cd .. && $(MAKE) uninstall && cd -
333
334################################################################
335POSTFLIGHT=$(REL_DIR)/resources/postflight
336PREFLIGHT=$(REL_DIR)/resources/preflight
337
338release: clean_release $(DIRS) rel_start rel_3rd_party rel_end
339
340testrelease: clean_release $(DIRS) rel_start  rel_end
341
342rel_start:
343        -@ cd ..; \
344          echo "********** copy dirs **********"; \
345          $(call copy_command,$(DIRS_TO_COPY),-r)
346
347        @## copy files, follow symbolic links
348        -@ cd ..; \
349          echo "********** copy files **********"; \
350          $(call copy_command,$(FILES_TO_COPY),-L) ; \
351          cp misc/licenses_files/Dutch/eID-toolkit_licensingtermsconditions.txt \
352                $(ROOT_DIR)/$(APPS_DIR)/licenses/license_NL.txt ; \
353          cp misc/licenses_files/English/eID-toolkit_licensingtermsconditions.txt \
354                $(ROOT_DIR)/$(APPS_DIR)/licenses/license_EN.txt ; \
355          cp misc/licenses_files/French/eID-toolkit_licensingtermsconditions.txt \
356                $(ROOT_DIR)/$(APPS_DIR)/licenses/license_FR.txt ; \
357          cp misc/licenses_files/German/eID-toolkit_licensingtermsconditions.txt \
358                $(ROOT_DIR)/$(APPS_DIR)/licenses/license_DE.txt ; \
359          cp misc/licenses_files/THIRDPARTY-LICENSES.txt $(ROOT_DIR)/$(APPS_DIR)/licenses/
360
361        @echo "********** copy/rename the pkcs11 bundle **********"; \
362         cp -r ../misc/mac/pkcs11.bundle $(ROOT_DIR)/$(INST_DIR)/lib/$(PKCS11_BUNDLE)
363
364        @echo "********** change ACs of the OOo.default files ***********"; \
365         chmod 644 $(ROOT_DIR)/$(INST_DIR)/lib/OOo.default/*
366         chmod 755 $(ROOT_DIR)/$(INST_DIR)/lib/OOo.default/
367
368rel_3rd_party:
369        @echo "********** copy third party files (QT, ...) **********"
370        @echo "QTBASEDIR:$(QTBASEDIR)"
371         mkdir -p $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/
372         cp $(QTFRAMEWORKSDIR)/QtGui.framework/Versions/4/QtGui $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/
373         cp $(QTFRAMEWORKSDIR)/QtCore.framework/Versions/4/QtCore  $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/
374         mkdir -p $(ROOT_DIR)/$(INST_DIR)/lib
375         cp ../../ThirdParty/Xerces/Xerces-3.1.0-mac/lib/libxerces-c-3.1.dylib $(ROOT_DIR)/$(INST_DIR)/lib/libxerces-c-3.1.dylib
376         mkdir -p $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/plugins/imageformats/
377         cp $(QTPLUGINDIR)/imageformats/libqjpeg.dylib $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/plugins/imageformats/libpteidjpeg.dylib
378         mkdir -p $(ROOT_DIR)/$(APPS_DIR)/$(EIDGUI).app/Contents/Resources
379         @echo "********** Changing install_names for use with the QT libs **********"
380         install_name_tool -change $(PATH_TO_QTCORE) \
381                $(INST_DIR)/lib/pteidqt/QtCore \
382                $(ROOT_DIR)/usr/bin/$(DLGSRV)
383         install_name_tool -change $(PATH_TO_QTGUI) \
384                $(INST_DIR)/lib/pteidqt/QtGui \
385                $(ROOT_DIR)/usr/bin/$(DLGSRV)
386         install_name_tool -change $(PATH_TO_QTCORE) \
387                $(INST_DIR)/lib/pteidqt/QtCore \
388                $(ROOT_DIR)/$(APPS_DIR)/$(EIDGUI).app/Contents/MacOS/$(EIDGUI)
389         install_name_tool -change $(PATH_TO_QTGUI) \
390                $(INST_DIR)/lib/pteidqt/QtGui \
391                $(ROOT_DIR)/$(APPS_DIR)/$(EIDGUI).app/Contents/MacOS/$(EIDGUI)
392         install_name_tool -change QtCore.framework/Versions/4/QtCore \
393                $(INST_DIR)/lib/pteidqt/QtCore \
394                $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/plugins/imageformats/libpteidjpeg.dylib
395         install_name_tool -change QtGui.framework/Versions/4/QtGui \
396                $(INST_DIR)/lib/pteidqt/QtGui \
397                $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/plugins/imageformats/libpteidjpeg.dylib
398         install_name_tool -change $(PATH_TO_QTCORE) \
399                $(INST_DIR)/lib/pteidqt/QtCore \
400                $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/QtGui
401
402rel_end:
403        @echo "********** manipulate mw_installer **********"
404        -@cd ..; \
405          sed -e "s;REPL_REL_VERSION;$(REL_VERSION);g" \
406                   $(INSTALLER_DIR)/Info.plist > $(REL_DIR)/Info.plist ; \
407          cp $(INSTALLER_DIR)/Description.plist  $(REL_DIR)/Description.plist ; \
408          svn export $(INSTALLER_DIR)/resources/ $(REL_DIR)/resources; \
409          sed -e "s;REL_NAME;$(REL_NAME);g" -e "s;PKCS11LIB_NAME_dylib;$(PKCS11LIB_NAME_dylib);g" \
410                   misc/mac/pkcs11.bundle/Contents/Info.plist > \
411                   $(ROOT_DIR)/$(INST_DIR)/lib/$(PKCS11_BUNDLE)/Contents/Info.plist
412
413##cp -r $(INSTALLER_DIR)/resources/ $(REL_DIR)/resources;
414         @echo "********** generate $(POSTFLIGHT) **********"
415        -@test -e $(POSTFLIGHT) && rm $(POSTFLIGHT)
416        @touch $(POSTFLIGHT)
417        @echo "#!/bin/bash" >> $(POSTFLIGHT)
418        @$(call test_and_link_command, $(BASE_LIBS),x_y_z_,x_y_,  $(POSTFLIGHT))
419        @$(call test_and_link_command, $(foreach var,$(BASE_LIBS), $(subst x_y_z_,x_y_,$(var)) ),x_y_,x_, $(POSTFLIGHT))
420        @$(call test_and_link_command, $(foreach var,$(BASE_LIBS), $(subst x_y_z_,x_,$(var)) ),x_,, $(POSTFLIGHT))
421## Old BE pkcs11 bundle was also put /usr/local/lib/pkcs11/Portugal-EID-pkcs11.bundle,
422## so we create this bundle too for backward compatibility
423        @echo "cp -r $(INST_DIR)/lib/$(PKCS11_BUNDLE)/ /usr/local/lib/pkcs11/Portugal-EID-pkcs11.bundle/" >> $(POSTFLIGHT)
424        @echo "test -e $(INST_DIR)/lib/$(PKCS11_BUNDLE)/Contents/MacOS/$(PKCS11LIB_NAME_dylib) && unlink $(INST_DIR)/lib/$(PKCS11_BUNDLE)/Contents/MacOS/$(PKCS11LIB_NAME_dylib)" >> $(POSTFLIGHT)
425        @echo "ln -fs $(INST_DIR)/lib/$(PKCS11LIB_NAME_x_y_z_dylib) $(INST_DIR)/lib/$(PKCS11_BUNDLE)/Contents/MacOS/$(PKCS11LIB_NAME_dylib)" >> $(POSTFLIGHT)
426        @echo "test -e /usr/local/lib/pkcs11/Portugal-EID-pkcs11.bundle/Contents/MacOS/$(PKCS11LIB_NAME_dylib) && unlink /usr/local/lib/pkcs11/Portugal-EID-pkcs11.bundle/Contents/MacOS/$(PKCS11LIB_NAME_dylib)" >> $(POSTFLIGHT)
427        @echo "ln -fs $(INST_DIR)/lib/$(PKCS11LIB_NAME_x_y_z_dylib) /usr/local/lib/pkcs11/Portugal-EID-pkcs11.bundle/Contents/MacOS/$(PKCS11LIB_NAME_dylib)" >> $(POSTFLIGHT)
428        @echo "" >> $(POSTFLIGHT)
429        @echo "test -e $(INST_DIR)/lib/libxerces-c-3.dylib && unlink $(INST_DIR)/lib/libxerces-c-3.dylib" >> $(POSTFLIGHT)
430        @echo "ln -fs $(INST_DIR)/lib/libxerces-c-3.1.dylib $(INST_DIR)/lib/libxerces-c-3.dylib" >> $(POSTFLIGHT)
431        @echo "test -e /Library/Java/Extensions/$(JAVALIB_NAME).jnilib && unlink /Library/Java/Extensions/$(JAVALIB_NAME).jnilib" >> $(POSTFLIGHT)
432        @echo "ln -fs /usr/local/lib/$(JAVALIB_NAME_x_y_z_dylib) /Library/Java/Extensions/$(JAVALIB_NAME).jnilib" >> $(POSTFLIGHT)
433        @echo "mkdir -p \"$(XPI_PLUGIN_DIR)\"" >> $(POSTFLIGHT)
434        @echo "mv $(APPS_DIR)/$(LATEST_XPI) \"$(XPI_PLUGIN_DIR)\"" >> $(POSTFLIGHT)
435        @echo "unzip -qq -o \"$(XPI_PLUGIN_DIR)/$(LATEST_XPI)\" -d \"$(XPI_PLUGIN_DIR)/\"" >> $(POSTFLIGHT)
436        @echo "rm \"$(XPI_PLUGIN_DIR)/$(LATEST_XPI)\"" >> $(POSTFLIGHT)
437        @echo "rm \"$(XPI_107)\"" >> $(POSTFLIGHT)
438        @echo 'if [[ $$(sw_vers -productVersion) == *10.5* ]]; then' >> $(POSTFLIGHT)
439        @echo "mv /Applications/PortugalIdentityCard/PTEID.tokend /System/Library/Security/tokend/; else" >> $(POSTFLIGHT)
440        @echo "test -e /System/Library/Security/tokend/PTEID.tokend && rm -R /System/Library/Security/tokend/PTEID.tokend;" >> $(POSTFLIGHT)
441        @echo "rm -R /Applications/PortugalIdentityCard/PTEID.tokend; fi" >> $(POSTFLIGHT)
442
443        @echo "mv $(APPS_DIR)/$(EIDGUI).app $(APPS_DIR)/$(EIDGUI_NAME).app" >> $(POSTFLIGHT)
444        @echo "mv $(APPS_DIR) \"$(APPS_DIR_NAME)\"" >> $(POSTFLIGHT)
445        @echo "sudo /usr/bin/security add-trusted-cert -d -r trustRoot -k /Library/KeyChains/System.keychain $(ROOT_DIR)/$(INST_DIR)/share/pteid/certs/pteid-cert-portugalrca2.der" >> $(POSTFLIGHT)
446
447        -@test -e tmp && rm temp
448        @cat $(POSTFLIGHT) ../../pteid-2.6/mac/postflight > temp
449        @mv temp $(POSTFLIGHT)
450        @chmod a+x $(POSTFLIGHT)
451
452         @echo "********** generate $(PREFLIGHT) **********"
453        -@test -e $(PREFLIGHT) && rm $(PREFLIGHT)
454        @touch $(PREFLIGHT)
455        @echo "#!/bin/bash" >> $(PREFLIGHT)
456        @echo "## Remove parts (GUI, Tray applet, pkcs11) of the previous middleware parts if they exist" >> $(PREFLIGHT)
457        @echo "test -e \"$(APPS_DIR_NAME)\" && rm -rf \"$(APPS_DIR_NAME)\"" >> $(PREFLIGHT)
458        @echo "test -e /usr/local/lib/$(PKCS11_BUNDLE) && rm -rf /usr/local/lib/$(PKCS11_BUNDLE)" >> $(PREFLIGHT)
459        @echo "test -e /usr/local/lib/pkcs11/$(PKCS11_BUNDLE) && rm -rf /usr/local/lib/pkcs11/$(PKCS11_BUNDLE)" >> $(PREFLIGHT)
460        @echo "test -e /usr/local/lib/pteid-pkcs11.bundle && rm -rf /usr/local/lib/pteid-pkcs11.bundle" >> $(PREFLIGHT)
461        @echo "" >> $(PREFLIGHT)
462        @$(call mkdir_command, $(DIRS_TO_CREATE), $(PREFLIGHT))
463        @chmod a+x $(PREFLIGHT)
464
465        @echo "********** generate $(PKG_NAME) and $(DMG_NAME) **********"
466        @rm -rf $(PKG_NAME)
467       
468        @chmod g+w $(ROOT_DIR)/Applications
469        @chmod g+w $(ROOT_DIR)/$(INST_DIR)
470        @chmod g+w $(ROOT_DIR)/$(INST_DIR)/lib
471        @chmod g+w $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt
472        @chmod g+w $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/plugins
473        @chmod g+w $(ROOT_DIR)/$(INST_DIR)/lib/pteidqt/plugins/imageformats
474        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/etc/pteid.conf
475        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/etc/pteidbase.conf
476        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/etc/pteidgui.conf
477        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/lib/pteidlib.jar
478        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/lib/pteid-pkcs11.bundle/Contents/Info.plist
479        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/lib/pteid-pkcs11.bundle/Contents/PkgInfo
480        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/share/pteid/certs/pteid-cert-portugalrca.der
481        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/share/pteid/certs/pteid-cert-portugalrca2.der
482        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/share/pteid/certs/pteid-cert-government.der
483        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/share/pteid/certs/pteid-cert-government2004.der
484        @chmod a-x $(ROOT_DIR)/$(INST_DIR)/share/pteid/certs/pteid-cert-government2005.der
485        @chmod a+x  $(ROOT_DIR)/$(INST_DIR)/lib/libpteid*.dylib
486        @chmod a+x  $(ROOT_DIR)/$(INST_DIR)/lib/libqt-mt*.dylib
487        #@chgrp -R wheel  $(ROOT_DIR)/System
488        @chgrp    wheel  $(ROOT_DIR)/usr
489        @chgrp    wheel  $(ROOT_DIR)/usr/bin
490        @chgrp    wheel  $(ROOT_DIR)/usr/local
491        @chgrp    wheel  $(ROOT_DIR)/usr/share
492        @chgrp    wheel  $(ROOT_DIR)/usr/local/lib
493        @chgrp    wheel  $(ROOT_DIR)/usr/share/man
494        @chgrp    wheel  $(ROOT_DIR)/usr/local/lib/siscardplugins
495        @chgrp    wheel  $(ROOT_DIR)/usr/local/lib/pteidqt
496        @chgrp    wheel  $(ROOT_DIR)/usr/local/lib/pteidqt/plugins
497        @chgrp    wheel  $(ROOT_DIR)/usr/share/man/man1
498        @chgrp -R admin  $(ROOT_DIR)/$(APPS_DIR)/PTEID.tokend
499
500        $(PKG_MAKER) -build -p $(PKG_NAME) -f $(r1) -ds -i $(REL_DIR)/Info.plist \
501                 -d $(REL_DIR)/Description.plist -r $(REL_DIR)/resources  -v
502        hdiutil create -srcfolder $(PKG_NAME) -volname "$(VOL_NAME)" $(DMG_NAME)
503        #hdiutil internet-enable -yes $(DMG_NAME)
504
505################################################################
506
507universal: clean_universal $(UNIVERSAL)
508        # "This expects that 'sudo make release' was already done on this machine;"
509        # "as well as on the other architecture, and that the release_build"
510        # "from that architecture was copied a dir called 'other'"
511
512        @echo "********** generate $(UDIR)/$(PKG_NAME) and $(DMG_NAME_u) **********"
513        rm -rf $(UDIR)/$(PKG_NAME)
514        $(PKG_MAKER) -build -p $(UDIR)/$(PKG_NAME) -f $(r3) -ds -i $(UDIR)/$(REL_DIR)/Info.plist \
515                -d $(UDIR)/$(REL_DIR)/Description.plist -r $(UDIR)/$(REL_DIR)/resources  -v
516        hdiutil create -srcfolder $(UDIR)/$(PKG_NAME) -volname "$(VOL_NAME)" $(DMG_NAME_u)
517        #hdiutil internet-enable -yes $(DMG_NAME_u)
518
519
520################################################################
521
522sdk: cleanSDK $(SDK_DIRS)
523        $(call copy_command,$(SDK_FILES_TO_COPY),-L)
524
525        cp "../sdk/samples/read_eid/C++/Makefile.mac" $(SDK_DIR)/samples/read_eid/C++/Makefile
526        cp "../sdk/samples/wait_card/C++/Makefile.mac" $(SDK_DIR)/samples/wait_card/C++/Makefile
527        cp "../sdk/samples/pin_eid/C++/Makefile.mac" $(SDK_DIR)/samples/pin_eid/C++/Makefile
528        cp "../sdk/samples/exception/C++/Makefile.mac" $(SDK_DIR)/samples/exception/C++/Makefile
529        cp "../sdk/samples/events/C++/Makefile.mac" $(SDK_DIR)/samples/events/C++/Makefile
530
531        cp ../sdk/samples/read_eid/Java/mac_compile_read_eid.sh \
532                $(SDK_DIR)/samples/read_eid/Java/compile_read_eid.sh
533        cp ../sdk/samples/read_eid/Java/mac_run_read_eid.sh \
534                $(SDK_DIR)/samples/read_eid/Java/run_read_eid.sh
535        cp ../sdk/samples/wait_card/Java/mac_compile_wait_card.sh \
536                $(SDK_DIR)/samples/wait_card/Java/compile_wait_card.sh
537        cp ../sdk/samples/wait_card/Java/mac_run_wait_card.sh \
538                $(SDK_DIR)/samples/wait_card/Java/run_wait_card.sh
539        cp ../sdk/samples/pin_eid/Java/mac_compile_pin_eid.sh \
540                $(SDK_DIR)/samples/pin_eid/Java/compile_pin_eid.sh
541        cp ../sdk/samples/pin_eid/Java/mac_run_pin_eid.sh \
542                $(SDK_DIR)/samples/pin_eid/Java/run_pin_eid.sh
543        cp ../sdk/samples/exception/Java/mac_compile_exception.sh \
544                $(SDK_DIR)/samples/exception/Java/compile_exception.sh
545        cp ../sdk/samples/exception/Java/mac_run_exception.sh \
546                $(SDK_DIR)/samples/exception/Java/run_exception.sh
547        cp ../sdk/samples/events/Java/mac_compile_events.sh \
548                $(SDK_DIR)/samples/events/Java/compile_events.sh
549        cp ../sdk/samples/events/Java/mac_run_events.sh \
550                $(SDK_DIR)/samples/events/Java/run_events.sh
551        cp ../sdk/samples/misc/Applet/Image/Java/compile.sh \
552                $(SDK_DIR)/samples/misc/Applet/Image/Java
553        chmod +x $(SDK_DIR)/samples/misc/Applet/Image/Java/compile.sh
554
555        cd ../_DocsInternal/API; chmod +x ./doxygen_sdk.sh; ./doxygen_sdk.sh
556        cp -r ../_DocsExternal/C++_Api $(SDK_DIR)/doc/C++_Api
557        cp -r ../_DocsExternal/Java_Api $(SDK_DIR)/doc/Java_Api
558
559        hdiutil create -srcfolder $(SDK_DIR) -volname "$(VOL_NAME_SDK)" $(DMG_NAME_SDK)
560
561################################################################
562## create directories in list DIRS intermediate directories as well
563
564$(DIRS): FORCE
565        @echo "mkdir $@"
566        @mkdir -p $@
567
568################################################################
569## create directories in list SDK_DIRS intermediate directories as well
570
571$(SDK_DIRS): FORCE
572        @echo "mkdir $@"
573        @mkdir -p $@
574
575################################################################
576cleanSDK:
577        - [ -d $(SDK_DIR) ] && rm -rf $(SDK_DIR)
578        - [ -e $(DMG_NAME_SDK) ] && rm $(DMG_NAME_SDK)
579
580################################################################
581## lipo command explanation:
582## $@ -> one element in the $(UNIVERSAL) list (which is a lib or
583## an executable with path in $(r3)   (1)
584## $(patsubst $(r3)%,$(r1)%,$@) -> substitutes $(r1) to $(r3) in the path of $@   (2)
585## $(patsubst $(r3)%,$(r2)%,$@) -> substitutes $(r2) to $(r3) in the path of $@   (3)
586## lipo the results of (2) and (3) to create (1)
587
588$(UNIVERSAL) :  FORCE
589        -lipo $(patsubst $(r3)%,$(r1)%,$@) $(patsubst $(r3)%,$(r2)%,$@)  -output $@ -create
590
591
592################################################################
593clean_universal:
594        - rm -rf $(UDIR)
595        - rm $(DMG_NAME_u)
596        mkdir $(UDIR)
597        cp -r $(REL_DIR) $(UDIR)/
598
599################################################################
600clean_release:
601        - [ -d $(REL_DIR) ] && rm -rf $(REL_DIR)
602        - [ -e $(DMG_NAME) ] && rm $(DMG_NAME)
603
604
605################################################################
606## phony target used as a dependency in some cases
607## to enforce the update of other targets
608FORCE:
609       
610       
611
612
613##############################################################
614# Helper functions                                           #
615##############################################################
616##                                                           #
617## These functions generate a sequence of bash commands.     #
618## Each command is run in its own shell, therefore they have #
619## to be chained with ";"  if one wants to use the result of #
620## a command in the following one.                           #
621## "\" extends the command over multiple lines.              #
622##                                                           #
623##############################################################
624
625## Copy files or directory with option $(2) (which might be empty)
626## The input $(1) contains strings of the form <source>_____<destination>,
627## which are parsed to define the source file and the destination file.
628
629define copy_command
630for FILE in $(1); do \
631  SOURCE=$$( echo $$FILE| sed "s#\(.*\)_____.*#\1#"); \
632  DESTINATION=$$(echo $$FILE | sed "s#.*_____\(.*\)#\1#"); \
633  echo "copy $(2) $$SOURCE --> $$DESTINATION" ; \
634  cp $(2) $${SOURCE} $${DESTINATION}; \
635done
636endef
637
638###########################################################
639
640## $(1) -> list of variables, the value of which is the name of a library
641## $(2) -> string in $(var) to be substituted
642## $(3) -> string with which $(2) is substituted
643## $(4) -> output file
644##
645## This function produces lines of the type:
646##
647## test -e $(INST_DIR)/lib/<lib_x_y_dylib> && unlink  $(INST_DIR)/lib/<lib_x_y_dylib>
648## ln -fs $(INST_DIR)/lib/<lib_x_y_z_dylib> $(INST_DIR)/lib/<lib_x_y_dylib>
649##
650## and sends them to the file specified by argument 4.
651##
652
653define test_and_link_command
654$(foreach var,$(1),  echo "test -e $(INST_DIR)/lib/$($(subst $(2),$(3),$(var))) && unlink $(INST_DIR)/lib/$($(subst $(2),$(3),$(var)))" >> $(4) ; \
655         echo "ln -fs $(INST_DIR)/lib/$($(var)) $(INST_DIR)/lib/$($(subst $(2),$(3),$(var)))" >> $(4); ) \
656echo >> $(4)
657endef
658
659###########################################################
660
661## Receives in input a list of directory, $(1), and a filename $(2).
662## For each elements of the list produces a mkdir command and pipes it to $(2).
663
664define mkdir_command
665$(foreach var,$(1),  echo "## Create $(var) if it does not exist yet" >> $(2); \
666                        echo "mkdir -p $(var)" >> $(2) ; \
667                        echo "" >> $(2); )
668endef
669
670###########################################################
Note: See TracBrowser for help on using the browser.