diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a666064..c453b4f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: name: Integration tests strategy: matrix: - platform: [macos-10.15, macos-11] + platform: [macos-11] runs-on: ${{ matrix.platform }} timeout-minutes: 40 steps: @@ -26,47 +26,19 @@ jobs: ifconfig - name: Install build dependencies of VDE run: brew install autoconf automake - - name: Make and Install VDE + - name: Make Install (x86_64) run: | - git clone https://github.com/virtualsquare/vde-2.git /tmp/vde-2 - cd /tmp/vde-2 - # Dec 12, 2021 - git checkout 74278b9b7cf816f0356181f387012fdeb6d65b52 - autoreconf -fis # compile for x86_64 - ./configure --prefix=/opt/vde - make PREFIX=/opt/vde - sudo make PREFIX=/opt/vde install - # cleanup - make distclean - # cross-compile for arm64 - export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) - export CC=$(xcrun --sdk macosx --find clang) - export CXX=$(xcrun --sdk macosx --find clang++) - export CFLAGS="-arch arm64e -isysroot $SDKROOT -Wno-error=implicit-function-declaration" - export CXXFLAGS=$CFLAGS - ./configure --prefix=/opt/vde.arm64 --host=arm-apple-darwin --target=arm-apple-darwin --build=x86_64-apple-darwin - make PREFIX=/opt/vde.arm64 - sudo make PREFIX=/opt/vde.arm64 install - unset SDKROOT CC CXX CFLAGS CXXFLAGS - - name: Make and Install vde_vmnet (x86_64) - run: | - git clone https://github.com/lima-vm/vde_vmnet.git /tmp/vde_vmnet - cd /tmp/vde_vmnet - make PREFIX=/opt/vde sudo make PREFIX=/opt/vde install + file /opt/vde/bin/* | grep -c x86_64 - name: Cleanup run: | - make clean - - name: Make and Install vde_vmnet (arm64) + sudo make clean + - name: Make Install (arm64) run: | - export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) - export CC=$(xcrun --sdk macosx --find clang) - export CXX=$(xcrun --sdk macosx --find clang++) - export CFLAGS="-arch arm64e -isysroot $SDKROOT -Wno-error=implicit-function-declaration" - export CXXFLAGS=$CFLAGS - make PREFIX=/opt/vde.arm64 - sudo make PREFIX=/opt/vde.arm64 install + # cross-compile for arm64 + sudo make PREFIX=/opt/vde.arm64 ARCH=arm64 install + file /opt/vde.arm64/bin/* | grep -c arm64 - name: Print launchd status (shared mode) run: launchctl print system/io.github.lima-vm.vde_vmnet.plist - name: Install test dependencies diff --git a/Makefile b/Makefile index 7c14726..ec40bb9 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,26 @@ PREFIX ?= /opt/vde # VDEPREFIX should be only writable by the root to avoid privilege escalation with launchd or sudo VDEPREFIX ?= $(PREFIX) -CFLAGS ?= -O3 +VMNET_CFLAGS ?= -O3 VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags) -CFLAGS += -I"$(VDEPREFIX)/include" -DVERSION=\"$(VERSION)\" -LDFLAGS += -L"$(VDEPREFIX)/lib" -lvdeplug -framework vmnet +VMNET_CFLAGS += -I"$(VDEPREFIX)/include" -DVERSION=\"$(VERSION)\" + +VMNET_LDFLAGS += -L"$(VDEPREFIX)/lib" -lvdeplug -framework vmnet + +# ARCH support arm64 and x86_64 +ARCH ?= + +ifneq (,$(findstring arm64,$(ARCH))) + HOST ?= --host arm-apple-darwin + VMNET_CFLAGS += -arch arm64 + VDE2_CFLAGS += -arch arm64 -Wno-error=implicit-function-declaration +else ifneq (,$(findstring x86_64,$(ARCH))) + HOST ?= --host x86_64-apple-darwin + VMNET_CFLAGS += -arch x86_64 + VDE2_CFLAGS += -arch x86_64 -Wno-error=implicit-function-declaration +endif # Interface name for bridged mode. Empty value (default) disables bridged mode. BRIDGED ?= @@ -19,17 +33,17 @@ all: vde_vmnet OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) %.o: %.c *.h - $(CC) $(CFLAGS) -c $< -o $@ + $(CC) $(VMNET_CFLAGS) -c $< -o $@ vde_vmnet: $(OBJS) - $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(OBJS) + $(CC) $(VMNET_CFLAGS) -o $@ $(VMNET_LDFLAGS) $(OBJS) install.bin: vde_vmnet install vde_vmnet "$(DESTDIR)/$(PREFIX)/bin/vde_vmnet" install.vde-2: git submodule update --init - cd vde-2 && autoreconf -fis && CFLAGS="" LDFLAGS="" ./configure --prefix=$(VDEPREFIX) && make && make install + cd vde-2 && autoreconf -fis && CFLAGS="$(VDE2_CFLAGS)" ./configure --prefix=$(VDEPREFIX) $(HOST) && make && make install install.launchd.plist: launchd/*.plist sed -e "s@/opt/vde@$(PREFIX)@g" launchd/io.github.virtualsquare.vde-2.vde_switch.plist > "$(DESTDIR)/Library/LaunchDaemons/io.github.virtualsquare.vde-2.vde_switch.plist" @@ -77,6 +91,10 @@ endif uninstall: uninstall.launchd.plist uninstall.bin uninstall.vde-2 +.PHONY: clean.vde-2 +clean.vde-2: + cd vde-2 && make distclean + .PHONY: clean -clean: +clean: clean.vde-2 rm -f vde_vmnet *.o