CUR_REL_PATH := base/exthdr_lib

include ../shared/config.mk

INST_INCLUDES = exten_header.h exten_header_plugin.h
LIB = libexthdr.a
APPS = plugin_test udp_pipe

CPPFLAGS  += -DLinux -DPLUGINDIR=\"$(IRIS_LIB)/exthdr/plugins\"
LDLIBS += -ldl

LDLIBS_plugin_test = -lpopt

CFLAGS_udp_pipe = -std=gnu99
LDLIBS_udp_pipe = -lpopt -lm

## LOADLIBES = $(LIB_DIR)/$(LIB)

LIB_OBJS := exten_header.o
APP_OBJS := $(patsubst %,%.o,$(APPS))

OBJS = $(LIB_OBJS) $(APPS_OBJS)
DEPS = $(patsubst %.o,%.d,$(OBJS))

all: $(LIB_DIR)/$(LIB) $(APPS)

clean:
	rm -f *.o *.d *.bak *~ $(APPS) $(LIB) $(LIB_DIR)/$(LIB)

install: all $(IRIS_BIN) $(IRIS_LIB)  $(IRIS_INCLUDE)
	install -m 0664 -o $(IRIS_USER) -g $(IRIS_GROUP) $(LIB) $(IRIS_LIB)
	install -m 0664 -o $(IRIS_USER) -g $(IRIS_GROUP) $(INST_INCLUDES) $(IRIS_INCLUDE)

test:

uninstall:
	if [ -d $(IRIS_LIB) ]; then cd $(IRIS_LIB) && rm -f $(LIB); fi
	if [ -d $(IRIS_INCLUDE) ]; then \
		cd $(IRIS_INCLUDE) && rm -f $(INST_INCLUDES); fi

$(LIB): $(LIB_OBJS)
	rm -f $@; $(AR) -rsc $@ $^

$(APPS): $(LIB_DIR)/$(LIB)

$(OBJS): Makefile

-include $(DEPS)
