CUR_REL_PATH := base/rtq_lib
PACKAGE := base-rtq_lib

include ../shared/config.mk

ifdef ENABLE_NLS
  SUBDIRS = po
endif

CONF_FILES = *.conf
APPS = rtd_v1_xmt rtd_v2_xmt rtd_nids3_xmt
INST_INCLUDES = rtq_lib.h
LIB = librtq.a

APP_SUPPORT_OBJS = RtdSupport.o \
		rtq_lib_nls_init.o

OBJS =	RtqGlobal.o

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

PRE_CPPFLAGS += -I../antenna_lib -I../config_lib -I../include -I../misc_lib -I../user_lib
LDLIBS += -lmisc -lantenna -lconfig -luser -lm $(LSEARCH_BSD)

all: $(APPS) $(LIB_DIR)/$(LIB)
	$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@;)

clean:
	$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@;)
	rm -f *.o *~ *.a *.d *.d.bak $(APPS) core $(LIB_DIR)/$(LIB)

install: all $(IRIS_INCLUDE) $(IRIS_BIN) $(IRIS_LIB)  ${IRIS_CONFIG_TMPL}
	$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@;)
	install -m 0664 -o $(IRIS_USER) -g $(IRIS_GROUP) $(INST_INCLUDES) $(IRIS_INCLUDE)
	install -m 0664 -o $(IRIS_USER) -g $(IRIS_GROUP) $(LIB) $(IRIS_LIB)
	install -m 6775 -o $(IRIS_USER) -g $(IRIS_GROUP) $(STRIP_OPT) $(APPS) $(IRIS_BIN)
	install -m 0664 -o ${IRIS_USER} -g ${IRIS_GROUP} ${CONF_FILES}      ${IRIS_CONFIG_TMPL}
test:
	$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@;)

uninstall:
	$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@;)
	if [ -d $(IRIS_BIN) ]; then cd $(IRIS_BIN) && rm -f $(APPS); fi
	rm -f $(IRIS_LIB)/$(LIB)
	if [ -d $(IRIS_INCLUDE) ]; then \
		cd $(IRIS_INCLUDE) && rm -f $(INST_INCLUDES); fi
	rm -rf ${IRIS_CONFIG_TMPL}

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

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

$(OBJS): Makefile

-include $(DEPS)
