TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ..
SRCDIR    = @srcdir@
VPATH     = @srcdir@
DEFS      = -D__WINESRC__ $(EXTRADEFS)

C_SRCS = \
	main.c \
	preloader.c

MAIN_BINARY    = @MAIN_BINARY@
EXTRA_BINARIES = @EXTRA_BINARIES@

PROGRAMS = \
	wine \
	wine-installed \
	wine-preloader

MANPAGES = \
	wine.man \
	wine.de.man \
	wine.fr.man

INSTALLDIRS = \
	$(DESTDIR)$(bindir) \
	$(DESTDIR)$(mandir)/man$(prog_manext) \
	$(DESTDIR)$(mandir)/de.UTF-8/man$(prog_manext) \
	$(DESTDIR)$(mandir)/fr.UTF-8/man$(prog_manext)

all: wine wine-installed $(EXTRA_BINARIES) $(MANPAGES)

@MAKE_RULES@

LIBPTHREAD  = @LIBPTHREAD@
LDEXECFLAGS = @LDEXECFLAGS@

wine-preloader: preloader.o Makefile.in
	$(CC) -o $@ -static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c000000 preloader.o $(LIBPORT) $(LDFLAGS)

wine: main.o Makefile.in
	$(CC) -o $@ $(LDEXECFLAGS) main.o $(LIBWINE) $(LIBPORT) $(LIBPTHREAD) $(EXTRALIBS) $(LDFLAGS) $(LDRPATH_LOCAL)

wine-installed: main.o Makefile.in
	$(CC) -o $@ $(LDEXECFLAGS) main.o $(LIBWINE) $(LIBPORT) $(LIBPTHREAD) $(EXTRALIBS) $(LDFLAGS) $(LDRPATH_INSTALL)

$(EXTRA_BINARIES:%=__install__%): $(EXTRA_BINARIES) $(DESTDIR)$(bindir) dummy
	f=`expr $@ : '__install__\(.*\)'` && $(INSTALL_PROGRAM) $$f $(DESTDIR)$(bindir)/$$f

.PHONY: install-man-pages $(EXTRA_BINARIES:%=__install__%)

install install-lib:: wine-installed $(DESTDIR)$(bindir) $(EXTRA_BINARIES:%=__install__%)
	$(INSTALL_PROGRAM) wine-installed $(DESTDIR)$(bindir)/$(MAIN_BINARY)

@WOW64_DISABLE@ install install-lib:: install-man-pages

install-man-pages: $(MANPAGES) $(INSTALLDIRS) dummy
	$(INSTALL_DATA) wine.man $(DESTDIR)$(mandir)/man$(prog_manext)/wine.$(prog_manext)
	$(INSTALL_DATA) wine.de.man $(DESTDIR)$(mandir)/de.UTF-8/man$(prog_manext)/wine.$(prog_manext)
	$(INSTALL_DATA) wine.fr.man $(DESTDIR)$(mandir)/fr.UTF-8/man$(prog_manext)/wine.$(prog_manext)

uninstall::
	-cd $(DESTDIR)$(bindir) && $(RM) $(MAIN_BINARY) $(EXTRA_BINARIES)
	$(RM) $(DESTDIR)$(mandir)/man$(prog_manext)/wine.$(prog_manext)
	$(RM) $(DESTDIR)$(mandir)/de.UTF-8/man$(prog_manext)/wine.$(prog_manext)
	$(RM) $(DESTDIR)$(mandir)/fr.UTF-8/man$(prog_manext)/wine.$(prog_manext)

@DEPENDENCIES@  # everything below this line is overwritten by make depend