tinn/Makefile

59 lines
869 B
Makefile
Raw Normal View History

2018-03-30 23:26:46 +03:00
# Makefile with support for Windows (mingw32) and NIX (clang / gcc)
2018-03-30 23:10:23 +03:00
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.
2018-03-30 23:10:23 +03:00
2018-03-27 00:11:15 +03:00
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.
2018-03-30 23:10:23 +03:00
2018-03-27 00:11:15 +03:00
$(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.
2018-03-30 23:10:23 +03:00
2018-03-27 00:11:15 +03:00
%.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.*
2018-03-31 01:53:38 +03:00
$(RM) saved.tinn
2018-03-27 00:11:15 +03:00
$(RM) $(BIN)
$(RM) $(SRCS:.c=.o)
$(RM) $(SRCS:.c=.d)