#!/usr/bin/make

include toc.make

CXXFLAGS := $(shell echo $(CXXFLAGS) | perl -pe 's/-O.?//') -g

SOURCES = \
	zfstream.cpp \
	test.cpp

HEADERS = \
	debuggering_macros.hpp \
	zfstream.hpp

ifeq (1,$(ENABLE_DYNASTREAM))
endif


ifeq (1,$(HAVE_ZLIB))
  SOURCES += gzstream.cpp
  HEADERS += gzstream.hpp
endif
ifeq (1,$(HAVE_BZLIB))
  SOURCES += bzstream.cpp
  HEADERS += bzstream.hpp
endif


INSTALL_PACKAGE_HEADERS += $(HEADERS) zfstream_config.hpp

OBJECTS = $(addsuffix .o,zfstream gzstream bzstream)

DISTCLEAN_FILES += zfstream_config.hpp
CLEAN_FILES += $(OBJECTS)

DIST_FILES += $(HEADERS) $(SOURCES) $(wildcard *.at)

LIBNAME = $(PACKAGE_NAME)
SHARED_LIBS = $(LIBNAME)
STATIC_LIBS = $(LIBNAME)
$(LIBNAME)_so_VERSION = $(PACKAGE_VERSION)
OBJLIST = zfstream
$(LIBNAME)_so_LDADD =
ifeq (1,$(HAVE_ZLIB))
  OBJLIST += gzstream
  $(LIBNAME)_so_LDADD += $(LDADD_ZLIB)
  $(LIBNAME)_a_LDADD += $(LDADD_ZLIB)
endif
ifeq (1,$(HAVE_BZLIB))
  OBJLIST += bzstream
  $(LIBNAME)_so_LDADD += $(LDADD_BZLIB)
  $(LIBNAME)_a_LDADD += $(LDADD_BZLIB)
endif
$(LIBNAME)_so_OBJECTS = $(addsuffix .o,$(OBJLIST))
$(LIBNAME)_a_OBJECTS = $($(LIBNAME)_so_OBJECTS)
include $(TOC_MAKESDIR)/SHARED_LIBS.make
include $(TOC_MAKESDIR)/STATIC_LIBS.make


BIN_PROGRAMS = test
test_bin_OBJECTS = test.o
test_bin_LDADD = -L. $(LIBZFSTREAM_CLIENT_LDADD)
include $(TOC_MAKESDIR)/BIN_PROGRAMS.make

BIN_PROGRAMS: SHARED_LIBS STATIC_LIBS

run: test
	LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH} ./test
	ls -l data.*

CLEAN_FILES += $(wildcard data.*)



all: SHARED_LIBS STATIC_LIBS BIN_PROGRAMS
# 08 Okt 2004 Maintenance note: the duplicate deps of *_LIBS and
# BIN_PROGRAMS is intentional: one use reported that without the
# explicit *_LIBS dep for 'all', his lib was not built before the test
# app. Odd.



