PREFIX = /usr/local
BINDEST = ${PREFIX}/bin
MANDEST = ${PREFIX}/man/man8

CC = gcc
CFLAGS = -O2 -Wall -I. -g
LDFLAGS = -g
LIBS =

ifdef OS2
LDFLAGS += -Zsmall-conv
LIBS += -lsocket
BINSUFFIX = .exe
endif

netselect: netselect.o
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
ifdef OS2
	emxbind -bwq netselect
else
	-sudo chown root netselect && sudo chmod +s netselect
endif

install: $(PROG)
	-install -d ${BINDEST}
#	-install -d ${MANDEST}
ifdef OS2
	emxbind -bwsq netselect
	install -o root -g root -m 4755 netselect$(BINSUFFIX) $(BINDEST)
else
	install -s -o root -g root -m 4755 netselect $(BINDEST)
endif
#	install -o root -g root -m 0644 netselect.8 $(MANDEST)

uninstall:
	$(RM) ${BINDEST}/netselect${BINSUFFIX} ${MANDEST}/netselect.8

clean:
	$(RM) netselect *.o *~ build-stamp core netselect.exe
