diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0e6e07..855dc60 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,10 +12,11 @@ jobs: build: strategy: matrix: - os: [ubuntu-latest] #, windows-latest] + os: [ubuntu-latest, macos-latest] compiler: [clang] runs-on: ${{ matrix.os }} + steps: - name: Checkout Repository uses: actions/checkout@v3 @@ -31,38 +32,59 @@ jobs: sudo apt update sudo apt install --no-install-recommends -y build-essential libboost-all-dev libssl-dev git - - name: Cache build artifacts (Ubuntu) - if: matrix.os == 'ubuntu-latest' - uses: actions/cache@v3 - with: - path: | - obj - libi2pd.a - key: ubuntu-build-${{ runner.os }}-${{ hashFiles('**/*.cpp', '**/*.h') }} -# + ####################### + # macOS dependencies # + #BY VADE = https://github.com/MetanoicArmor + ####################### + - name: Install dependencies (macOS) + if: matrix.os == 'macos-latest' + run: | + brew update + brew install boost openssl@3 cmake make + + ####################### + # Windows dependencies # + ####################### # - name: Install MSYS2 (Windows) # if: matrix.os == 'windows-latest' -# run: | -# Invoke-WebRequest -Uri "https://github.com/msys2/msys2-installer/releases/download/2025-08-30/msys2-x86_64-20250830.exe" -OutFile "msys2-installer.exe" -# Start-Process -Wait -FilePath "msys2-installer.exe" -ArgumentList "/S" -# C:\msys64\usr\bin\bash.exe -lc "pacman -Syu --noconfirm" -# C:\msys64\usr\bin\bash.exe -lc "export ARCH=x86_64; export MINGW=mingw64; pacman -S --noconfirm mingw-w64-$ARCH-gcc mingw-w64-$ARCH-boost mingw-w64-$ARCH-openssl git make" +## uses: msys2/setup-msys2@v2 + # with: + # msystem: CLANG64 + # install: base-devel git mingw-w64-x86_64-clang mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-miniupnpc + # update: true - name: Initialize Git Submodules run: git submodule update --init --recursive + ####################### + # Build Project + ####################### - name: Build Project (Ubuntu) if: matrix.os == 'ubuntu-latest' run: | - make -j8 + make -j$(nproc) make stripall make builddir -# + + - name: Build Project (macOS) + if: matrix.os == 'macos-latest' + run: | + make HOMEBREW=1 -j8 + make stripall + make builddir + # - name: Build Project (Windows) # if: matrix.os == 'windows-latest' -# run: | -# C:\msys64\usr\bin\bash.exe -lc "cd /c/runner/work/i2pd-tools/i2pd-tools && make && make stripall && make builddir" -# +## shell: msys2 {0} + # run: | + # cd "${GITHUB_WORKSPACE}" + # make -j$(nproc) + # make stripall + # make builddir + + ####################### + # Upload binaries + ####################### - name: Upload binaries uses: actions/upload-artifact@v4 with: diff --git a/Makefile b/Makefile index e8ccd4f..ce72543 100755 --- a/Makefile +++ b/Makefile @@ -1,59 +1,64 @@ -UNAME = $(shell uname -s) +UNAME := $(shell uname -s) -I2PD_PATH = i2pd -I2PD_LIB = libi2pd.a +I2PD_PATH := i2pd +I2PD_LIB := libi2pd.a -LIBI2PD_PATH = $(I2PD_PATH)/libi2pd -LIBI2PD_CLIENT_PATH = $(I2PD_PATH)/libi2pd_client +LIBI2PD_PATH := $(I2PD_PATH)/libi2pd +LIBI2PD_CLIENT_PATH := $(I2PD_PATH)/libi2pd_client CXX ?= g++ -CXXFLAGS = -Wall -std=c++17 -O2 -INCFLAGS = -I$(LIBI2PD_PATH) -I$(LIBI2PD_CLIENT_PATH) -DEFINES = -DOPENSSL_SUPPRESS_DEPRECATED - -LDFLAGS = -LDLIBS = $(I2PD_PATH)/$(I2PD_LIB) -lboost_system$(BOOST_SUFFIX) -lboost_program_options$(BOOST_SUFFIX) -lssl -lcrypto -lz +CXXFLAGS := -Wall -std=c++17 -O2 +INCFLAGS := -I$(LIBI2PD_PATH) -I$(LIBI2PD_CLIENT_PATH) +DEFINES := -DOPENSSL_SUPPRESS_DEPRECATED +LDFLAGS := +LDLIBS := $(I2PD_PATH)/$(I2PD_LIB) -lboost_program_options$(BOOST_SUFFIX) -lssl -lcrypto -lz ifeq ($(UNAME),Linux) - CXXFLAGS += -g + CXXFLAGS += -g + LDLIBS += -lrt -lpthread else ifeq ($(UNAME),Darwin) - CXXFLAGS += -g + CXXFLAGS += -g + LDLIBS += -lpthread + + ifeq ($(shell test -d /opt/homebrew && echo "true"),true) + BREW_PREFIX := /opt/homebrew + else + BREW_PREFIX := /usr/local + endif + + INCFLAGS += -I$(BREW_PREFIX)/include -I$(BREW_PREFIX)/opt/openssl@3/include + LDFLAGS += -L$(BREW_PREFIX)/lib -L$(BREW_PREFIX)/opt/openssl@3/lib + + LDLIBS += -lboost_program_options else ifeq ($(UNAME),FreeBSD) - CXXFLAGS += -g + CXXFLAGS += -g + LDLIBS += -lthr -lpthread + LDFLAGS += -L/usr/local/lib + INCFLAGS += -I/usr/local/include else -# Win32 - CXXFLAGS += -Os -fPIC -msse - DEFINES += -DWIN32_LEAN_AND_MEAN - BOOST_SUFFIX = -mt + # Windows + CXXFLAGS += -Os -fPIC -msse + DEFINES += -DWIN32_LEAN_AND_MEAN + LDFLAGS += -L/clang64/lib + INCFLAGS += -I/clang64/include + BOOST_SUFFIX = + LDLIBS += -lwsock32 -lws2_32 -liphlpapi -lpthread endif -ifeq ($(UNAME),Linux) - LDLIBS += -lrt -lpthread -else ifeq ($(UNAME),Darwin) - LDLIBS += -lpthread - LDFLAGS += -L/usr/local/opt/openssl@1.1/lib -L/usr/local/lib - INCFLAGS += -I/usr/local/opt/openssl@1.1/include -I/usr/local/include -else ifeq ($(UNAME),FreeBSD) - LDLIBS += -lthr -lpthread - LDFLAGS += -L/usr/local/lib - INCFLAGS += -I/usr/local/include -else -# Win32 - LDLIBS += -lwsock32 -lws2_32 -liphlpapi -lpthread - LDFLAGS += -s -static -endif - - +# ------------------------- +# Targets +# ------------------------- all: $(I2PD_LIB) vain keygen keyinfo famtool routerinfo regaddr regaddr_3ld i2pbase64 offlinekeys b33address regaddralias x25519 verifyhost autoconf -vain: vain.o $(I2PD_LIB) + +vain: vain.o $(I2PD_LIB) $(CXX) -o vain $(LDFLAGS) vain.o $(LDLIBS) autoconf: autoconf.o $(I2PD_LIB) $(CXX) -o autoconf $(DEFINES) $(LDFLAGS) autoconf.o $(LDLIBS) routerinfo: routerinfo.o $(I2PD_LIB) - $(CXX) -o routerinfo $(LDFLAGS) routerinfo.o $(LDLIBS) -latomic + $(CXX) -o routerinfo $(LDFLAGS) routerinfo.o $(LDLIBS) keygen: keygen.o $(I2PD_LIB) $(CXX) -o keygen $(DEFINES) $(LDFLAGS) keygen.o $(LDLIBS) @@ -62,7 +67,7 @@ keyinfo: keyinfo.o $(I2PD_LIB) $(CXX) -o keyinfo $(DEFINES) $(LDFLAGS) keyinfo.o $(LDLIBS) famtool: famtool.o $(I2PD_LIB) - $(CXX) -o famtool $(DEFINES) $(LDFLAGS) famtool.o $(LDLIBS) -latomic + $(CXX) -o famtool $(DEFINES) $(LDFLAGS) famtool.o $(LDLIBS) regaddr: regaddr.o $(I2PD_LIB) $(CXX) -o regaddr $(DEFINES) $(LDFLAGS) regaddr.o $(LDLIBS) @@ -88,7 +93,9 @@ x25519: x25519.o $(I2PD_LIB) verifyhost: verifyhost.o $(I2PD_LIB) $(CXX) -o verifyhost $(DEFINES) $(LDFLAGS) verifyhost.o $(LDLIBS) -.SUFFIXES: +# ------------------------- +# Object compilation +# ------------------------- .SUFFIXES: .c .cc .C .cpp .o $(I2PD_LIB): @@ -97,6 +104,9 @@ $(I2PD_LIB): %.o: %.cpp $(I2PD_LIB) $(CXX) $(CXXFLAGS) $(DEFINES) $(INCFLAGS) -c -o $@ $< +# ------------------------- +# Cleanup +# ------------------------- count: wc *.c *.cc *.C *.cpp *.h *.hpp @@ -105,19 +115,18 @@ clean-i2pd: clean-obj: rm -f $(wildcard *.o) + stripall: strip b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf + builddir: mkdir -p build mv b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf build/ || true + clean-bin: rm -f b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf clean: clean-i2pd clean-obj clean-bin -.PHONY: all -.PHONY: count -.PHONY: clean-i2pd -.PHONY: clean-obj -.PHONY: clean-bin -.PHONY: clean +.PHONY: all count clean-i2pd clean-obj clean-bin clean +