This repository has been archived by the owner on Jul 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile_cpp.go
142 lines (117 loc) · 2.26 KB
/
makefile_cpp.go
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
package main
const makefile_cxx = `# Set default C++ compiler.
# Clean implict CXX variable.
CXX=
ifndef CXX
ifeq ($(detected_OS),Windows)
CXX=cl
else ifeq ($(detected_OS),Darwin)
CXX=clang++
else
CXX=g++
endif
endif # CXX
export CXX
`
const MakefileCXXStandard = `# Clean CXX_STD variable.
CXX_STD=
ifndef CXX_STD
ifeq ($(detected_OS),Windows)
CXX_STD={{ .StandardWin }}
else ifeq ($(detected_OS),Darwin)
CXX_STD={{ .Standard }}
else
CXX_STD={{ .Standard }}
endif
endif # CXX_STD
export CXX_STD
`
const makefile_cxxflags_debug = `# Set CXXFLAGS for Debug target.
ifneq (,$(DEBUG))
ifeq ($(CXX),cl)
CXXFLAGS+=/DDEBUG /Zi /Od
else
CXXFLAGS+=-DDEBUG -g -O0
endif
else
ifeq ($(CXX),cl)
CXXFLAGS+=/O2
else
CXXFLAGS+=-O2
endif
endif
export CXXFLAGS
`
const makefile_cxxflags_release = `# Set CXXFLAGS
CXXFLAGS=
ifndef CXXFLAGS
ifeq ($(CXX),cl)
CXXFLAGS:=/W4 /sdl /EHsc /std:$(CXX_STD)
else
CXXFLAGS:=-Wall -Wextra -std=$(CXX_STD)
endif
endif
`
const makefileLibCpp = `# Set proper library name.
PROGRAM={{.Program}}
ifeq ($(detected_OS),Windows)
ifeq ($(CXX),cl)
DYNAMIC_LIB=$(PROGRAM).dll
else
DYNAMIC_LIB=lib$(PROGRAM).dll
endif # $(CXX)
else
ifeq ($(detected_OS),Darwin)
DYNAMIC_LIB=lib$(PROGRAM).dylib
else
DYNAMIC_LIB=lib$(PROGRAM).so
endif # $(detected_OS),Darwin
endif # $(detected_OS),Windows
export DYNAMIC_LIB
ifeq ($(CXX),cl)
STATIC_LIB=$(PROGRAM).lib
else
STATIC_LIB=lib$(PROGRAM).a
endif
export STATIC_LIB
# Add your own test programs as needed.
TEST_SOURCE=$(PROGRAM)_test.cpp
ifeq ($(CXX),cl)
TEST_OBJS=$(TEST_SOURCE:.cpp=.obj)
else
TEST_OBJS=$(TEST_SOURCE:.cpp=.o)
endif
export TEST_OBJS
`
const makefileObjectCpp = `# Modify it if more than one source files.
SOURCE=$(PROGRAM:.exe=).cpp
# Set object files.
ifeq ($(CXX),cl)
OBJS=$(SOURCE:.cpp=.obj)
else
OBJS=$(SOURCE:.cpp=.o)
endif # OBJS
export OBJS
`
const makefileObjCppLib = `# Modify it if more than one source files.
SOURCE=$(PROGRAM:.exe=).cpp
# Set object files.
ifeq ($(CXX),cl)
OBJS=$(SOURCE:.cpp=.obj)
else
OBJS=$(SOURCE:.cpp=.o)
endif # OBJS
export OBJS
`
const makefileExternalLibraryCpp = `# Set third-party include and library path
# Modify it as needed.
ifeq ($(CC),cl)
LDFLAGS=
LDLIBS=
else
LDFLAGS=
LDLIBS=
endif
export LDFLAGS
export LDLIBS
`