#
# $Id: Makefile,v 1.20 2005/10/13 19:57:39 evertonm Exp $
#

OOP_BASE = /usr/local/oop
OOP_INC  = $(OOP_BASE)/include
OOP_LIB  = $(OOP_BASE)/lib

ENABLE_DLOPEN = -DHAVE_DLOPEN

CC      = gcc
CFLAGS  = -Wall -g -ggdb -I$(OOP_INC) $(ENABLE_DLOPEN) \
	-DHAVE_IPV6_MREQ
LDFLAGS = -L$(OOP_LIB) -loop

PLATFORM=$(shell uname)

ifeq ($(PLATFORM),SunOS)
CFLAGS += -DHAVE_SUSECONDS_T -DHAVE_UCHAR_MCAST_TTL
LDFLAGS += -lsocket -lnsl
ifdef ENABLE_DLOPEN
LDFLAGS += -ldl
endif
endif

ifeq ($(PLATFORM),Linux)
CFLAGS += -DHAVE_STDINT -DHAVE_SUSECONDS_T -DHAVE_SIGHANDLER_T \
	-DHAVE_IP_MREQN
ifdef ENABLE_DLOPEN
LDFLAGS += -ldl
endif
else
CFLAGS += -DHAVE_INTTYPES
endif

OBJ    = main.o conf.o sock.o session.o pipe.o \
	common.o client.o server.o slot.o \
	udp_server.o udp_client.o greet.o \
	array.o usock.o str.o udp_header.o int.o \
	win.o bit.o tcpwrap.o

TARGET = nepim

.PHONY: default
default: $(TARGET)

.PHONY: clean
clean:
	rm -f *.o *~ $(TARGET)

.PHONY: build
build: clean default

$(TARGET): $(OBJ)
	$(CC) $(LDFLAGS) -o $@ $^
