From a23e8d016cbc4d5a9d3c3f28893c34f0dc6a6618 Mon Sep 17 00:00:00 2001
From: Levente Polyak <levente@leventepolyak.net>
Date: Sat, 27 Jan 2024 20:57:57 +0100
Subject: [PATCH] fix: make to respect distro flags

---
 Makefile | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index c63ed1b..2e84bb5 100644
--- a/Makefile
+++ b/Makefile
@@ -3,14 +3,13 @@ CC 	=	gcc
 INSTALL	=	install
 IFLAGS  = -idirafter dummyinc
 #CFLAGS = -g
-CFLAGS	=	-O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 \
+CFLAGS	?=	-O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 \
 	-Wall -W -Wshadow -Werror -Wformat-security \
 	-D_FORTIFY_SOURCE=2 \
 	#-pedantic -Wconversion
 
 LIBS	=	`./vsf_findlibs.sh`
-LINK	=	-Wl,-s
-LDFLAGS	=	-fPIE -pie -Wl,-z,relro -Wl,-z,now
+LDFLAGS	?=	-fPIE -pie -Wl,-z,relro -Wl,-z,now
 
 OBJS	=	main.o utility.o prelogin.o ftpcmdio.o postlogin.o privsock.o \
 		tunables.o ftpdataio.o secbuf.o ls.o \
@@ -23,10 +22,10 @@ OBJS	=	main.o utility.o prelogin.o ftpcmdio.o postlogin.o privsock.o \
 
 
 .c.o:
-	$(CC) -c $*.c $(CFLAGS) $(IFLAGS)
+	$(CC) -c $*.c $(CFLAGS) $(CPPFLAGS) $(IFLAGS)
 
 vsftpd: $(OBJS) 
-	$(CC) -o vsftpd $(OBJS) $(LINK) $(LDFLAGS) $(LIBS)
+	$(CC) -o vsftpd $(OBJS) $(LDFLAGS) $(LIBS)
 
 install:
 	if [ -x /usr/local/sbin ]; then \
-- 
2.43.0

