# @configure_input@
#
#
# Makefile.in
#
# This file is part of a free library for the Win32 API.
# 
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# start config section

SHELL = @SHELL@

srcdir = @srcdir@
VPATH = @srcdir@

build_alias = @build@
host_alias = @host@
target_alias = @target@
prefix = @prefix@
conf_prefix = @prefix@
# FIXME: this needs an appropriate AC_SUBST
host_os = mingw32

program_transform_name = @program_transform_name@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
tooldir = $(exec_prefix)/$(target_alias)
datadir = @datadir@
infodir = @infodir@
includedir = @includedir@

CC = @CC@
CC_FOR_TARGET = $(CC)
CFLAGS = @CFLAGS@

DLLTOOL = @DLLTOOL@
AS = @AS@
AS_FOR_TARGET = $(AS_FOR_TARGET)
WINDRES = @WINDRES@

RANLIB = @RANLIB@
AR = @AR@
LD = @LD@

TAR = tar
TARFLAGS = --lzma -
TARFILEEXT = .tar.lzma

# end config section

SUBDIRS = lib

PACKAGE = w32api
VERSION = 3.17
CYGRELEASE = 2

DISTFILES = \
  ChangeLog configure.ac Makefile.in Makefile.comm.in configure \
  config.guess config.sub install-sh README.w32api TODO CONTRIBUTIONS

all: lib

%-subdirs:
	for i in $(SUBDIRS); do \
	  $(MAKE) -C $$i $*; \
	done

lib:
	$(MAKE) -C $@

test:
	$(MAKE) -C lib test

install uninstall:
	for i in $(SUBDIRS); do \
		(cd $$i; $(MAKE) $@); \
	done

ifdef SNAPDATE
    distdir = $(PACKAGE)-$(VERSION)-$(SNAPDATE)-$(host_os)
else
   ifneq (,$(findstring cygwin, $(target_alias)))
      distdir=$(PACKAGE)-$(VERSION)-$(CYGRELEASE)
   else
      distdir=$(PACKAGE)-$(VERSION)-$(CYGRELEASE)-$(host_os)
   endif
endif

ifneq (,$(findstring mingw, $(target_alias)))
    dist_prefix=
else
    dist_prefix=/$(conf_prefix)
endif

ifneq (,$(findstring cygwin, $(target_alias)))
  TARFLAGS = j
  TARFILEEXT = .tar.bz2
endif

dist: srcdist bindist

srcdist:
	rm -rf $(distdir)
	mkdir $(distdir)
	chmod 755 $(distdir)
	for i in $(DISTFILES); do \
		cp -p $(srcdir)/$$i $(distdir)/$$i ; \
	done
	for i in $(SUBDIRS); do \
		(cd $$i; $(MAKE) distdir=../$(distdir) dist); \
	done
	rm -f $(distdir)-src$(TARFILEEXT)
	$(TAR) $(TARFLAGS)cf $(distdir)-src$(TARFILEEXT) $(distdir)

ifneq (,$(findstring cygwin, $(target_alias)))
bindist:
	rm -rf $(distdir)
	mkdir $(distdir)
	chmod 755 $(distdir)
	$(MAKE) install prefix=`pwd`/$(distdir)$(dist_prefix) exec_prefix=`pwd`/$(distdir)$(dist_prefix)
	rm -f $(distdir)$(TARFILEEXT)
	cd $(distdir); $(TAR) $(TARFLAGS)cf ../$(distdir)$(TARFILEEXT) *
else
bindist:
	rm -rf $(distdir)
	mkdir $(distdir)
	chmod 755 $(distdir)
	$(MAKE) install prefix=`pwd`/$(distdir)$(dist_prefix) exec_prefix=`pwd`/$(distdir)$(dist_prefix)
	rm -f $(distdir)$(TARFILEEXT)
	cd $(distdir); $(TAR) $(TARFLAGS)cf ../$(distdir)-dev$(TARFILEEXT) *
endif

snapshot:
	make dist SNAPDATE=$(shell date '+%Y%m%d')

Makefile: Makefile.in config.status configure
	$(SHELL) config.status

mostlyclean-top:
	rm -f *~
clean-top: mostlyclean-top
	rm -rf $(distdir)
	rm -f $(distdir)*$(TARFILEEXT)
maintainer-clean-top:

mostlyclean: mostlyclean-top mostlyclean-subdirs
clean: mostlyclean-top clean-subdirs
distclean: clean-top
	$(MAKE) -C lib/directx distclean
	$(MAKE) -C lib/ddk distclean
	$(MAKE) -C lib distclean
	rm -f Makefile config.status config.log config.cache TAGS *~
maintainer-clean: maintainer-clean-subdirs

.PHONY: lib test