#
# Makefile for DJGPP - unrar
#
# Note: you have to 'make clean' before you can build
#	the sfx module
#

# DOS32 using DJGPP 2.03 Patchlevel 2 and GCC 2.95.3
CXX = gpp
CXXFLAGS = -O2 -Wno-deprecated
#DEFINES = -D_MSC_VER -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE

##########################

.PHONY: all clean veryclean

COMPILE=$(CXX) $(CXXFLAGS) $(DEFINES)
LINK=$(CXX)

UNRAR_OBJ=filestr.o recvol.o rs.o scantree.o

OBJECTS=rar.o strlist.o strfn.o pathfn.o savepos.o smallfn.o global.o \
	file.o filefn.o filcreat.o archive.o arcread.o unicode.o \
	system.o isnt.o crypt.o crc.o rawread.o encname.o \
	resource.o match.o timefn.o rdwrfn.o consio.o options.o \
	ulinks.o errhnd.o rarvm.o rijndael.o getbits.o sha1.o \
	extinfo.o extract.o volume.o list.o find.o unpack.o cmddata.o

.cpp.o:
	$(COMPILE) -D$(WHAT) -c $<

all:	unrar

unrar:	WHAT=UNRAR
unrar:	$(OBJECTS) $(UNRAR_OBJ)
	$(LINK) -Wl,-s -o unrar.exe $(LDFLAGS) $(OBJECTS) $(UNRAR_OBJ) $(LIBS)
	exe2coff unrar.exe
	cp -u $(DJDIR)/bin/cwsdstub.exe .
	copy /b cwsdstub.exe+unrar unrar.exe
	-upx --ultra-brute unrar.exe

sfx:	WHAT=SFX_MODULE
sfx:	$(OBJECTS)
	$(LINK) -Wl,-s -o default.sfx $(LDFLAGS) $(OBJECTS) -DSFX_MODULE

clean:
	$(RM) $(OBJECTS) $(UNRAR_OBJ)

veryclean: clean
	$(RM) unrar.exe default.sfx cwsdstub.exe unrar
