include toc.make

######################################################################
#
# Subdirs overview:
#
# ./standalone: code which "stands on it's own" with no deps.
#
# ./cl: class_loader
#
# ./toolbox: exactly what it says. General utility code.
#
# ./node: "new-style" s11n code (0.7.0+).
#
# ./lite: "light" interface into new model.
#
# Dependencies are in that order, with the exception that
# (node, lite) do not depend on (s11n), and vice versa.
#
# OBSOLETE:
#
# ./s11n: "old-style" s11n code (0.6.x and earlier).
#
######################################################################

SUBDIRS = standalone cl toolbox node lite

configure_enable_s11nexpat ?= 0
ifneq (0,$(configure_enable_s11nexpat))
  SUBDIRS += expat
  CLEAN_FILES += libexpat_s11n.a
endif




############################## OBJECTS
# Note that these OBJECTS vars will resolve to empty on an initial
# build, requiring a sub-make (after building SUBDIRS) to get the
# proper values here:
LIBS11N_OBJECTS_STANDALONE = $(patsubst %,standalone/%.o,string_tokenizer stdstring_tokenizer)
LIBS11N_OBJECTS_CL = $(patsubst %,cl/%.o,class_loader path_finder)
LIBS11N_OBJECTS_TOOLBOX = $(wildcard toolbox/*.o)

LIBS11N_OBJECTS_S11NLITE = $(wildcard lite/*.o)

LIBS11N_OBJECTS_NODE = $(wildcard node/*.o node/lex/*.o)

LIBS11N_OBJECTS_SHARED =  $(LIBS11N_OBJECTS_STANDALONE) \
		$(LIBS11N_OBJECTS_CL) \
		$(LIBS11N_OBJECTS_TOOLBOX) \
		$(LIBS11N_OBJECTS_NODE) \
		$(LIBS11N_OBJECTS_S11NLITE) 

OBJECTS = $(LIBS11N_OBJECTS_SHARED)

S11N_LIBNAME ?= s11n
############################## static libs
build_a = 1
ifeq (1,$(build_a))
    STATIC_LIBS =  lib$(S11N_LIBNAME)
    lib$(S11N_LIBNAME)_a_OBJECTS = $(OBJECTS)
    include $(TOC_MAKESDIR)/STATIC_LIBS.make
endif

############################## enable/disable shared libs:
build_so = 1
ifeq (1,$(build_so))
    SHARED_LIBS = $(STATIC_LIBS)
    lib$(S11N_LIBNAME)_so_OBJECTS = $(OBJECTS)
    lib$(S11N_LIBNAME)_so_VERSION = $(PACKAGE_VERSION)
    lib$(S11N_LIBNAME)_so_LDADD = $(LIBS11N_LDADD)
    include $(TOC_MAKESDIR)/SHARED_LIBS.make
endif
# ^^^^ build shared libs?

all: subdirs
	@${MAKE} --no-print-directory STATIC_LIBS SHARED_LIBS

miniclean:
	for i in node lite; do ${MAKE} -C $$i clean; done
