Skip to content
This repository was archived by the owner on Nov 25, 2019. It is now read-only.

Commit f4063b6

Browse files
committed
Improvements to Makefile
1 parent ee33f33 commit f4063b6

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

Makefile

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
1-
OS := $(shell uname)
2-
ifneq (,$(findstring MINGW,$(OS)))
3-
OS := Windows
4-
else ifneq(,$(findstring MSYS,$(OS)))
5-
OS := Windows
6-
else ifneq(,$(findstring CYGWIN,$(OS)))
7-
OS := Windows
8-
endif # Cygwin
9-
endif # MSys
10-
endif # MinGW
1+
OS ?= $(shell uname)
112

12-
ifneq (,$(findstring $(OS),Darwin FreeBSD))
13-
CXX := clang++
3+
# Assume Visual C++ on Windows
4+
# Environments like Cygwin will hopefully fall through and pick up the
5+
# appropriate Unix-like options
6+
ifneq ($(OS),Windows_NT)
7+
EXE := bin\qqq.exe
8+
OUT := /out:$(EXE)
9+
CXX := cl
10+
CXXFLAGS := /EHsc /W4
1411
else
15-
CXX := g++
16-
endif
17-
18-
ifeq ($(OS),Windows)
19-
EXE := bin/qqq.exe
12+
EXE := bin/qqq
13+
OUT := -o $(EXE)
14+
CXXFLAGS := -Wall -O0
15+
ifneq (,$(findstring $(OS),Darwin FreeBSD))
16+
CXX := clang++
2017
else
21-
EXE := bin/qqq
22-
endif
18+
CXX := g++
19+
endif # macOS or FreeBSD
20+
endif # Windows
2321

2422
setup:
2523
-mkdir bin
2624

2725
cpp: setup
28-
$(CXX) cpp/qqq.cpp -o $(EXE) -Wall -O0
26+
$(CXX) cpp/qqq.cpp $(OUT) $(CXXFLAGS)
2927

3028
rust: setup
31-
rustc rust/main.rs -o $(EXE)
29+
rustc rust/main.rs $(OUT)
3230

3331
clean:
34-
-rm $(EXECUTABLE)
32+
-rm $(EXE)

0 commit comments

Comments
 (0)