-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (83 loc) · 2.53 KB
/
Makefile
File metadata and controls
99 lines (83 loc) · 2.53 KB
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
# Makefile for SOCKS5 to HTTPS Proxy
# Supports MinGW64/MSYS2 and Linux/Unix environments
# Project configuration
TARGET = https2socks5
SRCS = main.c socks5_client.c https_proxy.c
HEADERS = socket_util.h socks5_client.h https_proxy.h
# Environment detection
MINGW64 = $(shell uname -s 2>/dev/null | grep -c MINGW64)
ifeq ($(MINGW64),1)
# MinGW64 configuration
CC = gcc
CFLAGS = -O2 -std=c11 -DWIN32_LEAN_AND_MEAN -DWINVER=0x0601 -Wno-unknown-pragmas -Wno-sign-compare -Wno-missing-braces -Wno-pointer-sign -s -flto -ffunction-sections -fdata-sections
LDFLAGS = -Wl,--gc-sections -Wl,--strip-all
LIBS = -lws2_32
TARGET_EXT = .exe
RM = rm -f
MKDIR = mkdir -p
OBJ_EXT = .o
else
# Linux/Unix configuration
CC = gcc
CFLAGS = -O2 -std=c11 -pthread
LDFLAGS =
LIBS = -lpthread
TARGET_EXT =
RM = rm -f
MKDIR = mkdir -p
OBJ_EXT = .o
endif
# Build directories
BUILD_DIR = build
OBJ_FILES = $(addprefix $(BUILD_DIR)/, $(SRCS:.c=$(OBJ_EXT)))
# Default target
all: $(TARGET)$(TARGET_EXT)
# Create build directory
$(BUILD_DIR):
$(MKDIR) $(BUILD_DIR)
# Compilation
$(TARGET)$(TARGET_EXT): $(OBJ_FILES)
$(CC) $(LDFLAGS) -o $@ $(OBJ_FILES) $(LIBS)
$(RM) -r $(BUILD_DIR)
$(BUILD_DIR)/%$(OBJ_EXT): %.c $(HEADERS) | $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
# Clean build artifacts
clean:
$(RM) $(TARGET)$(TARGET_EXT) $(OBJ_FILES)
$(RM) -r $(BUILD_DIR)
# Install target (optional)
install: $(TARGET)$(TARGET_EXT)
ifeq ($(MINGW64),1)
@echo "On MinGW64, copy $(TARGET)$(TARGET_EXT) manually to desired location"
else
cp $(TARGET)$(TARGET_EXT) /usr/local/bin/
endif
# Uninstall target (optional)
uninstall:
ifeq ($(MINGW64),1)
@echo "On MinGW64, remove $(TARGET)$(TARGET_EXT) manually from installed location"
else
$(RM) /usr/local/bin/$(TARGET)$(TARGET_EXT)
endif
# Debug build
debug: CFLAGS += -DDEBUG -g
debug: all
# Release build with maximum optimization
release: CFLAGS += -O3 -DNDEBUG
release: all
# Help target
help:
@echo "Available targets:"
@echo " all - Build the project (default)"
@echo " clean - Remove build artifacts"
@echo " debug - Build with debug symbols"
@echo " release - Build with maximum optimization"
@echo " install - Install the binary"
@echo " uninstall- Remove the installed binary"
@echo " help - Show this help message"
# Phony targets
.PHONY: all clean install uninstall debug release help
# Dependencies
main.o: socket_util.h socks5_client.h https_proxy.h
socks5_client.o: socket_util.h socks5_client.h
https_proxy.o: socket_util.h https_proxy.h