Hello all,
I wonder what the proper way is to add an unconventional output (other than
*.o or *.obj) to the Makefile objects. As an example, here's a working way
to add rc resources to a Makefile (output from the resource compiler
rc.exe). It uses the BUILT_SOURCES and adds the output via the LDADD macro.
Working, but not so very pretty.

configure.ac
------------------------------------------
m4_define([prog_version_major],   [1])
m4_define([prog_version_minor],   [2])
m4_define([prog_version_release], [3])
            ...
AC_INIT([prog], [prog_full_version], [EMAIL PROTECTED])

# Add support for rc version resource
AC_ARG_ENABLE(use_rc, 
  AC_HELP_STRING(--enable-use_rc, support rc version resource),
  [if test "$enableval" = yes; then
    AC_MSG_RESULT([Adding support for rc version resource])
    AC_CHECK_PROG(RSC, 'rc.exe -?', rc.exe)
    AC_SUBST(RCFLAGS)
    AC_DEFINE([PROG_VERSION_MAJOR], [prog_version_major],
        [The major version number of this release])
           ...
  fi], enable_use_rc=no)
AM_CONDITIONAL(USE_RC_RESOURCE, [test "x$enable_use_rc" != xno])
------------------------------------------

Makefile.am
------------------------------------------
if USE_RC_RESOURCE
# add resource script to sources
prog_SOURCES += prog.rc
prog_LDADD += prog.res
BUILT_SOURCES = prog.res
CLEANFILES = *.res
endif

# resource compile
.rc.res:
  $(RSC) $(RCFLAGS) $(INCLUDES) $(DEFAULT_INCLUDES) -fo $@ $<
------------------------------------------

=> resulting Makefile
------------------------------------------
am__append_1 = prog.rc
am__append_2 = prog.res
am__objects_1 = 
am_prog_OBJECTS = $(am__objects_1)
prog_SOURCES = $(am__append_1)
prog_OBJECTS = $(am_prog_OBJECTS)
prog_DEPENDENCIES = $(am__append_2)
prog_LDADD = $(am__append_2)
------------------------------------------

How to automatically get prog.res in $(prog_OBJECTS) instead of
$(prog_LDADD)?

Thanks Erik





Reply via email to