Makefile 21.9 KB
Newer Older
1
# Makefile for MCE
Santtu Lakkala's avatar
Santtu Lakkala committed
2
# Copyright © 2004-2011 Nokia Corporation.
3
# Copyright (C) 2012-2019 Jolla Ltd.
4 5 6 7 8 9 10 11 12 13 14 15 16 17
#
# @author David Weinehall <david.weinehall@nokia.com>
# @author Tuomo Tanskanen
# @author Irina Bezruk <ext-irina.bezruk@nokia.com>
# @author Victor Portnov <ext-victor.portnov@nokia.com>
# @author Jukka Turunen <ext-jukka.t.turunen@nokia.com>
# @author Santtu Lakkala <ext-santtu.1.lakkala@nokia.com>
# @author Tapio Rantala <ext-tapio.rantala@nokia.com>
# @author Dmitry Rozhkov <dmitry.rozhkov@jollamobile.com>
# @author Kalle Jokiniemi <kalle.jokiniemi@jolla.com>
# @author Philippe De Swert <philippe.deswert@jollamobile.com>
# @author Pekka Lundstrom <pekka.lundstrom@jollamobile.com>
# @author Martin Kampas <martin.kampas@tieto.com>
# @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
18 19 20 21 22 23 24 25 26 27 28 29
#
# mce is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License
# version 2.1 as published by the Free Software Foundation.
#
# mce is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with mce.  If not, see <http://www.gnu.org/licenses/>.
30

spiiroin's avatar
spiiroin committed
31 32 33 34
# ----------------------------------------------------------------------------
# TOP LEVEL TARGETS
# ----------------------------------------------------------------------------

35
.PHONY: build modules tools check doc install clean distclean mostlyclean
spiiroin's avatar
spiiroin committed
36 37 38 39 40 41 42

build::

modules::

tools::

43 44
check::

spiiroin's avatar
spiiroin committed
45 46 47 48 49
doc::

install::

mostlyclean::
50
	$(RM) *.o *.bak *~ */*.o */*.bak */*~ */*/*.o */*/*.bak */*/*~
spiiroin's avatar
spiiroin committed
51 52 53 54 55 56 57 58 59

clean:: mostlyclean

distclean:: clean

# ----------------------------------------------------------------------------
# CONFIGURATION
# ----------------------------------------------------------------------------

60
VERSION := 1.106.7
61

spiiroin's avatar
spiiroin committed
62
INSTALL_BIN := install --mode=755
63
INSTALL_DIR := install -d
spiiroin's avatar
spiiroin committed
64
INSTALL_DTA := install --mode=644
65

spiiroin's avatar
spiiroin committed
66 67
DOXYGEN     := doxygen

68 69 70 71 72 73 74 75
# Allow "make clean" (and similar non-compile targets) to work outside
# the sdk chroot without warnings about missing pkg-config files
PKG_CONFIG_NOT_REQUIRED += doc
PKG_CONFIG_NOT_REQUIRED += mostlyclean
PKG_CONFIG_NOT_REQUIRED += clean
PKG_CONFIG_NOT_REQUIRED += distclean
PKG_CONFIG_NOT_REQUIRED += tags
PKG_CONFIG_NOT_REQUIRED += fixme
76
PKG_CONFIG_NOT_REQUIRED += normalize
77 78 79 80 81
PKG_CONFIG_NOT_REQUIRED += tarball
PKG_CONFIG_NOT_REQUIRED += tarball_from_git

ifneq ($(MAKECMDGOALS),)
ifeq ($(filter $(PKG_CONFIG_NOT_REQUIRED),$(MAKECMDGOALS)),$(MAKECMDGOALS))
spiiroin's avatar
spiiroin committed
82 83
PKG_CONFIG   := true
endif
84
endif
spiiroin's avatar
spiiroin committed
85
PKG_CONFIG   ?= pkg-config
86

87 88 89
# Whether to enable DEVEL release logging
ENABLE_DEVEL_LOGGING ?= y

90 91 92
# Whether to enable support for libhybris plugin
ENABLE_HYBRIS ?= y

93
# Whether to enable wakelock compatibility code
94
ENABLE_WAKELOCKS ?= y
95

96 97 98
# Whether to enable cpu scaling governor policy
ENABLE_CPU_GOVERNOR ?= y

99 100 101 102 103 104
# Whether to install systemd control files
ENABLE_SYSTEMD_SUPPORT ?= y

# Whether to install man pages
ENABLE_MANPAGE_INSTALL ?= y

105 106 107
# Whether to enable double-click == double-tap emulation
ENABLE_DOUBLETAP_EMULATION ?= y

108
# Whether to install unit tests
spiiroin's avatar
spiiroin committed
109
ENABLE_UNITTESTS_INSTALL ?= n
110

111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
# Install destination
DESTDIR               ?= /tmp/test-mce-install

# Standard directories
_PREFIX         ?= /usr#                         # /usr
_INCLUDEDIR     ?= $(_PREFIX)/include#           # /usr/include
_EXEC_PREFIX    ?= $(_PREFIX)#                   # /usr
_BINDIR         ?= $(_EXEC_PREFIX)/bin#          # /usr/bin
_SBINDIR        ?= $(_EXEC_PREFIX)/sbin#         # /usr/sbin
_LIBEXECDIR     ?= $(_EXEC_PREFIX)/libexec#      # /usr/libexec
_LIBDIR         ?= $(_EXEC_PREFIX)/lib#          # /usr/lib
_SYSCONFDIR     ?= /etc#                         # /etc
_DATADIR        ?= $(_PREFIX)/share#             # /usr/share
_MANDIR         ?= $(_DATADIR)/man#              # /usr/share/man
_INFODIR        ?= $(_DATADIR)/info#             # /usr/share/info
_DEFAULTDOCDIR  ?= $(_DATADIR)/doc#              # /usr/share/doc
_LOCALSTATEDIR  ?= /var#                         # /var
_UNITDIR        ?= /lib/systemd/system#
129
_TESTSDIR       ?= /opt/tests#                   # /opt/tests
130 131 132 133 134 135 136 137

# Install directories within DESTDIR
VARDIR                := $(_LOCALSTATEDIR)/lib/mce
RUNDIR                := $(_LOCALSTATEDIR)/run/mce
CONFDIR               := $(_SYSCONFDIR)/mce
MODULEDIR             := $(_LIBDIR)/mce/modules
DBUSDIR               := $(_SYSCONFDIR)/dbus-1/system.d
HELPERSCRIPTDIR       := $(_DATADIR)/mce
138
TESTSDESTDIR          := $(_TESTSDIR)/mce
139

spiiroin's avatar
spiiroin committed
140
# Source directories
141 142 143 144 145 146
DOCDIR          := doc
TOOLDIR         := tools
TESTSDIR        := tests
UTESTDIR        := tests/ut
MODULE_DIR      := modules
DBUS_GMAIN_DIR  := dbus-gmain
147

spiiroin's avatar
spiiroin committed
148 149 150 151
# Binaries to build
TARGETS += mce

# Plugins to build
152 153
MODULES += $(MODULE_DIR)/radiostates.so
MODULES += $(MODULE_DIR)/filter-brightness-als.so
154
MODULES += $(MODULE_DIR)/fingerprint.so
155 156 157 158 159
MODULES += $(MODULE_DIR)/proximity.so
MODULES += $(MODULE_DIR)/keypad.so
MODULES += $(MODULE_DIR)/inactivity.so
MODULES += $(MODULE_DIR)/camera.so
MODULES += $(MODULE_DIR)/alarm.so
160
MODULES += $(MODULE_DIR)/memnotify.so
161
MODULES += $(MODULE_DIR)/battery-bme.so
162
MODULES += $(MODULE_DIR)/battery-upower.so
163
MODULES += $(MODULE_DIR)/bluetooth.so
164
MODULES += $(MODULE_DIR)/battery-statefs.so
165
MODULES += $(MODULE_DIR)/battery-udev.so
166
MODULES += $(MODULE_DIR)/buttonbacklight.so
167
MODULES += $(MODULE_DIR)/display.so
168
MODULES += $(MODULE_DIR)/usbmode.so
169
MODULES += $(MODULE_DIR)/doubletap.so
170
MODULES += $(MODULE_DIR)/sensor-gestures.so
171 172 173 174
MODULES += $(MODULE_DIR)/led.so
MODULES += $(MODULE_DIR)/callstate.so
MODULES += $(MODULE_DIR)/audiorouting.so
MODULES += $(MODULE_DIR)/powersavemode.so
175
MODULES += $(MODULE_DIR)/cpu-keepalive.so
176
MODULES += $(MODULE_DIR)/packagekit.so
spiiroin's avatar
spiiroin committed
177 178 179

# Tools to build
TOOLS   += $(TOOLDIR)/mcetool
180
TOOLS   += $(TOOLDIR)/evdev_trace
181
TOOLS   += $(TOOLDIR)/dummy_compositor
spiiroin's avatar
spiiroin committed
182

183 184 185 186 187 188 189
# Unit tests to build
UTESTS  += $(UTESTDIR)/ut_display_conf
UTESTS  += $(UTESTDIR)/ut_display_stm
UTESTS  += $(UTESTDIR)/ut_display_filter
UTESTS  += $(UTESTDIR)/ut_display_blanking_inhibit
UTESTS  += $(UTESTDIR)/ut_display

spiiroin's avatar
spiiroin committed
190
# MCE configuration files
191 192
CONFFILE              := 10mce.ini
RADIOSTATESCONFFILE   := 20mce-radio-states.ini
spiiroin's avatar
spiiroin committed
193 194 195 196 197 198 199 200 201 202 203 204 205
DBUSCONF              := mce.conf

# ----------------------------------------------------------------------------
# DEFAULT FLAGS
# ----------------------------------------------------------------------------

# C Preprocessor
CPPFLAGS += -D_GNU_SOURCE
CPPFLAGS += -DG_DISABLE_DEPRECATED
CPPFLAGS += -DOSSOLOG_COMPILE
CPPFLAGS += -DMCE_VAR_DIR=$(VARDIR)
CPPFLAGS += -DMCE_RUN_DIR=$(RUNDIR)
CPPFLAGS += -DPRG_VERSION=$(VERSION)
206 207
# Default module path
CPPFLAGS += -DMCE_DEFAULT_MCE_MODULE_PATH=$(MODULEDIR)
208

209
ifeq ($(strip $(ENABLE_WAKELOCKS)),y)
spiiroin's avatar
spiiroin committed
210
CPPFLAGS += -DENABLE_WAKELOCKS
211 212
endif

213 214 215 216
ifeq ($(strip $(ENABLE_CPU_GOVERNOR)),y)
CPPFLAGS += -DENABLE_CPU_GOVERNOR
endif

217 218 219 220
ifeq ($(ENABLE_HYBRIS),y)
CPPFLAGS += -DENABLE_HYBRIS
endif

221 222 223 224
ifeq ($(ENABLE_DOUBLETAP_EMULATION),y)
CPPFLAGS += -DENABLE_DOUBLETAP_EMULATION
endif

225 226
ifeq ($(ENABLE_DEVEL_LOGGING),y)
CPPFLAGS += -DENABLE_DEVEL_LOGGING
227
CPPFLAGS += -DENABLE_BATTERY_SIMULATION
228 229
endif

spiiroin's avatar
spiiroin committed
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
# C Compiler
CFLAGS += -std=c99

# Do we really need all of these?
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -Wpointer-arith
CFLAGS += -Wundef
CFLAGS += -Wcast-align
CFLAGS += -Wshadow
CFLAGS += -Wbad-function-cast
CFLAGS += -Wwrite-strings
CFLAGS += -Wsign-compare
CFLAGS += -Waggregate-return
CFLAGS += -Wmissing-noreturn
CFLAGS += -Wnested-externs
#CFLAGS += -Wchar-subscripts (-Wall does this)
CFLAGS += -Wmissing-prototypes
CFLAGS += -Wformat-security
CFLAGS += -Wformat=2
CFLAGS += -Wformat-nonliteral
CFLAGS += -Winit-self
CFLAGS += -Wswitch-default
CFLAGS += -Wstrict-prototypes
CFLAGS += -Wdeclaration-after-statement
CFLAGS += -Wold-style-definition
CFLAGS += -Wmissing-declarations
CFLAGS += -Wmissing-include-dirs
258
CFLAGS += -Wstrict-aliasing=3
spiiroin's avatar
spiiroin committed
259 260 261 262 263 264 265 266
CFLAGS += -Wunsafe-loop-optimizations
CFLAGS += -Winvalid-pch
#CFLAGS += -Waddress  (-Wall does this)
CFLAGS += -Wvolatile-register-var
CFLAGS += -Wmissing-format-attribute
CFLAGS += -Wstack-protector
#CFLAGS += -Werror (OBS build might have different compiler)
CFLAGS += -Wno-declaration-after-statement
267
CFLAGS += -Wno-missing-field-initializers
268
CFLAGS += -Wimplicit-fallthrough=2
spiiroin's avatar
spiiroin committed
269 270 271 272 273 274 275 276

# Linker
LDLIBS   += -Wl,--as-needed

# ----------------------------------------------------------------------------
# MCE
# ----------------------------------------------------------------------------

277 278 279
%.o : %.c
	$(CC) -c -o $@ $< $(CPPFLAGS) $(CFLAGS)

spiiroin's avatar
spiiroin committed
280 281 282 283 284 285
MCE_PKG_NAMES += gobject-2.0
MCE_PKG_NAMES += glib-2.0
MCE_PKG_NAMES += gio-2.0
MCE_PKG_NAMES += gmodule-2.0
MCE_PKG_NAMES += dbus-1
MCE_PKG_NAMES += dsme
286
MCE_PKG_NAMES += libiphb
287
MCE_PKG_NAMES += libsystemd
288
MCE_PKG_NAMES += libngf0
289
MCE_PKG_NAMES += thermalmanager_dbus_if
spiiroin's avatar
spiiroin committed
290 291 292

MCE_PKG_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(MCE_PKG_NAMES))
MCE_PKG_LDLIBS := $(shell $(PKG_CONFIG) --libs   $(MCE_PKG_NAMES))
293

294
MCE_CFLAGS += -DMCE_CONF_DIR='"$(CONFDIR)"'
spiiroin's avatar
spiiroin committed
295 296 297 298 299
MCE_CFLAGS += $(MCE_PKG_CFLAGS)

MCE_LDLIBS += $(MCE_PKG_LDLIBS)

# These must be made callable from the plugins
300
MCE_CORE += datapipe.c
spiiroin's avatar
spiiroin committed
301 302 303
MCE_CORE += tklock.c
MCE_CORE += modetransition.c
MCE_CORE += powerkey.c
304
MCE_CORE += mce-common.c
305
MCE_CORE += mce-fbdev.c
spiiroin's avatar
spiiroin committed
306 307
MCE_CORE += mce-dbus.c
MCE_CORE += mce-dsme.c
308
MCE_CORE += mce-setting.c
309
MCE_CORE += mce-hbtimer.c
310
MCE_CORE += mce-wltimer.c
311
MCE_CORE += mce-wakelock.c
312
MCE_CORE += mce-worker.c
spiiroin's avatar
spiiroin committed
313 314 315 316
MCE_CORE += event-input.c
MCE_CORE += event-switches.c
MCE_CORE += mce-hal.c
MCE_CORE += mce-log.c
317
MCE_CORE += mce-command-line.c
spiiroin's avatar
spiiroin committed
318 319
MCE_CORE += mce-conf.c
MCE_CORE += mce-modules.c
320
MCE_CORE += multitouch.c
spiiroin's avatar
spiiroin committed
321 322
MCE_CORE += mce-io.c
MCE_CORE += mce-lib.c
323
MCE_CORE += evdev.c
324
MCE_CORE += filewatcher.c
325 326 327
ifeq ($(ENABLE_HYBRIS),y)
MCE_CORE += mce-hybris.c
endif
328
MCE_CORE += mce-sensorfw.c
329
MCE_CORE += builtin-gconf.c
330

331
ifeq ($(strip $(ENABLE_WAKELOCKS)),y)
spiiroin's avatar
spiiroin committed
332
MCE_CORE   += libwakelock.c
333 334
endif

335 336
MCE_CORE += $(DBUS_GMAIN_DIR)/dbus-gmain.c

spiiroin's avatar
spiiroin committed
337 338
mce : CFLAGS += $(MCE_CFLAGS)
mce : LDLIBS += $(MCE_LDLIBS)
339 340 341
ifeq ($(ENABLE_HYBRIS),y)
mce : LDLIBS += -ldl
endif
spiiroin's avatar
spiiroin committed
342 343
mce : mce.o $(patsubst %.c,%.o,$(MCE_CORE))

344 345 346
CFLAGS  += -g
LDFLAGS += -g

347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
# ----------------------------------------------------------------------------
# DBUS_GMAIN
# ----------------------------------------------------------------------------

# The dbus-gmain submodule contains sources that have
# issues and do not compile cleanly. As the content is
# what it is, silence warnings etc when compiling source
# files from there...

DBUS_GMAIN_CPPFLAGS += -I.
DBUS_GMAIN_CFLAGS   += -Wno-unused-parameter
DBUS_GMAIN_CFLAGS   += -Wno-cast-function-type

$(DBUS_GMAIN_DIR)/%.o : CPPFLAGS += $(DBUS_GMAIN_CPPFLAGS)
$(DBUS_GMAIN_DIR)/%.o : CFLAGS   += $(DBUS_GMAIN_CFLAGS)

spiiroin's avatar
spiiroin committed
363 364 365 366 367 368 369 370
# ----------------------------------------------------------------------------
# MODULES
# ----------------------------------------------------------------------------

MODULE_PKG_NAMES += gobject-2.0
MODULE_PKG_NAMES += glib-2.0
MODULE_PKG_NAMES += gmodule-2.0
MODULE_PKG_NAMES += dbus-1
371
MODULE_PKG_NAMES += usb_moded
372
MODULE_PKG_NAMES += libudev
spiiroin's avatar
spiiroin committed
373 374 375 376 377 378

MODULE_PKG_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(MODULE_PKG_NAMES))
MODULE_PKG_LDLIBS := $(shell $(PKG_CONFIG) --libs   $(MODULE_PKG_NAMES))

MODULE_CFLAGS += $(MODULE_PKG_CFLAGS)
MODULE_LDLIBS += $(MODULE_PKG_LDLIBS)
379

spiiroin's avatar
spiiroin committed
380 381 382 383 384
.PRECIOUS: %.pic.o

%.pic.o : %.c
	$(CC) -c -o $@ $< -fPIC $(CPPFLAGS) $(CFLAGS)

385 386 387
$(MODULE_DIR)/%.so : CFLAGS += $(MODULE_CFLAGS)
$(MODULE_DIR)/%.so : LDLIBS += $(MODULE_LDLIBS)
$(MODULE_DIR)/%.so : $(MODULE_DIR)/%.pic.o
spiiroin's avatar
spiiroin committed
388
	$(CC) -shared -o $@ $^ $(LDFLAGS) $(LDLIBS)
389

spiiroin's avatar
spiiroin committed
390 391 392
# ----------------------------------------------------------------------------
# TOOLS
# ----------------------------------------------------------------------------
393

spiiroin's avatar
spiiroin committed
394 395 396
TOOLS_PKG_NAMES += gobject-2.0
TOOLS_PKG_NAMES += glib-2.0
TOOLS_PKG_NAMES += dbus-1
397

spiiroin's avatar
spiiroin committed
398 399 400 401 402
TOOLS_PKG_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(TOOLS_PKG_NAMES))
TOOLS_PKG_LDLIBS := $(shell $(PKG_CONFIG) --libs   $(TOOLS_PKG_NAMES))

TOOLS_CFLAGS += $(TOOLS_PKG_CFLAGS)
TOOLS_LDLIBS += $(TOOLS_PKG_LDLIBS)
403

spiiroin's avatar
spiiroin committed
404 405
$(TOOLDIR)/mcetool : CFLAGS += $(TOOLS_CFLAGS)
$(TOOLDIR)/mcetool : LDLIBS += $(TOOLS_LDLIBS)
406
$(TOOLDIR)/mcetool : $(TOOLDIR)/mcetool.o mce-command-line.o
spiiroin's avatar
spiiroin committed
407

408 409
$(TOOLDIR)/evdev_trace : CFLAGS += $(TOOLS_CFLAGS)
$(TOOLDIR)/evdev_trace : LDLIBS += $(TOOLS_LDLIBS)
410
$(TOOLDIR)/evdev_trace : $(TOOLDIR)/evdev_trace.o evdev.o $(TOOLDIR)/fileusers.o
411

412 413
$(TOOLDIR)/dummy_compositor : CFLAGS += $(TOOLS_CFLAGS)
$(TOOLDIR)/dummy_compositor : LDLIBS += $(TOOLS_LDLIBS)
414
$(TOOLDIR)/dummy_compositor : $(TOOLDIR)/dummy_compositor.o $(DBUS_GMAIN_DIR)/dbus-gmain.o
415

416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
# ----------------------------------------------------------------------------
# UNIT TESTS
# ----------------------------------------------------------------------------

UTESTS_PKG_NAMES += check
UTESTS_PKG_NAMES += dbus-1
UTESTS_PKG_NAMES += glib-2.0
UTESTS_PKG_NAMES += gthread-2.0

UTESTS_PKG_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(UTESTS_PKG_NAMES))
UTESTS_PKG_LDLIBS := $(shell $(PKG_CONFIG) --libs   $(UTESTS_PKG_NAMES))

UTESTS_CFLAGS += $(UTESTS_PKG_CFLAGS)
UTESTS_LDLIBS += $(UTESTS_PKG_LDLIBS)

UTESTS_CFLAGS += -fdata-sections -ffunction-sections
UTESTS_LDLIBS += -Wl,--gc-sections

$(UTESTDIR)/% : CFLAGS += $(UTESTS_CFLAGS)
$(UTESTDIR)/% : LDLIBS += $(UTESTS_LDLIBS)
$(UTESTDIR)/% : LDLIBS += $(foreach fn_sym,$(LINK_STUBS),\
437
				    -Wl,--defsym=$(fn_sym)=stub__$(fn_sym))
438 439 440 441 442 443 444
$(UTESTDIR)/% : $(UTESTDIR)/%.o

$(UTESTDIR)/ut_display : LINK_STUBS += mce_log_file
$(UTESTDIR)/ut_display : LINK_STUBS += mce_write_string_to_file
$(UTESTDIR)/ut_display : datapipe.o
$(UTESTDIR)/ut_display : mce-lib.o
$(UTESTDIR)/ut_display : modetransition.o
445
$(UTESTDIR)/ut_display : $(DBUS_GMAIN_DIR)/dbus-gmain.o
446

spiiroin's avatar
spiiroin committed
447 448 449 450 451 452
# ----------------------------------------------------------------------------
# ACTIONS FOR TOP LEVEL TARGETS
# ----------------------------------------------------------------------------

build:: $(TARGETS) $(MODULES) $(TOOLS)

453 454 455 456
ifeq ($(ENABLE_UNITTESTS_INSTALL),y)
build:: $(UTESTS)
endif

spiiroin's avatar
spiiroin committed
457
modules:: $(MODULES)
458

spiiroin's avatar
spiiroin committed
459
tools:: $(TOOLS)
Santtu Lakkala's avatar
Santtu Lakkala committed
460

461 462 463
check:: $(UTESTS)
	for utest in $^; do ./$${utest} || exit; done

spiiroin's avatar
spiiroin committed
464 465
clean::
	$(RM) $(TARGETS) $(TOOLS) $(MODULES)
Santtu Lakkala's avatar
Santtu Lakkala committed
466

467 468 469 470
ifeq ($(ENABLE_UNITTESTS_INSTALL),y)
	$(RM) $(UTESTS)
endif

471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
install:: build
	$(INSTALL_DIR) $(DESTDIR)$(VARDIR)
	$(INSTALL_DIR) $(DESTDIR)$(RUNDIR)

	$(INSTALL_DIR) $(DESTDIR)$(_SBINDIR)
	$(INSTALL_BIN) $(TARGETS) $(DESTDIR)$(_SBINDIR)/
	$(INSTALL_BIN) $(TOOLS)   $(DESTDIR)$(_SBINDIR)/

	$(INSTALL_DIR) $(DESTDIR)$(MODULEDIR)
	$(INSTALL_BIN) $(MODULES) $(DESTDIR)$(MODULEDIR)/

	$(INSTALL_DIR) $(DESTDIR)$(DBUSDIR)
	$(INSTALL_DTA) $(DBUSCONF) $(DESTDIR)$(DBUSDIR)/

	$(INSTALL_DIR) $(DESTDIR)$(CONFDIR)
486 487
	$(INSTALL_DTA) inifiles/mce.ini $(DESTDIR)$(CONFDIR)/$(CONFFILE)
	$(INSTALL_DTA) inifiles/mce-radio-states.ini $(DESTDIR)$(CONFDIR)/$(RADIOSTATESCONFFILE)
488
	$(INSTALL_DTA) inifiles/hybris-led.ini $(DESTDIR)$(CONFDIR)/20hybris-led.ini
489
	$(INSTALL_DTA) inifiles/hybris-features.ini $(DESTDIR)$(CONFDIR)/20hybris-features.ini
490
	$(INSTALL_DTA) inifiles/debug-led.ini $(DESTDIR)$(CONFDIR)/20debug-led.ini
491
	$(INSTALL_DTA) inifiles/als-defaults.ini $(DESTDIR)$(CONFDIR)/20als-defaults.ini
492
	$(INSTALL_DTA) inifiles/legacy.ini $(DESTDIR)$(CONFDIR)/11legacy.ini
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513

ifeq ($(ENABLE_SYSTEMD_SUPPORT),y)
install:: install_systemd_support
endif

install_systemd_support::
	$(INSTALL_DIR) $(DESTDIR)$(_UNITDIR)/multi-user.target.wants/
	ln -s ../mce.service $(DESTDIR)$(_UNITDIR)/multi-user.target.wants/mce.service

	$(INSTALL_DTA) -D systemd/mce.service $(DESTDIR)$(_UNITDIR)/mce.service
	$(INSTALL_DTA) -D systemd/mce.conf    $(DESTDIR)$(_SYSCONFDIR)/tmpfiles.d/mce.conf

ifeq ($(ENABLE_MANPAGE_INSTALL),y)
install:: install_man_pages
endif

install_man_pages::
	$(INSTALL_DIR) $(DESTDIR)/$(_MANDIR)/man8
	$(INSTALL_DTA) man/mce.8        $(DESTDIR)/$(_MANDIR)/man8/mce.8
	$(INSTALL_DTA) man/mcetool.8    $(DESTDIR)/$(_MANDIR)/man8/mcetool.8

514 515 516 517 518 519 520 521 522
ifeq ($(ENABLE_UNITTESTS_INSTALL),y)
install:: install_unittests
endif

install_unittests::
	$(INSTALL_DIR) $(DESTDIR)$(TESTSDESTDIR)
	$(INSTALL_BIN) $(UTESTS) $(DESTDIR)$(TESTSDESTDIR)
	$(INSTALL_DTA) $(UTESTDIR)/tests.xml $(DESTDIR)$(TESTSDESTDIR)

spiiroin's avatar
spiiroin committed
523 524 525
# ----------------------------------------------------------------------------
# DOCUMENTATION
# ----------------------------------------------------------------------------
526

spiiroin's avatar
spiiroin committed
527 528 529
doc::
	mkdir -p doc
	$(DOXYGEN) > /dev/null # 2> $(DOCDIR)/warnings
Santtu Lakkala's avatar
Santtu Lakkala committed
530

spiiroin's avatar
spiiroin committed
531 532 533 534 535 536
clean::
	$(RM) -r doc # in case DOCDIR points somewhere funny ...

# ----------------------------------------------------------------------------
# CTAGS
# ----------------------------------------------------------------------------
537 538

.PHONY: tags
spiiroin's avatar
spiiroin committed
539 540 541 542 543 544 545 546 547
tags::
	find . $(MODULE_DIR) -maxdepth 1 -type f -name '*.[ch]' | xargs ctags -a --extra=+f

distclean::
	$(RM) tags

# ----------------------------------------------------------------------------
# FIXME
# ----------------------------------------------------------------------------
548 549

.PHONY: fixme
spiiroin's avatar
spiiroin committed
550 551 552 553 554 555 556
fixme::
	find . -type f -name "*.[ch]" | xargs grep -E "(FIXME|XXX|TODO)"

# ----------------------------------------------------------------------------
# AUTOMATIC HEADER DEPENDENCIES
# ----------------------------------------------------------------------------

557 558 559
# All sources, except ones from gmain git submodule
DEPEND_SOURCES = $(filter-out $(DBUS_GMAIN_DIR)/%.c, $(wildcard *.c */*.c */*/*.c))

spiiroin's avatar
spiiroin committed
560 561 562
.PHONY: depend
depend::
	@echo "Updating .depend"
563
	$(CC) -MM $(CPPFLAGS) $(MCE_CFLAGS) $(DEPEND_SOURCES) \
spiiroin's avatar
spiiroin committed
564 565 566 567 568 569 570
	./depend_filter.py > .depend

ifneq ($(MAKECMDGOALS),depend) # not while: make depend
ifneq (,$(wildcard .depend))   # not if .depend does not exist
include .depend
endif
endif
571

572 573 574 575 576 577 578 579
# ----------------------------------------------------------------------------
# DEVELOPMENT TIME WHITESPACE NORMALIZE
# ----------------------------------------------------------------------------

NORMALIZE_USES_SPC =\
	bme-dbus-names.h\
	builtin-gconf.c\
	builtin-gconf.h\
580 581
	datapipe.c\
	datapipe.h\
582 583
	evdev.c\
	evdev.h\
584
	event-input.c\
585 586 587 588
	event-input.h\
	event-switches.h\
	filewatcher.c\
	filewatcher.h\
589
	homekey.dot\
590
	libwakelock.h\
591 592
	mce-common.c\
	mce-common.h\
593
	mce-dbus.h\
594 595
	mce-dsme.c\
	mce-dsme.h\
596 597
	mce-fbdev.c\
	mce-fbdev.h\
598 599
	mce-command-line.c\
	mce-command-line.h\
600 601
	mce-hbtimer.c\
	mce-hbtimer.h\
602 603
	mce-wltimer.c\
	mce-wltimer.h\
604 605 606
	mce-hybris.c\
	mce-hybris.h\
	mce-modules.h\
607 608
	mce-sensorfw.c\
	mce-sensorfw.h\
609
	mce-setting.h\
610 611
	mce-wakelock.c\
	mce-wakelock.h\
612 613
	mce-worker.c\
	mce-worker.h\
614
	modetransition.h\
615
	modules/alarm.c\
616 617
	modules/audiorouting.c\
	modules/battery-upower.c\
618
	modules/battery-statefs.c\
619
	modules/battery-udev.c\
620
	modules/bluetooth.c\
621
	modules/buttonbacklight.c\
622 623 624 625 626
	modules/callstate.c\
	modules/callstate.h\
	modules/camera.h\
	modules/cpu-keepalive.c\
	modules/display.c\
627
	modules/display.h\
628
	modules/display.dot\
629 630
	modules/doubletap.c\
	modules/doubletap.h\
631 632
	modules/filter-brightness-als.c\
	modules/filter-brightness-als.h\
633
	modules/fingerprint.c\
634
	modules/keypad.h\
635
	modules/inactivity.c\
636
	modules/inactivity.h\
637 638
	modules/memnotify.c\
	modules/memnotify.h\
639 640
	modules/packagekit.c\
	modules/powersavemode.h\
641
	modules/proximity.c\
642
	modules/proximity.h\
643 644
	modules/radiostates.h\
	modules/sensor-gestures.c\
645
	modules/usbmode.c\
646 647
	multitouch.c\
	multitouch.h\
648
	ofono-dbus-names.h\
649 650 651
	powerkey.c\
	powerkey.h\
	powerkey.dot\
652 653 654 655
	systemui/dbus-names.h\
	tklock.c\
	tklock.h\
	tools/evdev_trace.c\
656
	tools/dummy_compositor.c\
657
	tools/mcetool.c\
658 659
	tools/fileusers.c\
	tools/fileusers.h\
660 661 662 663 664 665 666

NORMALIZE_USES_TAB =\
	event-switches.c\
	libwakelock.c\
	mce-conf.c\
	mce-conf.h\
	mce-dbus.c\
667
	mce-setting.c\
668 669 670 671 672 673 674 675 676 677 678
	mce-hal.c\
	mce-hal.h\
	mce-io.c\
	mce-io.h\
	mce-lib.c\
	mce-lib.h\
	mce-log.c\
	mce-log.h\
	mce-modules.c\
	mce.c\
	mce.h\
679
	mce.conf\
680 681 682 683 684 685 686 687 688 689 690
	modetransition.c\
	modules/battery-bme.c\
	modules/camera.c\
	modules/keypad.c\
	modules/led.c\
	modules/led.h\
	modules/powersavemode.c\
	modules/radiostates.c\
	systemui/tklock-dbus-names.h\

NORMALIZE_KNOWN := $(NORMALIZE_USES_SPC) $(NORMALIZE_USES_TAB)
691
SOURCEFILES_ALL := $(wildcard *.[ch] modules/*.[ch])
692 693 694 695 696 697
NORMALIZE_UNKNOWN = $(filter-out $(NORMALIZE_KNOWN), $(SOURCEFILES_ALL))

.PHONY: normalize

normalize::
	normalize_whitespace -M Makefile
698
	normalize_whitespace -a inifiles/*.ini config/*.conf
699
	normalize_whitespace -t -b -e -s $(NORMALIZE_USES_SPC)
700 701 702 703 704 705 706 707 708 709
	normalize_whitespace -T -e -s $(NORMALIZE_USES_TAB)
ifneq ($(NORMALIZE_UNKNOWN),)
	@echo "Unknown source files: $(NORMALIZE_UNKNOWN)"
	false
endif

# ----------------------------------------------------------------------------
# DEVELOPMENT TIME PROTOTYPE SCANNING
# ----------------------------------------------------------------------------

710
.SUFFIXES: .q .p .g
711

712 713 714 715 716 717 718 719 720 721 722
PROTO_CPPFLAGS += $(CPPFLAGS)
PROTO_CPPFLAGS += $(MCE_CFLAGS)
PROTO_CPPFLAGS += $(MODULE_CFLAGS)
PROTO_CPPFLAGS += -D_Float32=float
PROTO_CPPFLAGS += -D_Float64=double
PROTO_CPPFLAGS += -D_Float128="long double"
PROTO_CPPFLAGS += -D_Float32x=float
PROTO_CPPFLAGS += -D_Float64x=double
PROTO_CPPFLAGS += -D_Float128x="long double"

%.q : %.c ; $(CC) -o $@ -E $< $(PROTO_CPPFLAGS)
723 724
%.p : %.q ; cproto -s < $< | prettyproto.py | tee $@
%.g : %.q ; cproto < $< | prettyproto.py | tee $@
725

726 727 728 729
protos-q: $(patsubst %.c,%.q,$(wildcard *.c modules/*.c))
protos-p: $(patsubst %.c,%.p,$(wildcard *.c modules/*.c))
protos-g: $(patsubst %.c,%.g,$(wildcard *.c modules/*.c))

730
clean::
731
	$(RM) -f *.[qpg] modules/*.[qpg] tools/*.[qpg]
732

733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
# ----------------------------------------------------------------------------
# LOCAL RPMBUILD (copy mce.* from OBS to rpm subdir)
# ----------------------------------------------------------------------------

# The spec file expects to find a tarball with version ...
TARBALL=mce-$(VERSION).tar
# .. that unpacks to a directory without the version.
TARWORK=mce

.PHONY: tarball
tarball:: distclean
	$(RM) -r /tmp/$(TARWORK)
	mkdir /tmp/$(TARWORK)
	tar -cf - . --exclude=.git --exclude=.gitignore --exclude=rpm |\
	tar -xf - -C /tmp/$(TARWORK)/
	tar -cjf $(TARBALL).bz2 -C /tmp $(TARWORK)/
	$(RM) -r /tmp/$(TARWORK)

.PHONY: tarball_from_git
tarball_from_git::
	git archive --prefix=mce/ -o $(TARBALL) HEAD
	bzip2 $(TARBALL)

clean::
	$(RM) $(TARBALL).bz2

.PHONY: rpmbuild
rpmbuild:: tarball
	@test -d rpm || (echo "you need rpm/ subdir for this to work" && false)
	install -m644 $(TARBALL).bz2 rpm/mce.* ~/rpmbuild/SOURCES/
	rpmbuild -ba ~/rpmbuild/SOURCES/mce.spec