-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
164 lines (134 loc) · 3.68 KB
/
Makefile
File metadata and controls
164 lines (134 loc) · 3.68 KB
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
# Makefile for MinGW32/MinGW-W64
# Example usages:
# Out-of-source build:
# $ mkdir -p build/MinGW/Release
# $ cd build/MinGW/Release
# $ mingw32-make -f ../../../sakura_core/Makefile MYCFLAGS=-O2 OUTDIR=. -j4
#
# Debug build with coverage:
# $ cd sakura_core
# $ mingw32-make MYCFLAGS="-g --coverage" MYLIBS=--coverage -j4
# Path of "sakura_core" directory. Compute it from the path of Makefile.
SRCDIR = $(patsubst %/,%,$(subst \,/,$(dir $(firstword $(MAKEFILE_LIST)))))
# If SRCDIR is different from the current directory, set it to VPATH.
# (If SRCDIR ends with a backslash, remove it before set to VPATH.)
ifneq ($(SRCDIR),.)
VPATH = $(patsubst %\,%,$(SRCDIR))
endif
# The directory where the .exe files will be output.
# If empty, they will be output to the default directories.
OUTDIR =
ifeq ($(SHELL),sh.exe)
# If cmd.exe is used as a shell.
MKDIR = md
RM = del
DIRSEP = $(strip \ )
DEVNULL = NUL
ICONV = C:\msys64\usr\bin\iconv.exe
SED = C:\msys64\usr\bin\sed.exe
else
# If unix-like shell is used.
MKDIR = mkdir -p
RM = rm -f
DIRSEP = /
DEVNULL = /dev/null
ICONV = iconv
SED = sed
endif
ifndef PREFIX
PREFIX=
RCPREFIX=
else ifeq ($(PREFIX),x86_64-w64-mingw32-)
RCPREFIX=$(PREFIX)
else ifeq ($(PREFIX),i686-w64-mingw32-)
ifeq ($(OS),Windows_NT)
RCPREFIX=
else
RCPREFIX=$(PREFIX)
endif
endif
CC= $(PREFIX)gcc
CXX= $(PREFIX)g++
RC= $(RCPREFIX)windres
DEFINES= \
-DWIN32 \
-D_WIN32_WINNT=_WIN32_WINNT_WIN7 \
-D_UNICODE \
-DUNICODE \
$(MYDEFINES)
ifeq (,$(findstring -D_DEBUG,$(DEFINES)))
ifeq (,$(findstring -DNDEBUG,$(DEFINES)))
DEFINES += -DNDEBUG
endif
endif
CFLAGS= \
-finput-charset=utf-8 \
-fexec-charset=cp932 \
-MMD \
-I. \
-I$(SRCDIR) \
$(DEFINES) $(MYCFLAGS)
CXXFLAGS= $(CFLAGS) \
-std=c++17 \
$(MYCXXFLAGS)
LIBS= \
-static \
-lwinspool \
-lole32 \
-loleaut32 \
-luuid \
-lcomctl32 \
-limm32 \
-lmpr \
-limagehlp \
-lshlwapi \
-lwinmm \
-lwindowscodecs \
-lmsimg32 \
-mwindows \
-municode \
$(MYLIBS)
exe= $(or $(OUTDIR),.)/sakura.exe
SRCS = $(wildcard $(SRCDIR)/*.cpp) \
$(wildcard $(SRCDIR)/*/*.cpp) \
$(wildcard $(SRCDIR)/*/*/*.cpp)
OBJS = $(SRCS:$(SRCDIR)/%.cpp=%.o)
_DIRS = $(filter %/, $(wildcard $(SRCDIR)/*/)) \
$(filter %/, $(wildcard $(SRCDIR)/*/*/))
DIRS = $(_DIRS:$(SRCDIR)/%/=%)
DEPS= $(OBJS:%.o=%.d) StdAfx.h.d
GENERATED_FILES= \
Funccode_define.h \
Funccode_enum.h \
githash.h \
HEADERMAKETOOLDIR= $(SRCDIR)/../HeaderMake
HEADERMAKE= $(or $(OUTDIR),$(HEADERMAKETOOLDIR))/HeaderMake.exe
all: $(exe)
$(exe): $(OBJS) sakura_rc.o
$(CXX) -o $@ $(OBJS) sakura_rc.o $(LIBS)
Funccode_define.h: Funccode_x.hsrc $(HEADERMAKE)
$(HEADERMAKE) -in=$< -out=$@ -mode=define
Funccode_enum.h: Funccode_x.hsrc $(HEADERMAKE)
$(HEADERMAKE) -in=$< -out=$@ -mode=enum -enum=EFunctionCode
githash.h:
cmd /c $(subst /,\,$(SRCDIR))\..\sakura\githash.bat .
StdAfx.h.gch: StdAfx.h githash.h Funccode_enum.h
ifneq ($(SRCDIR),.)
-$(MKDIR) $(subst /,$(DIRSEP),$(DIRS)) > $(DEVNULL) 2>&1
endif
$(CXX) $(CXXFLAGS) -o $@ -c $<
.cpp.o:
$(CXX) $(CXXFLAGS) -o $@ -c $<
$(OBJS): StdAfx.h.gch
$(HEADERMAKE): $(HEADERMAKETOOLDIR)/HeaderMake.cpp
$(CXX) $(CXXFLAGS:-MMD=) $< -o $@ -static-libgcc
sakura_rc.o: sakura_rc.rc.utf8 sakura_rc.rc2.utf8 githash.h Funccode_define.h
$(RC) -c utf-8 --language=0411 $(DEFINES) -I. -I$(SRCDIR) $< -o $@
sakura_rc.rc.utf8 sakura_rc.rc2.utf8: sakura_rc.rc sakura_rc.rc2
$(ICONV) -f utf-16 -t utf-8 $(subst .utf8,,$(@F)) | $(SED) -e 1i'#pragma code_page(65001)' -e '/#include/s/.rc2\b/.rc2.utf8/' > $@
clean:
-$(RM) $(subst /,$(DIRSEP),$(exe) $(OBJS) $(HEADERMAKE)) StdAfx.h.gch $(GENERATED_FILES) sakura_rc.o sakura_rc.*.utf8
-$(RM) $(subst /,$(DIRSEP),$(DEPS))
.SUFFIXES: .cpp .o .rc
.PHONY: all clean
-include $(DEPS)