/ src / Makefile
Makefile
 1  ifndef MSYSTEM
 2  	CPREFIX = x86_64-w64-mingw32-
 3  endif
 4  
 5  WINDIVERTHEADERS = ../../../include
 6  WINDIVERTLIBS = ../../binary
 7  MINGWLIB = /usr/x86_64-w64-mingw32/lib/
 8  
 9  TARGET = goodbyedpi.exe
10  # Linking SSP does not work for some reason, the executable doesn't start.
11  #LIBS = -L$(WINDIVERTLIBS) -Wl,-Bstatic -lssp -Wl,-Bdynamic -lWinDivert -lws2_32
12  LIBS = -L$(WINDIVERTLIBS) -lWinDivert -lws2_32 -l:libssp.a
13  CC = $(CPREFIX)gcc
14  
15  CCWINDRES = $(CPREFIX)windres
16  ifeq (, $(shell which $(CPREFIX)windres))
17  	CCWINDRES = windres
18  endif
19  
20  CFLAGS = -std=c99 -pie -fPIE -pipe -I$(WINDIVERTHEADERS) -L$(WINDIVERTLIBS) \
21           -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
22           -Wall -Wextra -Wpedantic -Wformat=2 -Wformat-overflow=2 -Wformat-truncation=2 \
23           -Wformat-security -Wno-format-nonliteral -Wshadow -Wstrict-aliasing=1 \
24           -Wnull-dereference -Warray-bounds=2 -Wimplicit-fallthrough=3 \
25           -Wstringop-overflow=4 \
26           -Wformat-signedness -Wstrict-overflow=2 -Wcast-align=strict \
27           -Wfloat-equal -Wcast-align -Wsign-conversion \
28           #-fstack-protector-strong
29  LDFLAGS = -fstack-protector -Wl,-O1,-pie,--dynamicbase,--nxcompat,--sort-common,--as-needed \
30  -Wl,--image-base,0x140000000 -Wl,--disable-auto-image-base
31  
32  ifdef BIT64
33  	LDFLAGS += -Wl,--high-entropy-va -Wl,--pic-executable,-e,mainCRTStartup
34  else
35  	CFLAGS += -m32
36  	LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup -m32
37  endif
38  
39  .PHONY: default all clean
40  
41  default: $(TARGET)
42  all: default
43  
44  OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c utils/*.c)) goodbyedpi-rc.o
45  HEADERS = $(wildcard *.h utils/*.h)
46  
47  %.o: %.c $(HEADERS)
48  	$(CC) $(CFLAGS) -c $< -o $@
49  
50  goodbyedpi-rc.o:
51  	$(CCWINDRES) goodbyedpi-rc.rc goodbyedpi-rc.o
52  
53  .PRECIOUS: $(TARGET) $(OBJECTS)
54  
55  $(TARGET): $(OBJECTS)
56  	$(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -s -o $@
57  
58  clean:
59  	-rm -f *.o utils/*.o
60  	-rm -f $(TARGET)