1 # Global rules for building dlls -*-Makefile-*-
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 # SUBSYSTEM : (optional) subsystem (for native dlls)
9 # plus all variables required by the global Make.rules.in
14 IMPLIBEXT = @IMPLIBEXT@
15 LDRPATH = @LDDLLRPATH@
16 DEFS = -D__WINESRC__ $(EXTRADEFS)
17 BASEMODULE = $(MODULE:%.dll=%)
18 MAINSPEC = $(BASEMODULE).spec
19 SPEC_DEF = lib$(BASEMODULE).def
20 WIN16_FILES = $(SPEC_SRCS16:.spec=.spec.o) $(C_SRCS16:.c=.o) $(EXTRA_OBJS16)
21 ALL_OBJS = @WIN16_FILES@ $(OBJS) $(RC_SRCS:.rc=.res)
22 ALL_LIBS = -L$(LIBDIR) -lwine $(EXTRALIBS) $(LIBPORT) $(LDFLAGS) $(LIBS)
23 ALL_IMPORTS = $(DELAYIMPORTS) $(IMPORTS)
24 IMPLIB_OBJS = $(IMPLIB_SRCS:.c=.o)
25 STATICIMPLIB= $(IMPORTLIB:.def=.def.a)
26 DLL_LDPATH = -L$(DLLDIR) $(ALL_IMPORTS:%=-L$(DLLDIR)/%)
28 all: $(MODULE)$(DLLEXT) $(SUBDIRS)
34 $(MODULE).so: $(MAINSPEC) $(ALL_OBJS) Makefile.in
35 $(WINEGCC) -B$(TOOLSDIR)/tools/winebuild -shared $(SRCDIR)/$(MAINSPEC) $(ALL_OBJS) $(SUBSYSTEM:%=-Wb,--subsystem,%) $(BASEADDRESS:%=-Wl,--image-base,%) $(LDRPATH) -o $@ -L$(DLLDIR) $(ALL_IMPORTS:%=-l%) $(DELAYIMPORTS:%=-Wb,-d%) $(ALL_LIBS)
37 # Rules for .dll files
39 $(MODULE): $(RCOBJS) $(OBJS) $(SPEC_DEF) Makefile.in
40 $(DLLWRAP) -k --def $(SPEC_DEF) -o $@ $(RCOBJS) $(OBJS) $(DLL_LDPATH) $(ALL_IMPORTS:%=-l%) $(ALL_LIBS)
42 # Rules for import libraries
44 .PHONY: implib $(IMPLIB_OBJS:%=__static_implib__%)
46 all implib: $(IMPORTLIB) $(IMPLIB_OBJS:%=__static_implib__%)
48 $(IMPLIB_OBJS:%=__static_implib__%): $(STATICIMPLIB)
50 lib$(BASEMODULE).def: $(MAINSPEC)
51 $(WINEBUILD) -w --def -o $@ --export $(SRCDIR)/$(MAINSPEC)
53 lib$(BASEMODULE).def.a: $(IMPLIB_OBJS)
55 $(AR) $@ $(IMPLIB_OBJS)
58 lib$(BASEMODULE).a: $(SPEC_DEF) $(IMPLIB_OBJS)
59 $(DLLTOOL) -k -l $@ -d $(SPEC_DEF)
60 $(AR) $@ $(IMPLIB_OBJS)
65 # Rules for checking that no imports are missing
67 .PHONY: checklink16 $(WIN16_FILES:%=__checklink16__%)
69 $(WIN16_FILES:%=__checklink16__%): checklink16
71 checklink16:: $(MAINSPEC).o $(OBJS) dummy
72 $(CC) -o checklink -Wl,-rpath,$(TOPOBJDIR)/libs $(TOPSRCDIR)/dlls/checklink.c $(MAINSPEC).o $(OBJS) -L$(DLLDIR) $(ALL_LIBS) -lwinecrt0 -lm && $(RM) checklink $(MAINSPEC).o
74 checklink:: $(WIN16_FILES:%=__checklink16__%)
78 check test:: $(SUBDIRS:%=%/__test__)
80 crosstest:: $(SUBDIRS:%=%/__crosstest__)
82 # Rule to explicitly generate the .spec.s for debugging
84 $(MAINSPEC).s $(MAINSPEC).o: $(MAINSPEC) $(ALL_OBJS)
85 $(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --export $(SRCDIR)/$(MAINSPEC) $(SUBSYSTEM:%=--subsystem %) $(ALL_OBJS) $(DLL_LDPATH) $(ALL_IMPORTS:%=-l%) $(DELAYIMPORTS:%=-d%) $(DLLDIR)/libwinecrt0.a
87 # Rules for auto documentation
90 $(C2MAN) -o $(TOPOBJDIR)/documentation/man$(api_manext) -R$(TOPOBJDIR) -C$(SRCDIR) -S$(api_manext) $(INCLUDES) $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
93 $(C2MAN) -o $(TOPOBJDIR)/documentation/html -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Th $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
96 $(C2MAN) -o $(TOPOBJDIR)/documentation/api-guide -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Ts $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
98 .PHONY: man doc-html doc-sgml
100 # Rules for installation
102 EXE_SPECS16 = $(SPEC_SRCS16:.exe.spec=.exe16)
103 DRV_SPECS16 = $(EXE_SPECS16:.drv.spec=.drv16)
104 ALL_SPECS16 = $(DRV_SPECS16:.spec=.dll16)
106 WIN16_INSTALL = $(ALL_SPECS16:%=_install_/%)
108 .PHONY: install_lib install_static_implib_def install_static_implib_a
109 .PHONY: $(ALL_SPECS16:%=_install_/%) $(IMPORTLIB:%=_install_/%) $(IMPLIB_OBJS:%=_install_static_implib_/%)
111 $(ALL_SPECS16:%=_install_/%): install_lib
112 echo "$(MODULE)" > $(DESTDIR)$(dlldir)/`basename $@`
114 install_lib: $(MODULE)$(DLLEXT)
115 $(MKINSTALLDIRS) $(DESTDIR)$(dlldir)
116 $(INSTALL_PROGRAM) $(MODULE)$(DLLEXT) $(DESTDIR)$(dlldir)/$(MODULE)$(DLLEXT)
118 $(IMPORTLIB:%=_install_/%): $(IMPORTLIB)
119 $(MKINSTALLDIRS) $(DESTDIR)$(dlldir)
120 $(INSTALL_DATA) $(IMPORTLIB) $(DESTDIR)$(dlldir)/$(IMPORTLIB)
122 install_static_implib_def: $(STATICIMPLIB)
123 $(MKINSTALLDIRS) $(DESTDIR)$(dlldir)
124 $(INSTALL_DATA) $(STATICIMPLIB) $(DESTDIR)$(dlldir)/$(STATICIMPLIB)
126 install_static_implib_a:
128 $(IMPLIB_OBJS:%=_install_static_implib_/%): install_static_implib_$(IMPLIBEXT)
130 install install-lib:: install_lib @WIN16_INSTALL@
132 install install-dev:: $(IMPORTLIB:%=_install_/%) $(IMPLIB_OBJS:%=_install_static_implib_/%)
135 -cd $(DESTDIR)$(dlldir) && $(RM) $(MODULE)$(DLLEXT) $(IMPORTLIB) $(STATICIMPLIB) $(ALL_SPECS16)
142 $(SPEC_DEF) $(SPEC_SRCS16:.spec=.spec.o): $(WINEBUILD)
144 # End of global dll rules