-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
74 lines (58 loc) · 2.18 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
##
## Copyright (c) 2018-2025 Stéphane Micheloud
##
## Licensed under the MIT License.
##
##############################################################################
TOOLSET ?= gcc
CXXSTD ?= c++17
include ../Makefile.inc
PROJECT_NAME ?= $(shell basename $(CURDIR))
PROJECT_CONFIG ?= Release
SOURCE_DIR = src
TARGET_DIR = build
TARGET_EXE_DIR = $(TARGET_DIR)/$(PROJECT_CONFIG)
PTHREADS_ROOTPATH = ../pthreads-win32
PTHREADS_INCPATH = $(PTHREADS_ROOTPATH)/include
PTHREADS_LIBPATH = $(PTHREADS_ROOTPATH)/lib/$(ARCH)
PTHREADS_LIBNAME=pthreadVC2
ifeq ($(TOOLSET),msvc)
CXX = $(CL)
CXXFLAGS = -nologo -std:$(CXXSTD) -EHsc -I"$(MSVC_INCPATH)" -I"$(WINSDK_INCPATH)ucrt" -I"$(WINSDK_INCPATH)um" -D_TIMESPEC_DEFINED -I"$(PTHREADS_INCPATH)" -Fo"$(TARGET_DIR)/"
CXXLINK = -link -libpath:"$(MSVC_LIBPATH)" -libpath:"$(WINSDK_LIBPATH)ucrt/$(ARCH)" -libpath:"$(WINSDK_LIBPATH)um/$(ARCH)" -defaultlib:"$(PTHREADS_LIBPATH)/$(PTHREADS_LIBNAME)" -machine:$(ARCH)
else ifeq ($(TOOLSET),gcc)
CXX = $(CC)
CXXFLAGS = --std=$(CXXSTD) -O2 -lpthread -Wall -Wno-unused-variable -Wno-unused-but-set-variable
CXXLINK =
else ifeq ($(TOOLSET),clang)
CXX = $(CLANG)
CXXFLAGS = --std=$(CXXSTD) -O2 -D_TIMESPEC_DEFINED -I"$(PTHREADS_INCPATH)" -L"$(PTHREADS_LIBPATH)" -l$(PTHREADS_LIBNAME) -Wall -Wno-unused-variable
CXXLINK =
endif
CXXVARS =
##############################################################################
## main rules
SOURCES = $(wildcard $(SOURCE_DIR)/main/cpp/*.cpp)
TARGET = $(TARGET_EXE_DIR)/$(PROJECT_NAME)$(TARGET_EXT)
all: build run
build: $(TARGET)
$(TARGET): $(SOURCES)
@$(TEST) -d "$(TARGET_EXE_DIR)" || $(MKDIR) -p "$(TARGET_EXE_DIR)"
ifeq ($(TOOLSET),msvc)
@## https://docs.microsoft.com/en-us/cpp/build/reference/output-file-f-options
"$(CXX)" $(CXXDEBUG) $(CXXFLAGS) $(CXXVARS) -Fe"$@" $^ $(CXXLINK)
else
"$(CXX)" $(CXXDEBUG) $(CXXFLAGS) $(CXXVARS) -o $@ $^ $(CXXLINK)
endif
ifneq ($(TOOLSET),gcc)
"$(CP)" "$(PTHREADS_ROOTPATH)/dll/$(ARCH)/$(PTHREADS_LIBNAME).dll" "$(TARGET_EXE_DIR)/"
endif
clean:
$(RM) -rf "$(TARGET_DIR)"
run: build
$(TARGET)
##############################################################################
## phony
.PHONY: all build clean run
.SUFFIXES:
.SUFFIXES: .c .o .obj .exe