-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (51 loc) · 1.15 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
## Project settings
PROJECT_NAME ?= GlisyVAO
PREFIX ?= /usr/local
## Project command dependencies
MKDIR ?= mkdir -p
RM ?= rm -f
CP ?= cp -f
## Source files
SRC += $(wildcard src/*.c)
## Source objects
OBJS := $(SRC:.c=.o)
## Compiler flags
CFLAGS += -Ideps
CFLAGS += -Iinclude
CFLAGS += -Wall
CFLAGS += -O2
## Target static library
TARGET_STATIC := lib$(PROJECT_NAME).a
## Builds everything
.PHONY: all
all: $(TARGET_STATIC)
## Builds static library
$(TARGET_STATIC): $(OBJS)
$(AR) crus $@ $^
## Compiles object files
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
## Cleans project directory
.PHONY: clean
clean: test/clean
clean:
$(RM) $(OBJS)
$(RM) $(TARGET_STATIC)
## Compiles and runs all test
.PHONY: test
test: $(TARGET_STATIC)
if test -d; then $(MAKE) -C $@; fi
## Installs library into system
.PHONY: install
install: $(TARGET_STATIC)
$(CP) -r include/* $(PREFIX)/include/
$(CP) $(TARGET_STATIC) $(PREFIX)/lib
## Uninstalls library from system
.PHONY: uninstall
uninstall:
$(RM) -r $(PREFIX)/include/$(PROJECT_NAME)
$(RM) $(PREFIX)/lib/$(TARGET_STATIC)
## Cleans test directory
.PHONY: test/clean
test/clean:
if test -d test; then $(MAKE) clean -C test; fi