This moves the main package to cmd/mkinitfs, and configures the compiled binary to be named 'mkinitfs'. calling the full name 'postmarketos-mkinitfs' was unlikely to be used by anyone... This move makes the project source layout more consistent with other Go projects, and allows for adding more cmd/* things with their own main packages later if we want
52 lines
912 B
Makefile
52 lines
912 B
Makefile
.POSIX:
|
|
.SUFFIXES:
|
|
|
|
PREFIX?=/usr/local
|
|
BINDIR?=$(PREFIX)/sbin
|
|
SHAREDIR?=$(PREFIX)/share
|
|
GO?=go
|
|
GOFLAGS?=
|
|
LDFLAGS+=-s -w
|
|
RM?=rm -f
|
|
GOTEST=go test -count=1 -race
|
|
|
|
GOSRC!=find * -name '*.go'
|
|
GOSRC+=go.mod go.sum
|
|
|
|
all: mkinitfs
|
|
|
|
mkinitfs: $(GOSRC)
|
|
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o mkinitfs ./cmd/mkinitfs
|
|
|
|
.PHONY: fmt
|
|
fmt:
|
|
gofmt -w .
|
|
|
|
test:
|
|
@if [ `gofmt -l . | wc -l` -ne 0 ]; then \
|
|
gofmt -d .; \
|
|
echo "ERROR: source files need reformatting with gofmt"; \
|
|
exit 1; \
|
|
fi
|
|
@staticcheck ./...
|
|
|
|
@$(GOTEST) ./...
|
|
|
|
clean:
|
|
$(RM) mkinitfs
|
|
|
|
install: $(DOCS) mkinitfs
|
|
install -Dm755 mkinitfs -t $(DESTDIR)$(BINDIR)/
|
|
|
|
.PHONY: checkinstall
|
|
checkinstall:
|
|
test -e $(DESTDIR)$(BINDIR)/mkinitfs
|
|
|
|
RMDIR_IF_EMPTY:=sh -c '! [ -d $$0 ] || ls -1qA $$0 | grep -q . || rmdir $$0'
|
|
|
|
uninstall:
|
|
$(RM) $(DESTDIR)$(BINDIR)/mkinitfs
|
|
${RMDIR_IF_EMPTY} $(DESTDIR)$(BINDIR)
|
|
|
|
.PHONY: all clean install uninstall test
|