Skip to content

Commit

Permalink
enh(make): improve make file
Browse files Browse the repository at this point in the history
  • Loading branch information
tphakala committed Mar 27, 2024
1 parent 5cb90e3 commit fcd426a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,29 @@ LABELS_ZIP := internal/birdnet/labels.zip
# Default action
all: $(LABELS_ZIP) build

# Check required tools: go, unzip, git
check-tools:
@which go >/dev/null || { echo "go not found. Please download Go 1.22 or newer from https://go.dev/dl/ and follow the installation instructions."; exit 1; }
@which unzip >/dev/null || { sudo apt install -y unzip; }
@which git >/dev/null || { sudo apt install -y git; }

# Check and clone TensorFlow if not exists
check-tensorflow:
@if [ ! -f "$(HOME)/src/tensorflow/tensorflow/lite/c/c_api.h" ]; then \
echo "TensorFlow Lite C API header not found. Cloning TensorFlow source..."; \
mkdir -p $(HOME)/src; \
git clone --branch v2.14.0 --depth 1 https://github.com/tensorflow/tensorflow.git $(HOME)/src/tensorflow; \
else \
echo "TensorFlow Lite C API header exists."; \
fi

# labels.zip depends on all files in the labels directory
$(LABELS_ZIP): $(LABELS_FILES)
@echo "Creating or updating labels.zip from contents of internal/birdnet/labels/*"
@cd internal/birdnet/labels && zip -j $(CURDIR)/$(LABELS_ZIP) *

# Default build for local development
build:
build: check-tensorflow
$(CGO_FLAGS) go build $(LDFLAGS) -o $(BINARY_DIR)/$(BINARY_NAME)

# Build for Linux amd64
Expand Down

0 comments on commit fcd426a

Please sign in to comment.