rsaenh: Fix some memory leaks in the tests.
[wine] / dlls / Makedll.rules.in
1 # Global rules for building dlls     -*-Makefile-*-
2 #
3 # Each individual makefile should define the following variables:
4 # MODULE       : name of the main module being built
5 # EXTRALIBS    : extra libraries to link in (optional)
6 # SPEC_SRCS16  : interface definition files for 16-bit dlls (optional)
7 #
8 # plus all variables required by the global Make.rules.in
9 #
10
11 DLLFLAGS    = @DLLFLAGS@
12 DLLEXT      = @DLLEXT@
13 IMPLIBEXT   = @IMPLIBEXT@
14 MINGWAR     = @MINGWAR@
15 DEFS        = -D__WINESRC__ $(EXTRADEFS)
16 BASEMODULE  = $(MODULE:%.dll=%)
17 MAINSPEC    = $(BASEMODULE).spec
18 SPEC_DEF    = lib$(BASEMODULE).def
19 WIN16_FILES = $(SPEC_SRCS16:.spec=.spec.o) $(C_SRCS16:.c=.o) $(EXTRA_OBJS16)
20 ALL_OBJS    = @WIN16_FILES@ $(OBJS) $(RC_SRCS:.rc=.res)
21 ALL_LIBS    = $(EXTRALIBS) $(LIBPORT) $(LDFLAGS) $(LIBS)
22 IMPLIB_OBJS = $(IMPLIB_SRCS:.c=.o)
23 STATICIMPLIB= $(IMPORTLIB:.def=.def.a)
24 DLL_LDPATH  = -L$(DLLDIR) $(DELAYIMPORTS:%=-L$(DLLDIR)/%) $(IMPORTS:%=-L$(DLLDIR)/%)
25 INSTALLDIRS = $(DESTDIR)$(dlldir) $(DESTDIR)$(datadir)/wine
26
27 all: $(MODULE)$(DLLEXT) $(SUBDIRS)
28
29 @MAKE_RULES@
30
31 # Rules for .so files
32
33 $(MODULE).so: $(MAINSPEC) $(ALL_OBJS) Makefile.in
34         $(WINEGCC) -B$(TOOLSDIR)/tools/winebuild -shared $(SRCDIR)/$(MAINSPEC) $(ALL_OBJS) $(EXTRADLLFLAGS) -o $@ $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(DELAYIMPORTS:%=-Wb,-d%) $(ALL_LIBS)
35
36 # Rules for .dll files
37
38 $(MODULE): $(RCOBJS) $(OBJS) $(SPEC_DEF) Makefile.in
39         $(DLLWRAP) -k --def $(SPEC_DEF) -o $@ $(RCOBJS) $(OBJS) $(DLL_LDPATH) $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(LIBWINE) $(ALL_LIBS)
40
41 # Rules for import libraries
42
43 .PHONY: implib $(IMPLIB_SRCS:%=__static_implib__%)
44
45 all implib: $(IMPORTLIB) $(IMPLIB_SRCS:%=__static_implib__%)
46
47 $(IMPLIB_SRCS:%=__static_implib__%): $(STATICIMPLIB)
48
49 lib$(BASEMODULE).def: $(MAINSPEC)
50         $(WINEBUILD) -w --def -o $@ --export $(SRCDIR)/$(MAINSPEC)
51
52 lib$(BASEMODULE).def.a: $(IMPLIB_OBJS)
53         $(RM) $@
54         $(AR) $@ $(IMPLIB_OBJS)
55         $(RANLIB) $@
56
57 lib$(BASEMODULE).a: $(SPEC_DEF) $(IMPLIB_OBJS)
58         $(DLLTOOL) -k -l $@ -d $(SPEC_DEF)
59         $(MINGWAR) rs $@ $(IMPLIB_OBJS)
60
61 $(SUBDIRS): implib
62
63 # Rules for testing
64
65 check test:: $(SUBDIRS:%=%/__test__)
66
67 crosstest:: $(SUBDIRS:%=%/__crosstest__)
68
69 # Rules for auto documentation
70
71 man: $(C_SRCS) dummy
72         $(C2MAN) -o $(TOPOBJDIR)/documentation/man$(api_manext) -R$(TOPOBJDIR) -C$(SRCDIR) -S$(api_manext) $(INCLUDES) $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
73
74 doc-html: $(C_SRCS) dummy
75         $(C2MAN) -o $(TOPOBJDIR)/documentation/html -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Th $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
76
77 doc-sgml: $(C_SRCS) dummy
78         $(C2MAN) -o $(TOPOBJDIR)/documentation/api-guide -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Ts $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
79
80 .PHONY: man doc-html doc-sgml
81
82 # Rules for installation
83
84 EXE_SPECS16 = $(SPEC_SRCS16:.exe.spec=.exe16)
85 DRV_SPECS16 = $(EXE_SPECS16:.drv.spec=.drv16)
86 ALL_SPECS16 = $(DRV_SPECS16:.spec=.dll16)
87
88 WIN16_INSTALL = $(SPEC_SRCS16:%=_install_/%)
89
90 .PHONY: install_static_implib_def install_static_implib_a
91 .PHONY: $(SPEC_SRCS16:%=_install_/%) $(ALL_SPECS16:%=_install_/%) $(IMPORTLIB:%=_install_/%) $(IMPLIB_SRCS:%=_install_static_implib_/%)
92
93 $(SPEC_SRCS16:%=_install_/%): $(ALL_SPECS16:%=_install_/%)
94
95 $(ALL_SPECS16:%=_install_/%): $(DESTDIR)$(dlldir) dummy
96         echo "$(MODULE)" > $(DESTDIR)$(dlldir)/`basename $@`
97
98 $(IMPORTLIB:%=_install_/%): $(IMPORTLIB) $(DESTDIR)$(dlldir) dummy
99         $(INSTALL_DATA) $(IMPORTLIB) $(DESTDIR)$(dlldir)/$(IMPORTLIB)
100
101 install_static_implib_def: $(STATICIMPLIB) $(DESTDIR)$(dlldir) dummy
102         $(INSTALL_DATA) $(STATICIMPLIB) $(DESTDIR)$(dlldir)/$(STATICIMPLIB)
103
104 install_static_implib_a:
105
106 $(IMPLIB_SRCS:%=_install_static_implib_/%): install_static_implib_$(IMPLIBEXT)
107
108 install install-lib:: $(MODULE)$(DLLEXT) $(DESTDIR)$(dlldir) @WIN16_INSTALL@ dummy
109         $(INSTALL_PROGRAM) $(MODULE)$(DLLEXT) $(DESTDIR)$(dlldir)/$(MODULE)$(DLLEXT)
110
111 install install-dev:: $(IMPORTLIB:%=_install_/%) $(IMPLIB_SRCS:%=_install_static_implib_/%)
112
113 uninstall::
114         -cd $(DESTDIR)$(dlldir) && $(RM) $(MODULE)$(DLLEXT) $(IMPORTLIB) $(STATICIMPLIB) $(ALL_SPECS16)
115
116 # Misc. rules
117
118 clean::
119         $(RM) $(SPEC_DEF)
120
121 $(SPEC_DEF) $(SPEC_SRCS16:.spec=.spec.o): $(WINEBUILD)
122
123 # End of global dll rules