0


I have a repository of projects with following structure:

repo/
  configure.ac
  Makefile.am
  project1/
    configure.ac
    Makefile.am
    [sources]
  project2/
    configure.ac
    Makefile.am
    [sources]
  project3/
    configure.ac
    Makefile.am
    [sources]

And now I need to add directory (lets say common_logic/) into repo/ and modify somehow project1 and project2 to use sources from common_logic.

One of the solutions that I can see is to copy ../common_logic/ after ./configure (or before any rule in Makefile) executed in project1/ and add in Makefile.am following lines:

project1_la_CFLAGS += -I./common_logic

project1_la_SOURCES += ./common_logic/foo.h ./common_logic/foo.c

In this case neither make nor make dist are broken. However it is looks like a crutch to me.

Anyway, could you please tell me how should project1 and project2 be modified to use the newely created folder? Or point another solution?

ilardm
  • 146
  • 8

1 Answers1

1

Perhaps it is best to build a convenience library from common_logic:

noinst_LTLIBRARIES = libcommonlogic.la
libcommonlogic_la_SOURCES = foo.c foo.h

Then, in project1's Makefile.am:

project1_la_LIBADD = ../common_logic/libcommonlogic.la
ptomato
  • 56,175
  • 13
  • 112
  • 165
  • This is solution for _in-place_ build. But `make dist` would be broken, correct? – ilardm Oct 07 '12 at 09:39
  • Not correct; `make dist` will work because `libcommonlogic.la` will be built in `$(top_builddir)/common_logic/`, and the `project1.la` build will have a working directory of `$(top_builddir)/project1`. So the paths will remain the same relative to one another. – ptomato Oct 08 '12 at 12:05
  • But if you don't believe me, then just try it out - I could be wrong ;-) – ptomato Oct 08 '12 at 12:05
  • Well, `make dist` is broken as I expect. Either me or you did not understand each other. http://pastebin.com/UP9gFP1w – ilardm Oct 09 '12 at 06:32
  • I think we don't understand each other then ;-) I see nothing broken about that; `make dist` worked and you got a tarball, no? – ptomato Oct 09 '12 at 08:45
  • As you can see, neither `pdb.cpp` nor `pdb.h` are presented in tarball. Hence build from this tarball (e.g. rpmbuild) will be broken. – ilardm Oct 09 '12 at 12:22
  • Then something else is going wrong in your makefile. Any files declared in one of Automake's special `_SOURCES` variables should be in the tarball, no exceptions. Can you post more of your makefile? – ptomato Oct 09 '12 at 15:07
  • Can you post the toplevel and `libplugindriver` makefiles? – ptomato Oct 09 '12 at 18:31
  • I notice you didn't put `common_logic` into `SUBDIRS`? – ptomato Oct 10 '12 at 19:17
  • This did not changed anything. And, IMO, it shouldn't. – ilardm Oct 13 '12 at 12:31