PROG=	ethtimed
SRCS=	ethtimed.c

OS=	$(shell uname)

CC?=	cc
LD=	$(CC)

ifeq "$(OS)" "Linux"
SRCS+=	strtonum.c
endif

OBJS=	$(SRCS:.c=.o)
LIBS=	-lpcap

ifeq "$(STATIC)" "yes"
LDFLAGS=-static
endif

CFLAGS=	-O2 -pipe
CFLAGS+=-W -Wall -Werror -Wshadow -Winline -Wpointer-arith -Wcast-qual
CFLAGS+=-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
CFLAGS+=-pedantic -Wno-long-long -fno-builtin-log

ifeq "$(OS)" "Linux"
CFLAGS+=-Wno-format
endif

all:	$(PROG)

clean:
	rm -f $(OBJS) $(PROG) $(PROG).core core

$(PROG): $(OBJS)
	$(LD) $(LDFLAGS) -o $(PROG) $(OBJS) $(LIBS)
