makefiles: Rename the SRCDIR, TOPSRCDIR and TOPOBJDIR variables to follow autoconf...
[wine] / Make.rules.in
1 # Global rules shared by all makefiles     -*-Makefile-*-
2 #
3 # Each individual makefile may define the following variables:
4 # C_SRCS       : C sources for the module
5 # RC_SRCS      : resource source files
6 # EXTRA_SRCS   : extra source files for make depend
7 # EXTRA_OBJS   : extra object files
8 # IMPORTS      : dlls to import
9 # DELAYIMPORTS : dlls to import in delayed mode
10 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
11 # MODCFLAGS    : extra CFLAGS for this module
12
13 # First some useful definitions
14
15 LDSHARED     = @LDSHARED@
16 INCLUDES     = -I$(srcdir) -I. -I$(top_srcdir)/include -I$(top_builddir)/include $(EXTRAINCL)
17 ALLCFLAGS    = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS) $(MODCFLAGS)
18 ALLLINTFLAGS = $(INCLUDES) $(DEFS) $(LINTFLAGS)
19 IDLFLAGS     = $(INCLUDES) $(DEFS) $(EXTRAIDLFLAGS)
20 RCFLAGS      = --nostdinc $(INCLUDES) $(DEFS) $(EXTRARCFLAGS)
21
22 IDL_GEN_C_SRCS  = $(IDL_C_SRCS:.idl=_c.c) $(IDL_I_SRCS:.idl=_i.c) \
23                   $(IDL_P_SRCS:.idl=_p.c) $(IDL_S_SRCS:.idl=_s.c)
24 IDL_GEN_HEADERS = $(IDL_H_SRCS:.idl=.h) $(IDL_C_SRCS:.idl=.h) $(IDL_I_SRCS:.idl=.h) \
25                   $(IDL_P_SRCS:.idl=.h) $(IDL_S_SRCS:.idl=.h)
26
27 CLEAN_FILES   = *.o *.a *.so *.ln *.res *.fake *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej *.flc core
28 CLEAN_TARGETS = $(IDL_GEN_C_SRCS) $(IDL_GEN_HEADERS) $(IDL_TLB_SRCS:.idl=.tlb) $(IDL_P_SRCS:%=dlldata.c) \
29                 $(BISON_SRCS:.y=.tab.c) $(BISON_SRCS:.y=.tab.h) $(LEX_SRCS:.l=.yy.c) $(MC_SRCS:.mc=.mc.rc)
30
31 OBJS = $(C_SRCS:.c=.o) $(BISON_SRCS:.y=.tab.o) $(LEX_SRCS:.l=.yy.o) $(IDL_GEN_C_SRCS:.c=.o) \
32        $(RC_SRCS:.rc=.res) $(MC_SRCS:.mc=.mc.res) $(EXTRA_OBJS)
33
34 CROSSOBJS = $(OBJS:.o=.cross.o)
35 LINTS  = $(C_SRCS:.c=.ln)
36
37 filter: dummy
38         @$(top_srcdir)/tools/winapi/make_filter --make $(MAKE) all
39
40 .PHONY: all filter
41
42 # Implicit rules
43
44 .SUFFIXES: .mc .rc .mc.rc .res .idl .tlb .h .y .l .tab.c .tab.h .yy.c .ok .man.in .man _c.c _i.c _p.c _s.c .cross.o @MAINTAINER_MODE@ .sfd .ttf .svg .ico .bmp
45
46 .c.o:
47         $(CC) -c $(ALLCFLAGS) -o $@ $<
48
49 .c.cross.o:
50         $(CROSSCC) -c $(INCLUDES) $(DEFS) -DWINE_CROSSTEST $(CPPFLAGS) $(CFLAGS) -o $@ $<
51
52 .y.tab.c:
53         $(BISON) $(BISONFLAGS) -p $*_ -o $@ $<
54
55 .y.tab.h:
56         $(BISON) $(BISONFLAGS) -p $*_ -o $*.tab.c -d $<
57
58 .l.yy.c:
59         $(FLEX) $(LEXFLAGS) -o$@ $<
60
61 .mc.mc.rc:
62         $(LDPATH) $(WMC) -i -U -H /dev/null -o $@ $<
63
64 .rc.res:
65         $(LDPATH) $(WRC) $(RCFLAGS) -fo$@ $<
66
67 .idl.h:
68         $(WIDL) $(IDLFLAGS) -h -H $@ $<
69
70 .idl_c.c:
71         $(WIDL) $(IDLFLAGS) -c -C $@ $<
72
73 .idl_i.c:
74         $(WIDL) $(IDLFLAGS) -u -U $@ $<
75
76 .idl_p.c:
77         $(WIDL) $(IDLFLAGS) -p -P $@ $<
78
79 .idl_s.c:
80         $(WIDL) $(IDLFLAGS) -s -S $@ $<
81
82 .idl.tlb:
83         $(WIDL) $(TARGETFLAGS) $(IDLFLAGS) -t -T $@ $<
84
85 .c.ln:
86         $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
87
88 .c.ok:
89         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
90
91 .sfd.ttf:
92         $(FONTFORGE) -script $(top_srcdir)/fonts/genttf.ff $< $@
93
94 .man.in.man:
95         LC_ALL=C sed -e 's,@bindir\@,$(bindir),g' -e 's,@dlldir\@,$(dlldir),g' -e 's,@PACKAGE_STRING\@,@PACKAGE_STRING@,g' $< >$@ || ($(RM) $@ && false)
96
97 .svg.ico:
98         CONVERT="$(CONVERT)" ICOTOOL="$(ICOTOOL)" RSVG="$(RSVG)" $(BUILDIMAGE) $< $@
99
100 .svg.bmp:
101         CONVERT="$(CONVERT)" ICOTOOL="$(ICOTOOL)" RSVG="$(RSVG)" $(BUILDIMAGE) $< $@
102
103 # Rules for IDL files
104
105 dlldata.c: $(WIDL) Makefile.in
106         $(WIDL) $(IDLFLAGS) --dlldata-only --dlldata=$@ $(IDL_P_SRCS)
107
108 # Rule for linting
109
110 $(MODULE).ln : $(LINTS)
111         if test "$(LINTS)" ; \
112         then \
113                 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
114                 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
115         else \
116                 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
117         fi
118
119 lint:: $(MODULE).ln
120
121 # Rules for Windows API checking
122
123 winapi_check:: dummy
124         $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
125
126 .PHONY: winapi_check
127
128 # Rules for dependencies
129
130 DEPEND_SRCS = $(C_SRCS) $(RC_SRCS) $(MC_SRCS) \
131               $(IDL_H_SRCS) $(IDL_C_SRCS) $(IDL_I_SRCS) $(IDL_P_SRCS) $(IDL_S_SRCS) \
132               $(IDL_GEN_C_SRCS) $(IDL_TLB_SRCS) $(IDL_TLB_SRCS:.idl=.tlb) \
133               $(BISON_SRCS) $(LEX_SRCS) $(EXTRA_SRCS)
134
135 depend: dummy
136         $(MAKEDEP) $(MAKEDEPFLAGS) -C$(srcdir) -S$(top_srcdir) -T$(top_builddir) $(EXTRAINCL) $(DEPEND_SRCS)
137
138 .PHONY: depend
139
140 # Rules for cleaning
141
142 $(EXTRASUBDIRS:%=%/__clean__): dummy
143         -cd `dirname $@` && $(RM) $(CLEAN_FILES)
144
145 clean:: $(EXTRASUBDIRS:%=%/__clean__)
146         $(RM) $(CLEAN_FILES) $(CLEAN_TARGETS) $(PROGRAMS) $(MANPAGES)
147
148 .PHONY: clean $(EXTRASUBDIRS:%=%/__clean__)
149
150 # Rules for installing
151
152 $(INSTALLDIRS):
153         $(MKINSTALLDIRS) $@
154
155 install install-lib install-dev uninstall::
156
157 .PHONY: install install-lib install-dev uninstall
158
159 # Misc. rules
160
161 $(MC_SRCS:.mc=.mc.rc): $(WMC)
162
163 $(IDL_GEN_HEADERS) $(IDL_GEN_C_SRCS) $(IDL_TLB_SRCS:.idl=.tlb): $(WIDL)
164
165 $(RC_SRCS:.rc=.res) $(MC_SRCS:.mc=.mc.res): $(WRC)
166
167 dummy:
168
169 .PHONY: dummy
170
171 # End of global rules