Makefile 3.07 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: clean all debug release

5 6 7 8 9 10
#
# Pull in mms-lib configuration
#

include Config.mak

11
#
Slava Monich's avatar
Slava Monich committed
12
# Required packages
13 14
#

15
PKGS = libglibutil libwspcodec gmime-2.6 libsoup-2.4 glib-2.0
Slava Monich's avatar
Slava Monich committed
16 17 18 19 20 21 22 23 24 25 26

#
# Default target
#

all: debug release

#
# Sources
#

27 28 29 30 31 32 33 34 35 36 37 38
SRC = \
  mms_attachment.c \
  mms_attachment_image.c \
  mms_attachment_jpeg.c \
  mms_codec.c \
  mms_connection.c \
  mms_connman.c \
  mms_dispatcher.c \
  mms_error.c \
  mms_handler.c \
  mms_lib_util.c \
  mms_file_util.c \
39
  mms_message.c \
40 41 42 43 44 45 46 47 48 49 50 51
  mms_settings.c \
  mms_task.c \
  mms_task_ack.c \
  mms_task_decode.c \
  mms_task_encode.c \
  mms_task_http.c \
  mms_task_notification.c \
  mms_task_notifyresp.c \
  mms_task_publish.c \
  mms_task_read.c \
  mms_task_retrieve.c \
  mms_task_send.c \
52
  mms_util.c
Slava Monich's avatar
Slava Monich committed
53

54 55 56 57
ifeq ($(MMS_RESIZE),Qt)
SRC_CPP += mms_attachment_qt.cpp
endif

Slava Monich's avatar
Slava Monich committed
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
#
# Directories
#

SRC_DIR = src
INCLUDE_DIR = include
BUILD_DIR = build
DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
RELEASE_BUILD_DIR = $(BUILD_DIR)/release

#
# Code coverage
#

ifndef GCOV
GCOV = 0
endif

ifneq ($(GCOV),0)
CFLAGS += --coverage
endif

#
# Tools and flags
#

CC = $(CROSS_COMPILE)gcc
LD = $(CC)
Slava Monich's avatar
Slava Monich committed
86 87 88 89 90
ARFLAGS = rc
DEBUG_FLAGS = -g
RELEASE_FLAGS = -O2
DEBUG_DEFS = -DDEBUG
RELEASE_DEFS =
Slava Monich's avatar
Slava Monich committed
91
WARNINGS = -Wall
92
DEFINES = $(RESIZE_DEFINES)
Slava Monich's avatar
Slava Monich committed
93
INCLUDES = -I$(SRC_DIR) -I$(INCLUDE_DIR)
94
CFLAGS += -fPIC $(WARNINGS) $(INCLUDES) $(RESIZE_CFLAGS) \
95
  $(shell pkg-config --cflags $(PKGS)) -MMD
Slava Monich's avatar
Slava Monich committed
96 97 98 99 100 101 102 103 104

ifndef KEEP_SYMBOLS
KEEP_SYMBOLS = 0
endif

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

105 106 107 108 109 110
ifneq ($(MMS_LOG_SYSLOG),)
DEFINES += -DMMS_LOG_SYSLOG=$(MMS_LOG_SYSLOG)
endif

DEBUG_CFLAGS = $(DEFINES) $(DEBUG_FLAGS) $(DEBUG_DEFS) $(CFLAGS)
RELEASE_CFLAGS = $(DEFINES) $(RELEASE_FLAGS) $(RELEASE_DEFS) $(CFLAGS)
111 112
DEBUG_CPPFLAGS = -Wno-psabi $(RESIZE_CPPFLAGS) $(DEBUG_CFLAGS)
RELEASE_CPPFLAGS = -Wno-psabi $(RESIZE_CPPFLAGS) $(RELEASE_CFLAGS)
Slava Monich's avatar
Slava Monich committed
113 114 115 116 117

#
# Files
#

118 119 120 121 122 123 124
DEBUG_OBJS = \
  $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o) \
  $(SRC_CPP:%.cpp=$(DEBUG_BUILD_DIR)/%.o)
RELEASE_OBJS = \
  $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o) \
  $(SRC_CPP:%.cpp=$(RELEASE_BUILD_DIR)/%.o)

Slava Monich's avatar
Slava Monich committed
125 126 127 128 129 130 131 132 133 134 135
#
# Dependencies
#

DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
-include $(DEPS)
endif
endif

136 137 138
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)

Slava Monich's avatar
Slava Monich committed
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
#
# Rules
#
LIB = libmms.a
DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)

debug: $(DEBUG_LIB)

release: $(RELEASE_LIB) 

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

$(DEBUG_BUILD_DIR):
	mkdir -p $@

$(RELEASE_BUILD_DIR):
	mkdir -p $@

159 160
$(DEBUG_LIB): $(DEBUG_OBJS)
	$(AR) $(ARFLAGS) $@ $^
Slava Monich's avatar
Slava Monich committed
161

162 163
$(RELEASE_LIB): $(RELEASE_OBJS)
	$(AR) $(ARFLAGS) $@ $^
Slava Monich's avatar
Slava Monich committed
164 165 166 167 168 169

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

$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
	$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
170 171 172 173 174 175

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

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