tinn/Makefile

53 lines
779 B
Makefile
Raw Normal View History

2018-03-28 20:10:09 +03:00
CC = gcc
2018-03-27 00:11:15 +03:00
2018-03-29 08:05:28 +03:00
NAME = tinn
2018-03-27 00:11:15 +03:00
SRCS =
2018-03-29 22:34:28 +03:00
SRCS += test.c
2018-03-29 06:55:49 +03:00
SRCS += Tinn.c
2018-03-27 00:11:15 +03:00
# CompSpec defined in windows environment.
ifdef ComSpec
BIN = $(NAME).exe
else
BIN = $(NAME)
endif
CFLAGS =
2018-03-30 02:13:48 +03:00
CFLAGS += -std=c99
2018-03-27 00:11:15 +03:00
CFLAGS += -Wshadow -Wall -Wpedantic -Wextra -Wdouble-promotion -Wunused-result
CFLAGS += -g
2018-03-29 22:10:51 +03:00
CFLAGS += -Ofast -march=native -pipe
2018-03-27 00:11:15 +03:00
CFLAGS += -flto
LDFLAGS =
2018-03-29 06:55:49 +03:00
LDFLAGS += -lm
2018-03-27 00:11:15 +03:00
ifdef ComSpec
RM = del /F /Q
MV = ren
else
RM = rm -f
MV = mv -f
endif
# Link.
$(BIN): $(SRCS:.c=.o)
2018-03-29 06:55:49 +03:00
$(CC) $(CFLAGS) $(SRCS:.c=.o) $(LDFLAGS) -o $(BIN)
2018-03-27 00:11:15 +03:00
# Compile.
%.o : %.c Makefile
2018-03-29 06:55:49 +03:00
$(CC) $(CFLAGS) -MMD -MP -MT $@ -MF $*.td -c $<
$(RM) $*.d
$(MV) $*.td $*.d
2018-03-27 00:11:15 +03:00
%.d: ;
-include *.d
clean:
$(RM) vgcore.*
$(RM) cachegrind.out.*
$(RM) callgrind.out.*
$(RM) $(BIN)
$(RM) $(SRCS:.c=.o)
$(RM) $(SRCS:.c=.d)