forked from danielpaulus/go-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (36 loc) · 1.16 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Makefile to build and run go-ios and the cdc-ncm network driver
# cdc-ncm needs to be executed with sudo on Linux for USB Access and setting
# up virtual TAP network devices.
# use Make build to build both binaries.
# Make run is a simple target that just runs the cdc-ncm driver with sudo
# For development, use "make up" to rebuild and run cdc-ncm quickly
# Name of your Go binaries
GO_IOS_BINARY_NAME=ios
NCM_BINARY_NAME=go-ncm
# Detect the system architecture
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
# Default GOARCH value
GOARCH := amd64
# Set GOARCH based on the detected architecture
ifeq ($(UNAME_M),x86_64)
GOARCH := amd64
else ifeq ($(UNAME_M),armv7l)
GOARCH := arm
else ifeq ($(UNAME_M),aarch64)
GOARCH := arm64
# Add more architecture mappings as needed
endif
# Build the Go program
build:
@go work use .
@GOARCH=$(GOARCH) go build -o $(GO_IOS_BINARY_NAME) ./main.go
@go work use ./ncm
@CGO_ENABLED=1 GOARCH=$(GOARCH) go build -o $(NCM_BINARY_NAME) ./cmd/cdc-ncm/main.go
# Run the Go program with sudo
run: build
@sudo ./$(NCM_BINARY_NAME) --prometheusport=8080
# Build and run
up: build run
# Phony targets
.PHONY: build run up