Skip to content

Commit

Permalink
Les makefiles c'est de la m...
Browse files Browse the repository at this point in the history
  • Loading branch information
david-michel1 committed Dec 12, 2023
1 parent 35bc3a6 commit d3b4623
Show file tree
Hide file tree
Showing 7 changed files with 568 additions and 419 deletions.
131 changes: 31 additions & 100 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,116 +1,47 @@
# Check Makefile.config.template if you want to override some of the flags
# in this Makefile.

include Makefile.include

include makefiles/functions.mk
-include makefiles/svn.mk

ifeq ($(CODE_COVERAGE), 1)
CODE_COVERAGE_FLAG=--code_coverage
else
CODE_COVERAGE_FLAG=
endif

ifeq ($(TEST_FILTER), 1)
TEST_FILTER_FLAG=--dgfip_test_filter
else
TEST_FILTER_FLAG=
ifndef ROOT_DIR
ROOT_DIR:=$(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
endif

TEST_ERROR_MARGIN?=0.

MLANG_INTERPRETER_OPTS=\
--test_error_margin=$(TEST_ERROR_MARGIN) \
--mpp_function=$(MPP_FUNCTION)

MLANG=$(MLANG_BIN) $(MLANG_DEFAULT_OPTS) $(MLANG_INTERPRETER_OPTS) $(CODE_COVERAGE_FLAG)

default: build

##################################################
# Initializing the project
##################################################

# Workaround for Opam 2.0 bug. Empty switch creation then installation could be a one line
# "opam switch create . --deps-only" otherwise
create-switch:
opam switch create . --empty

init-without-switch:
opam install . --deps-only
git submodule update --init

init: create-switch init-without-switch

deps:
opam switch reinstall --deps-only
git submodule update

##################################################
# Building the compiler
##################################################
CURR_DIR:=$(realpath $(shell pwd))

format:
dune build @fmt --auto-promote | true
include $(ROOT_DIR)/makefiles/functions.mk
include $(ROOT_DIR)/makefiles/variables.mk
-include $(ROOT_DIR)/makefiles/svn.mk
include $(ROOT_DIR)/makefiles/mlang.mk
include $(ROOT_DIR)/makefiles/c_backend.mk

build: format dune
.PHONY: default \
create-switch init-without-switch init deps \
format dune build build-static \
doc \
test tests quick_test test_one \
calc_dir info_c calc_o dgfip_c_backend compile_dgfip_c_backend \
backend_tests test_dgfip_c_backend \
clean_backend clean_backend_c clean_backend_exe clean_backend_tmp clean_backend_res clean_backend_all \
test_java_backend

dune:
dune build $(DUNE_OPTIONS)

# Run only in an opam switch with musl and static options activated
build-static: DUNE_OPTIONS+=--profile=static
build-static: build

dgfip_c_backend: build
$(MAKE) -C examples/dgfip_c/ml_primitif calc/enchain.c

compile_dgfip_c_backend: dgfip_c_backend
$(MAKE) -C examples/dgfip_c/ml_primitif cal

##################################################
# Testing the compiler
##################################################

# use: TEST_FILE=bla make test
test: build
$(MLANG) --run_test=$(TEST_FILE) $(SOURCE_FILES) $(SOURCE_EXT_FILES)

# use: TESTS_DIR=bla make test
tests: build
$(MLANG) $(MLANGOPTS) --run_all_tests=$(TESTS_DIR) $(TEST_FILTER_FLAG) $(SOURCE_FILES) $(SOURCE_EXT_FILES)

test_java_backend: build
ifeq ($(OPTIMIZE), 0)
@echo "\033[0;31mWarning, non-optimized Java files cannot be executed for now (too many constants for the JVM)\033[0m"
else
endif
$(MAKE) -C examples/java/ run_tests

test_dgfip_c_backend: build
$(MAKE) -C examples/dgfip_c/ml_primitif backend_tests

quick_test: build
$(MLANG) --backend interpreter --function_spec $(M_SPEC_FILE) $(SOURCE_FILES) $(SOURCE_EXT_FILES)
FORCE:

test_one: build
$(MLANG) --backend interpreter --run_test=$(TEST_ONE) $(SOURCE_FILES) $(SOURCE_EXT_FILES)
.DEFAULT_GOAL:=default

all: tests test_java_backend test_dgfip_c_backend quick_test
default: FORCE build

##################################################
# Doc
##################################################
test_java_backend: FORCE build
@echo "\033[0;31mWarning: Java backend not supported\033[0m"
#ifeq ($(OPTIMIZE), 0)
# @echo "\033[0;31mWarning, non-optimized Java files cannot be executed for now (too many constants for the JVM)\033[0m"
#else
#endif
# $(MAKE) -C examples/java/ run_tests

doc: FORCE build
dune build @doc
ln -fs $(shell pwd)/_build/default/_doc/_html/index.html doc/doc.html
all: FORCE quick_test tests test_dgfip_c_backend test_java_backend

clean:
$(MAKE) -C examples/dgfip_c/ml_primitif cleanall
$(MAKE) -C examples/java clean
clean: FORCE
$(call make_in,$(DGFIP_DIR),clean_backend_all)
# $(MAKE) -C examples/java clean
rm -f doc/doc.html
dune clean

FORCE:
146 changes: 0 additions & 146 deletions Makefile.include

This file was deleted.

Loading

0 comments on commit d3b4623

Please sign in to comment.