From b8e9efc476abc248a17c9e9cd117f3d53e4a7f63 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 22 Nov 2013 15:54:18 +0100 Subject: [PATCH] New non-recursive, plain Make-based build system --- .gitignore | 1 + Makefile.config.in | 10 +++++ Makefile.lib | 63 ++++++++++++++++++++++++++++++++ Makefile.new | 22 +++++++++++ configure.ac | 1 + src/boost/format/Makefile.new | 5 +++ src/libexpr/Makefile.new | 10 +++++ src/libmain/Makefile.new | 7 ++++ src/libstore/Makefile.new | 19 ++++++++++ src/libutil/Makefile.new | 10 +++++ src/nix-daemon/Makefile.new | 7 ++++ src/nix-env/Makefile.new | 7 ++++ src/nix-hash/Makefile.new | 7 ++++ src/nix-instantiate/Makefile.new | 7 ++++ src/nix-store/Makefile.new | 7 ++++ 15 files changed, 183 insertions(+) create mode 100644 Makefile.config.in create mode 100644 Makefile.lib create mode 100644 Makefile.new create mode 100644 src/boost/format/Makefile.new create mode 100644 src/libexpr/Makefile.new create mode 100644 src/libmain/Makefile.new create mode 100644 src/libstore/Makefile.new create mode 100644 src/libutil/Makefile.new create mode 100644 src/nix-daemon/Makefile.new create mode 100644 src/nix-env/Makefile.new create mode 100644 src/nix-hash/Makefile.new create mode 100644 src/nix-instantiate/Makefile.new create mode 100644 src/nix-store/Makefile.new diff --git a/.gitignore b/.gitignore index 5dc9af7fc..a8f5a2379 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ Makefile Makefile.in +Makefile.config # / /aclocal.m4 diff --git a/Makefile.config.in b/Makefile.config.in new file mode 100644 index 000000000..3bb8cdda4 --- /dev/null +++ b/Makefile.config.in @@ -0,0 +1,10 @@ +VERSION = @VERSION@ +bindir = @bindir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +exec_prefix = @exec_prefix@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +prefix = @prefix@ +storedir = @storedir@ +sysconfdir = @sysconfdir@ diff --git a/Makefile.lib b/Makefile.lib new file mode 100644 index 000000000..d681cf741 --- /dev/null +++ b/Makefile.lib @@ -0,0 +1,63 @@ +default: all + +here = $(dir $(lastword $(MAKEFILE_LIST))) + +LIBS = + +QUIET = @ + +%.o: %.cc + $(QUIET) g++ -o $@ -c $^ -g -fPIC $(CXXFLAGS) $($@_CXXFLAGS) + +%.o: %.c + $(QUIET) gcc -o $@ -c $^ -g -fPIC $(CFLAGS) $($@_CFLAGS) + + +# Generate Make rules for libraries. +libs_list := + +define LIBS_template = + _d := $$($(1)_DIR) + _objs := $$(foreach src, $$($(1)_SOURCES), $$(_d)$$(basename $$(src)).o) + _libs := $$(foreach lib, $$($(1)_LIBS), $$(lib).a) + _lib := $$(_d)$(1).a + + $$(_lib): $$(_objs) + $(QUIET) ar crs $$@ $$? + + # Propagate CXXFLAGS to the individual object files. + $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) + + clean_list += $$(_lib) $$(_objs) + libs_list += $$(_lib) +endef + + +# Generate Make rules for programs. +programs_list := + +define PROGRAMS_template = + _d := $$($(1)_DIR) + _objs := $$(foreach src, $$($(1)_SOURCES), $$(_d)$$(basename $$(src)).o) + _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_DIR)$$(lib).a) + _prog := $$(_d)$(1) + + $$(_prog): $$(_objs) $$(_libs) + $(QUIET) g++ -o $$@ $$^ $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS)) + + # Propagate CXXFLAGS to the individual object files. + $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) + + clean_list += $$(_prog) $$(_objs) + programs_list += $$(_prog) +endef + + +# Cleaning stuff. +clean_list := + +clean: + rm -fv $(clean_list) + +dryclean: + @echo $(clean_list) diff --git a/Makefile.new b/Makefile.new new file mode 100644 index 000000000..566f1f7be --- /dev/null +++ b/Makefile.new @@ -0,0 +1,22 @@ +include Makefile.config +include Makefile.lib + +include src/boost/format/Makefile.new +include src/libutil/Makefile.new +include src/libstore/Makefile.new +include src/libmain/Makefile.new +include src/libexpr/Makefile.new +include src/nix-hash/Makefile.new +include src/nix-store/Makefile.new +include src/nix-instantiate/Makefile.new +include src/nix-env/Makefile.new +include src/nix-daemon/Makefile.new + +CXXFLAGS = -I . -I src -I src/libutil -I src/libstore -I src/libmain -I src/libexpr + +CFLAGS = + +$(foreach lib, $(LIBS), $(eval $(call LIBS_template,$(lib)))) +$(foreach prog, $(PROGRAMS), $(eval $(call PROGRAMS_template,$(prog)))) + +all: $(programs_list) diff --git a/configure.ac b/configure.ac index 7acd57557..c64766a2d 100644 --- a/configure.ac +++ b/configure.ac @@ -385,5 +385,6 @@ AC_CONFIG_FILES([Makefile misc/Makefile misc/emacs/Makefile tests/Makefile + Makefile.config ]) AC_OUTPUT diff --git a/src/boost/format/Makefile.new b/src/boost/format/Makefile.new new file mode 100644 index 000000000..28b66bd62 --- /dev/null +++ b/src/boost/format/Makefile.new @@ -0,0 +1,5 @@ +LIBS += libformat + +libformat_DIR := $(here) + +libformat_SOURCES = format_implementation.cc free_funcs.cc parsing.cc diff --git a/src/libexpr/Makefile.new b/src/libexpr/Makefile.new new file mode 100644 index 000000000..f6c900431 --- /dev/null +++ b/src/libexpr/Makefile.new @@ -0,0 +1,10 @@ +LIBS += libexpr + +libexpr_DIR := $(here) + +libexpr_SOURCES = \ + nixexpr.cc eval.cc primops.cc lexer-tab.cc parser-tab.cc \ + get-drvs.cc attr-path.cc value-to-xml.cc value-to-json.cc \ + common-opts.cc names.cc + +# FIXME: add rules for parser-tab.cc / lexer-tab.cc. diff --git a/src/libmain/Makefile.new b/src/libmain/Makefile.new new file mode 100644 index 000000000..1f74cea9c --- /dev/null +++ b/src/libmain/Makefile.new @@ -0,0 +1,7 @@ +LIBS += libmain + +libmain_DIR := $(here) + +libmain_SOURCES = shared.cc stack.cc + +libmain_LDFLAGS = -lgc diff --git a/src/libstore/Makefile.new b/src/libstore/Makefile.new new file mode 100644 index 000000000..24011c244 --- /dev/null +++ b/src/libstore/Makefile.new @@ -0,0 +1,19 @@ +LIBS += libstore + +libstore_DIR := $(here) + +libstore_SOURCES = \ + store-api.cc local-store.cc remote-store.cc derivations.cc build.cc misc.cc \ + globals.cc references.cc pathlocks.cc gc.cc optimise-store.cc + +libstore_LDFLAGS = -lsqlite3 -lbz2 + +libstore_CXXFLAGS = \ + -DNIX_STORE_DIR=\"$(storedir)\" \ + -DNIX_DATA_DIR=\"$(datadir)\" \ + -DNIX_STATE_DIR=\"$(localstatedir)/nix\" \ + -DNIX_LOG_DIR=\"$(localstatedir)/log/nix\" \ + -DNIX_CONF_DIR=\"$(sysconfdir)/nix\" \ + -DNIX_LIBEXEC_DIR=\"$(libexecdir)\" \ + -DNIX_BIN_DIR=\"$(bindir)\" \ + -DNIX_VERSION=\"$(VERSION)\" diff --git a/src/libutil/Makefile.new b/src/libutil/Makefile.new new file mode 100644 index 000000000..b90c1c0ca --- /dev/null +++ b/src/libutil/Makefile.new @@ -0,0 +1,10 @@ +LIBS += libutil + +libutil_DIR := $(here) + +libutil_SOURCES = util.cc hash.cc serialise.cc archive.cc xml-writer.cc affinity.cc \ + md5.c sha1.c sha256.c + +# FIXME: md5.c et al. should only be built when we don't have OpenSSL. + +libutil_LIBS = src/boost/format/libformat diff --git a/src/nix-daemon/Makefile.new b/src/nix-daemon/Makefile.new new file mode 100644 index 000000000..a2d98e790 --- /dev/null +++ b/src/nix-daemon/Makefile.new @@ -0,0 +1,7 @@ +PROGRAMS += nix-daemon + +nix-daemon_DIR := $(here) + +nix-daemon_SOURCES = nix-daemon.cc + +nix-daemon_LIBS = libmain libstore libutil libformat diff --git a/src/nix-env/Makefile.new b/src/nix-env/Makefile.new new file mode 100644 index 000000000..5c92274f3 --- /dev/null +++ b/src/nix-env/Makefile.new @@ -0,0 +1,7 @@ +PROGRAMS += nix-env + +nix-env_DIR := $(here) + +nix-env_SOURCES = nix-env.cc profiles.cc profiles.hh user-env.cc user-env.hh + +nix-env_LIBS = libexpr libmain libstore libutil libformat diff --git a/src/nix-hash/Makefile.new b/src/nix-hash/Makefile.new new file mode 100644 index 000000000..87aba716c --- /dev/null +++ b/src/nix-hash/Makefile.new @@ -0,0 +1,7 @@ +PROGRAMS += nix-hash + +nix-hash_DIR := $(here) + +nix-hash_SOURCES = nix-hash.cc + +nix-hash_LIBS = libmain libstore libutil libformat diff --git a/src/nix-instantiate/Makefile.new b/src/nix-instantiate/Makefile.new new file mode 100644 index 000000000..71e40706a --- /dev/null +++ b/src/nix-instantiate/Makefile.new @@ -0,0 +1,7 @@ +PROGRAMS += nix-instantiate + +nix-instantiate_DIR := $(here) + +nix-instantiate_SOURCES = nix-instantiate.cc + +nix-instantiate_LIBS = libexpr libmain libstore libutil libformat diff --git a/src/nix-store/Makefile.new b/src/nix-store/Makefile.new new file mode 100644 index 000000000..195d05a2d --- /dev/null +++ b/src/nix-store/Makefile.new @@ -0,0 +1,7 @@ +PROGRAMS += nix-store + +nix-store_DIR := $(here) + +nix-store_SOURCES = nix-store.cc dotgraph.cc xmlgraph.cc + +nix-store_LIBS = libmain libstore libutil libformat