-
Notifications
You must be signed in to change notification settings - Fork 218
/
co.mk
86 lines (68 loc) · 2.21 KB
/
co.mk
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
#
# Tencent is pleased to support the open source community by making Libco available.
#
# Copyright (C) 2014 THL A29 Limited, a Tencent company. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##### Makefile Rules ##########
MAIL_ROOT=.
SRCROOT=.
##define the compliers
CPP = g++
CC = gcc
AR = ar -rc
RANLIB = ranlib
CPPSHARE = $(CPP) -fPIC -shared -O2 -pipe -L$(SRCROOT)/solib/ -o
CSHARE = $(CC) -fPIC -shared -O2 -pipe -L$(SRCROOT)/solib/ -o
ifeq ($v,release)
CFLAGS= -O2 $(INCLS) -fPIC -DLINUX -pipe -Wno-deprecated -c
else
CFLAGS= -g $(INCLS) -fPIC -DLINUX -pipe -c -fno-inline
endif
ifneq ($v,release)
BFLAGS= -g
endif
STATICLIBPATH=$(SRCROOT)/lib
DYNAMICLIBPATH=$(SRCROOT)/solib
INCLS += -I$(SRCROOT)
## default links
ifeq ($(LINKS_DYNAMIC), 1)
LINKS += -L$(DYNAMICLIBPATH) -L$(STATICLIBPATH)
else
LINKS += -L$(STATICLIBPATH)
endif
CPPSRCS = $(wildcard *.cpp)
CSRCS = $(wildcard *.c)
CPPOBJS = $(patsubst %.cpp,%.o,$(CPPSRCS))
COBJS = $(patsubst %.c,%.o,$(CSRCS))
SRCS = $(CPPSRCS) $(CSRCS)
OBJS = $(CPPOBJS) $(COBJS)
CPPCOMPI=$(CPP) $(CFLAGS) -Wno-deprecated
CCCOMPI=$(CC) $(CFLAGS)
BUILDEXE = $(CPP) $(BFLAGS) -o $@ $^ $(LINKS)
CLEAN = rm -f *.o
CPPCOMPILE = $(CPPCOMPI) $< $(FLAGS) $(INCLS) $(MTOOL_INCL) -o $@
CCCOMPILE = $(CCCOMPI) $< $(FLAGS) $(INCLS) $(MTOOL_INCL) -o $@
ARSTATICLIB = $(AR) [email protected] $^ $(AR_FLAGS); \
if [ $$? -ne 0 ]; then exit 1; fi; \
test -d $(STATICLIBPATH) || mkdir -p $(STATICLIBPATH); \
mv -f [email protected] $(STATICLIBPATH)/$@;
BUILDSHARELIB = $(CPPSHARE) [email protected] $^ $(BS_FLAGS); \
if [ $$? -ne 0 ]; then exit 1; fi; \
test -d $(DYNAMICLIBPATH) || mkdir -p $(DYNAMICLIBPATH); \
mv -f [email protected] $(DYNAMICLIBPATH)/$@;
.cpp.o:
$(CPPCOMPILE)
.c.o:
$(CCCOMPILE)