| 1 |
MAKEFLAGS += --silent |
| 2 |
|
| 3 |
TARGET = hd-idle |
| 4 |
PLATFORM := $(shell uname -m) |
| 5 |
|
| 6 |
ARCH := |
| 7 |
ifeq ($(PLATFORM),x86_64) |
| 8 |
ARCH = amd64 |
| 9 |
endif |
| 10 |
ifeq ($(PLATFORM),aarch64) |
| 11 |
ARCH = arm64 |
| 12 |
endif |
| 13 |
ifeq ($(PLATFORM),armv7l) |
| 14 |
ARCH = armhf |
| 15 |
endif |
| 16 |
GOARCH := |
| 17 |
ifeq ($(ARCH),amd64) |
| 18 |
GOARCH = amd64 |
| 19 |
endif |
| 20 |
ifeq ($(ARCH),i386) |
| 21 |
GOARCH = 386 |
| 22 |
endif |
| 23 |
ifeq ($(ARCH),arm64) |
| 24 |
GOARCH = arm64 |
| 25 |
endif |
| 26 |
ifeq ($(ARCH),armhf) |
| 27 |
GOARCH = arm |
| 28 |
endif |
| 29 |
|
| 30 |
ifeq ($(GOARCH),) |
| 31 |
$(error Invalid ARCH: $(ARCH)) |
| 32 |
endif |
| 33 |
|
| 34 |
ifdef DESTDIR |
| 35 |
# dh_auto_install (Debian) sets this variable |
| 36 |
TARGET_DIR = $(DESTDIR)/usr |
| 37 |
else |
| 38 |
TARGET_DIR ?= /usr/local |
| 39 |
endif |
| 40 |
|
| 41 |
all: $(TARGET) |
| 42 |
|
| 43 |
distclean: clean |
| 44 |
|
| 45 |
clean: |
| 46 |
rm -f $(TARGET) |
| 47 |
|
| 48 |
install: $(TARGET) |
| 49 |
install -Dm755 $(TARGET) $(TARGET_DIR)/sbin/$(TARGET) |
| 50 |
install -Dm755 debian/$(TARGET).8 $(TARGET_DIR)/share/man/man8/$(TARGET).8 |
| 51 |
|
| 52 |
uninstall: |
| 53 |
rm -f $(TARGET_DIR)/sbin/$(TARGET) |
| 54 |
|
| 55 |
$(TARGET): |
| 56 |
GOOS=linux GOARCH=$(GOARCH) go build |
| 57 |
|
| 58 |
test: |
| 59 |
go test ./... -race -cover |