diff options
author | Cyril SIX <cyril.six@kalray.eu> | 2019-05-03 17:59:10 +0200 |
---|---|---|
committer | Cyril SIX <cyril.six@kalray.eu> | 2019-05-03 17:59:10 +0200 |
commit | 24442c874a0e45f6e93965919ff2b3594aca43e5 (patch) | |
tree | 6abf053b6d1d74810d5b564f6f4325e923bb08e2 | |
parent | 452da0d77523d15830d7a78198092d72822063a6 (diff) | |
download | compcert-kvx-24442c874a0e45f6e93965919ff2b3594aca43e5.tar.gz compcert-kvx-24442c874a0e45f6e93965919ff2b3594aca43e5.zip |
[#120] - Makefile generator + replaced binary_search/Makefile : it works
-rw-r--r-- | test/monniaux/binary_search/Makefile | 30 | ||||
-rw-r--r-- | test/monniaux/binary_search/make.proto | 1 | ||||
-rwxr-xr-x | test/monniaux/generate_makefiles.sh | 5 | ||||
-rwxr-xr-x | test/monniaux/genmake.py | 75 |
4 files changed, 81 insertions, 30 deletions
diff --git a/test/monniaux/binary_search/Makefile b/test/monniaux/binary_search/Makefile deleted file mode 100644 index ea34f1bc..00000000 --- a/test/monniaux/binary_search/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -include ../rules.mk - -PRODUCTS=binary_search.gcc.host.out binary_search.ccomp.host.out \ - binary_search.gcc.k1c.out binary_search.ccomp.k1c.out \ - binary_search.gcc.o1.k1c.out \ - binary_search.gcc.k1c.s binary_search.ccomp.k1c.s - -all: $(PRODUCTS) - -binary_search.gcc.host.s binary_search.ccomp.host.s binary_search.gcc.k1c.s binary_search.ccomp.k1c.s : ../clock.h - -binary_search.ccomp.host: binary_search.ccomp.host.o ../clock.gcc.host.o - $(CCOMP) $(CCOMPFLAGS) $+ -o $@ - -binary_search.gcc.host: binary_search.gcc.host.o ../clock.gcc.host.o - $(CC) $(CFLAGS) $+ -o $@ - -binary_search.gcc.k1c: binary_search.gcc.k1c.o ../clock.gcc.k1c.o - $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ - -binary_search.gcc.o1.k1c: binary_search.gcc.o1.k1c.o ../clock.gcc.k1c.o - $(K1C_CC) $(K1C_CFLAGS_O1) $+ -o $@ - -binary_search.ccomp.k1c: binary_search.ccomp.k1c.o ../clock.gcc.k1c.o - $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ - -clean: - -rm -f *.o *.s *.k1c - -.PHONY: clean diff --git a/test/monniaux/binary_search/make.proto b/test/monniaux/binary_search/make.proto new file mode 100644 index 00000000..19501e78 --- /dev/null +++ b/test/monniaux/binary_search/make.proto @@ -0,0 +1 @@ +binary_search diff --git a/test/monniaux/generate_makefiles.sh b/test/monniaux/generate_makefiles.sh new file mode 100755 index 00000000..ed8270b5 --- /dev/null +++ b/test/monniaux/generate_makefiles.sh @@ -0,0 +1,5 @@ +#!/usr/bin/bash + +for bench in binary_search; do + ./genmake.py $(cat $bench/make.proto) > $bench/Makefile +done diff --git a/test/monniaux/genmake.py b/test/monniaux/genmake.py new file mode 100755 index 00000000..8503b1ee --- /dev/null +++ b/test/monniaux/genmake.py @@ -0,0 +1,75 @@ +#!/usr/bin/python3.4 + +""" Custom Makefile generator + +Generates the Makefiles for the various benches, including extra rules for each different optimization options and/or compilers. + +See the source for more info. +""" + +from collections import namedtuple +import sys + +Optim = namedtuple("Optim", ["short", "full"]) +Env = namedtuple("Env", ["compiler", "optimizations", "target"]) +Compiler = namedtuple("Compiler", ["short", "full"]) + +## +# Variables you can change. +## + +# Defining the compilers and optimizations + +gcc_x86 = Env(compiler = Compiler("gcc", "$(CC)"), optimizations = [Optim("", "$(CFLAGS)")], target = "host") +gcc_k1c = Env(compiler = Compiler("gcc", "$(K1C_CC)"), optimizations = [Optim("", "$(K1C_CFLAGS)"), Optim("o1", "$(K1C_CFLAGS_O1)")], target = "k1c") +ccomp_x86 = Env(compiler = Compiler("ccomp", "$(CCOMP)"), optimizations = [Optim("", "$(CCOMPFLAGS)")], target = "host") +ccomp_k1c = Env(compiler = Compiler("ccomp", "$(K1C_CCOMP)"), optimizations = [Optim("", "$(K1C_CCOMPFLAGS)")], target = "k1c") + +environments = [gcc_x86, gcc_k1c, ccomp_x86, ccomp_k1c] + +## +# Argument parsing +## +if len(sys.argv) != 2: + raise Exception("Only 1 argument should be given to this script") +basename = sys.argv[1] + +## +# Printing the rules +## + +def make_product(env, optim): + return basename + "." + env.compiler.short + (("." + optim.short) if optim.short != "" else "") + "." + env.target + +def make_clock(env, optim): + return "clock.gcc." + env.target + +def print_rule(env, optim): + print("{product}: {product}.o ../{clock}.o" + .format(product = make_product(env, optim), clock = make_clock(env, optim))) + print(" {compiler} {flags} $+ -o $@" + .format(compiler = env.compiler.full, flags = optim.full)) + +products = [] +for env in environments: + for optim in env.optimizations: + products.append(make_product(env, optim) + ".out") + +print(""" +include ../rules.mk + +PRODUCTS?={} + +all: $(PRODUCTS) +""".format(" ".join(products))) + +for env in environments: + for optim in env.optimizations: + print_rule(env, optim) + +print(""" +clean: + -rm -f *.o *.s *.k1c + +.PHONY: clean +""") |