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
15 IMPLIBEXT = @IMPLIBEXT@
16 DEFS = -D__WINESRC__ $(DLLDEFS) $(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) $(MODULE).dbg.o $(RC_SRCS:.rc=.res)
22 ALL_LIBS = $(LIBWINE) $(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,%) -o $@ $(DLL_LDPATH) $(ALL_IMPORTS:%=-l%) $(DELAYIMPORTS:%=-Wb,-d%) $(ALL_LIBS)
37 # Rules for .dll files
39 $(MODULE): $(RCOBJS) $(OBJS) $(MODULE).dbg.o $(SPEC_DEF) Makefile.in
40 $(DLLWRAP) -k --def $(SPEC_DEF) -o $@ $(RCOBJS) $(OBJS) $(MODULE).dbg.o $(DLL_LDPATH) $(ALL_IMPORTS:%=-l%) $(ALL_LIBS)
42 # Rules for import libraries
44 .PHONY: implib static_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)
63 # Rules for checking that no imports are missing
65 .PHONY: checklink16 $(WIN16_FILES:%=__checklink16__%)
67 $(WIN16_FILES:%=__checklink16__%): checklink16
69 checklink16:: $(MAINSPEC).o $(OBJS) $(MODULE).dbg.o dummy
70 $(CC) -o checklink -Wl,-rpath,$(TOPOBJDIR)/libs $(TOPSRCDIR)/dlls/checklink.c $(MAINSPEC).o $(OBJS) $(MODULE).dbg.o -L$(DLLDIR) $(ALL_LIBS) -lwinecrt0 -lm && $(RM) checklink $(MAINSPEC).c $(MAINSPEC).o
72 checklink:: $(WIN16_FILES:%=__checklink16__%)
76 check test:: $(SUBDIRS:%=%/__test__)
78 crosstest:: $(SUBDIRS:%=%/__crosstest__)
80 # Rule to explicitly generate the .spec.c for debugging
82 $(MAINSPEC).c: $(MAINSPEC) $(ALL_OBJS)
83 $(WINEBUILD) $(DEFS) $(DLLFLAGS) --dll -o $@ --export $(SRCDIR)/$(MAINSPEC) $(SUBSYSTEM:%=--subsystem %) $(ALL_OBJS) $(DLL_LDPATH) $(ALL_IMPORTS:%=-l%) $(DELAYIMPORTS:%=-d%) $(DLLDIR)/libwinecrt0.a
85 # Rules for auto documentation
88 $(C2MAN) -o $(TOPOBJDIR)/documentation/man$(api_manext) -R$(TOPOBJDIR) -C$(SRCDIR) -S$(api_manext) $(INCLUDES) $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
91 $(C2MAN) -o $(TOPOBJDIR)/documentation/html -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Th $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
94 $(C2MAN) -o $(TOPOBJDIR)/documentation/api-guide -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Ts $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
96 .PHONY: man doc-html doc-sgml
98 # Rules for installation
100 EXE_SPECS16 = $(SPEC_SRCS16:.exe.spec=.exe)
101 DRV_SPECS16 = $(EXE_SPECS16:.drv.spec=.drv)
102 ALL_SPECS16 = $(DRV_SPECS16:.spec=.dll)
104 WIN16_INSTALL = $(ALL_SPECS16:%=_install_/%)
106 .PHONY: install_lib install_static_implib_def install_static_implib_a
107 .PHONY: $(ALL_SPECS16:%=_install_/%) $(IMPORTLIB:%=_install_/%) $(IMPLIB_OBJS:%=_install_static_implib_/%)
109 $(ALL_SPECS16:%=_install_/%): install_lib
110 cd $(dlldir) && $(RM) `basename $@`$(DLLEXT) && $(LN_S) $(MODULE)$(DLLEXT) `basename $@`$(DLLEXT)
112 install_lib: $(MODULE)$(DLLEXT)
113 $(MKINSTALLDIRS) $(dlldir)
114 $(INSTALL_PROGRAM) $(MODULE)$(DLLEXT) $(dlldir)/$(MODULE)$(DLLEXT)
116 $(IMPORTLIB:%=_install_/%): $(IMPORTLIB)
117 $(MKINSTALLDIRS) $(dlldir)
118 $(INSTALL_DATA) $(IMPORTLIB) $(dlldir)/$(IMPORTLIB)
120 install_static_implib_def: $(STATICIMPLIB)
121 $(MKINSTALLDIRS) $(dlldir)
122 $(INSTALL_DATA) $(STATICIMPLIB) $(dlldir)/$(STATICIMPLIB)
124 install_static_implib_a:
126 $(IMPLIB_OBJS:%=_install_static_implib_/%): install_static_implib_$(IMPLIBEXT)
128 install install-lib:: install_lib @WIN16_INSTALL@
130 install install-dev:: $(IMPORTLIB:%=_install_/%) $(IMPLIB_OBJS:%=_install_static_implib_/%)
133 [ ! -d $(dlldir) ] || (cd $(dlldir) && $(RM) $(MODULE)$(DLLEXT) $(IMPORTLIB) $(STATICIMPLIB) $(ALL_SPECS16:%=%$(DLLEXT)))
140 $(SPEC_DEF) $(SPEC_SRCS16:.spec=.spec.c): $(WINEBUILD)
142 # End of global dll rules