Makedll.rules.in 4.91 KB
Newer Older
1 2 3 4
# Global rules for building dlls     -*-Makefile-*-
#
# Each individual makefile should define the following variables:
# 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)
8 9 10 11
#
# plus all variables required by the global Make.rules.in
#

12
DLLDEFS     = @DLLDEFS@
13
DLLFLAGS    = @DLLFLAGS@
14
DLLEXT      = @DLLEXT@
15
IMPLIBEXT   = @IMPLIBEXT@
16
DEFS        = -D__WINESRC__ $(DLLDEFS) $(EXTRADEFS)
17 18 19
BASEMODULE  = $(MODULE:%.dll=%)
MAINSPEC    = $(BASEMODULE).spec
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 25
IMPLIB_OBJS = $(IMPLIB_SRCS:.c=.o)
STATICIMPLIB= $(IMPORTLIB:.def=.def.a)
26
DLL_LDPATH  = -L$(DLLDIR) $(ALL_IMPORTS:%=-L$(DLLDIR)/%)
27

28
all: $(MODULE)$(DLLEXT) $(SUBDIRS)
29 30 31

@MAKE_RULES@

32
# Rules for .so files
33

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)
36

37
# Rules for .dll files
38

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)
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
# Rules for import libraries

.PHONY: implib static_implib $(IMPLIB_OBJS:%=__static_implib__%)

all implib: $(IMPORTLIB) $(IMPLIB_OBJS:%=__static_implib__%)

$(IMPLIB_OBJS:%=__static_implib__%): $(STATICIMPLIB)

lib$(BASEMODULE).def: $(MAINSPEC)
	$(WINEBUILD) -w --def -o $@ --export $(SRCDIR)/$(MAINSPEC)

lib$(BASEMODULE).def.a: $(IMPLIB_OBJS)
	$(RM) $@
	$(AR) $@ $(IMPLIB_OBJS)
	$(RANLIB) $@

lib$(BASEMODULE).a: $(SPEC_DEF) $(IMPLIB_OBJS)
59
	$(DLLTOOL) -k -l $@ -d $(SPEC_DEF)
60 61
	$(AR) $@ $(IMPLIB_OBJS)
	$(RANLIB) $@
62

63 64
# Rules for checking that no imports are missing

65 66 67 68 69
.PHONY: checklink16 $(WIN16_FILES:%=__checklink16__%)

$(WIN16_FILES:%=__checklink16__%): checklink16

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
71

72
checklink:: $(WIN16_FILES:%=__checklink16__%)
73

74 75
# Rules for testing

76 77
check test:: $(SUBDIRS:%=%/__test__)

78 79
crosstest:: $(SUBDIRS:%=%/__crosstest__)

80 81
# 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
84

85 86
# Rules for auto documentation

87
man: $(C_SRCS)
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)
89

90
doc-html: $(C_SRCS)
91
	$(C2MAN) -o $(TOPOBJDIR)/documentation/html -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Th $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
92

93
doc-sgml: $(C_SRCS)
94
	$(C2MAN) -o $(TOPOBJDIR)/documentation/api-guide -R$(TOPOBJDIR) -C$(SRCDIR) $(INCLUDES) -Ts $(MAINSPEC:%=-w %) $(SPEC_SRCS16:%=-w %) $(C_SRCS) $(C_SRCS16)
95

96
.PHONY: man doc-html doc-sgml
97

98 99
# Rules for installation

100 101 102
EXE_SPECS16 = $(SPEC_SRCS16:.exe.spec=.exe)
DRV_SPECS16 = $(EXE_SPECS16:.drv.spec=.drv)
ALL_SPECS16 = $(DRV_SPECS16:.spec=.dll)
103

104
WIN16_INSTALL = $(ALL_SPECS16:%=_install_/%)
105

106 107
.PHONY: install_lib install_static_implib_def install_static_implib_a
.PHONY: $(ALL_SPECS16:%=_install_/%) $(IMPORTLIB:%=_install_/%) $(IMPLIB_OBJS:%=_install_static_implib_/%)
108 109 110 111

$(ALL_SPECS16:%=_install_/%): install_lib
	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)
115

116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
$(IMPORTLIB:%=_install_/%): $(IMPORTLIB)
	$(MKINSTALLDIRS) $(dlldir)
	$(INSTALL_DATA) $(IMPORTLIB) $(dlldir)/$(IMPORTLIB)

install_static_implib_def: $(STATICIMPLIB)
	$(MKINSTALLDIRS) $(dlldir)
	$(INSTALL_DATA) $(STATICIMPLIB) $(dlldir)/$(STATICIMPLIB)

install_static_implib_a:

$(IMPLIB_OBJS:%=_install_static_implib_/%): install_static_implib_$(IMPLIBEXT)

install install-lib:: install_lib @WIN16_INSTALL@

install install-dev:: $(IMPORTLIB:%=_install_/%) $(IMPLIB_OBJS:%=_install_static_implib_/%)
131

132 133
uninstall::
	[ ! -d $(dlldir) ] || (cd $(dlldir) && $(RM) $(MODULE)$(DLLEXT) $(IMPORTLIB) $(STATICIMPLIB) $(ALL_SPECS16:%=%$(DLLEXT)))
134

135 136
# Misc. rules

137 138 139 140
clean::
	$(RM) $(SPEC_DEF)

$(SPEC_DEF) $(SPEC_SRCS16:.spec=.spec.c): $(WINEBUILD)
141

142
# End of global dll rules