
#
# Makefile for the GNOKII tool suite.
#
# Copyright (C) 1999 Hugh Blemings & Pavel Jank ml.
#               2000 Karel Zak
#

TOPDIR=..
include $(TOPDIR)/Makefile.global

OBJS =	gnokii.o

ifdef OWN_GETOPT
	OBJS += $(TOPDIR)/getopt/libgetopt.a
endif

ifndef WIN32_CROSS
ifdef NO_SHARED
	GNOKII_LIB=libgnokii.a
else
	GNOKII_LIB=libgnokii.so
endif
PRGNAME=gnokii
else
ifdef NO_SHARED
	GNOKII_LIB=gnokii.lib
else
	GNOKII_LIB=gnokii.dll
endif
PRGNAME=gnokii.exe
endif

LDLIBS += -L$(TOPDIR)/common -lgnokii

ifdef XPM_LIBS
	LDLIBS += $(XPM_LIBS)
endif

ifdef ICONV_LIBS
	LDLIBS += $(ICONV_LIBS)
endif

all: $(PRGNAME)

gnokii: $(OBJS) $(TOPDIR)/common/$(GNOKII_LIB)
	$(CC) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@

gnokii.exe: $(OBJS) $(TOPDIR)/common/$(GNOKII_LIB)
	$(CC) -mconsole $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@

$(TOPDIR)/getopt/libgetopt.a:
	$(MAKE) -C $(TOPDIR)/getopt

clean:
	$(RM) $(OBJS) *~ depend gnokii *.exe core *.bak

install: all
	$(INSTALL) -d $(DESTDIR)$(bindir)
	$(INSTALL) gnokii $(DESTDIR)$(bindir)

install-strip: all
	$(INSTALL) -d $(DESTDIR)$(bindir)
	$(INSTALL) -s gnokii $(DESTDIR)$(bindir)
	@echo "done"

install-suid: all
	@if [ -z "/bin/grep -e '^gnokii:' /etc/group" ]; then \
		/usr/sbin/groupadd gnokii; \
	fi
	$(INSTALL) -d $(DESTDIR)$(bindir)
	$(INSTALL) -o root -g gnokii -m 0750 gnokii $(DESTDIR)$(bindir)
	@echo

install-ss: all
	@if [ -z "/bin/grep -e '^gnokii:' /etc/group" ]; then \
		/usr/sbin/groupadd gnokii; \
	fi
	$(INSTALL) -d $(DESTDIR)$(bindir)
	$(INSTALL) -o root -g gnokii -m 0750 -s gnokii $(DESTDIR)$(bindir)
	@echo

depend dep:
	$(CC) $(CFLAGS) -MM *.c >depend

ifeq (depend,$(wildcard depend))
include depend
endif

.PHONY: all install clean dep depend
