forked from xfwcfw/kelftool
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
36 lines (26 loc) · 829 Bytes
/
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
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
CXX = g++
LD = ld
name := kelftool
dir_source := src
dir_build := build
CXXFLAGS = --std=c++17
LDLIBS = -lcrypto
# next flags only for macos
# change paths to your location of [email protected]
ifdef HOMEBREW_PREFIX
OUTPUT_OPTION += -I$(HOMEBREW_PREFIX)/opt/[email protected]/include
LDLIBS += -L$(HOMEBREW_PREFIX)/opt/[email protected]/lib
endif
objects = $(patsubst $(dir_source)/%.cpp, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.cpp))
.PHONY: all
all: $(dir_build)/$(name)
.PHONY: clean
clean:
@rm -rf $(dir_build)/$(name) $(objects)
$(dir_build)/$(name): $(objects)
$(LINK.cc) $^ $(LDLIBS) $(OUTPUT_OPTION) -o $@
$(dir_build)/%.o: $(dir_source)/%.cpp
@mkdir -p "$(@D)"
$(COMPILE.cpp) $< $(OUTPUT_OPTION) -o $@