Makefile.in 11.6 KB
Newer Older
1
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2
#
3
# This file is part of the LibreOffice project.
4 5 6 7 8
#
# 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/.
#
9

10
.PHONY : all bootstrap build check clean clean-build clean-host test-install distclean distro-pack-install docs download fetch findunusedcode get-submodules id install install-strip subsequentcheck tags
11

12 13 14 15
ifeq ($(MAKECMDGOALS),)
MAKECMDGOALS:=all
endif

16
SHELL=/usr/bin/env bash
17 18
SRCDIR := @SRC_ROOT@
BUILDDIR := @BUILDDIR@
19
GIT_BUILD := $(if $(wildcard $(SRCDIR)/.git),T)
20

21 22 23 24 25 26 27 28
# Run autogen.sh if needed and force make to restart itself.
# ... but there are several cases where we do not want to run
# autogen.sh:
# 1. if we are building from tarballs, not git checkout (I do not
#    think packagers would ever want that. I certainly do not.)
# 2. if we are making help, clean or distclean, because they do not
#    need updated configuration
ifeq (,$(MAKE_RESTARTS)$(if $(GIT_BUILD),,T)$(if $(filter-out help clean distclean,$(MAKECMDGOALS)),,T))
29

30 31 32
.PHONY : force-restart
Makefile: $(BUILDDIR)/config_host.mk force-restart
	@touch $@
33

34
# run configure in an environment not polluted by config_host.mk
35
$(BUILDDIR)/config_host.mk : \
36
		$(SRCDIR)/config_host.mk.in \
37
		$(SRCDIR)/Makefile.in \
38
		$(SRCDIR)/instsetoo_native/util/openoffice.lst.in \
39
		$(SRCDIR)/configure.ac \
40
		$(wildcard $(SRCDIR)/config_host/*.h.in) \
41
		$(if $(wildcard $(BUILDDIR)/autogen.input),$(BUILDDIR)/autogen.input,$(if $(wildcard $(BUILDDIR)/autogen.lastrun),$(BUILDDIR)/autogen.lastrun))
42
	$(SRCDIR)/autogen.sh
43

44 45 46
# dummy rule in case any of the above prerequisites are removed, so
# that a stale Makefile still triggers autogen.sh, or in case
# autogen.input does not exist, or autogen.lastrun does not yet exist
47 48 49 50
$(SRCDIR)/config_host.mk.in \
$(SRCDIR)/Makefile.in \
$(SRCDIR)/instsetoo_native/util/openoffice.lst.in \
$(SRCDIR)/configure.ac \
51
$(BUILDDIR)/autogen.input \
52
$(BUILDDIR)/autogen.lastrun:
53 54
	@true

55 56 57 58 59
else # MAKE_RESTARTS

all: build

ifeq ($(gb_Side),)
Matúš Kukan's avatar
Matúš Kukan committed
60
gb_Side := host
61 62 63 64 65 66
endif

include $(BUILDDIR)/config_$(gb_Side).mk

ifeq ($(GMAKE_OPTIONS),)
ifeq ($(verbose)$(VERBOSE),)
67
export GMAKE_OPTIONS:=-rs$(MAKEFLAGS)
68
else
69
export GMAKE_OPTIONS:=-r$(MAKEFLAGS)
70 71 72
endif
endif

Matúš Kukan's avatar
Matúš Kukan committed
73 74 75
#
# Partial Build
#
76
define gbuild_module_rules
77
.PHONY: $(1) $(1).all $(1).build $(1).check $(1).clean $(1).showdeliverables $(1).subsequentcheck
78 79

$(1): bootstrap fetch
80
	cd $(SRCDIR)/$(1) && $(GNUMAKE) -j $(PARALLELISM) $(GMAKE_OPTIONS)
81

82
$(1).build $(1).check $(1).clean $(1).showdeliverables:
83
	cd $(SRCDIR)/$(1) && $(GNUMAKE) -j $(PARALLELISM) $(GMAKE_OPTIONS) $$(patsubst $(1).%,%,$$@)
84 85

$(1).subsequentcheck:
86
	cd $(SRCDIR)/$(1) && $(GNUMAKE) -j $(CHECK_PARALLELISM) $(GMAKE_OPTIONS) subsequentcheck
87

88
$(1).all: bootstrap fetch
89
	$(GNUMAKE) -j $(PARALLELISM) $(GMAKE_OPTIONS) -f $(SRCDIR)/Makefile.gbuild $(WORKDIR)/Module/$(1) $(if $(CROSS_COMPILING),,$(WORKDIR)/Module/check/$(1) $(WORKDIR)/Module/slowcheck/$(1))
90

91 92 93 94 95 96
endef

define gbuild_modules_rules
$(foreach m,$(1),$(call gbuild_module_rules,$(m)))
endef

97 98 99
gbuild_modules := $(filter-out Module%,$(subst /, ,$(subst $(SRCDIR)/,,$(wildcard $(SRCDIR)/*/Module_*.mk))))

$(eval $(call gbuild_modules_rules,$(gbuild_modules)))
100

101
gbuild_TARGETS := AllLangHelp \
David Tardon's avatar
David Tardon committed
102
	AllLangPackage \
103
	AllLangResTarget \
104
	AutoInstall \
105 106 107 108 109 110 111 112 113 114 115
	CliLibrary \
	CliNativeLibrary \
	CliUnoApiTarget \
	Configuration \
	CppunitTest \
	CustomTarget \
	Dictionary \
	Executable \
	Extension \
	ExternalPackage \
	ExternalProject \
116
	GeneratedPackage \
117 118 119 120 121 122 123 124
	InstallModule \
	InstallScript \
	InternalUnoApi \
	Jar \
	JunitTest \
	Library \
	Module \
	Package \
125
	PackageSet \
126
	Pagein \
127
	Postprocess \
128
	Pyuno \
129
	PythonTest \
130 131
	Rdb \
	StaticLibrary \
David Tardon's avatar
David Tardon committed
132
	UIConfig \
133 134 135
	UnoApi \
	UnpackedTarball \
	WinResTarget \
136
	Zip \
137

138
# build a generic gbuild target
139
$(foreach target,$(gbuild_TARGETS),$(target)_% $(foreach module,$(gbuild_modules),$(target)_$(module)/%)):
140
	$(GNUMAKE) -j $(PARALLELISM) $(GMAKE_OPTIONS) -f $(SRCDIR)/Makefile.gbuild $@
141 142 143 144 145 146 147

#
# Clean
#
clean: clean-host clean-build

clean-host:
148
	rm -fr $(TESTINSTALLDIR)
149
	rm -fr $(INSTDIR)
150 151 152 153 154 155
	rm -fr $(OUTDIR)
	rm -fr $(WORKDIR)
	rm -fr install

clean-build:
ifeq ($(CROSS_COMPILING),YES)
156
	rm -fr $(INSTDIR_FOR_BUILD)
Matúš Kukan's avatar
Matúš Kukan committed
157 158
	rm -fr $(OUTDIR_FOR_BUILD)
	rm -fr $(WORKDIR_FOR_BUILD)
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
endif

include $(SRCDIR)/compilerplugins/Makefile.mk

#
# Distclean
#
distclean : clean compilerplugins-clean
	rm -fr \
        $(BUILDDIR)/Makefile \
        $(BUILDDIR)/aclocal.m4 \
        $(BUILDDIR)/autom4te.cache \
        $(BUILDDIR)/config.log \
        $(BUILDDIR)/config.status \
        $(BUILDDIR)/config_build.mk \
        $(BUILDDIR)/config_host.mk \
        $(BUILDDIR)/config_host.mk.stamp \
176
        $(BUILDDIR)/config_host/*.h \
177
        $(BUILDDIR)/config_host/*.mk \
178
        $(BUILDDIR)/configure \
179
        $(BUILDDIR)/instsetoo_native/util/openoffice.lst \
Matúš Kukan's avatar
Matúš Kukan committed
180
        $(BUILDDIR)/lo.xcent
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
	find $(SOLARENV)/gdb -name "*.pyc" -exec rm {} \;

#
# custom command
#
cmd:
	echo "custom cmd" && ( $(cmd) )

#
# Fetch
#
ifneq ($(DO_FETCH_TARBALLS),NO)
include $(SRCDIR)/Makefile.fetch
fetch: download
fetch: get-submodules

ifneq (,$(wildcard $(SRCDIR)/.git))
get-submodules:
ifneq ($(foreach i,$(GIT_NEEDED_SUBMODULES),$(i)/.git),$(wildcard $(foreach i,$(GIT_NEEDED_SUBMODULES),$(i)/.git)))
	cd $(SRCDIR) && ./g -f clone
endif
202
	@cd $(SRCDIR) && ./g -z # make sure the git hooks are in place enen if no submodules are needed
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226

else # these sources are from a tarball, so get the other source tarballs
gb_LO_VER := $(shell . $(SRCDIR)/sources.ver && echo $$lo_sources_ver)
$(if $(gb_LO_VER),,$(error Error while retrieving $$lo_sources_ver from $(SRCDIR)/sources.ver))

get-submodules: | download
ifneq ($(foreach i,$(subst helpcontent2,help,$(GIT_NEEDED_SUBMODULES)),$(SRCDIR)/src/libreoffice-$(i)-$(gb_LO_VER)),$(wildcard $(foreach i,$(subst helpcontent2,help,$(GIT_NEEDED_SUBMODULES)),$(SRCDIR)/src/libreoffice-$(i)-$(gb_LO_VER))))
	$(foreach i,$(subst helpcontent2,help,$(GIT_NEEDED_SUBMODULES)),\
		$(call fetch_Download_item,http://download.documentfoundation.org/libreoffice/src/$(shell echo $(gb_LO_VER) | sed -e "s/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/"),libreoffice-$(i)-$(gb_LO_VER).tar.xz,no-check))
	$(SRCDIR)/bin/unpack-sources $(SRCDIR) $(foreach i,$(subst helpcontent2,help,$(GIT_NEEDED_SUBMODULES)),\
		$(TARFILE_LOCATION)/libreoffice-$(i)-$(gb_LO_VER).tar.xz)
endif

endif

else
fetch:
	@echo "Automatic fetching of external tarballs is disabled."

endif

#
# Bootstap
#
227
bootstrap: compilerplugins
228 229 230 231

#
# Build
#
232
build: bootstrap fetch $(if $(filter $(INPATH),$(INPATH_FOR_BUILD)),,cross-toolset)
233
	$(GNUMAKE) -j $(PARALLELISM) $(GMAKE_OPTIONS) -f $(SRCDIR)/Makefile.gbuild
234 235 236
ifneq ($(filter-out WNT MACOSX IOS ANDROID,$(OS)),)
	install-gdb-printers -a $(INSTDIR)
endif
237 238 239
ifeq ($(OS),IOS)
	$(GNUMAKE) -j $(PARALLELISM) $(GMAKE_OPTIONS) ios
endif
240

241 242
build-nocheck: bootstrap fetch $(if $(filter $(INPATH),$(INPATH_FOR_BUILD)),,cross-toolset)
	$(GNUMAKE) -j $(PARALLELISM) $(GMAKE_OPTIONS) -f $(SRCDIR)/Makefile.gbuild build
243 244

cross-toolset: bootstrap fetch
245
	$(GNUMAKE) gb_Side=build -j $(PARALLELISM) $(GMAKE_OPTIONS) -f $(SRCDIR)/Makefile.gbuild build-tools
246

247 248
ifneq ($(OS),MACOSX)

249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
#
# Install
#

install:
	echo "Installing in $(INSTALLDIR)..." && \
	ooinstall "$(INSTALLDIR)" && \
	echo "" && \
	echo "Installation finished, you can now execute:" && \
	echo "$(INSTALLDIR)/program/soffice"

install-strip:
	echo "Installing and stripping binaries in $(INSTALLDIR)..." && \
	ooinstall --strip "$(INSTALLDIR)" && \
	echo "" && \
	echo "Installation finished, you can now execute:" && \
	echo "$(INSTALLDIR)/program/soffice"

267 268
endif # !MACOSX

269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
dev-install:
	@echo
	@echo "dev-install is obsolete! Just build with \"make check\" and run"
ifeq ($(OS),MACOSX)
	@echo "  open instdir/*/$(PRODUCTNAME).app"
	@echo
	@echo "To debug: gdb instdir/*/$(PRODUCTNAME).app/Contents/MacOS/soffice"
else
	@echo "  instdir/*/program/soffice"
endif
	@echo
	@echo "(only if you have good reason to test an actual installation: make test-install)"
	@echo
	@false

test-install: build
285
	@rm -rf $(TESTINSTALLDIR)
286
	@mkdir -p $(TESTINSTALLDIR)
287
ifeq ($(OS_FOR_BUILD),WNT)
288
	cd $(SRCDIR)/instsetoo_native && $(GNUMAKE) LIBO_TEST_INSTALL=TRUE $(GMAKE_OPTIONS)
289
else
290
	@ooinstall $(TESTINSTALLDIR)
291
ifneq ($(MACOSX_CODESIGNING_IDENTITY),)
292
	@macosx-codesign-app-bundle $(TESTINSTALLDIR)/LibreOffice.app
293
endif
294
ifneq ($(OS),MACOSX)
295
	@install-gdb-printers -L
296
endif
297
endif
298 299 300
	@echo
	@echo "If you want to edit the .ui files with glade first execute:"
	@echo
301
	@echo "export GLADE_CATALOG_SEARCH_PATH=$(TESTINSTALLDIR)/share/glade"
302
ifneq ($(OS),MACOSX)
303
	@echo
304
	@echo "Test installation finished, you can now execute:"
305
	@echo
306 307
	@echo "  $(TESTINSTALLDIR)/program/soffice"
else
308
	@echo
309
	@echo "Test installation finished, you can now run:"
310
	@echo
311
	@echo "  open $(TESTINSTALLDIR)/LibreOffice.app"
312
	@echo
313
	@echo "To debug: gdb $(TESTINSTALLDIR)/LibreOffice.app/Contents/MacOS/soffice"
314
endif
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333

distro-pack-install: install
	$(SRCDIR)/bin/distro-install-clean-up
	$(SRCDIR)/bin/distro-install-desktop-integration
	$(SRCDIR)/bin/distro-install-sdk
	$(SRCDIR)/bin/distro-install-file-lists

id:
	@create-ids

tags:
	@create-tags

docs:
	@mkdocs.sh $(SRCDIR)/docs $(SOLARENV)/inc/doxygen.cfg

findunusedcode:
	@which callcatcher > /dev/null 2>&1 || \
	    (echo "callcatcher not installed" && false)
334 335 336 337
	@mkdir -p $(SRCDIR)/callcatcher/config_host
	@cp config_host/* callcatcher/config_host
	@cp config_host.mk* callcatcher
	@sed -e s,$$INPATH,callcatcher,g config_host.mk | sed -e s,"export OOO_JUNIT_JAR=.*","export OOO_JUNIT_JAR=",g > $(SRCDIR)/callcatcher/config_host.mk
338 339
	@sed -i -e s,g++,"callcatcher g++",g $(SRCDIR)/callcatcher/config_host.mk
	@sed -i -e s,gcc,"callcatcher gcc",g $(SRCDIR)/callcatcher/config_host.mk
340 341 342
	@echo unexport ARCH_FLAGS >> $(SRCDIR)/callcatcher/config_host.mk
	@echo unexport CFLAGS >> $(SRCDIR)/callcatcher/config_host.mk
	@echo unexport CXXFLAGS >> $(SRCDIR)/callcatcher/config_host.mk
343
	$(GNUMAKE) -f $(SOLARENV)/bin/callcatcher.Makefile findunusedcode
344 345 346 347 348 349 350
	@grep ::.*\( unusedcode.all \
              | grep -v ^Atom \
              | grep -v ^atom:: \
              | grep -v ^boost:: \
              | grep -v ^CIcc \
              | grep -v ^CLuceneError:: \
              | grep -v ^cppu:: \
351
              | grep -v ^CppUnit:: \
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
              | grep -v ^Dde \
              | grep -v ^graphite2:: \
              | grep -v ^jvmaccess:: \
              | grep -v ^libcdr:: \
              | grep -v ^libcmis:: \
              | grep -v ^libmspub:: \
              | grep -v ^libvisio:: \
              | grep -v ^libwpg:: \
              | grep -v ^libwps_tools_win:: \
              | grep -v ^lucene:: \
              | grep -v ^Matrix3d:: \
              | grep -v ^RelatedMultipart:: \
              | grep -v ^salhelper:: \
              | grep -v ^VSDInternalStream:: \
              | grep -v ^WP1 \
              | grep -v ^WP3 \
              | grep -v ^WP42 \
              | grep -v ^WP6 \
              | grep -v ^WPG \
              | grep -v ^WPS \
              | grep -v WPX \
              | grep -v ^WSObject \
              > unusedcode.easy

376
check: build subsequentcheck
377

378
dump-deps:
379
	@$(SRCDIR)/bin/module-deps.pl $(GNUMAKE) $(SRCDIR)/Makefile.gbuild
380

381 382 383
dump-deps-png:
	@$(SRCDIR)/bin/module-deps.pl $(GNUMAKE) $(SRCDIR)/Makefile.gbuild | dot -Tpng -o lo.png

384
subsequentcheck :| $(if $(filter-out subsequentcheck,$(MAKECMDGOALS)),build)
385
	$(GNUMAKE) -j $(CHECK_PARALLELISM) $(GMAKE_OPTIONS) -f $(SRCDIR)/Makefile.gbuild $@
386

Matúš Kukan's avatar
Matúš Kukan committed
387 388
.PHONY : debugrun help slowcheck translations unitcheck
debugrun help slowcheck translations unitcheck :
389
	$(GNUMAKE) -j $(PARALLELISM) $(GMAKE_OPTIONS) -f $(SRCDIR)/Makefile.gbuild $@
390 391 392 393

endif # MAKE_RESTARTS

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