--- unrar/makefile.orig	2024-08-19 10:26:32.000000000 +0200
+++ unrar/makefile	2024-11-18 08:01:57.119759500 +0100
@@ -14,6 +14,16 @@
 LDFLAGS=-pthread
 DESTDIR=/usr
 
+ifeq ($(OS), Windows_NT)
+	EXEEXT=.exe
+	SOEXT=.dll
+	LIBS=-lpowrprof -loleaut32 -lole32 -lwbemuuid
+	LDFLAGS+=-Wl,--out-implib,libunrar.dll.a
+else
+	EXEEXT=
+	SOEXT=.so
+endif
+
 ##########################
 
 COMPILE=$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES)
@@ -22,7 +32,7 @@
 WHAT=UNRAR
 
 UNRAR_OBJ=filestr.o recvol.o rs.o scantree.o qopen.o
-LIB_OBJ=filestr.o scantree.o dll.o qopen.o
+LIB_OBJ=filestr.o recvol.o rs.o scantree.o dll.o qopen.o
 
 OBJECTS=rar.o strlist.o strfn.o pathfn.o smallfn.o global.o file.o filefn.o filcreat.o \
 	archive.o arcread.o unicode.o system.o crypt.o crc.o rawread.o encname.o \
@@ -30,6 +40,10 @@
 	rijndael.o getbits.o sha1.o sha256.o blake2s.o hash.o extinfo.o extract.o volume.o \
 	list.o find.o unpack.o headers.o threadpool.o rs16.o cmddata.o ui.o largepage.o
 
+ifeq ($(OS), Windows_NT)
+OBJECTS+=isnt.o motw.o
+endif
+
 .cpp.o:
 	$(COMPILE) -D$(WHAT) -c $<
 
@@ -42,15 +56,15 @@
 clean:
 	@rm -f *.bak *~
 	@rm -f $(OBJECTS) $(UNRAR_OBJ) $(LIB_OBJ)
-	@rm -f unrar libunrar.*
+	@rm -f unrar$(EXEEXT) libunrar.*
 
 # We removed 'clean' from dependencies, because it prevented parallel
 # 'make -Jn' builds.
 
-unrar:	$(OBJECTS) $(UNRAR_OBJ)
-	@rm -f unrar
-	$(LINK) -o unrar $(LDFLAGS) $(OBJECTS) $(UNRAR_OBJ) $(LIBS)	
-	$(STRIP) unrar
+unrar: $(OBJECTS) $(UNRAR_OBJ)
+	@rm -f unrar$(EXEEXT)
+	$(LINK) -o unrar$(EXEEXT) $(LDFLAGS) $(OBJECTS) $(UNRAR_OBJ) $(LIBS)
+	$(STRIP) unrar$(EXEEXT)
 
 sfx:	WHAT=SFX_MODULE
 sfx:	$(OBJECTS)
@@ -62,18 +76,18 @@
 lib:	CXXFLAGS+=$(LIBFLAGS)
 lib:	$(OBJECTS) $(LIB_OBJ)
 	@rm -f libunrar.*
-	$(LINK) -shared -o libunrar.so $(LDFLAGS) $(OBJECTS) $(LIB_OBJ)
+	$(LINK) -shared -o libunrar$(SOEXT) $(LDFLAGS) $(OBJECTS) $(LIB_OBJ) $(LIBS)
 	$(AR) rcs libunrar.a $(OBJECTS) $(LIB_OBJ)
 
 install-unrar:
-			install -D unrar $(DESTDIR)/bin/unrar
+			install -D unrar $(DESTDIR)/bin/unrar$(EXEEXT)
 
 uninstall-unrar:
-			rm -f $(DESTDIR)/bin/unrar
+			rm -f $(DESTDIR)/bin/unrar$(EXEEXT)
 
 install-lib:
-		install libunrar.so $(DESTDIR)/lib
+		install libunrar$(SOEXT) $(DESTDIR)/lib
 		install libunrar.a $(DESTDIR)/lib
 
 uninstall-lib:
-		rm -f $(DESTDIR)/lib/libunrar.so
+		rm -f $(DESTDIR)/lib/libunrar$(SOEXT)
