#
# unRAR Makefile for Linux and GNU make
#
# Linux port by Markus F.X.J. Oberhumer <markus.oberhumer@jk.uni-linz.ac.at>
#


# This is a ready-to-run Makefile.
# Do a 'make' to build unrar.

# Do a 'make install' as root.
# You might want to change this, but probably not.
INSTALL_BINDIR = /usr/local/bin


DEPS = \
	compress.h const.h os.h \
	lochead.eng loctoup.eng \
	block.c comment.c compr.c crccrypt.c extract.c getargs.c \
	getopt.c global.c list.c os.c others.c rdwrfn.c smallfn.c \
	somefn.c unpack.c unpold.c unrar.c


# /***********************************************************************
# // main target
# ************************************************************************/

CC = gcc
CFLAGS = -D_UNIX -Wall -O2 -fomit-frame-pointer -fno-strength-reduce

unrar: $(DEPS)
	$(CC) $(CFLAGS) unrar.c  -s -o $@


# /***********************************************************************
# // installation
# ************************************************************************/

.PHONY: bin_install install clean

bin_install: unrar
	install -m 755 -o root -g root $^  $(INSTALL_BINDIR)/

install: unrar bin_install
	@echo 'unrar' installed.

clean:
	-rm -f *.o unrar


# /***********************************************************************
# // distribution (this won't work for you)
# ************************************************************************/

PWD       := $(shell sh -c "(cd .. && pwd)")
DIRNAME   := $(shell echo $(PWD) | sed -e 's|.*[/\\]||')
DISTNAME  := $(DIRNAME)

.PHONY: dist pack

dist pack:
	cd ../.. && (find $(DIRNAME) -type f -print | mkdist.pl -e | tar -covf- -T- | gzip -9 > $(DISTNAME).tar.gz)


