[LLVMdev] How to additionally compile the source files in subdirectories when using Makefile?
leftcopy.chx at gmail.com
Mon Jul 22 03:00:25 PDT 2013
I am writing a LLVM pass plugin, and just simply add a directory mypass into llvm/lib/Transforms. But since I don't hope this directory to contain too many source files, I add some subdirectories.
For instance, there are 2 files inside *mypass/sub: basic.h, basic.cpp. Here is the structure of the directory llvm/lib/Transforms/mypass
The problem is that basic.cpp will never be compiled into the loadable module which mypass.c symbols lies in. And LLVMLIBS USEDLIBS doesn't work either.
Here is mypass/Makefile
LEVEL = ../../..
DIRS = sub
LIBRARYNAME = mypass
LOADABLE_MODULE = 1
LEVEL = ../../../..
# LIBRARYNAME = test_sub
# ARCHIVE_LIBRARY = 1
# LOADABLE_MODULE = 1
When mypss/sub/Makefile uses LOADABLE_MODULE = 1 with another library name(test_sub), and by additionally loading it when using opt, it does work but I think there is a better way.
Also AFAIK, using cmake is much easier for this case since it only needs to use this configuration in mypass/Makefile:
But for some reasons I have to use GNU make to do this. Is there a good way?
More information about the llvm-dev