-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (41 loc) · 1.61 KB
/
Copy pathMakefile
File metadata and controls
52 lines (41 loc) · 1.61 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
# SimPed Makefile
# -----------------------------------------------------------------------------
# Builds the `simped` executable from src/simped.c with a recent C compiler.
# Tested with clang on macOS 14+ (Apple Silicon and Intel) and gcc on Linux.
#
# Common targets:
# make -> builds ./simped (release flags)
# make debug -> builds ./simped with -g and no optimization
# make check -> builds, runs the bundled examples and diffs the result
# against the precompiled reference outputs
# make install -> installs into $(PREFIX)/bin (default PREFIX=/usr/local)
# make uninstall -> removes the installed binary
# make clean -> removes build artefacts
# -----------------------------------------------------------------------------
CC ?= cc
CSTD ?= -std=c99
CFLAGS ?= -O2 -Wall -Wextra -Wno-unused-result $(CSTD)
LDFLAGS ?=
LIBS ?= -lm
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
SRC := src/simped.c
BIN := simped
.PHONY: all debug clean install uninstall check
all: $(BIN)
$(BIN): $(SRC)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(SRC) $(LIBS)
debug: CFLAGS := -g -O0 -Wall -Wextra $(CSTD)
debug: clean $(BIN)
install: $(BIN)
install -d $(DESTDIR)$(BINDIR)
install -m 0755 $(BIN) $(DESTDIR)$(BINDIR)/$(BIN)
uninstall:
rm -f $(DESTDIR)$(BINDIR)/$(BIN)
check: $(BIN)
@cd examples && ../$(BIN) input1.dat >/dev/null && \
echo "input1.dat: OK ($$(wc -l < pedfile1.pre) lines emitted)"
@cd examples && ../$(BIN) input2.dat >/dev/null && \
echo "input2.dat: OK ($$(wc -l < pedfile2.pre) lines emitted)"
clean:
rm -f $(BIN) examples/pedfile*.pre