-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
199 lines (161 loc) · 4.44 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# -*- tab-width : 4 -*-
#=======================================================================
# @file
# @brief format_class
# @author 平松邦仁 (hira@rvf-rc45.net)
# @copyright Copyright (C) 2019, 2023 Kunihito Hiramatsu @n
# Released under the MIT license @n
# https://github.com/hirakuni45/glfw_app/blob/master/LICENSE
#=======================================================================
TARGET = test_format_class
# 'debug' or 'release'
BUILD = release
VPATH =
CSOURCES =
PSOURCES = main.cpp
# platform switcher (Windows, Linux, OS-X)
ifeq ($(OS),Windows_NT)
FEXT = .exe
ICON_RC =
SYSTEM := WIN
CPP_VER := -std=c++17
LOCAL_INC_PATH :=
LOCAL_LIB_PATH :=
OPTLIBS =
CPMM = clang
CCMM = clang
CFLAGS = -DWIN32
PFLAGS = -DWIN32 -DBOOST_USE_WINDOWS_H
LFLAGS =
else
FEXT =
ICON_RC =
UNAME := $(shell uname -s)
ifeq ($(UNAME),Linux)
SYSTEM := LINUX
CPP_VER := -std=c++17
CFLAGS =
PFLAGS =
LFLAGS =
endif
ifeq ($(UNAME),Darwin)
SYSTEM := OSX
OSX_VER := $(shell sw_vers -productVersion | sed 's/^\([0-9]*.[0-9]*\).[0-9]*/\1/')
CPP_VER := -std=c++14
CFLAGS =
PFLAGS =
LFLAGS = -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \
-Wl,-search_paths_first -Wl,-headerpad_max_install_names \
-framework AGL -framework Cocoa -framework OpenGL -framework IOKit \
-framework CoreFoundation -framework CoreVideo -framework OpenAL
LOCAL_INC_PATH :=
LOCAL_LIB_PATH :=
OPTLIBS =
else
LOCAL_INC_PATH :=
LOCAL_LIB_PATH :=
endif
CPMM = clang++
CCMM = clang
endif
# build openjpeg any version path
# OPENJPEG_PATH := $(shell ls -d $(LOCAL_INC_PATH)/openjpeg*)
STDLIBS =
# OPTLIBS
INC_SYS =
INC_LIB =
LIBDIR =
PINC_APP = .
CINC_APP = .
INC_S = $(addprefix -isystem , $(INC_SYS))
INC_L = $(addprefix -isystem , $(INC_LIB))
INC_P = $(addprefix -I, $(PINC_APP))
INC_C = $(addprefix -I, $(CINC_APP))
CINCS = $(INC_S) $(INC_L) $(INC_C)
PINCS = $(INC_S) $(INC_L) $(INC_P)
LIBS = $(addprefix -L, $(LIBDIR))
LIBN = $(addprefix -l, $(STDLIBS))
LIBN += $(addprefix -l, $(OPTLIBS))
#
# Compiler, Linker Options, Resource_compiler
#
CP = clang++
CC = clang
LK = clang++
RC = windres
POPT = -O2 $(CPP_VER)
COPT = -O2
LOPT =
PFLAGS += -DHAVE_STDINT_H
CFLAGS +=
ifeq ($(BUILD),debug)
POPT += -g
COPT += -g
PFLAGS += -DDEBUG
CFLAGS += -DDEBUG
endif
ifeq ($(BUILD),release)
PFLAGS += -DNDEBUG
CFLAGS += -DNDEBUG
endif
# -Wuninitialized -Wunused -Werror -Wshadow
CCWARN = -Wimplicit -Wreturn-type -Wswitch \
-Wformat
CPWARN = -Wall -Werror -Wno-unused-private-field
OBJECTS = $(addprefix $(BUILD)/,$(patsubst %.cpp,%.o,$(PSOURCES))) \
$(addprefix $(BUILD)/,$(patsubst %.c,%.o,$(CSOURCES)))
DEPENDS = $(patsubst %.o,%.d, $(OBJECTS))
ifdef ICON_RC
ICON_OBJ = $(addprefix $(BUILD)/,$(patsubst %.rc,%.o,$(ICON_RC)))
endif
.PHONY: all clean
.SUFFIXES :
.SUFFIXES : .rc .hpp .h .c .cpp .o
all: $(BUILD) $(TARGET)$(FEXT)
$(TARGET)$(FEXT): $(OBJECTS) $(ICON_OBJ) Makefile
$(LK) $(LFLAGS) $(LIBS) $(OBJECTS) $(ICON_OBJ) $(LIBN) -o $(TARGET)$(FEXT)
$(BUILD)/%.o : %.c
mkdir -p $(dir $@); \
$(CC) -c $(COPT) $(CFLAGS) $(CINCS) $(CCWARN) -o $@ $<
$(BUILD)/%.o : %.cpp
mkdir -p $(dir $@); \
$(CP) -c $(POPT) $(PFLAGS) $(PINCS) $(CPWARN) -o $@ $<
$(ICON_OBJ): $(ICON_RC)
$(RC) -i $< -o $@
$(BUILD)/%.d : %.c
mkdir -p $(dir $@); \
$(CCMM) -MM -DDEPEND_ESCAPE $(COPT) $(CFLAGS) $(CINCS) $< \
| sed 's/$(notdir $*)\.o:/$(subst /,\/,$(patsubst %.d,%.o,$@) $@):/' > $@ ; \
[ -s $@ ] || rm -f $@
$(BUILD)/%.d : %.cpp
mkdir -p $(dir $@); \
$(CPMM) -MM -DDEPEND_ESCAPE $(POPT) $(PFLAGS) $(PINCS) $< \
| sed 's/$(notdir $*)\.o:/$(subst /,\/,$(patsubst %.d,%.o,$@) $@):/' > $@ ; \
[ -s $@ ] || rm -f $@
ifeq ($(SYSTEM),WIN)
strip:
$(LK) $(LFLAGS) $(LIBS) $(OBJECTS) $(ICON_OBJ) $(LIBN) -mwindows -o $(TARGET)$(FEXT)
endif
run:
make
./$(TARGET) -start
time_printf:
time ./$(TARGET) -printf > list
time_format:
time ./$(TARGET) -format > list
time_boost:
time ./$(TARGET) -boost > list
clean:
rm -rf $(BUILD) $(TARGET)$(FEXT)
clean_depend:
rm -f $(DEPENDS)
dllname:
objdump -p $(TARGET)$(FEXT) | grep --text "DLL Name"
tarball:
tar cfvz $(TARGET)_$(shell date +%Y%m%d%H).tgz \
*.[hc]pp Makefile ../common/*/*.[hc]pp ../common/*/*.[hc]
bin_zip:
$(LK) $(LFLAGS) $(LIBS) $(OBJECTS) $(ICON_OBJ) $(LIBN) -mwindows -o $(TARGET)$(FEXT)
rm -f $(TARGET)_$(shell date +%Y%m%d%H)_bin.zip
zip $(TARGET)_$(shell date +%Y%m%d%H)_bin.zip *.exe *.dll
-include $(DEPENDS)