forked from MonaSolutions/librtmfp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (86 loc) · 2.86 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
VERSION=0.1
prefix=/usr
LIBDIR=$(prefix)/lib/
ifeq ($(shell uname -m), x86_64)
ifneq "$(wildcard $(prefix)/lib64)" ""
LIBDIR="$(prefix)/lib64/"
else ifneq "$(wildcard $(prefix)/lib/x86_64-linux-gnu)" ""
LIBDIR="$(prefix)/lib/x86_64-linux-gnu/"
endif
endif
PKGCONFIGPATH=$(shell pkg-config --variable pc_path pkg-config | cut -d ':' -f 1)
ifeq ($(PKGCONFIGPATH), )
PKGCONFIGPATH=$(LIBDIR)/pkgconfig
endif
# pkgconfig description variables
CRYPTO_REQ=libssl,libcrypto
PUBLIC_LIBS=
PRIVATE_LIBS=
OS := $(shell uname -s)
# Variables with default values
GPP?=g++
# Variables extendable
CFLAGS+=-std=c++11 -Wall -Wno-reorder -Wno-terminate -Wno-unknown-pragmas -Wno-unknown-warning-option
ifeq ($(OS),FreeBSD)
CFLAGS+=-D_GLIBCXX_USE_C99
endif
override INCLUDES+=-I./include/
LIBS+=-Wl,-Bdynamic -lcrypto -lssl -lpthread
INCDIR=/usr/include/librtmfp/
# Variables fixed
ifeq ($(OS),Darwin)
LIBNAME=librtmfp.dylib
SHARED=-dynamiclib -install_name ./../LibRTMFP/$(LIB)
else
LIBNAME=librtmfp.so
AR=lib/librtmfp.a
SHARED=-shared
endif
LIB=lib/$(LIBNAME)
# Variables fixed
SOURCES = $(wildcard sources/*.cpp sources/Base/*.cpp)
OBJECT = $(SOURCES:sources/%.cpp=tmp/Release/%.o)
OBJECTD = $(SOURCES:sources/%.cpp=tmp/Debug/%.o)
.PHONY: debug release
release:
mkdir -p tmp/Release/Base
mkdir -p lib
@$(MAKE) -k $(OBJECT)
@echo creating dynamic lib $(LIB)
@$(GPP) $(CFLAGS) $(LIBDIRS) -fPIC $(SHARED) -o $(LIB) $(OBJECT) $(LIBS)
@if [ "$(OS)" != "Darwin" ]; then\
echo "creating static lib $(AR)";\
ar rcs $(AR) $(OBJECT);\
fi
debug:
mkdir -p tmp/Debug/Base
mkdir -p lib
@$(MAKE) -k $(OBJECTD)
@echo creating dynamic debug lib $(LIB)
@$(GPP) -g -D_DEBUG $(CFLAGS) $(LIBDIRS) -fPIC $(SHARED) -o $(LIB) $(OBJECTD) $(LIBS)
@if [ "$(OS)" != "Darwin" ]; then\
echo "creating static lib $(AR)";\
ar rcs $(AR) $(OBJECTD);\
fi
librtmfp.pc: librtmfp.pc.in Makefile
@echo "compiling librtmfp.pc.in"
sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(LIBDIR);" \
-e "s;@VERSION@;$(VERSION);" \
-e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" \
-e "s;@PUBLIC_LIBS@;$(PUBLIC_LIBS);" \
-e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS);" librtmfp.pc.in > $@
install: librtmfp.pc
-mkdir -p $(INCDIR)
cp ./include/librtmfp.h $(INCDIR) && chmod 644 $(INCDIR)/librtmfp.h
cp $(LIB) $(LIBDIR) && chmod 755 $(LIBDIR)/$(LIBNAME)
test -d "$(PKGCONFIGPATH)" || mkdir -p "$(PKGCONFIGPATH)" && cp librtmfp.pc $(PKGCONFIGPATH) && chmod 644 $(PKGCONFIGPATH)/librtmfp.pc
$(OBJECT): tmp/Release/%.o: sources/%.cpp
@echo compiling $(@:tmp/Release/%.o=sources/%.cpp)
@$(GPP) $(CFLAGS) -fpic $(INCLUDES) -c -o $(@) $(@:tmp/Release/%.o=sources/%.cpp)
$(OBJECTD): tmp/Debug/%.o: sources/%.cpp
@echo compiling $(@:tmp/Debug/%.o=sources/%.cpp)
@$(GPP) -g -D_DEBUG $(CFLAGS) -fpic $(INCLUDES) -c -o $(@) $(@:tmp/Debug/%.o=sources/%.cpp)
clean:
@echo cleaning project librtmfp
@rm -f $(OBJECT) $(LIB)
@rm -f $(OBJECTD) $(LIB)