#
# Each individual makefile should define the following variables:
# MODULE : name of the main module being built
-# ALTNAMES : alternate names for this dll (optional)
-# IMPORTS : dlls to import (optional)
# EXTRALIBS : extra libraries to link in (optional)
#
# plus all variables required by the global Make.rules.in
#
-DEFS = @DLLFLAGS@ -D__WINE__ $(EXTRADEFS)
-DLLEXT = @DLLEXT@
-ALTSPECS = $(ALTNAMES:%.dll=%)
-SPEC_SRCS = $(ALTSPECS:%=%.spec)
-ALL_OBJS = $(MODULE:%.dll=%).spec.o $(OBJS)
-ALL_LIBS = $(LIBWINE) $(EXTRALIBS) $(LIBS)
-
-all: $(MODULE)$(DLLEXT)
+DLLFLAGS = @DLLFLAGS@
+DEFS = -D__WINESRC__ $(EXTRADEFS)
+BASEMODULE = $(MODULE:%.dll=%)
+MAINSPEC = $(BASEMODULE).spec
+ALL_LIBS = $(LIBPORT) $(EXTRALIBS) $(LDFLAGS) $(LIBS)
+IMPLIB_OBJS = $(IMPLIB_SRCS:.c=.o)
+IMPLIBFLAGS = $(TARGETFLAGS) $(EXTRAIMPLIBFLAGS)
+IMPORTLIBFILE = $(IMPORTLIB:%=lib%.@IMPLIBEXT@)
+STATICIMPLIB = $(IMPORTLIBFILE:.def=.def.a)
+INSTALLDIRS = $(DESTDIR)$(dlldir) $(DESTDIR)$(fakedlldir) $(DESTDIR)$(datadir)/wine
@MAKE_RULES@
-# Rules for .so files
+all: $(MODULE)$(DLLEXT) $(MODULE)$(FAKEEXT)
+
+$(MODULE) $(MODULE).so $(MODULE).fake: $(MAINSPEC) $(OBJS) Makefile.in
+ $(WINEGCC) -shared $(srcdir)/$(MAINSPEC) $(OBJS) $(EXTRADLLFLAGS) -o $@ $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(DELAYIMPORTS:%=-Wb,-d%) $(ALL_LIBS)
+
+# Rules for import libraries
+
+IMPLIB_CROSSOBJS = $(IMPLIB_OBJS:.o=.cross.o)
-$(MODULE).so: $(ALL_OBJS) Makefile.in
- $(LDSHARED) $(LDDLLFLAGS) $(ALL_OBJS) -o $@ -L$(DLLDIR) $(IMPORTS:%=-l%) $(ALL_LIBS)
+.PHONY: $(IMPLIB_SRCS:%=__static_implib__%)
-# Rules for .dll files
+all: $(IMPORTLIBFILE) $(IMPLIB_SRCS:%=__static_implib__%) @CROSSTEST_DISABLE@ $(IMPORTLIB:%=lib%.cross.a)
-$(MODULE): $(ALL_OBJS) Makefile.in
- $(DLLWRAP) $(DLLWRAPFLAGS) --implib $(MODULE:.dll=.a) -o $(MODULE) $(ALL_OBJS) -L$(DLLDIR) $(IMPORTS:%=-l%) $(ALL_LIBS)
+$(IMPLIB_SRCS:%=__static_implib__%): $(STATICIMPLIB)
-# Rules for checking that no imports are missing
+$(IMPORTLIB:%=lib%.def): $(MAINSPEC)
+ $(WINEBUILD) $(IMPLIBFLAGS) -w --def -o $@ --export $(srcdir)/$(MAINSPEC)
-checklink:: $(MODULE)$(DLLEXT)
- $(CC) -o checklink $(TOPSRCDIR)/library/checklink.c $(MODULE)$(DLLEXT) $(ALL_LIBS) && $(RM) checklink
+$(IMPORTLIB:%=lib%.def.a): $(IMPLIB_OBJS)
+ $(RM) $@
+ $(AR) $(ARFLAGS) $@ $(IMPLIB_OBJS)
+ $(RANLIB) $@
-# Rules for testing
+$(IMPORTLIB:%=lib%.a): $(MAINSPEC) $(IMPLIB_OBJS)
+ $(WINEBUILD) $(IMPLIBFLAGS) -w --implib -o $@ --export $(srcdir)/$(MAINSPEC) $(IMPLIB_OBJS)
-$(TESTRESULTS): $(MODULE)$(DLLEXT)
+$(IMPORTLIB:%=lib%.cross.a): $(MAINSPEC) $(IMPLIB_CROSSOBJS)
+ $(WINEBUILD) $(IMPLIBFLAGS) $(CROSSTARGET:%=-b %) -w --implib -o $@ --export $(srcdir)/$(MAINSPEC) $(IMPLIB_CROSSOBJS)
-# Rules for debug channels
+# Rules for auto documentation
-debug_channels: dummy
- $(TOPSRCDIR)/tools/make_debug $(MAINSPEC) $(C_SRCS) $(SUBDIRS:%=%/*.c)
+manpages:: $(C_SRCS) dummy
+ $(C2MAN) -o $(top_builddir)/documentation/man$(api_manext) -R$(top_builddir) -C$(srcdir) -S$(api_manext) $(INCLUDES) $(MAINSPEC:%=-w %) $(C_SRCS)
-# Sanity check
+htmlpages:: $(C_SRCS) dummy
+ $(C2MAN) -o $(top_builddir)/documentation/html -R$(top_builddir) -C$(srcdir) $(INCLUDES) -Th $(MAINSPEC:%=-w %) $(C_SRCS)
-Makedll.rules: $(TOPSRCDIR)/Makedll.rules.in $(TOPSRCDIR)/configure
- @echo $? is newer than 'Makedll.rules', please rerun ./configure!
- @exit 1
+sgmlpages:: $(C_SRCS) dummy
+ $(C2MAN) -o $(top_builddir)/documentation/api-guide -R$(top_builddir) -C$(srcdir) $(INCLUDES) -Ts $(MAINSPEC:%=-w %) $(C_SRCS)
+
+xmlpages:: $(C_SRCS) dummy
+ $(C2MAN) -o $(top_builddir)/documentation/api-guide-xml -R$(top_builddir) -C$(srcdir) $(INCLUDES) -Tx $(MAINSPEC:%=-w %) $(C_SRCS)
# Rules for installation
-.PHONY: install_lib $(ALTNAMES:%=_install_/%$(DLLEXT))
+.PHONY: install_static_implib_def install_static_implib_a
+.PHONY: $(IMPORTLIB:%=_install_/%) $(IMPLIB_SRCS:%=_install_static_implib_/%)
-$(ALTNAMES:%=_install_/%$(DLLEXT)): install_lib
- cd $(dlldir) && $(RM) `basename $@` && $(LN_S) $(MODULE)$(DLLEXT) `basename $@`
+$(IMPORTLIB:%=_install_/%): $(IMPORTLIBFILE) $(DESTDIR)$(dlldir) dummy
+ $(INSTALL_DATA) $(IMPORTLIBFILE) $(DESTDIR)$(dlldir)/$(IMPORTLIBFILE)
-install_lib: $(MODULE)$(DLLEXT)
- [ -d $(dlldir) ] || $(MKDIR) $(dlldir)
- $(INSTALL_PROGRAM) $(MODULE)$(DLLEXT) $(dlldir)/$(MODULE)$(DLLEXT)
+install_static_implib_def: $(STATICIMPLIB) $(DESTDIR)$(dlldir) dummy
+ $(INSTALL_DATA) $(STATICIMPLIB) $(DESTDIR)$(dlldir)/$(STATICIMPLIB)
-install:: install_lib $(ALTNAMES:%=_install_/%$(DLLEXT))
+install_static_implib_a:
-uninstall::
- $(RM) $(dlldir)/$(MODULE)$(DLLEXT) $(ALTNAMES:%=$(dlldir)/%$(DLLEXT))
+$(IMPLIB_SRCS:%=_install_static_implib_/%): install_static_implib_$(IMPLIBEXT)
+
+.PHONY: install_dll install_dll.so install_dll.fake
-# Extra install rules for dlls not yet properly separated
+install_dll: $(MODULE) $(DESTDIR)$(dlldir) dummy
+ $(INSTALL_PROGRAM) $(MODULE) $(DESTDIR)$(dlldir)/$(MODULE)
+
+install_dll.so: $(MODULE).so $(DESTDIR)$(dlldir) dummy
+ $(INSTALL_PROGRAM) $(MODULE).so $(DESTDIR)$(dlldir)/$(MODULE).so
+
+install_dll.fake: $(MODULE).fake $(DESTDIR)$(fakedlldir) dummy
+ $(INSTALL_DATA) $(MODULE).fake $(DESTDIR)$(fakedlldir)/$(MODULE)
+
+install install-lib:: install_dll$(DLLEXT) install_dll$(FAKEEXT)
+
+install install-dev:: $(IMPORTLIB:%=_install_/%) $(IMPLIB_SRCS:%=_install_static_implib_/%) dummy
+
+uninstall::
+ -cd $(DESTDIR)$(dlldir) && $(RM) $(MODULE)$(DLLEXT) $(IMPORTLIBFILE) $(STATICIMPLIB)
+ $(RM) $(DESTDIR)$(fakedlldir)/$(MODULE)
-install_libdir:: install_lib
- cd $(libdir) && $(RM) lib$(MODULE).$(LIBEXT) && if [ "$(dlldir)" = "$(libdir)/wine" ]; \
- then $(LN_S) wine/$(MODULE)$(DLLEXT) lib$(MODULE).$(LIBEXT); \
- else $(LN_S) $(dlldir)/$(MODULE)$(DLLEXT) lib$(MODULE).$(LIBEXT); fi
+# Misc. rules
-uninstall_libdir::
- $(RM) $(libdir)/lib$(MODULE).$(LIBEXT)
+clean::
+ $(RM) $(IMPORTLIBFILE)
# End of global dll rules