-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (54 loc) · 1.52 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
# $@ - Name of the target
# $? - List of dependencies more recent than target
# $^ - All dependencies without duplicates
# $+ - All dependencies with duplicates
# $< - First dependency
# $(@D) - The directory part of the file name of the target
# % - Wildcard, matches text stored in $*
# OBJ = $(SRC:.c=.o) - replace .c extension with .o
# OBJS:= $(addprefix $(BUILD_DIR)/, $(OBJS)) - add prefix to list
OBJS:= main.o stat_gen.o cloud_conn.o http_conn.o s3_conn.o cf_conn.o \
http_req.o logging.o
TARGET:= cloud-ping
AR:=ar
AS:=as
ASFLAGS:= -gstabs
LD:=g++
LDFALGS:=
#CC:=gcc
CC:=g++
GCCVERSION:=$(shell gcc -dumpversion |cut -f1,2 -d. --output-delimiter='0')
CFLAGS:= -g -Wall -fPIC
ifeq ($(shell [ $(GCCVERSION) -lt 407 ] && echo 1), 1)
CFLAGS += -std=c++0x
else
CFLAGS += -std=c++11
endif
LIBS:= -lboost_program_options -lcurl -lcrypto -lgcrypt
INCLUDES:=
BUILD_DIR:= build
OBJS:= $(addprefix $(BUILD_DIR)/, $(OBJS))
TARGET:= $(addprefix $(BUILD_DIR)/, $(TARGET))
$(TARGET): $(OBJS)
$(LD) $(LDFALGS) -o $@ $^ $(LIBS)
$(TARGET).a: $(OBJS)
mkdir -p $(@D)
$(AR) rcs $@ $^
$(TARGET).so: $(OBJS)
mkdir -p $(@D)
$(LD) -shared -soname [email protected] -o [email protected] $^
-include $(OBJS:.o=.d)
$(BUILD_DIR)/%.o: %.S
mkdir -p $(@D)
$(AS) $(ASFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.c
mkdir -p $(@D)
$(CC) -c -MD $(CFLAGS) $(INCLUDES) -o $@ $<
$(BUILD_DIR)/%.o: %.cc
mkdir -p $(@D)
$(CC) -c -MD $(CFLAGS) $(INCLUDES) -o $@ $<
$(BUILD_DIR)/%.o: %.cpp
mkdir -p $(@D)
$(CC) -c -MD $(CFLAGS) $(INCLUDES) -o $@ $<
clean:
-rm -rf $(BUILD_DIR)