Skip to content

Commit f176222

Browse files
committed
Fix: Eliminate compiler warnings during build process (#3)
Addressed all compiler warnings by: - Fixed variable type mismatches in function parameters - Properly handled unused variables with appropriate casts - Corrected format string specifiers for various platform compatibility - Ensured consistent return values in all code paths - Added explicit initialization for potentially uninitialized variables Build now completes cleanly without warnings on standard compiler settings. Signed-off-by: editheman <edipana0409@gmail.com> Improve Makefile for cross-platform build reliability (#3) Created a robust Makefile that: - Adds proper OpenSSL detection via pkg-config with intelligent fallbacks - Supports multiple platforms with OS-specific adaptations - Handles common macOS package locations (Homebrew and MacPorts) - Implements flexible compiler settings with strict warning flags - Includes a dedicated debug target for development - Ensures clean builds with proper dependencies This ensures vfdecrypt builds consistently across different environments without manual configuration. Signed-off-by: editheman <edipana0409@gmail.com> Add .gitignore to exclude build artifacts and editor config Signed-off-by: editheman <edipana0409@gmail.com>
1 parent e6fa062 commit f176222

File tree

3 files changed

+350
-119
lines changed

3 files changed

+350
-119
lines changed

.gitignore

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,54 @@
1-
/vfdecrypt
1+
# Prerequisites
2+
*.d
3+
4+
# Object files
5+
*.o
6+
*.ko
7+
*.obj
8+
*.elf
9+
10+
# Linker output
11+
*.ilk
12+
*.map
13+
*.exp
14+
15+
# Precompiled Headers
16+
*.gch
17+
*.pch
18+
19+
# Libraries
20+
*.lib
21+
*.a
22+
*.la
23+
*.lo
24+
25+
# Shared objects (inc. Windows DLLs)
26+
*.dll
27+
*.so
28+
*.so.*
29+
*.dylib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app
35+
*.i*86
36+
*.x86_64
37+
*.hex
38+
vfdecrypt
39+
40+
# Debug files
41+
*.dSYM/
42+
*.su
43+
*.idb
44+
*.pdb
45+
46+
# Project specific
47+
decrypted.dmg
48+
49+
# OS X
50+
.DS_Store
51+
52+
# Editors
53+
.vscode/
54+
.idea/

Makefile

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,62 @@
1-
CFLAGS = -Wall
2-
LDLIBS = -lcrypto
1+
CC ?= cc
2+
CFLAGS ?= -O2
3+
CFLAGS += -Wall -Wextra -Wpedantic -std=c11
4+
# If you want even stricter checks, uncomment:
5+
# CFLAGS += -Wshadow -Wconversion -Wmissing-prototypes -Wstrict-prototypes
6+
7+
RM ?= rm -f
8+
9+
OPENSSL_PKG := $(shell pkg-config --exists openssl && echo openssl || \
10+
pkg-config --exists openssl@3 && echo openssl@3 || echo)
11+
12+
ifeq ($(strip $(OPENSSL_PKG)),)
13+
OPENSSL_CFLAGS :=
14+
OPENSSL_LIBS :=
15+
else
16+
OPENSSL_CFLAGS := $(shell pkg-config --cflags $(OPENSSL_PKG) 2>/dev/null)
17+
OPENSSL_LIBS := $(shell pkg-config --libs $(OPENSSL_PKG) 2>/dev/null)
18+
endif
19+
20+
ifeq ($(strip $(OPENSSL_LIBS)),)
21+
LDLIBS += -lcrypto
22+
else
23+
CPPFLAGS += $(OPENSSL_CFLAGS)
24+
LDLIBS += $(OPENSSL_LIBS)
25+
endif
326

427
UNAME_S := $(shell uname -s)
528
ifeq ($(UNAME_S),Darwin)
6-
LDFLAGS = -L/opt/local/lib
7-
CPPFLAGS = -I/opt/local/include -DMAC_OSX
8-
endif
29+
CPPFLAGS += -DMAC_OSX
930

10-
.PHONY: all clean
31+
ifeq ($(strip $(OPENSSL_LIBS)),)
32+
HB_ARM := /opt/homebrew/opt/openssl@3
33+
HB_INTEL := /usr/local/opt/openssl@3
34+
ifneq ("$(wildcard $(HB_ARM)/include/openssl)","")
35+
CPPFLAGS += -I$(HB_ARM)/include
36+
LDFLAGS += -L$(HB_ARM)/lib
37+
endif
38+
ifneq ("$(wildcard $(HB_INTEL)/include/openssl)","")
39+
CPPFLAGS += -I$(HB_INTEL)/include
40+
LDFLAGS += -L$(HB_INTEL)/lib
41+
endif
42+
ifneq ("$(wildcard /opt/local/include/openssl)","")
43+
CPPFLAGS += -I/opt/local/include
44+
LDFLAGS += -L/opt/local/lib
45+
endif
46+
endif
47+
endif
1148

49+
.PHONY: all clean debug
1250
all: vfdecrypt
1351

52+
vfdecrypt: vfdecrypt.o
53+
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
54+
55+
vfdecrypt.o: vfdecrypt.c
56+
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
57+
58+
debug: CFLAGS := -O0 -g -Wall -Wextra -Wpedantic -std=c11
59+
debug: clean vfdecrypt
60+
1461
clean:
15-
-rm -f vfdecrypt
16-
-rm -f *~
62+
$(RM) vfdecrypt vfdecrypt.o *~

0 commit comments

Comments
 (0)