-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
46 lines (35 loc) · 1.13 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
# Compiler options
CC := g++
RC := windres
CFLAGS := -DNAME="\"PingDD\"" -DVERSION="\"1.0.0\"" -DAUTHOR="\"Jubair Hasan (Joy)\""
LDFLAGS := -lws2_32
# Directories
SRCDIR := ./src
BINDIR_X64 := ./bin/x64
OBJDIR_X64 := ./obj/x64
# Source files
SRCS := $(wildcard $(SRCDIR)/*.cpp)
OBJS_X64 := $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR_X64)/%.o,$(SRCS))
RC_FILE := version.rc
RC_OBJ_X64 := $(OBJDIR_X64)/version.res
# Executable
TARGET_X64 := $(BINDIR_X64)/pingdd
.PHONY: all clean
all: $(TARGET_X64)
# Build rules for x64 target
$(TARGET_X64): $(OBJS_X64) $(RC_OBJ_X64) | $(BINDIR_X64)
$(CC) -m64 $^ -o $@ $(LDFLAGS)
# Object file compilation rules for x64
$(OBJDIR_X64)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR_X64)
$(CC) $(CFLAGS) -m64 -c $< -o $@
# Resource compilation rule for x64
$(RC_OBJ_X64): $(RC_FILE) | $(OBJDIR_X64)
$(RC) -O coff $< -o $@
# Directory creation targets (using PowerShell on Windows)
$(BINDIR_X64):
powershell -Command "New-Item -ItemType Directory -Force -Path $(BINDIR_X64)"
$(OBJDIR_X64):
powershell -Command "New-Item -ItemType Directory -Force -Path $(OBJDIR_X64)"
# Clean target
clean:
rm -rf $(BINDIR_X64) $(OBJDIR_X64)