summaryrefslogtreecommitdiff
path: root/ios/CustomTarget_MobileLibreOffice_app.mk
blob: 300d67fd269db2ece6c215be01f92172c67fc96f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

#- Env ------------------------------------------------------------------------

LO_XCCONFIG 	:= lo.xcconfig
DEST_RESOURCE 	:= MobileLibreOffice/resource_link
BUILDID			:=$(shell cd $(SRCDIR) && git log -1 --format=%H)
          
#- Macros ---------------------------------------------------------------------

define MobileLibreOfficeXcodeBuild 
	CC=;xcodebuild -project MobileLibreOffice/MobileLibreOffice.xcodeproj -scheme MobileLibreOffice -arch armv7 -configuration $(if $(ENABLE_DEBUG),Debug,Release) $(1) >/dev/null
endef

#- Targets --------------------------------------------------------------------

.PHONY: MobileLibreOffice_setup 

#==============================================================================
# Register target
$(eval $(call gb_CustomTarget_CustomTarget,ios/MobileLibreOffice))
#==============================================================================

#==============================================================================
# Build
$(call gb_CustomTarget_get_target,ios/MobileLibreOffice): MobileLibreOffice_setup
#==============================================================================
	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),APP,2)
	$(call MobileLibreOfficeXcodeBuild, clean build)

#==============================================================================
# Setup
MobileLibreOffice_setup:
#==============================================================================
	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),ENV,2)

	# Put xcconfig in source dir for Xcode projects
	if test $(SRCDIR) != $(BUILDDIR); then \
		cp $(BUILDDIR)/ios/$(LO_XCCONFIG) $(SRCDIR)/ios; \
	fi

	# Libs #
	# Create the link flags in the xcconfig for Xcode linkage
	for path in $(INSTDIR)/program \
				$(WORKDIR)/LinkTarget/StaticLibrary \
				$(WORKDIR)/UnpackedTarball/*/.libs \
				$(WORKDIR)/UnpackedTarball/*/src/.libs \
				$(WORKDIR)/UnpackedTarball/*/src/*/.libs \
				$(WORKDIR)/UnpackedTarball/xslt/libxslt/.libs \
				$(WORKDIR)/UnpackedTarball/icu/source/lib \
				$(WORKDIR)/UnpackedTarball/openssl; do \
		flags=''; \
    	for lib in $$path/lib*.a; do \
        	if [ ! -r $$lib ]; then \
            	continue; \
        	fi; \
        	base="$${lib##*/lib}"; \
        	base=$${base%\.a}; \
        	flags+=" -l$${base}"; \
    	done; \
		if [ "$$flags" ]; then \
			all_flags+=" -L$$path $$flags"; \
		fi; \
	done; \
	file=$(LO_XCCONFIG); \
	sed -i '' -e "s|^\(LINK_LDFLAGS =\).*$$|\1 $$all_flags|" $$file;

	# Resources #
	rm -rf $(DEST_RESOURCE) 2>/dev/null
	mkdir -p $(DEST_RESOURCE)
	mkdir -p $(DEST_RESOURCE)/ure

	# copy rdb files
	cp $(INSTDIR)/program/types/offapi.rdb      $(DEST_RESOURCE)
	cp $(INSTDIR)/program/types/oovbaapi.rdb  	$(DEST_RESOURCE)
	cp $(INSTDIR)/program/services/services.rdb $(DEST_RESOURCE)
	cp $(INSTDIR)/ure/share/misc/services.rdb   $(DEST_RESOURCE)/ure

	# copy .res files
	# program/resource is hardcoded in tools/source/rc/resmgr.cxx. Sure,
	# we could set STAR_RESOURCE_PATH instead. sigh...
	mkdir -p $(DEST_RESOURCE)/program/resource
	cp $(INSTDIR)/program/resource/*en-US.res $(DEST_RESOURCE)/program/resource

	# soffice.cfg
	mkdir -p $(DEST_RESOURCE)/share/config
	cp -R $(INSTDIR)/share/config/soffice.cfg $(DEST_RESOURCE)/share/config
            
	# "registry"
	cp -R $(INSTDIR)/share/registry $(DEST_RESOURCE)/share
            
	# Set up rc, the "inifile". See getIniFileName_Impl().
	file=$(DEST_RESOURCE)/rc; \
	echo '[Bootstrap]'                                       >  $$file; \
	echo 'URE_BOOTSTRAP=file://$$APP_DATA_DIR/fundamentalrc' >> $$file; \
	echo 'HOME=$$APP_DATA_DIR/tmp'                           >> $$file;

	# Set up fundamentalrc, unorc, bootstraprc and versionrc.
	# Do we really need all these?
	file=$(DEST_RESOURCE)/fundamentalrc; \
	echo '[Bootstrap]'                                      >  $$file; \
	echo 'BRAND_BASE_DIR=file://$$APP_DATA_DIR'             >> $$file; \
	echo 'CONFIGURATION_LAYERS=xcsxcu:$${BRAND_BASE_DIR}/share/registry res:$${BRAND_BASE_DIR}/registry' >> $$file;

	file=$(DEST_RESOURCE)/unorc; \
	echo '[Bootstrap]' > $$file;

	# bootstraprc must be in $BRAND_BASE_DIR/program
	mkdir -p $(DEST_RESOURCE)/program
	file=$(DEST_RESOURCE)/program/bootstraprc; \
	echo '[Bootstrap]'                                                              >  $$file; \
	echo 'InstallMode=<installmode>'                                                >> $$file; \
	echo "ProductKey=LibreOffice $(PRODUCTVERSION)"                                 >> $$file; \
	echo 'UserInstallation=file://$$APP_DATA_DIR/../Library/Application%20Support'  >> $$file;

	# Is this really needed?
	file=$(DEST_RESOURCE)/program/versionrc; \
	echo '[Version]'            >  $$file; \
	echo 'AllLanguages=en-US'   >> $$file; \
	echo 'BuildVersion='        >> $$file; \
	echo "buildid=$(BUILDID)"   >> $$file; \
	echo 'ProductMajor=360'     >> $$file; \
	echo 'ProductMinor=1'       >> $$file; 
	 
#==============================================================================
# Clean
$(call gb_CustomTarget_get_clean_target,ios/MobileLibreOffice):
#==============================================================================
	$(call gb_Output_announce,$(subst $(WORKDIR)/Clean/,,$@),$(false),APP,2)
	$(call MobileLibreOfficeXcodeBuild, clean)

#------------------------------------------------------------------------------
# vim: set noet sw=4 ts=4: