-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
77 lines (59 loc) · 1.58 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
NAME=ulas
IDIR=./src
SDIR=./src
CC=gcc
DBGCFLAGS=-g -fsanitize=address
DBGLDFLAGS=-fsanitize=address
CFLAGS=-I$(IDIR) -Wall -pedantic $(DBGCFLAGS) -std=gnu99
LIBS=
TEST_LIBS=
LDFLAGS=$(DBGLDFLAGS) $(LIBS)
TAG_LIBS=/usr/include/unistd.h /usr/include/stdio.h /usr/include/stdlib.h /usr/include/assert.h /usr/include/errno.h /usr/include/ctype.h
ODIR=obj
TEST_ODIR=obj/test
BDIR=bin
BNAME=$(NAME)
MAIN=main.o
TEST_MAIN=test.o
TEST_BNAME=testulas
BIN_INSTALL_DIR=/usr/local/bin
MAN_INSTALL_DIR=/usr/local/man
_OBJ = $(MAIN) ulas.o archs.o uldas.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
all: bin test
release:
make DBGCFLAGS="" DBGLDFLAGS=""
$(ODIR)/%.o: src/%.c src/*.h
mkdir -p $(@D)
$(CC) -c -o $@ $< $(CFLAGS) $(LDFLAGS)
bin: $(OBJ)
mkdir -p $(BDIR)
$(CC) -o $(BDIR)/$(BNAME) $^ $(CFLAGS) $(LDFLAGS)
test:
echo "building tests"
make bin MAIN=$(TEST_MAIN) BNAME=$(TEST_BNAME) ODIR=$(TEST_ODIR) LIBS=$(TEST_LIBS)
.PHONY: clean
clean:
rm -f ./$(ODIR)/*.o
rm -f ./$(TEST_ODIR)/*.o
rm -f ./$(BDIR)/$(BNAME)
rm -f ./$(BDIR)/$(TEST_BNAME)
.PHONY: install
install:
cp ./$(BDIR)/$(BNAME) $(BIN_INSTALL_DIR)
cp ./doc/$(BNAME).man $(MAN_INSTALL_DIR)
.PHONY: tags
tags:
ctags --recurse=yes --exclude=.git --exclude=bin --exclude=obj --extras=* --fields=* --c-kinds=* --language-force=C $(TAG_LIBS) .
.PHONY:
ccmds:
bear -- make SHELL="sh -x -e" --always-make
.PHONY: format
format:
clang-format -i ./src/*.c ./src/*.h
.PHONY: lint
lint:
clang-tidy ./src/*.h ./src/*.c
buildtests:
./$(BDIR)/$(BNAME) tests/t0.s -l - -o tests/t0.bin
./$(BDIR)/$(BNAME) tests/t0.bin -d - -o tests/t0_dasm.s