#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
# Top-level Makefile for TCNATIVE
#

CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
CC_OLD = @CC@
LIBTOOL_OLD = @LIBTOOL@

# gets substituted into some targets
TCNATIVE_MAJOR_VERSION=@TCNATIVE_MAJOR_VERSION@
TCNATIVE_DOTTED_VERSION=@TCNATIVE_DOTTED_VERSION@
TCNATIVE_LIBTOOL_VERSION=@TCNATIVE_LIBTOOL_VERSION@

srcdir = @srcdir@
VPATH = @srcdir@

# this sucks, but it's the only way to add extra flags to the LT_COMPILE
INCLUDES = @CFLAGS@ @CPPFLAGS@ @TCNATIVE_INCLUDES@ @TCNATIVE_PRIV_INCLUDES@ @APR_INCLUDES@
TCNATIVE_LDFLAGS = @TCNATIVE_LDFLAGS@
TCNATIVE_LIBS = @TCNATIVE_LIBS@

TARGET_LIB = lib@TCNATIVE_LIBNAME@.la
EXTRA_OS_LINK=@EXTRA_OS_LINK@
TCNATIVE_PCFILE = tcnative-$(TCNATIVE_MAJOR_VERSION).pc
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@

TARGETS = $(TARGET_LIB)

# bring in rules.mk for standard functionality
@INCLUDE_RULES@
@INCLUDE_OUTPUTS@

ifneq ($(CC_OLD),$(CC))
    CC=$(CC_OLD)
endif

ifneq ($(LIBTOOL_OLD),$(LIBTOOL))
    LIBTOOL=$(LIBTOOL_OLD)
endif

LINK          = $(LIBTOOL) $(LTFLAGS) --mode=link --tag=CC $(LT_LDFLAGS) $(COMPILE) -version-info $(TCNATIVE_LIBTOOL_VERSION) $(ALL_LDFLAGS) -o $@
CLEAN_SUBDIRS = test

CLEAN_TARGETS = .make.dirs
DISTCLEAN_TARGETS = config.cache config.log config.status libtool \
	build/rules.mk tcnative.pc
EXTRACLEAN_TARGETS = configure aclocal.m4 build-outputs.mk \
	build/apr_common.m4 build/find_apr.m4 build/install.sh \
	build/config.guess build/config.sub tcnative.spec

prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
includedir=@includedir@
top_srcdir=@abs_srcdir@
top_blddir=@abs_builddir@


install: $(TARGET_LIB)
	$(APR_MKDIR) $(DESTDIR)$(includedir) $(DESTDIR)$(libdir)/pkgconfig \
		     $(DESTDIR)$(libdir) $(DESTDIR)$(bindir)
	$(INSTALL_DATA) tcnative.pc $(DESTDIR)$(libdir)/pkgconfig/$(TCNATIVE_PCFILE)
	list='$(INSTALL_SUBDIRS)'; for i in $$list; do \
		( cd $$i ; $(MAKE) DESTDIR=$(DESTDIR) install ); \
	done
	$(LIBTOOL) --mode=install $(INSTALL) -m 755 $(TARGET_LIB) $(DESTDIR)$(libdir)

$(TARGET_LIB): $(OBJECTS)
	$(LINK) @lib_target@ $(TCNATIVE_LDFLAGS) $(TCNATIVE_LIBS)

check: $(TARGET_LIB)
	(cd test && $(MAKE) check)
