-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (45 loc) · 1.08 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
# Paths
PREFIX=/usr
INCPREFIX=$(PREFIX)/include
LIBPREFIX=$(PREFIX)/lib
# Flags
CC=gcc
CFLAGS=-g -Wall
LDLIBS=-lcurl -lcrypto -lm
SRC=src
OBJ=obj
LIBDIR=lib
LIB_STATIC=$(LIBDIR)/libcbpro.a
LIB_SHARED=$(LIBDIR)/libcbpro.so
SRCS=$(wildcard $(SRC)/*.c)
OBJS=$(patsubst $(SRC)%.c, $(OBJ)/%.o, $(SRCS))
TEST=get_product\
get_all_products\
get_product_book\
get_product_candles\
get_product_stats\
all: $(LIB_SHARED)
test: $(LIB_SHARED) $(TEST)
$(OBJ)/%.o: $(SRC)/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(LDLIBS) -c $^ -o $@
$(LIB_STATIC): $(OBJS)
@mkdir -p $(@D)
ar -rcs $@ $^
$(LIB_SHARED): $(SRCS)
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(LDLIBS) -fPIC -shared $^ -o $@
$(TEST):
@mkdir -p test/bin
$(CC) $(CFLAGS) $(LDLIBS) test/src/$@.c -o test/bin/$@ -L./lib -lcbpro
install: all
mkdir -p $(DESTDIR)$(LIBPREFIX)
mkdir -p $(DESTDIR)$(INCPREFIX)
cp -f $(LIB_SHARED) $(DESTDIR)$(LIBPREFIX)
cp -f src/cbpro.h $(DESTDIR)$(INCPREFIX)
uninstall:
rm -f $(DESTDIR)$(LIBPREFIX)/libcbpro.so
rm -f $(DESTDIR)$(INCPREFIX)/cbpro.h
clean:
rm -f $(OBJ)/* test/bin/* lib/*
.PHONY: all test clean