-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
110 lines (78 loc) · 2.69 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
MAKEFILE = Makefile
####### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES = -std=c++14 # -Wextra -pedantic
CFLAGS = -O2 -Wall $(DEFINES)
CXXFLAGS = -O2 -Wall $(DEFINES)
INCPATH = -I.
LINK = g++
LFLAGS = -Wl,-O1
LIBS = $(SUBLIBS) # -lpthread -lstdc++
AR = ar cqs
RANLIB =
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = cp -f
COPY_DIR = cp -f -R
STRIP = strip
INSTALL_FILE = install -m 644 -p
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
####### Output directory
OBJECTS_DIR = ./
####### Files
SOURCES =
OBJECTS = entropy.o main.o main_test.o commandline.o ## TODO: add all corresponding .o files here
DIST =
DESTDIR = #avoid trailing-slash linebreak
TARGET = test entropy
first: all
####### Implicit rules
# .SUFFIXES: .o .c .cpp .cc .cxx .C
# .cpp.o:
# $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
# .cc.o:
# $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
# .cxx.o:
# $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
# .C.o:
# $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
# .c.o:
# $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
####### Build rules
all: $(TARGET)
test: entropy.o main_test.o
$(LINK) $(LFLAGS) entropy.o main_test.o $(LIBS) -o test
entropy: entropy.o main.o commandline.o
$(LINK) $(LFLAGS) entropy.o main.o commandline.o $(LIBS) -o entropy
# $(TARGET): $(OBJECTS)
# $(LINK) $(LFLAGS) $(OBJECTS) $(OBJCOMP) $(LIBS) -o $(TARGET)
dist:
@test -d .tmp/test1.0.0 || mkdir -p .tmp/test1.0.0
$(COPY_FILE) --parents $(DIST) .tmp/test1.0.0/ && $(COPY_FILE) --parents hello.h .tmp/test1.0.0/ && $(COPY_FILE) --parents hello.cpp main.cpp .tmp/test1.0.0/ && (cd `dirname .tmp/test1.0.0` && $(TAR) test1.0.0.tar test1.0.0 && $(COMPRESS) test1.0.0.tar) && $(MOVE) `dirname .tmp/test1.0.0`/test1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/test1.0.0
clean:compiler_clean
-$(DEL_FILE) $(OBJECTS)
distclean: clean
-$(DEL_FILE) $(TARGET)
####### Sub-libraries
check: first
compiler_clean:
####### Compile
# TODO: add all dependencies for the .o
commandline.o: commandline.cpp commandline.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o commandline.o commandline.cpp
entropy.o: entropy.cpp entropy.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o entropy.o entropy.cpp
main_test.o: main_test.cpp entropy.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main_test.o main_test.cpp
main.o: main.cpp entropy.h commandline.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp