-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
72 lines (52 loc) · 1.33 KB
/
makefile
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
SRCS := $(wildcard *.c)
OBJS := $(patsubst %.c,%.o,$(SRCS))
ROBJS := $(addprefix release/,$(OBJS))
DOBJS := $(addprefix debug/,$(OBJS))
POBJS := $(addprefix profile/,$(OBJS))
CC = gcc
CFLAGS = -Wall
LDFLAGS =
LIBS = -lm -lgmp
UNAME = $(shell uname -a)
ifneq (,$(findstring MINGW, $(UNAME)))
EXT = .exe
else ifneq (,$(findstring MSYS, $(UNAME)))
EXT = .exe
else
EXT =
endif
TARGET = kiss$(EXT)
.PHONY: all clean test
all: release release/$(TARGET) release_cp
release:
mkdir release
release_cp:
cp release/$(TARGET) .
release/$(TARGET): $(ROBJS)
$(CC) $(LDFLAGS) -O3 -o $@ $^ $(LIBS)
release/%.o: %.c kiss.h
$(CC) -c -O3 $(CFLAGS) $< -o $@
# 'make d' for debug
d: debug debug/$(TARGET) debug_cp
debug:
mkdir debug
debug_cp:
cp debug/$(TARGET) .
debug/$(TARGET): $(DOBJS)
$(CC) $(LDFLAGS) -O0 -g -o $@ $^ $(LIBS)
debug/%.o: %.c kiss.h
$(CC) -c -O0 $(CFLAGS) -g $< -o $@
# 'make p' for profile
p: profile profile/$(TARGET) profile_cp
profile:
mkdir profile
profile_cp:
cp profile/$(TARGET) .
profile/$(TARGET): $(POBJS)
$(CC) $(LDFLAGS) -O3 -pg -o $@ $^ $(LIBS)
profile/%.o: %.c kiss.h
$(CC) -c -O3 $(CFLAGS) -pg $< -o $@
clean:
rm -f release/$(TARGET) debug/$(TARGET) profile/$(TARGET)
rm -f $(OBJS) $(ROBJS) $(DOBJS) $(POBJS)
rm -f newfile example.dat