Makefile 6.38 KB
Newer Older
Slava Monich's avatar
Slava Monich committed
1
# -*- Mode: makefile-gmake -*-
Slava Monich's avatar
Slava Monich committed
2 3 4

.PHONY: all debug release clean cleaner
.PHONY: mms_lib_debug_lib mms_lib_release_lib
5
.PHONY: mms_connman_debug_lib mms_connman_release_lib
Slava Monich's avatar
Slava Monich committed
6
.PHONY: mms_handler_debug_lib mms_handler_release_lib
7
.PHONY: mms_settings_debug_lib mms_settings_release_lib
Slava Monich's avatar
Slava Monich committed
8

9 10 11 12 13 14 15
#
# Pull in mms-lib configuration
#

include ../mms-lib/Config.mak

#
Slava Monich's avatar
Slava Monich committed
16
# Required packages
17 18
#

19 20
PKGS = gio-unix-2.0 gio-2.0 libglibutil
LIB_PKGS = libwspcodec gmime-2.6 libgofono libsoup-2.4 dconf
21 22 23 24 25

ifdef MMS_CONNMAN_NEMO
LIB_PKGS += libgofonoext
endif

26
LIB_PKGS += $(RESIZE_PKG) $(PKGS)
Slava Monich's avatar
Slava Monich committed
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

#
# Default target
#

all: debug release

#
# Sources
#

SRC = main.c mms_engine.c
GEN_SRC = org.nemomobile.MmsEngine.c

#
# Directories
#

SRC_DIR = .
BUILD_DIR = build
SPEC_DIR = .
GEN_DIR = $(BUILD_DIR)
DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
RELEASE_BUILD_DIR = $(BUILD_DIR)/release

#
# mms-lib
#

MMS_LIB_LIB = libmms.a
MMS_LIB_DIR = ../mms-lib
MMS_LIB_BUILD_DIR = $(MMS_LIB_DIR)/build
MMS_LIB_DEBUG_LIB = $(MMS_LIB_BUILD_DIR)/debug/$(MMS_LIB_LIB)
MMS_LIB_RELEASE_LIB = $(MMS_LIB_BUILD_DIR)/release/$(MMS_LIB_LIB)

#
63
# mms-connman
Slava Monich's avatar
Slava Monich committed
64 65
#

66 67 68 69 70 71 72
ifdef MMS_CONNMAN_NEMO
MMS_CONNMAN = nemo
else
MMS_CONNMAN = ofono
endif
MMS_CONNMAN_LIB = libmms-connman-$(MMS_CONNMAN).a
MMS_CONNMAN_DIR = ../mms-connman-$(MMS_CONNMAN)
73 74 75
MMS_CONNMAN_BUILD_DIR = $(MMS_CONNMAN_DIR)/build
MMS_CONNMAN_DEBUG_LIB = $(MMS_CONNMAN_BUILD_DIR)/debug/$(MMS_CONNMAN_LIB)
MMS_CONNMAN_RELEASE_LIB = $(MMS_CONNMAN_BUILD_DIR)/release/$(MMS_CONNMAN_LIB)
Slava Monich's avatar
Slava Monich committed
76 77 78 79 80 81 82 83 84 85 86

#
# mms-handler-dbus
#

MMS_HANDLER_LIB = libmms-handler-dbus.a
MMS_HANDLER_DIR = ../mms-handler-dbus
MMS_HANDLER_BUILD_DIR = $(MMS_HANDLER_DIR)/build
MMS_HANDLER_DEBUG_LIB = $(MMS_HANDLER_BUILD_DIR)/debug/$(MMS_HANDLER_LIB)
MMS_HANDLER_RELEASE_LIB = $(MMS_HANDLER_BUILD_DIR)/release/$(MMS_HANDLER_LIB)

87 88 89 90 91 92 93 94 95 96
#
# mms-settings-dconf
#

MMS_SETTINGS_LIB = libmms-settings-dconf.a
MMS_SETTINGS_DIR = ../mms-settings-dconf
MMS_SETTINGS_BUILD_DIR = $(MMS_SETTINGS_DIR)/build
MMS_SETTINGS_DEBUG_LIB = $(MMS_SETTINGS_BUILD_DIR)/debug/$(MMS_SETTINGS_LIB)
MMS_SETTINGS_RELEASE_LIB = $(MMS_SETTINGS_BUILD_DIR)/release/$(MMS_SETTINGS_LIB)

Slava Monich's avatar
Slava Monich committed
97 98 99 100 101 102 103 104 105 106 107
#
# Tools and flags
#

CC = $(CROSS_COMPILE)gcc
LD = $(CC)
DEBUG_FLAGS = -g
RELEASE_FLAGS = -O2
DEBUG_DEFS = -DDEBUG
RELEASE_DEFS =
WARN = -Wall
108
CFLAGS = -fPIC $(shell pkg-config --cflags $(PKGS)) -I. -I$(GEN_DIR) \
109
 -I$(MMS_LIB_DIR)/include -I$(MMS_CONNMAN_DIR)/include \
110
 -I$(MMS_HANDLER_DIR)/include -I$(MMS_SETTINGS_DIR)/include -MMD
Slava Monich's avatar
Slava Monich committed
111

Slava Monich's avatar
Slava Monich committed
112 113 114 115 116 117 118 119 120
ifndef KEEP_SYMBOLS
KEEP_SYMBOLS = 0
endif

ifneq ($(KEEP_SYMBOLS),0)
RELEASE_FLAGS += -g
SUBMAKE_OPTS += KEEP_SYMBOLS=1
endif

121 122
ifdef MMS_ENGINE_VERSION
CFLAGS += -DMMS_ENGINE_VERSION="$(MMS_ENGINE_VERSION)"
123 124
endif

125 126 127 128
ifdef MMS_CONNMAN_NEMO
CFLAGS += -DMMS_CONNMAN_NEMO
endif

Slava Monich's avatar
Slava Monich committed
129 130 131
DEBUG_CFLAGS = $(DEBUG_FLAGS) $(DEBUG_DEFS) $(CFLAGS)
RELEASE_CFLAGS = $(RELEASE_FLAGS) $(RELEASE_DEFS) $(CFLAGS)

132
LIBS = $(shell pkg-config --libs $(LIB_PKGS)) -lmagic -ljpeg $(RESIZE_LIBS)
Slava Monich's avatar
Slava Monich committed
133
DEBUG_LIBS = \
134
  $(MMS_CONNMAN_DEBUG_LIB) \
Slava Monich's avatar
Slava Monich committed
135
  $(MMS_HANDLER_DEBUG_LIB) \
136
  $(MMS_SETTINGS_DEBUG_LIB) \
Slava Monich's avatar
Slava Monich committed
137 138 139
  $(MMS_LIB_DEBUG_LIB) \
  $(LIBS)
RELEASE_LIBS = \
140
  $(MMS_CONNMAN_RELEASE_LIB) \
Slava Monich's avatar
Slava Monich committed
141
  $(MMS_HANDLER_RELEASE_LIB) \
142
  $(MMS_SETTINGS_RELEASE_LIB) \
Slava Monich's avatar
Slava Monich committed
143 144 145 146 147 148 149 150 151 152 153 154 155
  $(MMS_LIB_RELEASE_LIB) \
  $(LIBS)

#
# Files
#

DEBUG_OBJS = \
  $(GEN_SRC:%.c=$(DEBUG_BUILD_DIR)/%.o) \
  $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
RELEASE_OBJS = \
  $(GEN_SRC:%.c=$(RELEASE_BUILD_DIR)/%.o) \
  $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
156 157
GEN_FILES = $(GEN_SRC:%=$(GEN_DIR)/%)
.PRECIOUS: $(GEN_FILES)
Slava Monich's avatar
Slava Monich committed
158 159 160 161 162 163 164

#
# Dependencies
#

DEBUG_DEPS = \
  mms_lib_debug_lib \
165
  mms_connman_debug_lib \
166 167
  mms_handler_debug_lib \
  mms_settings_debug_lib
Slava Monich's avatar
Slava Monich committed
168 169
RELEASE_DEPS = \
  mms_lib_release_lib \
170
  mms_connman_release_lib \
171 172
  mms_handler_release_lib \
  mms_settings_release_lib
Slava Monich's avatar
Slava Monich committed
173 174
DEBUG_EXE_DEPS = \
  $(MMS_LIB_DEBUG_LIB) \
175
  $(MMS_CONNMAN_DEBUG_LIB) \
176 177
  $(MMS_HANDLER_DEBUG_LIB) \
  $(MMS_SETTINGS_DEBUG_LIB)
Slava Monich's avatar
Slava Monich committed
178 179
RELEASE_EXE_DEPS = \
  $(MMS_LIB_RELEASE_LIB) \
180
  $(MMS_CONNMAN_RELEASE_LIB) \
181 182
  $(MMS_HANDLER_RELEASE_LIB) \
  $(MMS_SETTINGS_RELEASE_LIB)
Slava Monich's avatar
Slava Monich committed
183 184 185 186 187 188 189
DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
-include $(DEPS)
endif
endif

190 191 192 193
$(GEN_FILES): | $(GEN_DIR)
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)

Slava Monich's avatar
Slava Monich committed
194 195 196 197 198 199 200 201 202 203
#
# Rules
#

EXE = mms-engine
DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)

debug: $(DEBUG_DEPS) $(DEBUG_EXE)

204
release: $(RELEASE_DEPS) $(RELEASE_EXE)
Slava Monich's avatar
Slava Monich committed
205 206 207 208 209

clean:
	rm -fr $(BUILD_DIR) $(SRC_DIR)/*~

cleaner: clean
Slava Monich's avatar
Slava Monich committed
210
	make -C $(MMS_LIB_DIR) $(SUBMAKE_OPTS) clean
211
	make -C $(MMS_CONNMAN_DIR) $(SUBMAKE_OPTS) clean
Slava Monich's avatar
Slava Monich committed
212
	make -C $(MMS_HANDLER_DIR) $(SUBMAKE_OPTS) clean
213
	make -C $(MMS_SETTINGS_DIR) $(SUBMAKE_OPTS) clean
Slava Monich's avatar
Slava Monich committed
214 215 216 217 218 219 220 221 222 223 224

$(GEN_DIR):
	mkdir -p $@

$(DEBUG_BUILD_DIR):
	mkdir -p $@

$(RELEASE_BUILD_DIR):
	mkdir -p $@

mms_lib_debug_lib:
Slava Monich's avatar
Slava Monich committed
225
	make -C $(MMS_LIB_DIR) $(SUBMAKE_OPTS) debug
Slava Monich's avatar
Slava Monich committed
226 227

mms_lib_release_lib:
Slava Monich's avatar
Slava Monich committed
228
	make -C $(MMS_LIB_DIR) $(SUBMAKE_OPTS) release
Slava Monich's avatar
Slava Monich committed
229

230 231
mms_connman_debug_lib:
	make -C $(MMS_CONNMAN_DIR) $(SUBMAKE_OPTS) debug
Slava Monich's avatar
Slava Monich committed
232

233 234
mms_connman_release_lib:
	make -C $(MMS_CONNMAN_DIR) $(SUBMAKE_OPTS) release
Slava Monich's avatar
Slava Monich committed
235 236

mms_handler_debug_lib:
Slava Monich's avatar
Slava Monich committed
237
	make -C $(MMS_HANDLER_DIR) $(SUBMAKE_OPTS) debug
Slava Monich's avatar
Slava Monich committed
238 239

mms_handler_release_lib:
Slava Monich's avatar
Slava Monich committed
240
	make -C $(MMS_HANDLER_DIR) $(SUBMAKE_OPTS) release
Slava Monich's avatar
Slava Monich committed
241

242 243 244 245 246 247
mms_settings_debug_lib:
	make -C $(MMS_SETTINGS_DIR) $(SUBMAKE_OPTS) debug

mms_settings_release_lib:
	make -C $(MMS_SETTINGS_DIR) $(SUBMAKE_OPTS) release

Slava Monich's avatar
Slava Monich committed
248 249 250 251
$(MMS_LIB_DEBUG_LIB): mms_lib_debug_lib

$(MMS_LIB_RELEASE_LIB): mms_lib_release_lib

252
$(MMS_CONNMAN_DEBUG_LIB): mms_connman_debug_lib
Slava Monich's avatar
Slava Monich committed
253

254
$(MMS_CONNMAN_RELEASE_LIB): mms_connman_release_lib
Slava Monich's avatar
Slava Monich committed
255 256 257 258 259

$(MMS_HANDLER_DEBUG_LIB): mms_handler_debug_lib

$(MMS_HANDLER_RELEASE_LIB): mms_handler_release_lib

260 261 262 263
$(MMS_SETTINGS_DEBUG_LIB): mms_settings_debug_lib

$(MMS_SETTINGS_RELEASE_LIB): mms_settings_release_lib

Slava Monich's avatar
Slava Monich committed
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
$(GEN_DIR)/%.c: $(SPEC_DIR)/%.xml
	gdbus-codegen --generate-c-code $(@:%.c=%) $<

$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
	$(CC) -c $(WARN) $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@

$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
	$(CC) -c $(WARN) $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@

$(DEBUG_BUILD_DIR)/%.o : $(GEN_DIR)/%.c
	$(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@

$(RELEASE_BUILD_DIR)/%.o : $(GEN_DIR)/%.c
	$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@

$(DEBUG_EXE): $(DEBUG_EXE_DEPS) $(DEBUG_OBJS)
	$(LD) $(DEBUG_FLAGS) $(DEBUG_OBJS) $(DEBUG_LIBS) -o $@

$(RELEASE_EXE): $(RELEASE_EXE_DEPS) $(RELEASE_OBJS)
	$(LD) $(RELEASE_FLAGS) $(RELEASE_OBJS) $(RELEASE_LIBS) -o $@
Slava Monich's avatar
Slava Monich committed
284 285 286
ifeq ($(KEEP_SYMBOLS),0)
	strip $@
endif