This repository was archived by the owner on Jun 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (46 loc) · 1.57 KB
/
Copy pathMakefile
File metadata and controls
59 lines (46 loc) · 1.57 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
# Path to prebuilt libbinaryninjaapi.a
BINJA_API_A := ~/Documents/Repos/binaryninja-api/bin/libbinaryninjaapi.a
# Path to binaryninjaapi.h and json
INC := -I/Users/user/Documents/Repos/binaryninja-api/
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
# Path to binaryninja install
BINJAPATH := $(shell cat ~/.binaryninja/lastrun)
PLUGIN_DIR := ~/.binaryninja/plugins/
CC := g++
else
BINJAPATH := /Applications/Binary\ Ninja.app/Contents/MacOS
PLUGIN_DIR := ~/Library/Application\ Support/Binary\ Ninja/plugins/
CC := clang++
endif
SRCDIR := src
BUILDDIR := build
TARGETDIR := bin
TARGETNAME := fat_macho
TARGET := $(TARGETDIR)/$(TARGETNAME)
SRCEXT := cpp
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
LIBS := -L$(BINJAPATH) -lbinaryninjacore
CFLAGS := -c -std=gnu++11 -O2 -Wall -W -fPIC -pipe -Wno-unused-function
all: $(TARGET)
ifeq ($(UNAME_S),Linux)
$(TARGET): $(OBJECTS)
@mkdir -p $(TARGETDIR)
$(CC) $^ $(BINJA_API_A) $(LIBS) -shared -Wl,-rpath=$(BINJAPATH) -ldl -o bin/lib$(TARGETNAME).so
else
$(TARGET): $(OBJECTS)
@mkdir -p $(TARGETDIR)
$(CC) $^ $(BINJA_API_A) $(LIBS) -single_module -dynamiclib -o bin/lib$(TARGETNAME).dylib
install_name_tool -add_rpath $(BINJAPATH)/libbinaryninjacore.dylib bin/lib$(TARGETNAME).dylib
endif
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(BUILDDIR)
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
# src/asmx86/libasmx86.a:
# $(MAKE) -C src/asmx86
install:
cp bin/lib$(TARGETNAME).dylib $(PLUGIN_DIR)
clean:
$(RM) -r $(BUILDDIR) $(TARGETDIR)
.PHONY: clean