# Path to parent kernel include files directory (default /usr/include)
#KERNEL_INCLUDE=
#KERNEL_INCLUDE=/net/minus/home/src/BH/vger3/vger-mirror-softirq/linux/include
#KERNEL_INCLUDE=/home1/root/vger-129/vger-mirror/linux/include
KERNEL_INCLUDE=/usr/src/linux/include

DEFINES= -DRESOLVE_HOSTNAMES

#options if you have a bind>=4.9.4 libresolv (or, maybe, glibc)
LDLIBS=-lresolv
ADDLIB=

#options if you compile with libc5, and without a bind>=4.9.4 libresolv
#LDLIBS=
#ADDLIB=inet_ntop.o inet_pton.o

#options for decnet
ADDLIB+=dnet_ntop.o dnet_pton.o

#options for ipx
ADDLIB+=ipx_ntop.o ipx_pton.o

ifeq (/usr/include/socketbits.h,$(wildcard /usr/include/socketbits.h))
  ifeq (/usr/include/net/if_packet.h,$(wildcard /usr/include/net/if_packet.h))
    GLIBCFIX=-I../include-glibc -include ../include-glibc/glibc-bugs.h
  endif
endif
ifeq (/usr/include/bits/socket.h,$(wildcard /usr/include/bits/socket.h))
  GLIBCFIX=-I../include-glibc -include ../include-glibc/glibc-bugs.h
endif

CC=gcc
CFLAGS=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g $(GLIBCFIX) -I$(KERNEL_INCLUDE) -I../include $(DEFINES)

LDLIBS += -L../lib -lnetlink -lutil

SUBDIRS=lib ip tc

LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a

all: check-kernel
	@set -e; \
	for i in $(SUBDIRS); \
	do $(MAKE) -C $$i; done

check-kernel:
ifeq ($(KERNEL_INCLUDE),)
	@echo "Please, set correct KERNEL_INCLUDE"; false
else
	@set -e; \
	if [ ! -r $(KERNEL_INCLUDE)/linux/autoconf.h ]; then \
		echo "Please, Compile the kernel first"; false; fi
endif

clean:
	for i in $(SUBDIRS) doc; \
	do $(MAKE) -C $$i clean; done

.EXPORT_ALL_VARIABLES:
