-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
44 lines (32 loc) · 792 Bytes
/
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
CC ?= gcc
# library name
LIB_NAME = button
# source directory and output name
SRC_DIR = src
OUTPUT = lib$(LIB_NAME).so
# flags for debugging
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g -DDEBUG
else
CFLAGS += -O3
endif
# flags
CFLAGS += $(CONFIG) -Wall -Wextra -fPIC -std=gnu99
LDFLAGS += -shared
# libraries
LIBS =
# source and object files
SRC = $(wildcard $(SRC_DIR)/*.c)
OBJ = $(SRC:.c=.o)
# library version
LIB_VERSION = $(shell grep -oP "define.*VERSION[ \t]*\K[0-9.\"]*" $(SRC_DIR)/$(LIB_NAME).h)
.PHONY: doc
$(OUTPUT): $(OBJ)
$(CC) $(OBJ) $(LDFLAGS) $(LIBS) -o $@
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
clean:
rm -f $(OBJ) $(OUTPUT)
doc:
@( cat Doxyfile ; echo "PROJECT_NUMBER=$(LIB_VERSION)" ) | doxygen -
@echo "Documentation for $(LIB_NAME) version $(LIB_VERSION) generated"