# Makefile for utelnetd
# 
# Configure this with the following environment variables:
#

# where to install
#INSTDIR		:= /usr/local/bin/
INSTDIR		:= $(PREFIX)/sbin

# GNU target string 
#CROSS		:=

# where to find login program
ifneq ("", "$(BSD)")
LOGIN		:= /usr/bin/login
else
LOGIN		:= /bin/login
endif

ifneq ("", "$(BSD)")
CORE		:= utelnetd.core
else
CORE		:= core
endif

# nothing to configure below this line... ---8<---8<---8<---

PROGS     = utelnetd

INSTMODE  = 0755
INSTOWNER = root
INSTGROUP = root

OBJS      = utelnetd.o

CC        = $(CROSS)gcc
INSTALL   = install

CFLAGS	 += -I. -pipe -DHAS_TIMEOUT -DSHELLPATH=\"$(LOGIN)\" -Wall $(EXTRA_CFLAGS)
LDFLAGS   = $(EXTRA_LDFLAGS)

ifneq ("","$(DEBUG)")
CFLAGS   += -DDEBUG -g -Os
STRIP	  = \#
else
CFLAGS	 += -fomit-frame-pointer
STRIP	  = $(CROSS)strip 
endif

ifeq ("1", "$(BSD)")
CFLAGS   += -DBSD
endif


all: $(PROGS)

%.o: %.c
	@echo 'CC $@'
	@$(CC) $(DEFINE) $(CFLAGS) $(INCLUDE) -c $< -o $@

$(PROGS): $(OBJS)
	@echo 'CC $@'
	@$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
	$(STRIP) --remove-section=.comment --remove-section=.note $@

.PHONY: install
install:
	#$(INSTALL) -d $(INSTDIR)
	#$(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP) $(PROGS) $(INSTDIR)
	$(INSTALL) -c $(PROGS) $(INSTDIR)

.PHONY: clean
clean:
	rm -f $(PROGS) *.o $(CORE)
