REhints/HexRaysCodeXplorer

View on GitHub
src/HexRaysCodeXplorer/makefile.lnx

Summary

Maintainability
Test Coverage
# use this makefile to build HexRaysCodeXplorer for Linux

CC=g++
LD=ld

LDFLAGS=-shared -m64 -static-libgcc -static-libstdc++

LIBDIR=-L$(IDA_DIR)
SRCDIR=./
HEXRAYS_SDK=$(IDA_DIR)/plugins/hexrays_sdk
INCLUDES=-I$(IDA_SDK)/include -I$(HEXRAYS_SDK)/include
__X64__=1

SRC=$(SRCDIR)CodeXplorer.cpp \
    $(SRCDIR)CtreeGraphBuilder.cpp \
    $(SRCDIR)ObjectExplorer.cpp \
    $(SRCDIR)TypeReconstructor.cpp \
    $(SRCDIR)CtreeExtractor.cpp \
    $(SRCDIR)TypeExtractor.cpp \
    $(SRCDIR)Utility.cpp \
    $(SRCDIR)MSVCObjectFormatParser.cpp \
    $(SRCDIR)IObjectFormatParser.cpp \
    $(SRCDIR)GCCObjectFormatParser.cpp \
    $(SRCDIR)GCCVtableInfo.cpp \
    $(SRCDIR)GCCTypeInfo.cpp \
    $(SRCDIR)Debug.cpp

OBJS=$(subst .cpp,.o,$(SRC))

CFLAGS=-m64 -fPIC -D__LINUX__ -D__PLUGIN__ -std=c++11 -D__X64__ -D_GLIBCXX_USE_CXX11_ABI=0
LIBS=-lc -lpthread -ldl

ifeq ($(EA64),1)
    CFLAGS+=-D__EA64__
    LIBS+=-lida64
    EXT=so
    SUFFIX=64
else
    EXT=so
    LIBS+=-lida
    SUFFIX=
endif

all: check-env clean HexRaysCodeXplorer$(SUFFIX).$(EXT)

HexRaysCodeXplorer$(SUFFIX).$(EXT): $(OBJS)    
    $(CC) $(LDFLAGS) $(LIBDIR) -o HexRaysCodeXplorer$(SUFFIX).$(EXT) $(OBJS) $(LIBS)

%.o: %.cpp
    $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

clean:
    rm -f $(OBJS) HexRaysCodeXplorer$(SUFFIX).$(EXT)

install:
    cp -f HexRaysCodeXplorer$(SUFFIX).$(EXT) $(IDA_DIR)/plugins

check-env:
ifndef IDA_SDK
    $(error IDA_SDK is undefined)
endif
ifndef IDA_DIR
    $(error IDA_DIR is undefined)
endif
ifndef EA64
    $(error specify EA64=0 for 32 bit build or EA64=1 for 64 bit build)
endif
.PHONY: check-env