-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmakefile
More file actions
72 lines (54 loc) · 1.57 KB
/
makefile
File metadata and controls
72 lines (54 loc) · 1.57 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
VERSION ?= dev
CC = gcc
CFLAGS = -g -O2 -W -Wall -I. -DPACKAGE_VERSION=\"$(VERSION)\"
LDFLAGS =
LIBS = -lutil
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
STATIC_FLAG =
else
STATIC_FLAG = -static
endif
OBJ = attach.o master.o atch.o
SRC = attach.c master.c atch.c
IMAGE = atch-builder
BUILDDIR ?= .
archs = amd64 arm64
arch ?= $(shell arch)
atch: $(OBJ)
$(CC) -o $(BUILDDIR)/$@ $(STATIC_FLAG) $(LDFLAGS) $(OBJ) $(LIBS)
atch.1.md: README.md scripts/readme2man.sh
bash scripts/readme2man.sh $< > $@
atch.1: atch.1.md
pandoc --standalone -t man $< -o $@
man: atch.1
clean:
rm -f atch $(OBJ) *.1.md *.c~
.PHONY: fmt
fmt:
docker run --rm -v "$$PWD":/src -w /src alpine:latest sh -c "apk add --no-cache indent && indent -linux $(SRCS) && indent -linux $(SRCS)"
.PHONY: fmt-all
fmt-all:
$(MAKE) fmt SRCS="*.c"
attach.o: ./attach.c ./atch.h config.h
master.o: ./master.c ./atch.h config.h
atch.o: ./atch.c ./atch.h config.h
.PHONY: build-image
build-image:
docker build -t $(IMAGE):$(arch) --platform linux/$(arch) -f build.dockerfile .
build-docker: build-image
$(MAKE) clean
docker run --rm -v "$$PWD":/src -e VERSION=$(VERSION) -w /src \
--platform linux/$(arch) $(IMAGE):$(arch) ./build.sh
.PHONY: test
test: build-docker
docker run --rm -v "$$PWD":/src \
--platform linux/$(arch) $(IMAGE):$(arch) \
sh /src/tests/test.sh /src/build/atch
.PHONY: release
release: man $(archs)
$(archs):
mkdir -p release
$(MAKE) build-docker arch=$@ VERSION=$(VERSION)
export COPYFILE_DISABLE=true; \
tar -czf ./release/atch-linux-$@.tgz README.md atch.1 -C ./build atch; \