Skip to content

Commit

Permalink
make: multi-os
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesob committed Jan 27, 2025
1 parent ce3ae20 commit 1ed61df
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ jobs:
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install secp256k1 libsodium python3 go
sudo mkdir -p /usr/local/{lib,include}
sudo chmod 755 /usr/local/{lib,include}
fi
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.uv/bin" >> $GITHUB_PATH
Expand Down
38 changes: 35 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
CC := $(shell command -v clang 2>/dev/null || command -v $(CC) 2>/dev/null || echo cc)
CFLAGS = -DDEBUG -Wall -Werror
LDFLAGS = -lsecp256k1 -lsodium
CFLAGS = -Wall -Werror
ifdef DEBUG
CFLAGS += -g -DDEBUG
else
CFLAGS += -O2
endif

LDCONFIG := ldconfig

UNAME_S := $(shell uname -s)

# Set default paths
STD_INCLUDE_PATHS := /usr/local/include
STD_LIB_PATHS := /usr/local/lib

# Add Homebrew paths for macOS
ifeq ($(UNAME_S),Darwin)
UNAME_MACHINE := $(shell uname -m)
LDCONFIG := ls
ifeq ($(UNAME_MACHINE),arm64)
BREW_PREFIX := /opt/homebrew
else
BREW_PREFIX := /usr/local
endif
INCLUDE_PATHS := $(BREW_PREFIX)/include $(STD_INCLUDE_PATHS)
LIB_PATHS := $(BREW_PREFIX)/lib $(STD_LIB_PATHS)
else
INCLUDE_PATHS := $(STD_INCLUDE_PATHS)
LIB_PATHS := $(STD_LIB_PATHS)
endif

# Convert paths to compiler flags
CFLAGS += $(foreach path,$(INCLUDE_PATHS),-I$(path))
LDFLAGS += $(foreach path,$(LIB_PATHS),-L$(path)) -lsecp256k1 -lsodium

all: libbip32.so
$(CC) $(CFLAGS) -o bip32-cli cli.c libbip32.so $(LDFLAGS)
Expand All @@ -24,7 +56,7 @@ fuzz: fuzz_target
install: libbip32.so
install -m755 libbip32.so /usr/local/lib/
install -m755 bip32.h /usr/local/include/
ldconfig
$(LDCONFIG)

.PHONY: clean
clean:
Expand Down

0 comments on commit 1ed61df

Please sign in to comment.