-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (70 loc) · 2.19 KB
/
Makefile
File metadata and controls
86 lines (70 loc) · 2.19 KB
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
# Makefile for Alpaca API client programs
# Compiler and flags
CXX = g++
CXXFLAGS = -Wall -Wextra -std=c++17 -O2
# Installation directory
B = $(HOME)/bin
# Common library flags
COMMON_LIBS = -lpthread -lm
# Program specific library flags
CURL_LIBS = -lcurl -lssl -lcrypto
SQLITE_LIBS = -lsqlite3
# Program names
PROGRAMS = alpaca_account \
get_bars \
trade_fetcher \
trade_processor
# Define installation targets
INSTALL_TARGETS = $(addprefix $(B)/, $(PROGRAMS))
# Default target - now builds locally
all: $(PROGRAMS)
# Special rule for trade_processor with SQLite
trade_processor: trade_processor.cpp
$(CXX) $(CXXFLAGS) $< $(COMMON_LIBS) $(SQLITE_LIBS) -o $@
@chmod 755 $@
@echo "$@ built in current directory"
# General rule for curl-based programs
alpaca_account get_bars trade_fetcher: %: %.cpp
$(CXX) $(CXXFLAGS) $< $(COMMON_LIBS) $(CURL_LIBS) -o $@
@chmod 755 $@
@echo "$@ built in current directory"
# Installation target
install: $(INSTALL_TARGETS)
@echo "All programs installed in $(B)"
@touch $@
# Special installation rule for trade_processor
$(B)/trade_processor: trade_processor.cpp
@mkdir -p $(B)
$(CXX) $(CXXFLAGS) $< $(COMMON_LIBS) $(SQLITE_LIBS) -o $@
@chmod 755 $@
@echo "$* installed in $(B)"
# General installation rule for curl-based programs
$(B)/alpaca_account $(B)/get_bars $(B)/trade_fetcher: $(B)/%: %.cpp
@mkdir -p $(B)
$(CXX) $(CXXFLAGS) $< $(COMMON_LIBS) $(CURL_LIBS) -o $@
@chmod 755 $@
@echo "$* installed in $(B)"
# Rebuild everything
remake:
-touch *.cpp
-rm -f $(PROGRAMS) $(INSTALL_TARGETS)
$(MAKE)
# Build in debug mode
debug: CXXFLAGS += -g -DDEBUG
debug: clean all
# Clean build artifacts
clean:
rm -f $(PROGRAMS) $(INSTALL_TARGETS)
rm -f a.out core *.o
# Print help information
help:
@echo "Makefile for Alpaca API client programs"
@echo ""
@echo "Targets:"
@echo " all - Build all programs in current directory (default)"
@echo " install - Build and install programs in $(B)"
@echo " clean - Remove all built programs"
@echo " remake - Force rebuild of all programs"
@echo " debug - Build with debugging symbols"
@echo " help - Show this help message"
.PHONY: all install clean remake debug help