-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (68 loc) · 1.75 KB
/
Makefile
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
CWD=$(shell pwd)
AR ?= ar
CC ?= gcc
PREFIX ?= /usr/local
SCANBUILD ?= scan-build
uname = $(shell uname -s)
CFLAGS = -c -g -O0 -Wall -std=c99
SRCS = $(wildcard src/*.c)
INCS = -Iinclude/
OBJS = $(SRCS:.c=.o)
TEST_SRCS = $(wildcard test/*.c)
TESTS = $(addprefix bin/,$(TEST_SRCS:.c=))
LIBSTS = build/libsts.a
EXAMPLE = example
show:
@echo src: $(TEST_SRCS)
@echo bin: $(TESTS)
all: clean $(LIBSTS)
$(LIBSTS): $(OBJS)
@mkdir -p build
$(AR) rcs $@ $(OBJS)
run: run-pipe-thru
run-file-stream: bin/file-stream-transform
@echo "\n\033[1;33m>>>\033[0m"
$<
@echo "\n\033[1;33m<<<\033[0m\n"
make clean
run-pipe-thru: bin/pipe-thru-transforms
@echo "\n\033[1;33m>>>\033[0m"
$<
@echo "\n\033[1;33m<<<\033[0m\n"
make clean
bin/pipe-thru-transforms: $(OBJS) examples/pipe-thru-transforms.o
@mkdir -p bin
$(CC) $(LDFLAGS) $(OBJS) examples/pipe-thru-transforms.o -o $@
bin/file-stream-transform: $(OBJS) examples/file-stream-transform.o
@mkdir -p bin
$(CC) $(LDFLAGS) $(OBJS) examples/file-stream-transform.o -o $@
install: all
cp -f $(LIBSTS) $(PREFIX)/lib/libsts.a
cp -f src/sts.h $(PREFIX)/include/sts.h
uninstall:
rm -f $(PREFIX)/lib/libsts.a
rm -f $(PREFIX)/include/sts.h
check: all
$(SCANBUILD) $(MAKE) test
test: $(TESTS)
set -e; for file in $^; do echo "\n\033[00;32m+++ $$file +++\033[00m\n" && ./$$file; done
bin/test/%: $(OBJS) test/%.o
@mkdir -p bin/test
$(CC) $(LDFLAGS) $^ -o $@
ifeq ($(uname),Darwin)
dsymutil $@
endif
.SUFFIXES: .c .o
.c.o:
$(CC) $< $(CFLAGS) $(INCS) -o $@
clean:
find . -name "*.gc*" -exec rm {} \;
rm -rf `find . -name "*.dSYM" -print`
rm -rf bin $(OBJS)
rm -rf examples/*.o
rm -rf test/*.o
rm -f test/fixtures/sample.out.txt
rm -rf deps/**/build
.PHONY: clean
include valgrind.mk
include container.mk