aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: d92729f850a635eec96737665c44cb0a05ce7387 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
# ========================
# =====    ===============
# ======  ================
# ======  ================
# ======  ====   ====   ==
# ======  ===     ==  =  =
# ======  ===  =  ==     =
# =  ===  ===  =  ==  ====
# =  ===  ===  =  ==  =  =
# ==     =====   ====   ==
# ========================
#
# unixize: Makefile
# 2020-11-02 21:43
# Joe
#
# GNU Makefile

.DEFAULT_GOAL	:= asan
SHELL			:= /bin/sh

DESTDIR			 = /usr/local
SRCS_DIR		 = src/
OBJS_DIR		 = obj/

CC				 = cc
CFLAGS			 = -std=c89
CFLAGS			+= -Wall
CFLAGS			+= -Wextra
CFLAGS			+= -Werror
CFLAGS			+= -pedantic

RM				 = rm -rf
MKDIR			 = mkdir -p

SRCS_NAME		 = c_lfiles
SRCS_NAME		+= c_opts
SRCS_NAME		+= c_subst
SRCS_NAME		+= c_unixize
SRCS_NAME		+= u_utils

SRCS			 = $(addprefix ${SRCS_DIR}, $(addsuffix .c, ${SRCS_NAME}))
INCS			 = $(addprefix ${SRCS_DIR}, $(addsuffix .h, ${SRCS_NAME}))
OBJS			 = $(patsubst ${SRCS_DIR}%.c, ${OBJS_DIR}%.c.o, ${SRCS})

TARGET			 = unixize

${OBJS_DIR}%.c.o: ${SRCS_DIR}%.c ${INCS} Makefile
	@${MKDIR} ${OBJS_DIR}
	${CC} -c ${CFLAGS} -o $@ $<

${TARGET}: ${OBJS}
	${CC} ${CFLAGS} -o ${TARGET} ${OBJS}

opti: CFLAGS += -march=ivybridge -O2 -pipe
opti: all

all: ${TARGET}

debug: CFLAGS += -g3
debug: all

asan: CFLAGS += -g3
asan: CFLAGS += -fsanitize=address
asan: all

msan: CFLAGS += -g3
msan: CFLAGS += -fsanitize=memory
msan: CFLAGS += -fsanitize-memory-track-origins
msan: all

clean:
	${RM} ${OBJS_DIR}
	${RM} ${TARGET}

.PHONY:	all clean debug asan msan