4

We have a project (c++) and it needs to include a binary file into shared library. This is done on windows by referencing the binary file from a resource file. On Linux it can be achieved by using objcopy as shown here

The question is how can this be automated this using autoconf/automake? There exists Makefile.am and configure.ac files. Is this going to be a manual task?

(Maybe this question needs to be on the unix stack exchange site?)

Community
  • 1
  • 1
Satpal
  • 309
  • 2
  • 8

1 Answers1

6

Does your binary file have a distinctive extension? If so, refer to the Suffixes chapter of the manual:

.bin.o:
        bin2o -o $@ $<

And you then list foo.bin in your foo_SOURCES variable.

If you don't have a distinctive extension, try something like this:

foo_SOURCES = foo.c bar.c baz.c
foo_LDADD = foobin$(OBJEXT)

foobin$(OBJEXT): foobin
        bin2o -o $@ $<
Jack Kelly
  • 18,264
  • 2
  • 56
  • 81
  • 1
    That worked a treat. Thanks. Sorry can;t upvote the answer as I don't have enough rep :( – Satpal Jun 27 '11 at 06:37
  • 2
    In the second case, you may want to add `foobin$(OBJEXT)` to `CLEANFILES`, so it's removed by `make clean`. – Jack Kelly Jun 27 '11 at 10:49