Project

General

Profile

Feature #191 » compile.mk

Hammel, 19 Jul 2013 10:41

 
1
#  Copyright (c) 2010,
2
#  Gavriloaie Eugen-Andrei (shiretu@gmail.com)
3
#
4
#  This file is part of crtmpserver.
5
#  crtmpserver is free software: you can redistribute it and/or modify
6
#  it under the terms of the GNU General Public License as published by
7
#  the Free Software Foundation, either version 3 of the License, or
8
#  (at your option) any later version.
9
#
10
#  crtmpserver is distributed in the hope that it will be useful,
11
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
#  GNU General Public License for more details.
14
#
15
#  You should have received a copy of the GNU General Public License
16
#  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>.
17

    
18
#toolchain paths
19
CCOMPILER?=$(TOOLCHAIN_BASE)$(TOOLCHAIN_PREFIX)gcc
20
CXXCOMPILER?=$(TOOLCHAIN_BASE)$(TOOLCHAIN_PREFIX)g++
21

    
22
#output settings
23
OUTPUT_BASE = ./output
24
OUTPUT_BIN = $(OUTPUT_BASE)
25
OUTPUT_OBJ = $(OUTPUT_BASE)
26
OUTPUT_DYNAMIC = $(OUTPUT_BIN)/dynamic
27
OUTPUT_STATIC = $(OUTPUT_BIN)/static
28
dynamic_lib_name = $(OUTPUT_DYNAMIC)$(2)/$(DYNAMIC_LIB_PREFIX)$(1)$(DYNAMIC_LIB_SUFIX)
29
static_lib_name = $(OUTPUT_STATIC)$(2)/$(STATIC_LIB_PREFIX)$(1)$(STATIC_LIB_SUFIX)
30
dynamic_exec_name = $(OUTPUT_DYNAMIC)$(2)/$(1)
31
static_exec_name = $(OUTPUT_STATIC)$(2)/$(1)
32

    
33
#project paths
34
PROJECT_BASE_PATH=../..
35

    
36
FEATURES_DEFINES = \
37
	-DCreateRTCPPacket=CreateRTCPPacket_mystyle_only_once \
38
	-DFeedDataAudioMPEG4Generic=FeedDataAudioMPEG4Generic_one_by_one \
39
	-DHandleTSVideoData=HandleVideoData_version3 \
40
	-DHAS_PROTOCOL_HTTP \
41
	-DHAS_PROTOCOL_RTMP \
42
	-DHAS_PROTOCOL_LIVEFLV \
43
	-DHAS_PROTOCOL_RTP \
44
	-DHAS_PROTOCOL_TS \
45
	-DHAS_PROTOCOL_VAR \
46
	-DHAS_LUA \
47
	-DHAS_MEDIA_MP3 \
48
	-DHAS_MEDIA_MP4 \
49
	-DHAS_MEDIA_FLV
50

    
51

    
52
DEFINES = $(PLATFORM_DEFINES) $(FEATURES_DEFINES)
53

    
54
#library paths
55
# SSL_INCLUDE=-I$(SSL_BASE)/include
56
# SSL_LIB=-L$(SSL_BASE)/lib -lssl -lcrypto
57
SSL_INCLUDE=
58
SSL_LIB=$(LDFLAGS) -ltinyxml -lssl -lcrypto
59

    
60
#lua
61
LUA_INCLUDE=-I$(PROJECT_BASE_PATH)/3rdparty/lua-dev
62
LUA_SRCS = $(shell find $(PROJECT_BASE_PATH)/3rdparty/lua-dev -type f -name "*.c")
63
LUA_OBJS = $(LUA_SRCS:.c=.lua.o)
64

    
65
#tinyxml
66
# TINYXML_INCLUDE=-I$(PROJECT_BASE_PATH)/3rdparty/tinyxml
67
# TINYXML_SRCS = $(shell find $(PROJECT_BASE_PATH)/3rdparty/tinyxml -type f -name "*.cpp")
68
# TINYXML_OBJS = $(TINYXML_SRCS:.cpp=.tinyxml.o)
69
TINYXML_INCLUDE=$(TINYXML_INC)
70
TINYXML_SRCS = 
71
TINYXML_OBJS = 
72

    
73
#common
74
COMMON_INCLUDE=$(LUA_INCLUDE) $(TINYXML_INCLUDE) $(SSL_INCLUDE) -I$(PROJECT_BASE_PATH)/sources/common/include
75
# COMMON_LIBS=$(SSL_LIB) -L$(OUTPUT_DYNAMIC) -llua -ltinyxml
76
COMMON_LIBS=$(SSL_LIB) -L$(OUTPUT_DYNAMIC) -llua 
77
COMMON_SRCS = $(shell find $(PROJECT_BASE_PATH)/sources/common/src -type f -name "*.cpp")
78
COMMON_OBJS = $(COMMON_SRCS:.cpp=.common.o)
79

    
80
#thelib
81
THELIB_INCLUDE=$(COMMON_INCLUDE) -I$(PROJECT_BASE_PATH)/sources/thelib/include
82
THELIB_LIBS=$(COMMON_LIBS) -L$(OUTPUT_DYNAMIC) -lcommon
83
THELIB_SRCS = $(shell find $(PROJECT_BASE_PATH)/sources/thelib/src -type f -name "*.cpp")
84
THELIB_OBJS = $(THELIB_SRCS:.cpp=.thelib.o)
85

    
86
#tests
87
TESTS_INCLUDE=$(THELIB_INCLUDE) -I$(PROJECT_BASE_PATH)/sources/tests/include
88
TESTS_LIBS=$(THELIB_LIBS) -L$(OUTPUT_DYNAMIC) -lthelib
89
TESTS_SRCS=$(shell find $(PROJECT_BASE_PATH)/sources/tests/src -type f -name "*.cpp")
90
TESTS_OBJS=$(TESTS_SRCS:.cpp=.tests.o)
91

    
92
#crtmpserver
93
CRTMPSERVER_INCLUDE=$(THELIB_INCLUDE) -I$(PROJECT_BASE_PATH)/sources/crtmpserver/include
94
CRTMPSERVER_LIBS=$(THELIB_LIBS) -L$(OUTPUT_DYNAMIC) -lthelib
95
CRTMPSERVER_SRCS=$(shell find $(PROJECT_BASE_PATH)/sources/crtmpserver/src -type f -name "*.cpp")
96
CRTMPSERVER_OBJS_DYNAMIC=$(CRTMPSERVER_SRCS:.cpp=.crtmpserver_dynamic.o)
97
CRTMPSERVER_OBJS_STATIC=$(CRTMPSERVER_SRCS:.cpp=.crtmpserver_static.o)
98

    
99
#targets
100
all: create_output_dirs lua common thelib applications tests crtmpserver
101

    
102
include apps.mk
103

    
104
create_output_dirs:
105
	@mkdir -p $(OUTPUT_STATIC)
106
	@mkdir -p $(OUTPUT_DYNAMIC)
107

    
108
lua: create_output_dirs $(LUA_OBJS)
109
	$(CCOMPILER) -shared -o $(call dynamic_lib_name,lua,) $(call dynamic_lib_flags,lua) $(LUA_OBJS)
110

    
111
%.lua.o: %.c
112
	$(CCOMPILER) $(COMPILE_FLAGS) -c $< -o $@
113

    
114
# tinyxml: lua $(TINYXML_OBJS)
115
# 	$(CXXCOMPILER) -shared -o $(call dynamic_lib_name,tinyxml,) $(call dynamic_lib_flags,tinyxml) $(TINYXML_OBJS)
116
tinyxml: lua 
117

    
118
%.tinyxml.o: %.cpp
119
	$(CXXCOMPILER) $(COMPILE_FLAGS) $(DEFINES) $(COMMON_INCLUDE) -c $< -o $@
120

    
121
common: tinyxml $(COMMON_OBJS)
122
	$(CXXCOMPILER) -shared $(COMMON_LIBS) -o $(call dynamic_lib_name,common,) $(call dynamic_lib_flags,common) $(COMMON_OBJS)
123

    
124
%.common.o: %.cpp
125
	$(CXXCOMPILER) $(COMPILE_FLAGS) $(DEFINES) $(COMMON_INCLUDE) -c $< -o $@
126

    
127
thelib: common $(THELIB_OBJS)
128
	$(CXXCOMPILER) -shared $(THELIB_LIBS) -o $(call dynamic_lib_name,thelib,) $(call dynamic_lib_flags,thelib) $(THELIB_OBJS)
129

    
130
%.thelib.o: %.cpp
131
	$(CXXCOMPILER) $(COMPILE_FLAGS) $(DEFINES) $(THELIB_INCLUDE) -c $< -o $@
132

    
133
tests: thelib $(TESTS_OBJS)
134
	$(CXXCOMPILER)  $(TESTS_LIBS) -o $(call dynamic_exec_name,tests,) $(call dynamic_exec_flags,tests) $(TESTS_OBJS)
135
	$(CXXCOMPILER)  $(SSL_LIB) -o $(call static_exec_name,tests) $(call static_exec_flags,tests) \
136
		$(TESTS_OBJS) \
137
		$(LUA_OBJS) \
138
		$(TINYXML_OBJS) \
139
		$(COMMON_OBJS) \
140
		$(THELIB_OBJS)
141

    
142
%.tests.o: %.cpp
143
	$(CXXCOMPILER) $(COMPILE_FLAGS) $(DEFINES) $(TESTS_INCLUDE) -c $< -o $@
144

    
145
crtmpserver: applications $(CRTMPSERVER_OBJS_DYNAMIC) $(CRTMPSERVER_OBJS_STATIC)
146
	$(CXXCOMPILER) $(CRTMPSERVER_LIBS) -o $(call dynamic_exec_name,crtmpserver,) $(call dynamic_exec_flags,crtmpserver) $(CRTMPSERVER_OBJS_DYNAMIC)
147
	$(CXXCOMPILER) $(SSL_LIB) -o $(call static_exec_name,crtmpserver,) $(call static_exec_flags,crtmpserver) \
148
		$(CRTMPSERVER_OBJS_STATIC) \
149
		$(LUA_OBJS) \
150
		$(TINYXML_OBJS) \
151
		$(COMMON_OBJS) \
152
		$(THELIB_OBJS) \
153
		$(ALL_APPS_OBJS)
154
	@cp $(PROJECT_BASE_PATH)/builders/cmake/crtmpserver/crtmpserver.lua $(OUTPUT_DYNAMIC)
155
	@cp $(PROJECT_BASE_PATH)/builders/cmake/crtmpserver/crtmpserver.lua $(OUTPUT_STATIC)
156

    
157
%.crtmpserver_dynamic.o: %.cpp
158
	$(CXXCOMPILER) $(COMPILE_FLAGS) $(DEFINES) $(CRTMPSERVER_INCLUDE) -c $< -o $@
159

    
160
%.crtmpserver_static.o: %.cpp
161
	$(CXXCOMPILER) $(COMPILE_FLAGS) -DCOMPILE_STATIC $(ACTIVE_APPS) $(DEFINES) $(CRTMPSERVER_INCLUDE) -c $< -o $@
162

    
163
clean:
164
	@rm -rfv $(OUTPUT_BASE)
165
	@sh cleanupobjs.sh
166
	
(2-2/3)