VERSION	= 1.0.1

DEBUG	= -g
CFLAGS	= $(DEBUG) -Wall -O -DVERSION=\"$(VERSION)\"
LFLAGS	= $(DEBUG)

INSTALL	= install
SUDO	= sudo
PACKAGE	= elmmpc-$(VERSION)

prefix	= /usr/local
bindir	= $(prefix)/bin

all: elmmpc

install: elmmpc
	strip elmmpc
	$(INSTALL) -c -m 4755 -o root -g root elmmpc $(bindir)

install-local: elmmpc
	$(SUDO) chown root.root elmmpc
	$(SUDO) chmod u+s elmmpc

elmmpc: mpc.c
	$(CC) -o elmmpc $(CFLAGS) mpc.c

tar:
	$(MAKE) real-tar tmpdir=/tmp/$$$$

real-tar:
	@$(MAKE) clean
	@rm -f $(PACKAGE).tar.gz
	mkdir $(tmpdir)
	cp -rp . $(tmpdir)/$(PACKAGE)
	(cd $(tmpdir); $(SUDO) chown -R nobody.nogroup .)
	(cd $(tmpdir); tar cf - $(PACKAGE)) | gzip -c > $(PACKAGE).tar.gz
	$(SUDO) rm -r $(tmpdir)

clean:
	-rm -f elmmpc
