-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (36 loc) · 849 Bytes
/
Makefile
File metadata and controls
44 lines (36 loc) · 849 Bytes
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
export NAME:=main
export TESTS
export CFLAGS:=-Wall -std=c11 -pedantic -Wextra -Wno-implicit-fallthrough -I../include $(CFLAGS)
export LDLIBS:=-lm
PREFIX:=${or $(PREFIX),$(PREFIX),/usr/local}
includes=${wildcard include/*.h}
ifdef DEBUG
CFLAGS:=$(CFLAGS) -g -DDEBUG
else
CFLAGS:=$(CFLAGS) -O3 -DNDEBUG
endif
.PHONY: build
build:
$(MAKE) -C src
.PHONY: example
example:
$(MAKE) -C src $(NAME)
cp src/$(NAME) $(NAME)$(EXE)
.PHONY: test
test: build
$(MAKE) -C test
.PHONY: install
install: build
mkdir -p "$(PREFIX)/lib"
mkdir -p "$(PREFIX)/include"
cp src/lib$(NAME).a "$(PREFIX)/lib"
cp $(includes) "$(PREFIX)/include"
.PHONY: uninstall
uninstall:
$(RM) "$(PREFIX)/lib/lib$(NAME).a"
$(RM) ${foreach header,$(includes),"$(PREFIX)/$(header)"}
.PHONY: clean
clean:
$(MAKE) -C src clean
$(MAKE) -C test clean
$(RM) $(NAME)$(EXE)