A handful of build system fixes:
[cvc5.git] / Makefile.builds.in
1 # -*- makefile -*-
2 #
3 # This Makefile produces the Makefile in the top-level builds/
4 # directory for standard-path builds (e.g., those configured from the
5 # source tree). It has some autoconf cruft in it, documented below.
6 #
7 # Its main purposes are to:
8 # 1. build the current build profile
9 # 2. install into "builds/$(CURRENT_BUILD)/$(prefix)"
10 # 3. set up "builds/$(CURRENT_BUILD)/{bin,lib}" symlinks
11 # 4. install into "builds/$(prefix)"
12 # 5. set up "builds/bin" and "builds/lib"
13 #
14 # Steps 2 and 4 require libtool-relinking for dynamically-linked
15 # executables and libraries, since build/bin is not the final
16 # installation path.
17
18 # Include the "current" build profile.
19 include current
20
21 # Set up $(MAKE)
22 @SET_MAKE@
23
24 # Set up some basic autoconf make vars
25 install_sh = @install_sh@
26 mkinstalldirs = $(install_sh) -d
27 exec_prefix = @exec_prefix@
28 prefix = @prefix@
29 bindir = @bindir@
30 libdir = @libdir@
31 abs_builddir = @abs_builddir@
32
33 # Are we building static/dynamic libraries/binaries? One or the other can be
34 # on, or both.
35 BUILDING_STATIC = @BUILDING_STATIC@
36 BUILDING_SHARED = @BUILDING_SHARED@
37 STATIC_BINARY = @STATIC_BINARY@
38
39 .PHONY: _default_build_ all
40 _default_build_: all
41 all:
42 # build the current build profile
43 (cd $(CURRENT_BUILD) && $(MAKE) $@)
44 # set up builds/$(CURRENT_BUILD)/...prefix.../bin
45 # and builds/$(CURRENT_BUILD)/...prefix.../lib
46 $(mkinstalldirs) "$(CURRENT_BUILD)$(bindir)" "$(CURRENT_BUILD)$(libdir)"
47 # install libcvc4
48 $(CURRENT_BUILD)/libtool --mode=install install -v \
49 $(CURRENT_BUILD)/src/libcvc4.la \
50 "$(abs_builddir)$(libdir)"
51 # install libcvc4parser
52 $(CURRENT_BUILD)/libtool --mode=install install -v \
53 $(CURRENT_BUILD)/src/parser/libcvc4parser.la \
54 "$(abs_builddir)$(libdir)"
55 ifeq ($(BUILDING_SHARED)$(STATIC_BINARY),10)
56 # if we're building shared libs and the binary is not static, relink
57 thelibdir="$(abs_builddir)$(libdir)"; \
58 progdir="$(abs_builddir)$(bindir)"; file=cvc4; \
59 eval `grep '^relink_command=' $(CURRENT_BUILD)/src/main/cvc4 | sed 's:-Wl,-rpath:-Wl,-rpath -Wl,\\\\$$thelibdir -Wl,-rpath:'`; \
60 eval "(cd $(CURRENT_BUILD)/src/main && $$relink_command)"
61 else
62 # if we're building static libs only, just install the driver binary directly
63 $(install_sh) \
64 $(CURRENT_BUILD)/src/main/cvc4 \
65 "$(abs_builddir)$(bindir)"
66 endif
67 # set up builds/$(CURRENT_BUILD)/bin and builds/$(CURRENT_BUILD)/lib
68 test -e $(CURRENT_BUILD)/lib || ln -sfv "$(abs_builddir)$(libdir)" $(CURRENT_BUILD)/lib
69 test -e $(CURRENT_BUILD)/bin || ln -sfv "$(abs_builddir)$(bindir)" $(CURRENT_BUILD)/bin
70 # set up builds/...prefix.../bin and builds/...prefix.../lib
71 $(mkinstalldirs) ".$(bindir)" ".$(libdir)"
72 # install libcvc4
73 $(CURRENT_BUILD)/libtool --mode=install install -v $(CURRENT_BUILD)/src/libcvc4.la "`pwd`$(libdir)"
74 # install libcvc4parser
75 $(CURRENT_BUILD)/libtool --mode=install install -v $(CURRENT_BUILD)/src/parser/libcvc4parser.la "`pwd`$(libdir)"
76 ifeq ($(BUILDING_SHARED)$(STATIC_BINARY),10)
77 # if we're building shared libs and the binary is not static, relink
78 thelibdir="`pwd`$(libdir)"; progdir="`pwd`$(bindir)"; file=cvc4; \
79 eval `grep '^relink_command=' $(CURRENT_BUILD)/src/main/cvc4 | sed 's:-Wl,-rpath:-Wl,-rpath -Wl,\\\\$$thelibdir -Wl,-rpath:'`; \
80 eval "(cd $(CURRENT_BUILD)/src/main && $$relink_command)"
81 else
82 # if we're building static libs only, just install the driver binary directly
83 $(install_sh) $(CURRENT_BUILD)/src/main/cvc4 "`pwd`$(bindir)"
84 endif
85 # set up builds/bin and builds/lib
86 test -e lib || ln -sfv ".$(libdir)" lib
87 test -e bin || ln -sfv ".$(bindir)" bin
88
89 regress0 regress1 regress2 regress3: all
90 (cd $(CURRENT_BUILD) && $(MAKE) $@)
91
92 # any other target than the default doesn't do the extra stuff above
93 %:
94 (cd $(CURRENT_BUILD) && $(MAKE) $@)