| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
CXX := g++ |
| 5 |
PLUGIN_INCLUDE_DIR := $(shell $(CXX) -print-file-name=plugin) |
| 6 |
CXXFLAGS += -Wall -Wextra |
| 7 |
CXXFLAGS += -I$(PLUGIN_INCLUDE_DIR)/include -fPIC -fno-rtti -O2 -std=c++17 |
| 8 |
GCC_MAJOR_VERSION := $(shell $(CXX) -dumpversion) |
| 9 |
GCC_ARCH := $(shell $(CXX) -dumpmachine) |
| 10 |
|
| 11 |
ESSTRACORE_SOURCES := esstracore.cpp |
| 12 |
ESSTRACORE := $(ESSTRACORE_SOURCES:.cpp=.so) |
| 13 |
|
| 14 |
|
| 15 |
THIRD_PARTY_DIR = ../third-party |
| 16 |
WJCRYPTLIB_DIR := $(THIRD_PARTY_DIR)/WjCryptLib/lib |
| 17 |
WJCRYPTLIB_FILES := \ |
| 18 |
$(WJCRYPTLIB_DIR)/WjCryptLib_Md5.c \ |
| 19 |
$(WJCRYPTLIB_DIR)/WjCryptLib_Sha1.c \ |
| 20 |
$(WJCRYPTLIB_DIR)/WjCryptLib_Sha256.c |
| 21 |
ESSTRACORE_SOURCES += $(WJCRYPTLIB_FILES) |
| 22 |
CXXFLAGS += -I $(WJCRYPTLIB_DIR) |
| 23 |
|
| 24 |
PREFIX ?= /usr/local |
| 25 |
INSTALLDIR := $(DESTDIR)/$(PREFIX)/lib/gcc/$(GCC_ARCH)/$(GCC_MAJOR_VERSION)/plugin |
| 26 |
INSTALLDIR := $(subst //,/,$(INSTALLDIR)) |
| 27 |
|
| 28 |
SPECFILE := $(shell dirname `gcc -print-libgcc-file-name`)/specs |
| 29 |
|
| 30 |
.PHONY: all clean install install-specs uninstall-specs uninstall-core uninstall |
| 31 |
|
| 32 |
all: $(ESSTRACORE) |
| 33 |
|
| 34 |
$(WJCRYPTLIB_FILES): |
| 35 |
(cd $(THIRD_PARTY_DIR) && git submodule init && git submodule update) |
| 36 |
|
| 37 |
$(ESSTRACORE): $(ESSTRACORE_SOURCES) |
| 38 |
$(CXX) -shared $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ -o $@ |
| 39 |
|
| 40 |
install: $(ESSTRACORE) |
| 41 |
install -m 755 -d $(INSTALLDIR) |
| 42 |
install -m 755 $(ESSTRACORE) $(INSTALLDIR) |
| 43 |
|
| 44 |
clean: |
| 45 |
rm -f *.so |
| 46 |
|
| 47 |
install-specs: $(INSTALLDIR)/$(ESSTRACORE) |
| 48 |
gcc -dumpspecs | \ |
| 49 |
sed -E "N;s|\*cc1:\n(.+)$$|*cc1:\n\1 %{!fplugin:-fplugin=$(INSTALLDIR)/$(ESSTRACORE)}|" \ |
| 50 |
> $(SPECFILE) |
| 51 |
|
| 52 |
uninstall-specs: $(SPECFILE) |
| 53 |
rm -f $(SPECFILE) |
| 54 |
|
| 55 |
uninstall-core: |
| 56 |
rm -f $(INSTALLDIR)/$(ESSTRACORE) |
| 57 |
|
| 58 |
uninstall: uninstall-core uninstall-specs |