about summary refs log tree commit diff stats
path: root/c/Makefile
blob: 57fa7cf7874a901b7d9574e1313145a5a91bdf3c (plain) (blame)
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
PREFIX    := /usr/local
BINPREFIX := $(DESTDIR)$(PREFIX)/bin
MANPREFIX := $(DESTDIR)$(PREFIX)/share/man/man1

BIN_NAME := project_name

SRC := $(wildcard src/*.c)
OBJ := $(SRC:.c=.o)
DEP := $(OBJ:.o=.d)

LIBS :=

ALL_CFLAGS  := -O3 -MMD -Wall -Wextra -Wno-unused-parameter $(CFLAGS) $(CPPFLAGS)
ALL_LDFLAGS := $(addprefix -l,$(LIBS)) $(CFLAGS) $(LDFLAGS)



$(BIN_NAME): $(OBJ)
	$(CC) -o $@ $+ $(ALL_LDFLAGS)

install: $(BIN_NAME)
	install -d $(BINPREFIX)
	install $^ $(BINPREFIX)

.c.o:
	$(CC) -o $@ $< -c $(ALL_CFLAGS)

valgrind-out.txt: $(BIN_NAME)
	valgrind --leak-check=full \
         --show-leak-kinds=all \
         --show-error-list=yes \
         --track-origins=yes \
         --log-file=valgrind-out.txt \
         ./rename

.PHONY : clean options install test
options:
	@echo "CC      = $(CC)"
	@echo "CFLAGS  = $(ALL_CFLAGS)"
	@echo "LDFLAGS = $(ALL_LDFLAGS)"
	@echo "OBJ = $(OBJ)"
	@echo "DEP = $(DEP)"
	@echo ""

clean :
	rm $(BIN_NAME) valgrind-out.txt $(OBJ) $(DEP)

test:
	./test