# vim: ft=make ts=4 sw=4 noet
.DEFAULT_GOAL := all

NAME    = pkgconf
VERSION = 2.5.1
GARTYPE = v2

DESCRIPTION = Package compiler and linker metadata toolkit
define BLURB
  pkgconf is a program which helps to configure compiler and linker
  flags for development libraries, compatible with pkg-config.
endef

MASTER_SITES = http://distfiles.ariadne.space/pkgconf/
DISTFILES   += $(DISTNAME).tar.gz

LICENSE = COPYING

PACKAGES                  += OZSWpkgconf
SPKG_DESC_OZSWpkgconf     = pkg-config compatible package metadata tool
CATALOGNAME_OZSWpkgconf   = pkgconf
# Catch-all: leave PKGFILES_OZSWpkgconf unset

# Build a static binary so pkgconf itself has no runtime library deps.
EXTRA_CONFIGURE_ARGS += --enable-static --disable-shared
EXTRA_CONFIGURE_ARGS += --with-pkg-config-dir=$(prefix)/lib/pkgconfig

# Solaris compat: O_DIRECTORY and readlinkat are absent from OpenSolaris
# headers.  Append stubs to the generated libpkgconf/config.h after autoconf.
# Also fix libtool's ECHO="print -r --" (ksh93 builtin, not available under bash).
# Guards with -f so these are no-ops during the global modulation pass.
post-configure:
	@if [ -f $(WORKSRC)/libtool ]; then \
	    find $(WORKSRC) -name "libtool" -type f -exec \
	        gsed -i 's/ECHO="print -r --"/ECHO="printf %s\\n"/g' {} \; ; \
	fi
	@if [ -f $(WORKSRC)/libpkgconf/config.h ]; then \
	    printf '%s\n' \
	        '' \
	        '#ifdef __sun' \
	        '#include <sys/stat.h>' \
	        '#include <fcntl.h>' \
	        '#include <unistd.h>' \
	        '#ifndef O_DIRECTORY' \
	        '#define O_DIRECTORY 0' \
	        '#endif' \
	        'static inline ssize_t readlinkat(int d, const char *p, char *b, size_t s) { (void)d; return readlink(p, b, s); }' \
	        '#endif /* __sun */' \
	        >> $(WORKSRC)/libpkgconf/config.h; \
	fi
	@$(MAKECOOKIE)

include gar/category.mk
