Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to substitute a pattern in Makefile.am

I have an application with several subdirectories, which I want to compile non-recursive. For this I have seperated all sorucefiles from the subdirectories into several variables, which I then use in the final collection of sources. Something like this:

GUI_SOURCEFILES = Gui/MainWindow.cc \
                  Gui/StatusBar.cc
...
foo_SOURCES = $(GUI_SOURCEFILES) \
              $(DATABASE_SOURCEFILES) \
              main.cc

Now however this forces me to write Gui/ for all gui sourcefiles and Db\ in front of all database files. I think it should be possible to create this prefix automaticall, but I cannot find a way to do this correctly. I tried the usual make way:

GUI_SOURCEFILES = MainWindow.cc \
                  StatusBar.cc
...
foo_SOURCES = $(GUI_SOURCEFILES) \
              $(patsubst %,Gui/%,$(DATABASE_SOURCEFILES)) \
              main.cc

But autotools will not compile this Makefile.am at all.

Is there a way to get autotools to do this for me?

like image 583
LiKao Avatar asked Jan 24 '26 12:01

LiKao


1 Answers

There is no way here, all filenames must be available at automake time, and that precludes certain make-time like functions (non-portable at that).

like image 59
jørgensen Avatar answered Jan 26 '26 11:01

jørgensen