mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Use buildprefix
in a few more places
`installcheck` doesn't yet work, but the rest of the build can now happen mostly inside a separate build directory. Progress on #9342 Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
This commit is contained in:
parent
a8fea5a54f
commit
52e0911302
11 changed files with 64 additions and 35 deletions
6
Makefile
6
Makefile
|
@ -1,5 +1,7 @@
|
||||||
-include Makefile.config
|
include mk/build-dir.mk
|
||||||
clean-files += Makefile.config
|
|
||||||
|
-include $(buildprefix)Makefile.config
|
||||||
|
clean-files += $(buildprefix)Makefile.config
|
||||||
|
|
||||||
ifeq ($(ENABLE_BUILD), yes)
|
ifeq ($(ENABLE_BUILD), yes)
|
||||||
makefiles = \
|
makefiles = \
|
||||||
|
|
|
@ -146,6 +146,31 @@ $ nix build .#packages.aarch64-linux.default
|
||||||
Cross-compiled builds are available for ARMv6 (`armv6l-linux`) and ARMv7 (`armv7l-linux`).
|
Cross-compiled builds are available for ARMv6 (`armv6l-linux`) and ARMv7 (`armv7l-linux`).
|
||||||
Add more [system types](#system-type) to `crossSystems` in `flake.nix` to bootstrap Nix on unsupported platforms.
|
Add more [system types](#system-type) to `crossSystems` in `flake.nix` to bootstrap Nix on unsupported platforms.
|
||||||
|
|
||||||
|
### Building for multiple platforms at once
|
||||||
|
|
||||||
|
It is useful to perform multiple cross and native builds on the same source tree,
|
||||||
|
for example to ensure that better support for one platform doesn't break the build for another.
|
||||||
|
In order to facilitate this, Nix has some support for being built out of tree – that is, placing build artefacts in a different directory than the source code:
|
||||||
|
|
||||||
|
1. Create a directory for the build, e.g.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir build
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Run the configure script from that directory, e.g.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd build
|
||||||
|
../configure <configure flags>
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Run make from the source directory, but with the build directory specified, e.g.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make builddir=build <make flags>
|
||||||
|
```
|
||||||
|
|
||||||
## System type
|
## System type
|
||||||
|
|
||||||
Nix uses a string with he following format to identify the *system type* or *platform* it runs on:
|
Nix uses a string with he following format to identify the *system type* or *platform* it runs on:
|
||||||
|
|
10
mk/build-dir.mk
Normal file
10
mk/build-dir.mk
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Initialise support for build directories.
|
||||||
|
builddir ?=
|
||||||
|
|
||||||
|
ifdef builddir
|
||||||
|
buildprefix = $(builddir)/
|
||||||
|
buildprefixrel = $(builddir)
|
||||||
|
else
|
||||||
|
buildprefix =
|
||||||
|
buildprefixrel = .
|
||||||
|
endif
|
11
mk/install-dirs.mk
Normal file
11
mk/install-dirs.mk
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Default installation paths.
|
||||||
|
prefix ?= /usr/local
|
||||||
|
libdir ?= $(prefix)/lib
|
||||||
|
bindir ?= $(prefix)/bin
|
||||||
|
libexecdir ?= $(prefix)/libexec
|
||||||
|
datadir ?= $(prefix)/share
|
||||||
|
localstatedir ?= $(prefix)/var
|
||||||
|
sysconfdir ?= $(prefix)/etc
|
||||||
|
mandir ?= $(prefix)/share/man
|
||||||
|
|
||||||
|
DESTDIR ?=
|
25
mk/lib.mk
25
mk/lib.mk
|
@ -43,27 +43,6 @@ define newline
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
||||||
# Default installation paths.
|
|
||||||
prefix ?= /usr/local
|
|
||||||
libdir ?= $(prefix)/lib
|
|
||||||
bindir ?= $(prefix)/bin
|
|
||||||
libexecdir ?= $(prefix)/libexec
|
|
||||||
datadir ?= $(prefix)/share
|
|
||||||
localstatedir ?= $(prefix)/var
|
|
||||||
sysconfdir ?= $(prefix)/etc
|
|
||||||
mandir ?= $(prefix)/share/man
|
|
||||||
|
|
||||||
|
|
||||||
# Initialise support for build directories.
|
|
||||||
builddir ?=
|
|
||||||
|
|
||||||
ifdef builddir
|
|
||||||
buildprefix = $(builddir)/
|
|
||||||
else
|
|
||||||
buildprefix =
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
# Pass -fPIC if we're building dynamic libraries.
|
# Pass -fPIC if we're building dynamic libraries.
|
||||||
BUILD_SHARED_LIBS ?= 1
|
BUILD_SHARED_LIBS ?= 1
|
||||||
|
|
||||||
|
@ -94,6 +73,8 @@ ifeq ($(BUILD_DEBUG), 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
include mk/build-dir.mk
|
||||||
|
include mk/install-dirs.mk
|
||||||
include mk/functions.mk
|
include mk/functions.mk
|
||||||
include mk/tracing.mk
|
include mk/tracing.mk
|
||||||
include mk/clean.mk
|
include mk/clean.mk
|
||||||
|
@ -112,7 +93,7 @@ define include-sub-makefile
|
||||||
include $(1)
|
include $(1)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach mf, $(makefiles), $(eval $(call include-sub-makefile, $(mf))))
|
$(foreach mf, $(makefiles), $(eval $(call include-sub-makefile,$(mf))))
|
||||||
|
|
||||||
|
|
||||||
# Instantiate stuff.
|
# Instantiate stuff.
|
||||||
|
|
|
@ -10,10 +10,10 @@ endef
|
||||||
|
|
||||||
ifneq ($(MAKECMDGOALS), clean)
|
ifneq ($(MAKECMDGOALS), clean)
|
||||||
|
|
||||||
%.h: %.h.in
|
$(buildprefix)%.h: %.h.in
|
||||||
$(trace-gen) rm -f $@ && ./config.status --quiet --header=$@
|
$(trace-gen) rm -f $@ && cd $(buildprefixrel) && ./config.status --quiet --header=$(@:$(buildprefix)%=%)
|
||||||
|
|
||||||
%: %.in
|
$(buildprefix)%: %.in
|
||||||
$(trace-gen) rm -f $@ && ./config.status --quiet --file=$@
|
$(trace-gen) rm -f $@ && cd $(buildprefixrel) && ./config.status --quiet --file=$(@:$(buildprefix)%=%)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -12,4 +12,4 @@ libcmd_LDFLAGS = $(EDITLINE_LIBS) $(LOWDOWN_LIBS) -pthread
|
||||||
|
|
||||||
libcmd_LIBS = libstore libutil libexpr libmain libfetchers
|
libcmd_LIBS = libstore libutil libexpr libmain libfetchers
|
||||||
|
|
||||||
$(eval $(call install-file-in, $(d)/nix-cmd.pc, $(libdir)/pkgconfig, 0644))
|
$(eval $(call install-file-in, $(buildprefix)$(d)/nix-cmd.pc, $(libdir)/pkgconfig, 0644))
|
||||||
|
|
|
@ -36,7 +36,7 @@ $(d)/lexer-tab.cc $(d)/lexer-tab.hh: $(d)/lexer.l
|
||||||
|
|
||||||
clean-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh
|
clean-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh
|
||||||
|
|
||||||
$(eval $(call install-file-in, $(d)/nix-expr.pc, $(libdir)/pkgconfig, 0644))
|
$(eval $(call install-file-in, $(buildprefix)$(d)/nix-expr.pc, $(libdir)/pkgconfig, 0644))
|
||||||
|
|
||||||
$(foreach i, $(wildcard src/libexpr/value/*.hh), \
|
$(foreach i, $(wildcard src/libexpr/value/*.hh), \
|
||||||
$(eval $(call install-file-in, $(i), $(includedir)/nix/value, 0644)))
|
$(eval $(call install-file-in, $(i), $(includedir)/nix/value, 0644)))
|
||||||
|
@ -47,4 +47,4 @@ $(d)/primops.cc: $(d)/imported-drv-to-derivation.nix.gen.hh
|
||||||
|
|
||||||
$(d)/eval.cc: $(d)/primops/derivation.nix.gen.hh $(d)/fetchurl.nix.gen.hh $(d)/flake/call-flake.nix.gen.hh
|
$(d)/eval.cc: $(d)/primops/derivation.nix.gen.hh $(d)/fetchurl.nix.gen.hh $(d)/flake/call-flake.nix.gen.hh
|
||||||
|
|
||||||
src/libexpr/primops/fromTOML.o: ERROR_SWITCH_ENUM =
|
$(buildprefix)src/libexpr/primops/fromTOML.o: ERROR_SWITCH_ENUM =
|
||||||
|
|
|
@ -14,4 +14,4 @@ libmain_LIBS = libstore libutil
|
||||||
|
|
||||||
libmain_ALLOW_UNDEFINED = 1
|
libmain_ALLOW_UNDEFINED = 1
|
||||||
|
|
||||||
$(eval $(call install-file-in, $(d)/nix-main.pc, $(libdir)/pkgconfig, 0644))
|
$(eval $(call install-file-in, $(buildprefix)$(d)/nix-main.pc, $(libdir)/pkgconfig, 0644))
|
||||||
|
|
|
@ -59,7 +59,7 @@ $(d)/build.cc:
|
||||||
|
|
||||||
clean-files += $(d)/schema.sql.gen.hh $(d)/ca-specific-schema.sql.gen.hh
|
clean-files += $(d)/schema.sql.gen.hh $(d)/ca-specific-schema.sql.gen.hh
|
||||||
|
|
||||||
$(eval $(call install-file-in, $(d)/nix-store.pc, $(libdir)/pkgconfig, 0644))
|
$(eval $(call install-file-in, $(buildprefix)$(d)/nix-store.pc, $(libdir)/pkgconfig, 0644))
|
||||||
|
|
||||||
$(foreach i, $(wildcard src/libstore/builtins/*.hh), \
|
$(foreach i, $(wildcard src/libstore/builtins/*.hh), \
|
||||||
$(eval $(call install-file-in, $(i), $(includedir)/nix/builtins, 0644)))
|
$(eval $(call install-file-in, $(i), $(includedir)/nix/builtins, 0644)))
|
||||||
|
|
|
@ -140,9 +140,9 @@ ifeq ($(ENABLE_BUILD), yes)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(d)/test-libstoreconsumer.sh.test $(d)/test-libstoreconsumer.sh.test-debug: \
|
$(d)/test-libstoreconsumer.sh.test $(d)/test-libstoreconsumer.sh.test-debug: \
|
||||||
$(d)/test-libstoreconsumer/test-libstoreconsumer
|
$(buildprefix)$(d)/test-libstoreconsumer/test-libstoreconsumer
|
||||||
$(d)/plugins.sh.test $(d)/plugins.sh.test-debug: \
|
$(d)/plugins.sh.test $(d)/plugins.sh.test-debug: \
|
||||||
$(d)/plugins/libplugintest.$(SO_EXT)
|
$(buildprefix)$(d)/plugins/libplugintest.$(SO_EXT)
|
||||||
|
|
||||||
install-tests += $(foreach x, $(nix_tests), $(d)/$(x))
|
install-tests += $(foreach x, $(nix_tests), $(d)/$(x))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue