From dae1ad10f93ed1a39c9afee41acd8cca8a1af8b5 Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Mon, 30 Aug 2021 16:49:20 +0200 Subject: [PATCH] Add initial make infrastructure --- Makefile | 20 ++++++++++++++++++-- bench/config.mk | 5 +++++ bench/test_main.cxx | 6 ++++++ etc/config/gcc.mk | 6 ++++++ etc/ctf.mk | 2 ++ etc/ctf_rules.mk | 20 ++++++++++++++++++++ etc/ctf_vars.mk | 10 ++++++++++ 7 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 bench/config.mk create mode 100644 bench/test_main.cxx create mode 100644 etc/config/gcc.mk create mode 100644 etc/ctf.mk create mode 100644 etc/ctf_rules.mk create mode 100644 etc/ctf_vars.mk diff --git a/Makefile b/Makefile index b01ae3f..ee3c801 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,8 @@ +ATRIP_ROOT := $(PWD) +CONFIG ?= gcc +include etc/config/$(CONFIG).mk +include ./bench/config.mk + EMACS = emacs -q --batch define tangle $(EMACS) $(1) --eval "(require 'org)" --eval '(org-babel-tangle)' @@ -12,6 +17,17 @@ $(SOURCES): $(MAIN) tangle: $(SOURCES) clean: - rm -r $(SOURCES) + -rm -v $(SOURCES) + +clean-all: bench-clean clean + +bench: $(BENCH_TARGETS) + +.PHONY: clean tangle bench + +%: %.o + $(CXX) $< $(CXXFLAGS) $(LDFLAGS) -o $@ + +%.o: %.cxx + $(CXX) -c $< $(CXXFLAGS) -o $@ -.PHONY: clean tangle diff --git a/bench/config.mk b/bench/config.mk new file mode 100644 index 0000000..e7a0b5e --- /dev/null +++ b/bench/config.mk @@ -0,0 +1,5 @@ +BENCH_SOURCES = $(wildcard $(ATRIP_ROOT)/bench/test*.cxx) +BENCH_TARGETS = $(patsubst %.cxx,%,$(BENCH_SOURCES)) + +bench-clean: + -rm -v $(BENCH_TARGETS) diff --git a/bench/test_main.cxx b/bench/test_main.cxx new file mode 100644 index 0000000..a160aaa --- /dev/null +++ b/bench/test_main.cxx @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello world" << std::endl; + return 0; +} diff --git a/etc/config/gcc.mk b/etc/config/gcc.mk new file mode 100644 index 0000000..0a9aad5 --- /dev/null +++ b/etc/config/gcc.mk @@ -0,0 +1,6 @@ +include etc/ctf.mk + +CXX = mpic++ + +CXXFLAGS += -I$(CTF_INCLUDE_PATH) +LDFLAGS += -L$(CTF_BUILD_PATH) -lctf diff --git a/etc/ctf.mk b/etc/ctf.mk new file mode 100644 index 0000000..1142943 --- /dev/null +++ b/etc/ctf.mk @@ -0,0 +1,2 @@ +include ./etc/ctf_vars.mk +include ./etc/ctf_rules.mk diff --git a/etc/ctf_rules.mk b/etc/ctf_rules.mk new file mode 100644 index 0000000..832aadd --- /dev/null +++ b/etc/ctf_rules.mk @@ -0,0 +1,20 @@ +$(CTF_SRC_PATH)/configure: + mkdir -p $(@D) + git clone $(CTF_REPOSITORY) $(@D) + cd $(@D) && git checkout $(CTF_COMMIT) + +$(CTF_BUILD_PATH)/Makefile: $(CTF_SRC_PATH)/configure + mkdir -p $(CTF_BUILD_PATH) + cd $(CTF_BUILD_PATH) && $(CTF_SRC_PATH)/configure $(CTF_CONFIG_FLAGS) + +$(CTF_STATIC_LIB): $(CTF_BUILD_PATH)/Makefile + $(info Compiling $@) + cd $(CTF_BUILD_PATH) && $(MAKE) + +.PHONY: ctf ctf-clean +ctf: $(CTF_STATIC_LIB) + +ctf-clean: + rm -rf $(CTF_BUILD_PATH) + +IN_PROJECT_DEPENDENCIES += ctf diff --git a/etc/ctf_vars.mk b/etc/ctf_vars.mk new file mode 100644 index 0000000..490d26b --- /dev/null +++ b/etc/ctf_vars.mk @@ -0,0 +1,10 @@ +CTF_REPOSITORY = https://github.com/cyclops-community/ctf +CTF_COMMIT ?= v1.5.0 + +CTF_SRC_PATH = $(ATRIP_ROOT)/lib/src/ctf/$(CTF_COMMIT) +CTF_BUILD_PATH = $(ATRIP_ROOT)/lib/build/ctf/$(CTF_COMMIT) + +CTF_CONFIG_FLAGS = + +CTF_STATIC_LIB = $(CTF_BUILD_PATH)/lib/libctf.a +CTF_INCLUDE_PATH = $(CTF_BUILD_PATH)/include