CUR_REL_PATH := base/maps_lib
PACKAGE := base-maps_lib

include ../../config.mk

SUBDIRS := overlay_icons
ifdef ENABLE_NLS
  SUBDIRS := $(SUBDIRS) po
endif

LIB = libmaps.a
INST_INCLUDES = maps_lib.h

OBJS =	\
	catch_load.o \
	maps_lib_nls_init.o \
	overlay_files.o \
	overlay_load.o \
	OverlayMap.o \
	OverlaySave.o \
	TerrainLoad.o

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

PRE_CPPFLAGS += -I../include -I../user_lib -I../vtv_lib

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

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

install: all $(IRIS_INCLUDE) $(IRIS_LIB)
	$(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)

test:
	$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@;)

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

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

$(OBJS): Makefile

-include $(DEPS)
