From e393f84799651e420ad652da43d575849b33bd01 Mon Sep 17 00:00:00 2001 From: Jevin Sweval Date: Thu, 15 Dec 2022 11:27:32 -0500 Subject: [PATCH] Fix sim module build on MacOS arm64 --- litex/build/sim/core/Makefile | 10 ++++++++-- .../build/sim/core/modules/gmii_ethernet/Makefile | 1 + litex/build/sim/core/modules/rules.mak | 15 +++++++++++---- .../sim/core/modules/xgmii_ethernet/Makefile | 1 + 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/litex/build/sim/core/Makefile b/litex/build/sim/core/Makefile index e662f27fe..8eda365b7 100644 --- a/litex/build/sim/core/Makefile +++ b/litex/build/sim/core/Makefile @@ -1,9 +1,15 @@ include variables.mak UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) ifeq ($(UNAME_S),Darwin) - CFLAGS += -I/usr/local/include/ - LDFLAGS += -L/usr/local/lib + ifeq ($(UNAME_M),x86_64) + CFLAGS += -I/usr/local/include + LDFLAGS += -L/usr/local/lib + else + CFLAGS += -I/opt/homebrew/include + LDFLAGS += -L/opt/homebrew/lib + endif LDFLAGS += -lpthread -ljson-c -lz -lm -lstdc++ -ldl -levent else CC ?= gcc diff --git a/litex/build/sim/core/modules/gmii_ethernet/Makefile b/litex/build/sim/core/modules/gmii_ethernet/Makefile index 392ede182..862c8057c 100644 --- a/litex/build/sim/core/modules/gmii_ethernet/Makefile +++ b/litex/build/sim/core/modules/gmii_ethernet/Makefile @@ -4,6 +4,7 @@ UNAME_S := $(shell uname -s) include $(SRC_DIR)/modules/rules.mak CFLAGS += -I$(TAPCFG_DIRECTORY)/src/include +LDFLAGS += -lz OBJS = $(MOD).o tapcfg.o taplog.o $(MOD).so: $(OBJS) diff --git a/litex/build/sim/core/modules/rules.mak b/litex/build/sim/core/modules/rules.mak index 52d9aa90e..b14b99eee 100644 --- a/litex/build/sim/core/modules/rules.mak +++ b/litex/build/sim/core/modules/rules.mak @@ -1,12 +1,19 @@ CC ?= gcc UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) ifeq ($(UNAME_S),Darwin) - CFLAGS += -I/usr/local/include/ - LDFLAGS += -L/usr/local/lib -ljson-c - CFLAGS += -Wall -O3 -ggdb -fPIC + ifeq ($(UNAME_M),x86_64) + CFLAGS += -I/usr/local/include + LDFLAGS += -L/usr/local/lib + else + CFLAGS += -I/opt/homebrew/include + LDFLAGS += -L/opt/homebrew/lib + endif + LDFLAGS += -ljson-c + CFLAGS += -Wall -O3 -ggdb -fPIC else - CFLAGS += -Wall -O3 -ggdb -fPIC -Werror + CFLAGS += -Wall -O3 -ggdb -fPIC -Werror endif LDFLAGS += -levent -shared -fPIC diff --git a/litex/build/sim/core/modules/xgmii_ethernet/Makefile b/litex/build/sim/core/modules/xgmii_ethernet/Makefile index 392ede182..862c8057c 100644 --- a/litex/build/sim/core/modules/xgmii_ethernet/Makefile +++ b/litex/build/sim/core/modules/xgmii_ethernet/Makefile @@ -4,6 +4,7 @@ UNAME_S := $(shell uname -s) include $(SRC_DIR)/modules/rules.mak CFLAGS += -I$(TAPCFG_DIRECTORY)/src/include +LDFLAGS += -lz OBJS = $(MOD).o tapcfg.o taplog.o $(MOD).so: $(OBJS)