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
|
# SPDX-FileCopyrightText: Copyright 2024-2025 Sony Group Corporation
# SPDX-License-Identifier: MIT
CXX := g++
PLUGIN_INCLUDE_DIR := $(shell $(CXX) -print-file-name=plugin)
CXXFLAGS += -Wall -Wextra
CXXFLAGS += -I$(PLUGIN_INCLUDE_DIR)/include -fPIC -fno-rtti -O2 -std=c++17
GCC_MAJOR_VERSION := $(shell $(CXX) -dumpversion)
GCC_ARCH := $(shell $(CXX) -dumpmachine)
ESSTRACORE_SOURCES := esstracore.cpp
ESSTRACORE := $(ESSTRACORE_SOURCES:.cpp=.so)
# hash functions
THIRD_PARTY_DIR = ../third-party
WJCRYPTLIB_DIR := $(THIRD_PARTY_DIR)/WjCryptLib/lib
WJCRYPTLIB_FILES := \
$(WJCRYPTLIB_DIR)/WjCryptLib_Md5.c \
$(WJCRYPTLIB_DIR)/WjCryptLib_Sha1.c \
$(WJCRYPTLIB_DIR)/WjCryptLib_Sha256.c
ESSTRACORE_SOURCES += $(WJCRYPTLIB_FILES)
CXXFLAGS += -I $(WJCRYPTLIB_DIR)
PREFIX ?= /usr/local
INSTALLDIR := $(DESTDIR)/$(PREFIX)/lib/gcc/$(GCC_ARCH)/$(GCC_MAJOR_VERSION)/plugin
INSTALLDIR := $(subst //,/,$(INSTALLDIR))
SPECFILE := $(shell dirname `gcc -print-libgcc-file-name`)/specs
.PHONY: all clean install install-specs uninstall-specs uninstall-core uninstall
all: $(ESSTRACORE)
$(WJCRYPTLIB_FILES):
(cd $(THIRD_PARTY_DIR) && git submodule init && git submodule update)
$(ESSTRACORE): $(ESSTRACORE_SOURCES)
$(CXX) -shared $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ -o $@
install: $(ESSTRACORE)
install -m 755 -d $(INSTALLDIR)
install -m 755 $(ESSTRACORE) $(INSTALLDIR)
clean:
rm -f *.so
install-specs: $(INSTALLDIR)/$(ESSTRACORE)
gcc -dumpspecs | \
sed -E "N;s|\*cc1:\n(.+)$$|*cc1:\n\1 %{!fplugin:-fplugin=$(INSTALLDIR)/$(ESSTRACORE)}|" \
> $(SPECFILE)
uninstall-specs: $(SPECFILE)
rm -f $(SPECFILE)
uninstall-core:
rm -f $(INSTALLDIR)/$(ESSTRACORE)
uninstall: uninstall-core uninstall-specs
|