# $Id: Makefile 27118 2011-08-25 18:02:55Z vch $
# simple build file for n2lib

# Note: make sure you've set the N2ROOT variable before running this file
#       (e.g. by sourcing setup.sh in the N2 installation directory)

# Note: you may need to update the PYTHON, PYINCLUDE and PYLIB variables
#       before running this script, especially if you're not using Python
#       2.1 or you're not running on a Linux system.

# Note: for more info, see "The n2lib Library" chapter in the N2 docs;
#       http://nordrad.pythonware.net/zone/library-n2lib.htm
CUR_REL_PATH := iris/nordrad2

include ../../config.mk

TESTS =  n2nettest n2filetest n2subtest
APPS = $(TESTS)

LIB = libn2lib.so

LIBOBJS = n2lib.o

N2ROOT=/usr

PYINCLUDE=-I$(N2ROOT)/include/$(PYTHON_VERSION)

LDLIBS += -ln2lib -l$(PYTHON_VERSION) -lm -ltk -lpthread -lutil


CPPFLAGS += $(PYINCLUDE)
CFLAGS += -fPIC

LDFLAGS = -L$(IRIS_DYN_LIB) -Xlinker -export-dynamic 

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

all: $(LIB_DIR)/$(LIB)

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

$(LIB): $(LIBOBJS)
	gcc -shared $^ -o $@

n2nettest: n2nettest.o
n2filetest: n2filetest.o
n2subtest: n2subtest.o
tests: $(TESTS)

install: all $(IRIS_DYN_LIB)
	install -m 0775 -o $(IRIS_USER) -g $(IRIS_GROUP) $(LIB) $(IRIS_DYN_LIB)

test:

uninstall:
	rm -f $(IRIS_DYN_LIB)/$(LIB)

$(OBJS) : Makefile

-include $(DEPS)
