-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·185 lines (145 loc) · 4.27 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#------------------------------------------------------------------------------
#
# createcat Makefile
#
#------------------------------------------------------------------------------
TARGET = createcat
#------------------------------------------------------------------------------
# Defines
#------------------------------------------------------------------------------
#platform = WIN32
#crosscompile = 1
ifndef platform
platform = UNIX
endif
VERSION_MAJOR = 0
VERSION_MINOR = 2
VERSION_STR = $(VERSION_MAJOR).$(VERSION_MINOR)
ifeq ($(platform), UNIX)
FINAL_TARGET = $(TARGET)
else
FINAL_TARGET = $(TARGET).exe
endif
EXTRA_TARGETS = $(FINAL_TARGET)
OBJ = src
#------------------------------------------------------------------------------
# Utilities
#------------------------------------------------------------------------------
ifeq ($(platform), WIN32)
ifeq ($(crosscompile), 1)
AR = i686-w64-mingw32-ar
CC = i686-w64-mingw32-gcc
CXX = i686-w64-mingw32-g++
LD = i686-w64-mingw32-g++
MD = mkdir
RM = rm
else
AR = ar
CC = gcc
LD = gcc
MD = mkdir.exe
RM = rm.exe
endif
else ifeq ($(platform), UNIX)
AR = /usr/bin/x86_64-linux-gnu-ar
CC = /usr/bin/x86_64-linux-gnu-gcc
CXX = /usr/bin/x86_64-linux-gnu-g++-8
LD = /usr/bin/x86_64-linux-gnu-g++-8
MD = mkdir
RM = rm
endif
#------------------------------------------------------------------------------
# File include path
#------------------------------------------------------------------------------
INCDIR = \
src
ifeq ($(crosscompile), 1)
INCDIR += src/include
endif
INCDIR += src/include
#------------------------------------------------------------------------------
# Object Directory
#------------------------------------------------------------------------------
OBJDIRS = \
$(OBJ)
#------------------------------------------------------------------------------
# Object Files
#------------------------------------------------------------------------------
OBJS = \
$(OBJ)/categories.o \
$(OBJ)/common.o \
$(OBJ)/main.o
#------------------------------------------------------------------------------
# Compiler Defines
#------------------------------------------------------------------------------
ifeq ($(platform), WIN32)
CDEFS = \
-DCRLF=3 \
-DWINVER=0x0400 \
-D_WIN32_WINNT=0x0500 \
-DWIN32 \
-D_WINDOWS \
-DINLINE='static __inline' \
-Dinline=__inline \
-D__inline__=__inline \
-DVERSION_STR='"$(VERSION_STR)"' \
$(addprefix -I,$(INCDIR))
else
CDEFS = \
-DCRLF=3 \
-DINLINE='static __inline' \
-Dinline=__inline \
-D__inline__=__inline \
-DVERSION_STR='"$(VERSION_STR)"' \
$(addprefix -I,$(INCDIR))
endif
ifeq ($(platform), UNIX)
CDEFS += -DUNIX=1
endif
#------------------------------------------------------------------------------
# Compiler Flags
#------------------------------------------------------------------------------
CFLAGS = -Ofast $(CDEFS)
CXXFLAGS = $(CFLAGS) -std=c++17
#---------------------------------------------------------------------
# Linker Flags
#---------------------------------------------------------------------
LDFLAGS = -s
ifeq ($(platform), WIN32)
ifeq ($(crosscompile), 1)
LDFLAGS += -mconsole
else
LDFLAGS += -mconsole
endif
endif
#------------------------------------------------------------------------------
# Library
#------------------------------------------------------------------------------
ifeq ($(platform), WIN32)
ifeq ($(crosscompile), 1)
LIBS = -luser32 -lcomdlg32 -lshell32 -static-libgcc -static-libstdc++ -lstdc++fs
else
LIBS = -lstdc++ -luser32 -lcomdlg32 -lshell32 -lstdc++fs
endif
else
LIBS = -lstdc++ -lstdc++fs
endif
#------------------------------------------------------------------------------
# Rules to make libraries
#------------------------------------------------------------------------------
all: $(EXTRA_TARGETS)
$(FINAL_TARGET): $(OBJS)
@echo Linking $@...
$(LD) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
#------------------------------------------------------------------------------
# Rules to manage files
#------------------------------------------------------------------------------
$(OBJ)/%.o: src/%.c
@echo Compiling $<...
@$(CC) $(CDEFS) $(CFLAGS) -c $< -o$@
$(OBJ)/%.o: src/%.cpp
@echo Compiling $<...
@$(CXX) $(CDEFS) $(CXXFLAGS) -c $< -o$@
clean:
@$(RM) -rf $(OBJS)
@$(RM) -f $(FINAL_TARGET)