1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/utils/MTP/Makefile b/utils/MTP/Makefile
index 6c709ec..8439f8b 100644
--- a/utils/MTP/Makefile
+++ b/utils/MTP/Makefile
@@ -1,11 +1,14 @@
 CFLAGS = -Wall
 LIBS = -lmtp
 OUTPUT = sendfirm
+EXTRA_CFLAGS = $(shell echo -e \
+	'\#include <libmtp.h>\nlibmtp version: LIBMTP_VERSION' | \
+	gcc -E -P - -o - | grep -q '^libmtp version: 0\.2' && echo '-DOLDMTP')

 all: $(OUTPUT)

 $(OUTPUT): sendfirm.c
-	gcc $(CFLAGS) $(LIBS) -o $(OUTPUT) sendfirm.c || gcc $(CFLAGS) $(LIBS) -DOLDMTP -o $(OUTPUT) sendfirm.c
+	gcc $(EXTRA_CFLAGS) $(CFLAGS) $(LIBS) -o $(OUTPUT) sendfirm.c

 $(OUTPUT).exe: sendfirm_win.c
 	mingw32-gcc $(CFLAGS) -o $(OUTPUT).exe sendfirm_win.c MTP_DLL.dll