DEFS      = -DINCLUDEDIR="\"$(includedir)\""
TOPSRCDIR = ../..
TOPOBJDIR = ../..
SRCDIR    = .

EXEEXT    = 

PROGRAMS = wrc$(EXEEXT) wrc-installed
MANPAGES = wrc.man
MODULE   = none

C_SRCS = \
	dumpres.c \
	genres.c \
	newstruc.c \
	readres.c \
	translation.c \
	utils.c \
	wrc.c \
	writeres.c

LEX_SRCS   = parser.l
BISON_SRCS = parser.y

INSTALLDIRS = $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man$(prog_manext)

all: $(PROGRAMS) $(MANPAGES)

# Global rules shared by all makefiles     -*-Makefile-*-
#
# Each individual makefile must define the following variables:
# TOPSRCDIR    : top-level source directory
# TOPOBJDIR    : top-level object directory
# SRCDIR       : source directory for this module
# MODULE       : name of the module being built
#
# Each individual makefile may define the following additional variables:
# C_SRCS       : C sources for the module
# C_SRCS16     : 16-bit C sources for the module
# RC_SRCS      : resource source files
# EXTRA_SRCS   : extra source files for make depend
# EXTRA_OBJS   : extra object files
# IMPORTS      : dlls to import
# DELAYIMPORTS : dlls to import in delayed mode
# SUBDIRS      : subdirectories that contain a Makefile
# EXTRASUBDIRS : subdirectories that do not contain a Makefile
# INSTALLSUBDIRS : subdirectories to run make install/uninstall into
# MODCFLAGS    : extra CFLAGS for this module

# First some useful definitions

SHELL     = /bin/sh
CC        = gcc
CFLAGS    = -g -O2
CPPFLAGS  = 
LIBS      = 
BISON     = bison
FLEX      = flex
EXEEXT    = 
OBJEXT    = o
LIBEXT    = so
DLLEXT    = .so
IMPLIBEXT = def
LDSHARED  = $(CC) -shared $(SONAME:%=-Wl,-soname,%) $(VERSCRIPT:%=-Wl,--version-script=%)
DLLTOOL   = false
DLLWRAP   = 
AR        = ar rc
RANLIB    = ranlib
STRIP     = strip
WINDRES   = false
LN        = ln
LN_S      = ln -s
TOOLSDIR  = $(TOPOBJDIR)
AS        = as
LD        = ld
LDFLAGS   = 
PRELINK   = /usr/sbin/prelink
RM        = rm -f
MV        = mv
LINT      = 
LINTFLAGS = 
FONTFORGE = fontforge
INCLUDES     = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
EXTRACFLAGS  = -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith
ALLCFLAGS    = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS) $(MODCFLAGS)
ALLLINTFLAGS = $(INCLUDES) $(DEFS) $(LINTFLAGS)
IDLFLAGS     = $(INCLUDES) $(DEFS) $(EXTRAIDLFLAGS)
WINEBUILDFLAGS = $(DLLFLAGS) --as-cmd "$(AS)"
MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs -m 755
WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi/winapi_check
WINEWRAPPER  = $(TOPSRCDIR)/tools/winewrapper
C2MAN        = $(TOPSRCDIR)/tools/c2man.pl
RUNTEST      = $(TOPSRCDIR)/tools/runtest
WINEBUILD    = $(TOOLSDIR)/tools/winebuild/winebuild
MAKEDEP      = $(TOOLSDIR)/tools/makedep
MAKECTESTS   = $(TOOLSDIR)/tools/make_ctests
WRC          = $(TOOLSDIR)/tools/wrc/wrc
WMC          = $(TOOLSDIR)/tools/wmc/wmc
WIDL         = $(TOOLSDIR)/tools/widl/widl
WINEGCC      = $(TOOLSDIR)/tools/winegcc/winegcc
RELPATH      = $(TOOLSDIR)/tools/relpath
SFNT2FNT     = $(TOOLSDIR)/tools/sfnt2fnt
FNT2FON      = $(TOOLSDIR)/tools/fnt2fon
RC           = $(WRC)
RC16         = $(WRC)
RCFLAGS      = --nostdinc $(INCLUDES) $(DEFS) $(EXTRARCFLAGS)
RC16FLAGS    = -O res16 $(RCFLAGS)
LDPATH       = 
DLLDIR       = $(TOPOBJDIR)/dlls
LIBPORT      = $(TOPOBJDIR)/libs/port/libwine_port.a
LIBWPP       = $(TOPOBJDIR)/libs/wpp/libwpp.a
LIBWINE      = -L$(TOPOBJDIR)/libs/wine -lwine
LDRPATH_INSTALL = -Wl,--rpath,\$$ORIGIN/`$(RELPATH) $(bindir) $(libdir)` -Wl,--enable-new-dtags
LDRPATH_LOCAL   = -Wl,--rpath,\$$ORIGIN/$(TOPOBJDIR)/libs/wine



# Installation infos

INSTALL         = /usr/bin/install -c $(INSTALL_FLAGS)
INSTALL_PROGRAM = ${INSTALL} $(INSTALL_PROGRAM_FLAGS)
INSTALL_SCRIPT  = ${INSTALL} $(INSTALL_SCRIPT_FLAGS)
INSTALL_DATA    = ${INSTALL} -m 644 $(INSTALL_DATA_FLAGS)
prefix          = /usr/local
exec_prefix     = ${prefix}
bindir          = ${exec_prefix}/bin
libdir          = ${exec_prefix}/lib
datarootdir     = ${prefix}/share
datadir         = ${datarootdir}
infodir         = ${datarootdir}/info
mandir          = ${datarootdir}/man
sysconfdir      = ${prefix}/etc
includedir      = ${prefix}/include/wine
dlldir          = ${exec_prefix}/lib/wine
prog_manext     = 1
api_manext      = 3w
conf_manext     = 5
CLEAN_FILES     = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej *.flc core

IDL_GEN_C_SRCS  = $(IDL_C_SRCS:.idl=_c.c) $(IDL_I_SRCS:.idl=_i.c) \
                  $(IDL_P_SRCS:.idl=_p.c) $(IDL_S_SRCS:.idl=_s.c)
IDL_GEN_HEADERS = $(IDL_H_SRCS:.idl=.h) $(IDL_C_SRCS:.idl=.h) $(IDL_I_SRCS:.idl=.h) \
                  $(IDL_P_SRCS:.idl=.h) $(IDL_S_SRCS:.idl=.h)

CLEAN_TARGETS = $(IDL_GEN_C_SRCS) $(IDL_GEN_HEADERS) $(IDL_TLB_SRCS:.idl=.tlb) \
                $(BISON_SRCS:.y=.tab.c) $(BISON_SRCS:.y=.tab.h) $(LEX_SRCS:.l=.yy.c) \
                $(MC_SRCS:.mc=.mc.rc) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res)

OBJS = $(C_SRCS:.c=.o) $(BISON_SRCS:.y=.tab.o) $(LEX_SRCS:.l=.yy.o) $(IDL_GEN_C_SRCS:.c=.o) $(EXTRA_OBJS)

RCOBJS = $(RC_SRCS:.rc=.res.o)
LINTS  = $(C_SRCS:.c=.ln)

# Implicit rules

.SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.o .idl .tlb .h .y .l .tab.c .tab.h .yy.c .ok .sfd .ttf .man.in .man _c.c _i.c _p.c _s.c

.c.o:
	$(CC) -c $(ALLCFLAGS) -o $@ $<

.s.o:
	$(AS) -o $@ $<

.y.tab.c:
	$(BISON) $(BISONFLAGS) -p $*_ -o $@ $<

.y.tab.h:
	$(BISON) $(BISONFLAGS) -p $*_ -o $*.tab.c -d $<

.l.yy.c:
	$(FLEX) $(LEXFLAGS) -o$@ $<

.mc.mc.rc:
	$(LDPATH) $(WMC) -i -U -H /dev/null -o $@ $<

.rc.res:
	$(LDPATH) $(RC) $(RCFLAGS) -fo$@ $<

.res.res.o:
	$(WINDRES) -i $< -o $@

.spec.spec.o:
	$(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --main-module $(MODULE) --export $<

.idl.h:
	$(WIDL) $(IDLFLAGS) -h -H $@ $<

.idl_c.c:
	$(WIDL) $(IDLFLAGS) -c -C $@ $<

.idl_i.c:
	$(WIDL) $(IDLFLAGS) -u -U $@ $<

.idl_p.c:
	$(WIDL) $(IDLFLAGS) -p -P $@ $<

.idl_s.c:
	$(WIDL) $(IDLFLAGS) -s -S $@ $<

.idl.tlb:
	$(WIDL) $(IDLFLAGS) -t -T $@ $<

.c.ln:
	$(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )

.c.ok:
	$(RUNTEST) $(RUNTESTFLAGS) $< && touch $@

.sfd.ttf:
	$(FONTFORGE) -script $(TOPSRCDIR)/fonts/genttf.ff $< $@

.man.in.man:
	sed -e 's,@bindir\@,$(bindir),g' -e 's,@dlldir\@,$(dlldir),g' -e 's,@PACKAGE_STRING\@,Wine 0.9.48,g' $< >$@ || ($(RM) $@ && false)

# 'all' target first in case the enclosing Makefile didn't define any target

all:

filter: dummy
	@$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all

.PHONY: all filter

# Rules for resources

$(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res): $(WRC) $(IDL_TLB_SRCS:.idl=.tlb)

# Rule for linting

$(MODULE).ln : $(LINTS)
	if test "$(LINTS)" ; \
	then \
		$(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
	        $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
	else \
		$(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
	fi

lint:: $(MODULE).ln

# Rules for Windows API checking

winapi_check:: dummy
	$(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .

.PHONY: winapi_check

# Rules for dependencies

DEPEND_SRCS = $(C_SRCS) $(C_SRCS16) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(IDL_H_SRCS) $(IDL_C_SRCS) $(IDL_I_SRCS) $(IDL_P_SRCS) $(IDL_S_SRCS) $(IDL_GEN_C_SRCS) $(BISON_SRCS) $(LEX_SRCS) $(EXTRA_SRCS)

$(SUBDIRS:%=%/__depend__): dummy
	@cd `dirname $@` && $(MAKE) depend

depend: $(SUBDIRS:%=%/__depend__) dummy
	$(MAKEDEP) -C$(SRCDIR) -S$(TOPSRCDIR) -T$(TOPOBJDIR) $(EXTRAINCL) $(DEPEND_SRCS)

.PHONY: depend $(SUBDIRS:%=%/__depend__)

# Rules for cleaning

$(SUBDIRS:%=%/__clean__): dummy
	@cd `dirname $@` && $(MAKE) clean

$(EXTRASUBDIRS:%=%/__clean__): dummy
	-cd `dirname $@` && $(RM) $(CLEAN_FILES)

clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
	$(RM) $(CLEAN_FILES) $(CLEAN_TARGETS) $(PROGRAMS) $(MANPAGES)

.PHONY: clean $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)

# Rules for installing

$(SUBDIRS:%=%/__install__): dummy
	@cd `dirname $@` && $(MAKE) install

$(SUBDIRS:%=%/__install-lib__): dummy
	@cd `dirname $@` && $(MAKE) install-lib

$(SUBDIRS:%=%/__install-dev__): dummy
	@cd `dirname $@` && $(MAKE) install-dev

$(SUBDIRS:%=%/__uninstall__): dummy
	@cd `dirname $@` && $(MAKE) uninstall

install:: $(INSTALLSUBDIRS:%=%/__install__)

uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)

$(INSTALLDIRS):
	$(MKINSTALLDIRS) $@

.PHONY: install install-lib install-dev uninstall \
	$(SUBDIRS:%=%/__install__) $(SUBDIRS:%=%/__uninstall__) \
	$(SUBDIRS:%=%/__install-lib__) $(SUBDIRS:%=%/__install-dev__)

# Rules for testing

$(TESTSUBDIRS:%=%/__test__): dummy
	@cd `dirname $@` && $(MAKE) test

$(TESTSUBDIRS:%=%/__crosstest__): dummy
	@cd `dirname $@` && $(MAKE) crosstest

$(TESTSUBDIRS:%=%/__testclean__): dummy
	@cd `dirname $@` && $(MAKE) testclean

check test:: $(TESTSUBDIRS:%=%/__test__)

crosstest:: $(TESTSUBDIRS:%=%/__crosstest__)

testclean:: $(TESTSUBDIRS:%=%/__testclean__)

.PHONY: check test testclean crosstest $(TESTSUBDIRS:%=%/__test__) $(TESTSUBDIRS:%=%/__crosstest__) $(TESTSUBDIRS:%=%/__testclean__) 

# Rules for auto documentation

$(DOCSUBDIRS:%=%/__man__): dummy
	@cd `dirname $@` && $(MAKE) man

$(DOCSUBDIRS:%=%/__doc_html__): dummy
	@cd `dirname $@` && $(MAKE) doc-html

$(DOCSUBDIRS:%=%/__doc_sgml__): dummy
	@cd `dirname $@` && $(MAKE) doc-sgml

man: $(DOCSUBDIRS:%=%/__man__)
doc-html: $(DOCSUBDIRS:%=%/__doc_html__)
doc-sgml: $(DOCSUBDIRS:%=%/__doc_sgml__)

.PHONY: man doc-html doc-sgml $(DOCSUBDIRS:%=%/__man__) $(DOCSUBDIRS:%=%/__doc_html__) $(DOCSUBDIRS:%=%/__doc_sgml__)

# Misc. rules

$(MC_SRCS:.mc=.mc.rc): $(WMC)

$(IDL_GEN_HEADERS) $(IDL_GEN_C_SRCS) $(IDL_TLB_SRCS:.idl=.tlb): $(WIDL)

$(SUBDIRS): dummy
	@cd $@ && $(MAKE)

dummy:

.PHONY: dummy $(SUBDIRS)

# End of global rules

wrc$(EXEEXT): $(OBJS) $(LIBWPP)
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBWPP) $(LIBWINE) $(LIBPORT) $(LDFLAGS) $(LDRPATH_LOCAL)

wrc-installed: $(OBJS) $(LIBWPP)
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBWPP) $(LIBWINE) $(LIBPORT) $(LDFLAGS) $(LDRPATH_INSTALL)

install:: wrc-installed $(MANPAGES) $(INSTALLDIRS)
	$(INSTALL_DATA) wrc.man $(DESTDIR)$(mandir)/man$(prog_manext)/wrc.$(prog_manext)
	$(INSTALL_PROGRAM) wrc-installed $(DESTDIR)$(bindir)/wrc$(EXEEXT)

uninstall::
	$(RM) $(DESTDIR)$(bindir)/wrc$(EXEEXT) $(DESTDIR)$(mandir)/man$(prog_manext)/wrc.$(prog_manext)

parser.tab.c: parser.tab.h   # for parallel makes

### Dependencies:
dumpres.o: dumpres.c ../../include/config.h wrc.h wrctypes.h \
 ../../include/windef.h ../../include/winnt.h ../../include/basetsd.h \
 ../../include/guiddef.h ../../include/pshpack2.h \
 ../../include/poppack.h ../../include/pshpack8.h \
 ../../include/pshpack4.h ../../include/winbase.h \
 ../../include/winerror.h ../../include/winnls.h \
 ../../include/winver.h dumpres.h
genres.o: genres.c ../../include/config.h wrc.h wrctypes.h \
 ../../include/windef.h ../../include/winnt.h ../../include/basetsd.h \
 ../../include/guiddef.h ../../include/pshpack2.h \
 ../../include/poppack.h ../../include/pshpack8.h \
 ../../include/pshpack4.h ../../include/winbase.h \
 ../../include/winerror.h ../../include/winnls.h \
 ../../include/winver.h genres.h utils.h ../../include/wingdi.h \
 ../../include/winuser.h ../../include/wine/unicode.h
newstruc.o: newstruc.c ../../include/config.h wrc.h wrctypes.h \
 ../../include/windef.h ../../include/winnt.h ../../include/basetsd.h \
 ../../include/guiddef.h ../../include/pshpack2.h \
 ../../include/poppack.h ../../include/pshpack8.h \
 ../../include/pshpack4.h ../../include/winbase.h \
 ../../include/winerror.h ../../include/winnls.h \
 ../../include/winver.h newstruc.h utils.h parser.h \
 ../../include/wingdi.h
readres.o: readres.c ../../include/config.h ../../include/wine/port.h \
 wrc.h wrctypes.h ../../include/windef.h ../../include/winnt.h \
 ../../include/basetsd.h ../../include/guiddef.h \
 ../../include/pshpack2.h ../../include/poppack.h \
 ../../include/pshpack8.h ../../include/pshpack4.h \
 ../../include/winbase.h ../../include/winerror.h \
 ../../include/winnls.h ../../include/winver.h readres.h newstruc.h \
 utils.h genres.h
translation.o: translation.c dumpres.h wrctypes.h \
 ../../include/windef.h ../../include/winnt.h ../../include/basetsd.h \
 ../../include/guiddef.h ../../include/pshpack2.h \
 ../../include/poppack.h ../../include/pshpack8.h \
 ../../include/pshpack4.h ../../include/winbase.h \
 ../../include/winerror.h ../../include/winnls.h \
 ../../include/winver.h utils.h wrc.h
utils.o: utils.c ../../include/config.h ../../include/wine/port.h \
 ../../include/wine/unicode.h ../../include/windef.h \
 ../../include/winnt.h ../../include/basetsd.h ../../include/guiddef.h \
 ../../include/pshpack2.h ../../include/poppack.h \
 ../../include/pshpack8.h ../../include/pshpack4.h \
 ../../include/winbase.h ../../include/winerror.h \
 ../../include/winnls.h wrc.h wrctypes.h ../../include/winver.h \
 utils.h parser.h
wrc.o: wrc.c ../../include/config.h ../../include/wine/port.h wrc.h \
 wrctypes.h ../../include/windef.h ../../include/winnt.h \
 ../../include/basetsd.h ../../include/guiddef.h \
 ../../include/pshpack2.h ../../include/poppack.h \
 ../../include/pshpack8.h ../../include/pshpack4.h \
 ../../include/winbase.h ../../include/winerror.h \
 ../../include/winnls.h ../../include/winver.h utils.h readres.h \
 dumpres.h genres.h newstruc.h parser.h ../../include/wine/wpp.h
writeres.o: writeres.c ../../include/config.h \
 ../../include/wine/port.h ../../include/wine/unicode.h \
 ../../include/windef.h ../../include/winnt.h ../../include/basetsd.h \
 ../../include/guiddef.h ../../include/pshpack2.h \
 ../../include/poppack.h ../../include/pshpack8.h \
 ../../include/pshpack4.h ../../include/winbase.h \
 ../../include/winerror.h ../../include/winnls.h wrc.h wrctypes.h \
 ../../include/winver.h genres.h newstruc.h utils.h
parser.tab.o: parser.tab.c ../../include/config.h \
 ../../include/wine/port.h wrc.h wrctypes.h ../../include/windef.h \
 ../../include/winnt.h ../../include/basetsd.h ../../include/guiddef.h \
 ../../include/pshpack2.h ../../include/poppack.h \
 ../../include/pshpack8.h ../../include/pshpack4.h \
 ../../include/winbase.h ../../include/winerror.h \
 ../../include/winnls.h ../../include/winver.h utils.h newstruc.h \
 dumpres.h ../../include/wine/wpp.h ../../include/wine/unicode.h \
 parser.h ../../include/wingdi.h ../../include/winuser.h
parser.yy.o: parser.yy.c ../../include/wine/unicode.h \
 ../../include/windef.h ../../include/winnt.h ../../include/basetsd.h \
 ../../include/guiddef.h ../../include/pshpack2.h \
 ../../include/poppack.h ../../include/pshpack8.h \
 ../../include/pshpack4.h ../../include/winbase.h \
 ../../include/winerror.h ../../include/winnls.h wrc.h wrctypes.h \
 ../../include/winver.h utils.h parser.h newstruc.h parser.tab.h
