Reputation: 2684
I am building a project using autotool
. Basically the project depends on several 3rd-party projects which are also managed by autotool
.
my_project/
my_project/3rd-party/
To enable recursive build, I add AC_CONFIG_SUBDIRS
macros in my configure.ac:
AC_CONFIG_SUBDIRS([3rd-party/gtest-1.7.0])
AC_CONFIG_SUBDIRS([3rd-party/libstatgrab-0.91])
AC_CONFIG_SUBDIRS([3rd-party/leveldb-1.2.0])
This gives me a convenience of recursive build, link, and clean. However, I do not want to install all these 3rd-party libraries but my own project when I hit make install
. Is there anyway for me to get rid of this particular recursion?
Upvotes: 10
Views: 463
Reputation: 2698
This is isn't quite what I was hoping for because you also have to bring in every recursive rule that you want to work in those subtrees, but it's closer.
https://github.com/protocolbuffers/protobuf/blob/master/Makefile.am#L14
DIST_SUBDIRS = src conformance benchmarks third_party/googletest
# Build gmock before we build protobuf tests. We don't add gmock to SUBDIRS
# because then "make check" would also build and run all of gmock's own tests,
# which takes a lot of time and is generally not useful to us. Also, we don't
# want "make install" to recurse into gmock since we don't want to overwrite
# the installed version of gmock if there is one.
check-local:
@echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
@cd third_party/googletest/googletest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
@cd third_party/googletest/googlemock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
# We would like to clean gmock when "make clean" is invoked. But we have to
# be careful because clean-local is also invoked during "make distclean", but
# "make distclean" already recurses into gmock because it's listed among the
# DIST_SUBDIRS. distclean will delete gmock/Makefile, so if we then try to
# cd to the directory again and "make clean" it will fail. So, check that the
# Makefile exists before recursing.
clean-local:
@if test -e third_party/googletest/Makefile; then \
echo "Making clean in googletest"; \
cd third_party/googletest && $(MAKE) $(AM_MAKEFLAGS) clean; \
fi; \
Upvotes: 0
Reputation: 7287
I don't think you can simply remove this single one if you don't change any makefile in the 3rd-pardy directories (which you could even do from the main Makefile, just rename the target via sed
[dirty hack]).
I guess you internal call configure in the 3rd-party directories, don't you? If yes you may set the prefix
(or data-prefix
and exec-prefix) different. It may be a good idea in any case to create a
3rd-party-build` directory and both build the 3rd-party stuff there and change the install prefix to use this.
You didn't asked for it but the "solution" is different: remove the 3rd-party stuff from your main makefile:
build_dep.sh
This both solves the problem and allows to use the libraries/tools if they exist already and gives the user the option to use a different version while keeping the simple "you can have it all from the main directories and don't need to get/build the dependencies on your own"
Upvotes: 4