Add note about building against QtWebKit in Makefile help
[browser-dbus-bridge.git] / build / project.mk
1 O               ?= debug
2 # V
3
4 # CONFIG
5
6 # CROSS_COMPILE
7 CCACHE          ?= $(if $(shell which ccache),ccache,)
8
9 ifeq ($(origin CC),default)
10 CC              := $(CCACHE) $(CROSS_COMPILE)gcc
11 endif
12
13 ifeq ($(origin CXX),default)
14 CXX             := $(CCACHE) $(CROSS_COMPILE)g++
15 endif
16
17 ifeq ($(origin AR),default)
18 AR              := $(CCACHE) $(CROSS_COMPILE)ar
19 endif
20
21 CCLINKER        ?= $(CC)
22 CXXLINKER       ?= $(CXX)
23
24 PKG_CONFIG      ?= pkg-config
25 # PKG_CONFIG_PATH
26
27 # CPPFLAGS
28 CFLAGS          ?= -g -Wall
29 # CCFLAGS
30 # CXXFLAGS
31 # LDFLAGS
32 # LIBS
33
34 CXXPATTERNS     ?= %.cc %.cp %.cxx %.cpp %.CPP %.c++ %.C
35
36 PREFIX          ?= /usr/local
37 BINDIR          ?= $(PREFIX)/bin
38 SBINDIR         ?= $(PREFIX)/sbin
39 LIBDIR          ?= $(PREFIX)/lib
40 PLUGINDIR       ?= $(LIBDIR)
41 DATADIR         ?= $(PREFIX)/share
42 SYSCONFDIR      ?= /etc
43
44 # DESTDIR
45
46 # LD_LIBRARY_PATH
47
48 include build/common.mk
49
50 ifneq ($(wildcard $(O)/config.mk),)
51  include $(O)/config.mk
52 else
53  -include $(O).mk
54 endif
55
56 export O V
57 export CONFIG
58 export CC CXX CCLINKER CXXLINKER AR
59 export PKG_CONFIG PKG_CONFIG_PATH
60 export CPPFLAGS CFLAGS CCFLAGS CXXFLAGS LDFLAGS LIBS
61 export CXXPATTERNS
62 export PREFIX BINDIR SBINDIR LIBDIR PLUGINDIR DATADIR SYSCONFDIR
63 export DESTDIR
64 export TEST_LIBRARY_PATH := $(LD_LIBRARY_PATH)
65
66 DIST            ?= $(BINARIES) $(LIBRARIES) $(PLUGINS)
67 DO_DIST         := $(filter-out $(NODIST),$(DIST))
68
69 LIBRARY_TARGETS := $(foreach L,$(LIBRARIES),$(L)-shared $(L)-static)
70 PLUGIN_TARGETS  := $(foreach L,$(PLUGINS),$(L)-plugin)
71 TARGETS         := $(BINARIES) $(TESTS) $(LIBRARY_TARGETS) $(PLUGIN_TARGETS)
72 CHECK_TARGETS   := $(foreach T,$(TESTS),check-$(T))
73 INSTALL_TARGETS := $(foreach I,$(DO_DIST),install-$(I))
74
75 build:
76 check: $(CHECK_TARGETS)
77 all: build check
78 install: $(INSTALL_TARGETS)
79
80 clean:
81         $(QUIET) test "$(PWD)" && readlink -f "$(O)" | grep -q "^$(PWD)/."
82         $(call echo,Remove,$(O))
83         $(QUIET) if [ -d "$(O)" ]; then rm -r "$(O)"; fi
84
85 makefile        = $(firstword $(wildcard $(1).mk) $(1)/build.mk)
86 librarymakefile = $(call makefile,$(patsubst %-static,%,$(patsubst %-shared,%,$(1))))
87 librarytarget   = build-$(call lastword,$(subst -, ,$(1)))
88 pluginmakefile  = $(call makefile,$(patsubst %-plugin,%,$(1)))
89 plugintarget    = build-$(call lastword,$(subst -, ,$(1)))
90 testmakefile    = $(call makefile,$(patsubst check-%,%,$(1)))
91 distmakefile    = $(call makefile,$(patsubst install-%,%,$(1)))
92
93 $(BINARIES) $(TESTS):
94         $(QUIET) $(MAKE) --no-print-directory -f $(call makefile,$@) build
95
96 $(PLUGIN_TARGETS):
97         $(QUIET) $(MAKE) --no-print-directory -f $(call pluginmakefile,$@) $(call plugintarget,$@)
98
99 $(LIBRARY_TARGETS):
100         $(QUIET) $(MAKE) --no-print-directory -f $(call librarymakefile,$@) $(call librarytarget,$@)
101
102 $(CHECK_TARGETS): $(TESTS)
103         $(QUIET) $(MAKE) --no-print-directory -f $(call testmakefile,$@) check
104
105 $(INSTALL_TARGETS): $(DO_DIST)
106         $(QUIET) $(MAKE) --no-print-directory -f $(call distmakefile,$@) install
107
108 .PHONY: build install all check clean
109 .PHONY: $(TARGETS) $(CHECK_TARGETS) $(INSTALL_TARGETS) $(LIBRARIES) $(PLUGINS)