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 LDRPATH = @LDDLLRPATH@
17 DEFS = -D__WINESRC__ $(DLLDEFS) $(EXTRADEFS)
18 BASEMODULE = $(MODULE:%.dll=%)
19 MAINSPEC = $(BASEMODULE).spec
20 SPEC_DEF = lib$(BASEMODULE).def
21 WIN16_FILES = $(SPEC_SRCS16:.spec=.spec.o) $(C_SRCS16:.c=.o) $(EXTRA_OBJS16)
22 ALL_OBJS = @WIN16_FILES@ $(OBJS) $(RC_SRCS:.rc=.res)
23 ALL_LIBS = -L$(LIBDIR) -lwine $(EXTRALIBS) $(LIBPORT) $(LDFLAGS) $(LIBS)
24 ALL_IMPORTS = $(DELAYIMPORTS) $(IMPORTS)
25 IMPLIB_OBJS = $(IMPLIB_SRCS:.c=.o)
26 STATICIMPLIB= $(IMPORTLIB:.def=.def.a)
27 DLL_LDPATH = -L$(DLLDIR) $(ALL_IMPORTS:%=-L$(DLLDIR)/%)
29 all: $(MODULE)$(DLLEXT) $(SUBDIRS)
35 $(MODULE).so: $(MAINSPEC) $(ALL_OBJS) Makefile.in
36 $(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)
38 # Rules for .dll files
40 $(MODULE): $(RCOBJS) $(OBJS) $(SPEC_DEF) Makefile.in
41 $(DLLWRAP) -k --def $(SPEC_DEF) -o $@ $(RCOBJS) $(OBJS) $(DLL_LDPATH) $(ALL_IMPORTS:%=-l%) $(ALL_LIBS)
43 # Rules for import libraries
45 .PHONY: implib $(IMPLIB_OBJS:%=__static_implib__%)
47 all implib: $(IMPORTLIB) $(IMPLIB_OBJS:%=__static_implib__%)
49 $(IMPLIB_OBJS:%=__static_implib__%): $(STATICIMPLIB)
51 lib$(BASEMODULE).def: $(MAINSPEC)
52 $(WINEBUILD) -w --def -o $@ --export $(SRCDIR)/$(MAINSPEC)
54 lib$(BASEMODULE).def.a: $(IMPLIB_OBJS)
56 $(AR) $@ $(IMPLIB_OBJS)
59 lib$(BASEMODULE).a: $(SPEC_DEF) $(IMPLIB_OBJS)
60 $(DLLTOOL) -k -l $@ -d $(SPEC_DEF)
61 $(AR) $@ $(IMPLIB_OBJS)
66 # Rules for checking that no imports are missing
68 .PHONY: checklink16 $(WIN16_FILES:%=__checklink16__%)
70 $(WIN16_FILES:%=__checklink16__%): checklink16
72 checklink16:: $(MAINSPEC).o $(OBJS) dummy
73 $(CC) -o checklink -Wl,-rpath,$(TOPOBJDIR)/libs $(TOPSRCDIR)/dlls/checklink.c $(MAINSPEC).o $(OBJS) -L$(DLLDIR) $(ALL_LIBS) -lwinecrt0 -lm && $(RM) checklink $(MAINSPEC).o
75 checklink:: $(WIN16_FILES:%=__checklink16__%)
79 check test:: $(SUBDIRS:%=%/__test__)
81 crosstest:: $(SUBDIRS:%=%/__crosstest__)
83 # Rule to explicitly generate the .spec.s for debugging
85 $(MAINSPEC).s $(MAINSPEC).o: $(MAINSPEC) $(ALL_OBJS)
86 $(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --export $(SRCDIR)/$(MAINSPEC) $(SUBSYSTEM:%=--subsystem %) $(ALL_OBJS) $(DLL_LDPATH) $(ALL_IMPORTS:%=-l%) $(DELAYIMPORTS:%=-d%) $(DLLDIR)/libwinecrt0.a
88 # Rules for auto documentation
91 $(C2MAN) -o $(TOPOBJDIR)/documentation/man$(api_manext) -R$(TOPOBJDIR) -C$(SRCDIR) -S$(api_manext) $(INCLUDES) $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
94 $(C2MAN) -o $(TOPOBJDIR)/documentation/html -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Th $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
97 $(C2MAN) -o $(TOPOBJDIR)/documentation/api-guide -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Ts $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
99 .PHONY: man doc-html doc-sgml
101 # Rules for installation
103 EXE_SPECS16 = $(SPEC_SRCS16:.exe.spec=.exe16)
104 DRV_SPECS16 = $(EXE_SPECS16:.drv.spec=.drv16)
105 ALL_SPECS16 = $(DRV_SPECS16:.spec=.dll16)
107 WIN16_INSTALL = $(ALL_SPECS16:%=_install_/%)
109 .PHONY: install_lib install_static_implib_def install_static_implib_a
110 .PHONY: $(ALL_SPECS16:%=_install_/%) $(IMPORTLIB:%=_install_/%) $(IMPLIB_OBJS:%=_install_static_implib_/%)
112 $(ALL_SPECS16:%=_install_/%): install_lib
113 echo "$(MODULE)" > $(DESTDIR)$(dlldir)/`basename $@`
115 install_lib: $(MODULE)$(DLLEXT)
116 $(MKINSTALLDIRS) $(DESTDIR)$(dlldir)
117 $(INSTALL_PROGRAM) $(MODULE)$(DLLEXT) $(DESTDIR)$(dlldir)/$(MODULE)$(DLLEXT)
119 $(IMPORTLIB:%=_install_/%): $(IMPORTLIB)
120 $(MKINSTALLDIRS) $(DESTDIR)$(dlldir)
121 $(INSTALL_DATA) $(IMPORTLIB) $(DESTDIR)$(dlldir)/$(IMPORTLIB)
123 install_static_implib_def: $(STATICIMPLIB)
124 $(MKINSTALLDIRS) $(DESTDIR)$(dlldir)
125 $(INSTALL_DATA) $(STATICIMPLIB) $(DESTDIR)$(dlldir)/$(STATICIMPLIB)
127 install_static_implib_a:
129 $(IMPLIB_OBJS:%=_install_static_implib_/%): install_static_implib_$(IMPLIBEXT)
131 install install-lib:: install_lib @WIN16_INSTALL@
133 install install-dev:: $(IMPORTLIB:%=_install_/%) $(IMPLIB_OBJS:%=_install_static_implib_/%)
136 -cd $(DESTDIR)$(dlldir) && $(RM) $(MODULE)$(DLLEXT) $(IMPORTLIB) $(STATICIMPLIB) $(ALL_SPECS16)
143 $(SPEC_DEF) $(SPEC_SRCS16:.spec=.spec.o): $(WINEBUILD)
145 # End of global dll rules