CUR_REL_PATH := "base/ngpipes/hdf5"

include ../../../config.mk

CONFS = nexrad2iris.conf

APPS := nexrad2iris archive2dump
TESTS := endian_test  archive2cdump
SHARED_OBJS := volumehdr.o messagehdr.o message.o message5.o message31.o a2volumeconfig.o a2sweepconfig.o a2moment.o a2rayconfig.o a2ray.o

#CPPFLAGS += -Wall -MMD -D_REENTRANT
#CFLAGS += -g -O0
#CXXFLAGS +=  -g -O0 -std=c++11
#LDFLAGS += -lboost_program_options

APPS_OBJS = $(patsubst %,%.o,$(APPS))
#TESTS_OBJS = $(patsubst %,%.o,$(TESTS))

OBJS := $(APPS_OBJS) $(TESTS_OBJS) $(SHARED_OBJS)
DEPS := $(patsubst %.o,%.d,$(OBJS))

PRE_CPPFLAGS += -I../../wrdata_lib -I../
PRE_LDFLAGS += -L../../lib

LINK.o = $(LINK.cc)
LDLIBS += -lwrdata -lrscan -ldsp -lmisc -lhimath -luser -lsiglog -lconfig -lboost_program_options -lboost_system -lboost_filesystem

all: $(APPS) $(TESTS)

#archive2cdump: archive2cdump.c

#nexrad2iris: nexrad2iris.o $(SHARED_OBJS)
#	$(LINK.cc) $< -o $@

#archive2dump: archive2dump.o $(SHARED_OBJS)
#	$(LINK.cc) $^ -o $@

install: all ${IRIS_PIPES} ${IRIS_PIPES_TMPL} ${IRIS_CONFIG_TMPL}
	install -m 0775 -o ${IRIS_USER} -g ${IRIS_GROUP} $(STRIP_OPT) ${APPS} ${IRIS_PIPES}
	install -m 0775 -o ${IRIS_USER} -g ${IRIS_GROUP} $(STRIP_OPT) ${APPS} ${IRIS_PIPES_TMPL}
	install -m 0664 -o ${IRIS_USER} -g ${IRIS_GROUP} ${CONFS} ${IRIS_CONFIG_TMPL}

uninstall:
	if [ -d ${IRIS_PIPES}       ]; then cd ${IRIS_PIPES}       && rm -f ${APPS}; fi
	if [ -d ${IRIS_PIPES_TMPL}  ]; then cd ${IRIS_PIPES_TMPL}  && rm -f ${APPS}; fi
	if [ -d ${IRIS_CONFIG_TMPL} ]; then cd ${IRIS_CONFIG_TMPL} && rm -f ${CONFS}; fi

clean:
	rm -f *.o *~ *.a *.d *.d.bak $(APPS) $(TESTS)

$(APPS): $(SHARED_OBJS)

$(APP_OBJS):

$(OBJS): Makefile

-include $(DEPS)
