-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile.dev
55 lines (39 loc) · 1.73 KB
/
Makefile.dev
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
include Makefile
CC = gcc
CFLAGS = -pipe -fno-lto -Og -g3 -Wall -Wextra -Werror -pedantic -Wshadow
LDFLAGS = -pipe -fno-lto
CPPFLAGS = -I. -D_POSIX_C_SOURCE=200809L -DVERSION=$(VERSION) -DGITHASH=$(GITHASH)
PATH_BUILD = build
PATH_SRC = src
PATH_TEST = test
GITHASH = $(shell git rev-parse --short HEAD)
OBJ_D := $(patsubst $(PATH_SRC)/%.c, $(PATH_BUILD)/%.o, $(SRC))
OBJ_T := $(patsubst $(PATH_SRC)/%.c, $(PATH_BUILD)/%.t, $(SRC)) $(PATH_BUILD)/utils/tree.t
$(PATH_BUILD):
@mkdir -p $(patsubst src%, build%, $(shell find src -type d))
$(PATH_BUILD)/%.o: $(PATH_SRC)/%.c | config.h $(PATH_BUILD) $(MBEDTLS)
@echo "$(CC) $(CFLAGS) $<"
@$(CC) -std=c11 $(CPPFLAGS) $(CFLAGS) $(MBEDTLS_CFLAGS) -MM -MP -MT $@ -MF $(@:.o=.o.d) $<
@$(CC) -std=c11 $(CPPFLAGS) $(CFLAGS) $(MBEDTLS_CFLAGS) -c -o $@ $<
$(PATH_BUILD)/%.t: $(PATH_TEST)/%.c | config.h $(PATH_BUILD) $(MBEDTLS)
@echo "$(CC) $(CFLAGS) $<"
@$(CC) -std=c11 $(CPPFLAGS) $(CFLAGS) $(MBEDTLS_CFLAGS) -MM -MP -MT $@ -MF $(@:.t=.t.d) $<
@$(CC) -std=c11 $(CPPFLAGS) $(CFLAGS) $(MBEDTLS_CFLAGS) -c -o $(@:.t=.t.o) $<
@$(CC) -std=c11 $(LDFLAGS) -o $@ $(@:.t=.t.o) $(MBEDTLS)
rirc.debug: config.h $(OBJ_D) $(MBEDTLS)
@echo "$(CC) $(LDFLAGS) $@"
@$(CC) $(LDFLAGS) -pthread $(OBJ_D) $(MBEDTLS) -o $@
check: $(OBJ_T)
@prove --failures $(OBJ_T)
clean-dev: clean
@rm -rf rirc.debug $(PATH_BUILD)
clean-lib:
@rm -rf $(MBEDTLS_SRC)
gperf:
gperf --output-file=src/handlers/irc_ctcp.gperf.out src/handlers/irc_ctcp.gperf
gperf --output-file=src/handlers/irc_recv.gperf.out src/handlers/irc_recv.gperf
gperf --output-file=src/handlers/irc_send.gperf.out src/handlers/irc_send.gperf
libs: $(MBEDTLS)
-include $(OBJ_D:.o=.o.d)
-include $(OBJ_T:.t=.t.d)
.PHONY: check clean-dev clean-lib gperf libs