This repository has been archived by the owner on Nov 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
60 lines (47 loc) · 1.37 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
# Set defaults
EXEEXT := .exe
# Windows-specific settings
ifeq ($(OS), Windows_NT)
# Directories
SRCDIR := .\src
BUILDDIR := .\build
INCDIR := .\inc
WILD_OBJ := \*.o
WILD_EXE := \*.exe
CXX := x86_64-w64-mingw32-g++
CXXFLAGS := -I$(INCDIR) -Wall -Wextra -std=c++23 -O1 -static -Wno-missing-field-initializers -Wno-ignored-qualifiers -s -DDEBUG
LDFLAGS := -L$(INCDIR) -luser32 -lkernel32 -loleaut32 -lwbemuuid -lole32 -s
MKDIR := if not exist "$(BUILDDIR)" mkdir "$(BUILDDIR)"
RM := del
else
# Cross-compiling from Linux to Windows
# Directories
SRCDIR := ./src
BUILDDIR := ./build
INCDIR := ./inc
WILD_OBJ := /*.o
WILD_EXE := \*.exe
CXX := x86_64-w64-mingw32-g++
CXXFLAGS := -I$(INCDIR) -Wall -Wextra -std=c++23 -O1 -static -Wno-missing-field-initializers -Wno-ignored-qualifiers -s -DDEBUG
LDFLAGS := -L$(INCDIR) -lntdll -luser32 -lkernel32 -loleaut32 -lwbemuuid -lole32 -s
MKDIR := mkdir -p $(BUILDDIR)
RM := rm -f
endif
# Target executable
TARGET := $(BUILDDIR)/T-1$(EXEEXT)
# Source files
SRCS := $(wildcard $(SRCDIR)/*.cxx)
# Object files
OBJS := $(SRCS:$(SRCDIR)/%.cxx=$(BUILDDIR)/%.o)
# Rules
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) $(LDFLAGS) -o $@
$(RM) $(BUILDDIR)$(WILD_OBJ)
$(BUILDDIR)/%.o: $(SRCDIR)/%.cxx
$(MKDIR)
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) $(BUILDDIR)$(WILD_OBJ)
$(RM) $(BUILDDIR)$(WILD_EXE)
.PHONY: all clean