top_srcdir = @top_srcdir@
srcdir = @srcdir@
prefix = @prefix@
datarootdir = @datarootdir@
exec_prefix = @exec_prefix@
bindir = @bindir@
mandir = @mandir@

CC = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@ $(DEFS) -I$(NBASEDIR)
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ $(NBASELIB) $(MAC_FLAGS)
DEFS = @DEFS@ -D_FORTIFY_SOURCE=2
APR_LIBS = @APR_LIBS@
SVN_LIBS = @SVN_LIBS@

INSTALL = @INSTALL@
STRIP = @STRIP@
SHTOOL = ../shtool

DESTDIR =

SOURCES = nmap-update svn_auth
C_FILES = $(addsuffix .c,$(SOURCES))
O_FILES = $(addsuffix .o,$(SOURCES))

NBASEDIR = ../nbase
NBASELIB = $(NBASEDIR)/libnbase.a

all: nmap-update

nmap-update: $(O_FILES) $(NBASELIB)
	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(SVN_LIBS) $(APR_LIBS) $(OPENSSL_LIBS) $(LIBS)

%.o: %.c
	$(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<

$(NBASELIB):
	cd $(NBASEDIR) && $(MAKE)

install: nmap-update
	$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
	$(INSTALL) -c -m 755 nmap-update $(DESTDIR)$(bindir)
	$(STRIP) -x $(DESTDIR)$(bindir)/nmap-update
	$(INSTALL) -c -m 644 ../docs/nmap-update.1 $(DESTDIR)$(mandir)/man1/

uninstall:
	$(RM) -f $(DESTDIR)$(bindir)/nmap-update

clean:
	rm -f nmap-update *.o

distclean: clean
	rm -f Makefile makefile.dep

Makefile: Makefile.in
	./config.status

makefile.dep:
	$(CC) -MM $(CPPFLAGS) $(C_FILES) > $@
-include makefile.dep

.PHONY: all clean
