#
# Each individual makefile should define the following variables:
# MODULE : name of the main module being built
-# ALTNAMES : alternate names for this dll (optional)
# EXTRALIBS : extra libraries to link in (optional)
+# SPEC_SRCS16 : interface definition files for 16-bit dlls (optional)
#
# plus all variables required by the global Make.rules.in
#
-DEFS = @DLLFLAGS@ -D__WINE__ $(EXTRADEFS)
+DLLFLAGS = @DLLFLAGS@
DLLEXT = @DLLEXT@
-ALTSPECS = $(ALTNAMES:%.dll=%)
-SPEC_SRCS = $(ALTSPECS:%=%.spec)
-MAINSPEC = $(MODULE:%.dll=%).spec
-SPEC_DEF = $(MAINSPEC).def
-ALL_OBJS = $(MAINSPEC).o $(SPEC_SRCS:.spec=.spec.o) $(OBJS) $(MODULE).dbg.o
-ALL_LIBS = $(LIBWINE) $(EXTRALIBS) $(LIBS)
-TESTIMPORTS = $(MODULE) $(DELAYIMPORTS) $(IMPORTS)
-
-all: $(MODULE)$(DLLEXT)
+IMPLIBEXT = @IMPLIBEXT@
+MINGWAR = @MINGWAR@
+DEFS = -D__WINESRC__ $(EXTRADEFS)
+BASEMODULE = $(MODULE:%.dll=%)
+MAINSPEC = $(BASEMODULE).spec
+SPEC_DEF = $(BASEMODULE).def
+WIN16_FILES = $(SPEC_SRCS16:.spec=.spec.o) $(C_SRCS16:.c=.o) $(EXTRA_OBJS16)
+ALL_OBJS = @WIN16_FILES@ $(OBJS) $(RC_SRCS:.rc=.res)
+ALL_LIBS = $(LIBPORT) $(EXTRALIBS) $(LDFLAGS) $(LIBS)
+IMPLIB_OBJS = $(IMPLIB_SRCS:.c=.o)
+IMPORTLIBFILE = $(IMPORTLIB:%=lib%.$(IMPLIBEXT))
+STATICIMPLIB = $(IMPORTLIBFILE:.def=.def.a)
+DLL_LDPATH = -L$(DLLDIR) $(DELAYIMPORTS:%=-L$(DLLDIR)/%) $(IMPORTS:%=-L$(DLLDIR)/%)
+INSTALLDIRS = $(DESTDIR)$(dlldir) $(DESTDIR)$(datadir)/wine
+
+all: $(MODULE)$(DLLEXT) $(SUBDIRS)
@MAKE_RULES@
-# Rule for main module spec file
-
-$(MAINSPEC).c: $(MAINSPEC) $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(WINEBUILD)
- $(LDPATH) $(WINEBUILD) $(DEFS) $(SYMBOLFILE:%=-sym %) -o $@ -spec $(SRCDIR)/$(MAINSPEC) $(RC_SRCS:%.rc=-res %.res) -L$(DLLDIR) $(DELAYIMPORTS:%=-dl%) $(IMPORTS:%=-l%)
-
# Rules for .so files
-$(MODULE).so: $(ALL_OBJS) Makefile.in
- $(LDSHARED) $(LDDLLFLAGS) $(ALL_OBJS) -o $@ -L$(DLLDIR) $(LDIMPORTS:%=-l%) $(ALL_LIBS)
+$(MODULE).so: $(MAINSPEC) $(ALL_OBJS) Makefile.in
+ $(WINEGCC) -B$(TOOLSDIR)/tools/winebuild -shared $(SRCDIR)/$(MAINSPEC) $(ALL_OBJS) $(EXTRADLLFLAGS) -o $@ $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(DELAYIMPORTS:%=-Wb,-d%) $(ALL_LIBS)
# Rules for .dll files
-$(MODULE): $(OBJS) $(MODULE).dbg.o $(SPEC_DEF) Makefile.in
- $(DLLWRAP) $(DLLWRAPFLAGS) --def $(SPEC_DEF) --implib $(MODULE:.dll=.a) -o $(MODULE) $(OBJS) $(MODULE).dbg.o -L$(DLLDIR) $(IMPORTS:%=-l%) $(ALL_LIBS)
+$(MODULE): $(RCOBJS) $(OBJS) $(SPEC_DEF) Makefile.in
+ $(DLLWRAP) -k --def $(SPEC_DEF) -o $@ $(RCOBJS) $(OBJS) $(DLL_LDPATH) $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(LIBWINE) $(ALL_LIBS)
+
+# Rules for import libraries
+
+.PHONY: implib $(IMPLIB_SRCS:%=__static_implib__%)
+
+all implib: $(IMPORTLIBFILE) $(IMPLIB_SRCS:%=__static_implib__%)
+
+$(IMPLIB_SRCS:%=__static_implib__%): $(STATICIMPLIB)
+
+$(SPEC_DEF) $(IMPORTLIB:%=lib%.def): $(MAINSPEC)
+ $(WINEBUILD) $(TARGETFLAGS) -w --def -o $@ --export $(SRCDIR)/$(MAINSPEC)
-$(SPEC_DEF): $(WINEBUILD)
+$(IMPORTLIB:%=lib%.def.a): $(IMPLIB_OBJS)
+ $(RM) $@
+ $(AR) $(ARFLAGS) $@ $(IMPLIB_OBJS)
+ $(RANLIB) $@
-# Rules for checking that no imports are missing
+$(IMPORTLIB:%=lib%.a): $(SPEC_DEF) $(IMPLIB_OBJS)
+ $(DLLTOOL) -k -l $@ -d $(SPEC_DEF)
+ $(MINGWAR) rs $@ $(IMPLIB_OBJS)
-checklink:: $(MODULE)$(DLLEXT)
- $(CC) -o checklink $(TOPSRCDIR)/library/checklink.c $(MODULE)$(DLLEXT) && $(RM) checklink
+$(SUBDIRS): implib
# Rules for testing
-$(TESTRESULTS): $(MODULE)$(DLLEXT)
+check test:: $(SUBDIRS:%=%/__test__)
-# Sanity check
+crosstest:: $(SUBDIRS:%=%/__crosstest__)
-Makedll.rules: $(TOPSRCDIR)/Makedll.rules.in $(TOPSRCDIR)/configure
- @echo $? is newer than 'Makedll.rules', please rerun ./configure!
- @exit 1
+# Rules for auto documentation
+
+man: $(C_SRCS) dummy
+ $(C2MAN) -o $(TOPOBJDIR)/documentation/man$(api_manext) -R$(TOPOBJDIR) -C$(SRCDIR) -S$(api_manext) $(INCLUDES) $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
+
+doc-html: $(C_SRCS) dummy
+ $(C2MAN) -o $(TOPOBJDIR)/documentation/html -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Th $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
+
+doc-sgml: $(C_SRCS) dummy
+ $(C2MAN) -o $(TOPOBJDIR)/documentation/api-guide -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Ts $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
+
+.PHONY: man doc-html doc-sgml
# 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_/%)
+
+$(IMPORTLIB:%=_install_/%): $(IMPORTLIBFILE) $(DESTDIR)$(dlldir) dummy
+ $(INSTALL_DATA) $(IMPORTLIBFILE) $(DESTDIR)$(dlldir)/$(IMPORTLIBFILE)
+
+install_static_implib_def: $(STATICIMPLIB) $(DESTDIR)$(dlldir) dummy
+ $(INSTALL_DATA) $(STATICIMPLIB) $(DESTDIR)$(dlldir)/$(STATICIMPLIB)
+
+install_static_implib_a:
-$(ALTNAMES:%=_install_/%$(DLLEXT)): install_lib
- cd $(dlldir) && $(RM) `basename $@` && $(LN_S) $(MODULE)$(DLLEXT) `basename $@`
+$(IMPLIB_SRCS:%=_install_static_implib_/%): install_static_implib_$(IMPLIBEXT)
-install_lib: $(MODULE)$(DLLEXT)
- $(MKINSTALLDIRS) $(dlldir)
- $(INSTALL_PROGRAM) $(MODULE)$(DLLEXT) $(dlldir)/$(MODULE)$(DLLEXT)
+install install-lib:: $(MODULE)$(DLLEXT) $(DESTDIR)$(dlldir) dummy
+ $(INSTALL_PROGRAM) $(MODULE)$(DLLEXT) $(DESTDIR)$(dlldir)/$(MODULE)$(DLLEXT)
-install:: install_lib $(ALTNAMES:%=_install_/%$(DLLEXT))
+install install-dev:: $(IMPORTLIB:%=_install_/%) $(IMPLIB_SRCS:%=_install_static_implib_/%)
uninstall::
- $(RM) $(dlldir)/$(MODULE)$(DLLEXT) $(ALTNAMES:%=$(dlldir)/%$(DLLEXT))
+ -cd $(DESTDIR)$(dlldir) && $(RM) $(MODULE)$(DLLEXT) $(IMPORTLIBFILE) $(STATICIMPLIB)
-# Extra install rules for dlls not yet properly separated
+# Misc. rules
-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
+clean::
+ $(RM) $(SPEC_DEF) $(IMPORTLIBFILE)
-uninstall_libdir::
- $(RM) $(libdir)/lib$(MODULE).$(LIBEXT)
+$(SPEC_DEF) $(SPEC_SRCS16:.spec=.spec.o): $(WINEBUILD)
# End of global dll rules