@@ -59,6 +59,7 @@ make clean 2>/dev/null || true
5959
6060# Set up compiler flags for macOS
6161EXTRA_CFLAGS=" "
62+ EXTRA_LDFLAGS=" "
6263if [[ " $OSTYPE " == " darwin" * ]]; then
6364 # On macOS, add Homebrew paths for sparsehash
6465 if command -v brew & > /dev/null; then
@@ -68,11 +69,16 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
6869 echo -e " ${YELLOW} Using Homebrew prefix: ${BREW_PREFIX}${NC} "
6970 echo -e " ${YELLOW} Using sparsehash include: ${SPARSEHASH_PREFIX} /include${NC} "
7071 fi
72+
73+ # Build universal binary for macOS (x86_64 + arm64)
74+ EXTRA_CFLAGS=" ${EXTRA_CFLAGS} -arch x86_64 -arch arm64"
75+ EXTRA_LDFLAGS=" -arch x86_64 -arch arm64"
76+ echo -e " ${YELLOW} Building universal binary (x86_64 + arm64)${NC} "
7177fi
7278
7379# Build onion
7480echo -e " ${YELLOW} Compiling Onion...${NC} "
75- if make CFLAGS=" -Wall -O3 -std=c++11 ${EXTRA_CFLAGS} " ; then
81+ if make CFLAGS=" -Wall -O3 -std=c++11 ${EXTRA_CFLAGS} " LDFLAGS= " ${EXTRA_LDFLAGS} " ; then
7682 echo -e " ${GREEN} ✓ Compilation successful${NC} "
7783else
7884 echo -e " ${RED} ✗ Compilation failed${NC} "
8894# Get platform info
8995PLATFORM=$( uname -s | tr ' [:upper:]' ' [:lower:]' )
9096ARCH=$( uname -m)
97+
98+ # On macOS, use "universal" as arch since we build a fat binary
99+ if [[ " $OSTYPE " == " darwin" * ]]; then
100+ ARCH=" universal"
101+ fi
102+
91103echo -e " ${YELLOW} Platform: $PLATFORM -$ARCH ${NC} "
92104
93105# Create output directory
@@ -104,6 +116,12 @@ ln -sf "onion-$PLATFORM-$ARCH" "$OUTPUT_DIR/onion"
104116echo -e " ${GREEN} === Build Complete ===${NC} "
105117echo -e " ${GREEN} Binary location: $OUTPUT_DIR /onion-$PLATFORM -$ARCH ${NC} "
106118
119+ # On macOS, verify it's a universal binary
120+ if [[ " $OSTYPE " == " darwin" * ]]; then
121+ echo -e " ${YELLOW} Verifying universal binary architectures:${NC} "
122+ lipo -info " $OUTPUT_DIR /onion-$PLATFORM -$ARCH "
123+ fi
124+
107125# Verify binary works
108126if " $OUTPUT_DIR /onion-$PLATFORM -$ARCH " -h & > /dev/null; then
109127 echo -e " ${GREEN} ✓ Binary is executable and working${NC} "
0 commit comments