#
# Makefile for realpath.
# "@(#)realpath:$Id: Makefile 222 2008-04-01 22:24:09Z robert $"
#

VERSION	= $(shell dpkg-parsechangelog | sed -ne 's/^Version: *//p')

CC	= gcc
CFLAGS	= -Wall -Wstrict-prototypes -Wmissing-prototypes -DVERSION='"$(VERSION)"' 
LDFLAGS	=


ifeq (,$(findstring nodebug,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -g
endif

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -O0
else
  CFLAGS += -O2
endif

ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
  LDFLAGS += -s
endif


prefix		= debian/realpath

bindir		= $(prefix)/usr/bin
man1dir		= $(prefix)/usr/share/man/man1

bin		= realpath
man1		= man/*.1

generated	= realpath 

all: $(source_links) $(generated)


realpath: realpath.o
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)

	
debug:
	DEB_BUILD_OPTIONS=noopt,nostrip $(MAKE) all


clean:
	rm -f $(source_links)
	rm -f core *.o $(generated)


installdirs:
	for i in $(prefix) $(man1dir) ; \
	do  \
		echo "$$i"; \
		test -d $$i || install -p -d $$i; \
	done

install: installdirs

	install -p -m 0755 $(bin) $(bindir)
	install -p -m 0644 $(man1) $(man1dir)


.PHONY: all debug clean install installdirs
