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