-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (47 loc) · 1.55 KB
/
Copy pathMakefile
File metadata and controls
60 lines (47 loc) · 1.55 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
CC ?= cc
CFLAGS ?= -std=c11 -Wall -Wextra -O2
CPPFLAGS ?= -DABOUT_VERSION=\"$(VERSION)\"
VERSION ?= 0.3.0
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
SRC = src/about.c
BIN = about
COSMOCC ?= cosmocc
COSMOCC_DIR ?= .cosmocc
# Fat amd64+arm64 by default. On WSL, prefer: make ape COSMOCC_FLAGS=-m64
COSMOCC_FLAGS ?=
.PHONY: all clean install uninstall ape ape-toolchain test smoke
all: $(BIN)
$(BIN): $(SRC)
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $(SRC)
ape-toolchain:
@if [ ! -x "$(COSMOCC_DIR)/bin/$(COSMOCC)" ]; then \
echo "Downloading cosmocc toolchain…"; \
mkdir -p "$(COSMOCC_DIR)"; \
curl -fsSL -o /tmp/cosmocc.zip https://cosmo.zip/pub/cosmocc/cosmocc.zip; \
unzip -qo /tmp/cosmocc.zip -d "$(COSMOCC_DIR)"; \
rm -f /tmp/cosmocc.zip; \
fi
ape: ape-toolchain
@if [ -f /proc/sys/fs/binfmt_misc/WSLInterop ]; then \
echo "Note: on WSL, APE often needs: sudo sh -c 'echo -1 > /proc/sys/fs/binfmt_misc/WSLInterop'"; \
fi
$(COSMOCC_DIR)/bin/$(COSMOCC) $(COSMOCC_FLAGS) $(CPPFLAGS) -O2 -o $(BIN).com $(SRC)
@echo "Built Actually Portable Executable: $(BIN).com"
@echo "Runs on Linux, macOS, Windows, and BSDs (amd64 + arm64)."
smoke: $(BIN)
./$(BIN) --version
./$(BIN) -q
./$(BIN) --tips >/dev/null
./$(BIN) --nu --tips >/dev/null
./$(BIN) --format nuon >/dev/null
./$(BIN) about >/dev/null || true
./$(BIN) tar >/dev/null || true
test: smoke
install: $(BIN)
install -d "$(DESTDIR)$(BINDIR)"
install -m 755 $(BIN) "$(DESTDIR)$(BINDIR)/$(BIN)"
uninstall:
rm -f "$(DESTDIR)$(BINDIR)/$(BIN)"
clean:
rm -f $(BIN) $(BIN).exe $(BIN).com $(BIN).com.dbg