From 860583378193efead071332b28be6ac426a99ece Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Mon, 14 Mar 2022 05:23:48 -0700 Subject: [PATCH 1/2] core out Makefile, add freebsd building --- Makefile | 81 ++++----------------------------------------------- build_odin.sh | 10 +++++++ 2 files changed, 15 insertions(+), 76 deletions(-) diff --git a/Makefile b/Makefile index bea0569a9..77a30b46a 100644 --- a/Makefile +++ b/Makefile @@ -1,90 +1,19 @@ -GIT_SHA=$(shell git rev-parse --short HEAD) -DISABLED_WARNINGS=-Wno-switch -Wno-macro-redefined -Wno-unused-value -LDFLAGS=-pthread -lm -lstdc++ -CFLAGS=-std=c++14 -DGIT_SHA=\"$(GIT_SHA)\" -CFLAGS:=$(CFLAGS) -DODIN_VERSION_RAW=\"dev-$(shell date +"%Y-%m")\" -CC=clang - -OS=$(shell uname) - -ifeq ($(OS), Darwin) - - ARCH=$(shell uname -m) - LLVM_CONFIG=llvm-config - - # allow for arm only llvm's with version 13 - ifeq ($(ARCH), arm64) - LLVM_VERSIONS = "13.%.%" - else - # allow for x86 / amd64 all llvm versions begining from 11 - LLVM_VERSIONS = "13.%.%" "12.0.1" "11.1.0" - endif - - LLVM_VERSION_PATTERN_SEPERATOR = )|( - LLVM_VERSION_PATTERNS_ESCAPED_DOT = $(subst .,\.,$(LLVM_VERSIONS)) - LLVM_VERSION_PATTERNS_REPLACE_PERCENT = $(subst %,.*,$(LLVM_VERSION_PATTERNS_ESCAPED_DOT)) - LLVM_VERSION_PATTERN_REMOVE_ELEMENTS = $(subst " ",$(LLVM_VERSION_PATTERN_SEPERATOR),$(LLVM_VERSION_PATTERNS_REPLACE_PERCENT)) - LLMV_VERSION_PATTERN_REMOVE_SINGLE_STR = $(subst ",,$(LLVM_VERSION_PATTERN_REMOVE_ELEMENTS)) - LLVM_VERSION_PATTERN = "^(($(LLMV_VERSION_PATTERN_REMOVE_SINGLE_STR)))" - - ifeq ($(shell $(LLVM_CONFIG) --version | grep -E $(LLVM_VERSION_PATTERN)),) - ifeq ($(ARCH), arm64) - $(error "Requirement: llvm-config must be base version 13 for arm64") - else - $(error "Requirement: llvm-config must be base version greater than 11 for amd64/x86") - endif - endif - - LDFLAGS:=$(LDFLAGS) -liconv -ldl - CFLAGS:=$(CFLAGS) $(shell $(LLVM_CONFIG) --cxxflags --ldflags) - LDFLAGS:=$(LDFLAGS) -lLLVM-C -endif -ifeq ($(OS), Linux) - LLVM_CONFIG=llvm-config-11 - ifneq ($(shell which llvm-config-11 2>/dev/null),) - LLVM_CONFIG=llvm-config-11 - else ifneq ($(shell which llvm-config-11-64 2>/dev/null),) - LLVM_CONFIG=llvm-config-11-64 - else - ifeq ($(shell $(LLVM_CONFIG) --version | grep '^11\.'),) - $(error "Requirement: llvm-config must be version 11") - endif - endif - - LDFLAGS:=$(LDFLAGS) -ldl - CFLAGS:=$(CFLAGS) $(shell $(LLVM_CONFIG) --cxxflags --ldflags) - LDFLAGS:=$(LDFLAGS) $(shell $(LLVM_CONFIG) --libs core native --system-libs) -endif -ifeq ($(OS), OpenBSD) - LLVM_CONFIG=/usr/local/bin/llvm-config - - LDFLAGS:=$(LDFLAGS) -liconv - CFLAGS:=$(CFLAGS) $(shell $(LLVM_CONFIG) --cxxflags --ldflags) - LDFLAGS:=$(LDFLAGS) $(shell $(LLVM_CONFIG) --libs core native --system-libs) -endif -ifeq ($(OS), FreeBSD) - LLVM_CONFIG=/usr/local/bin/llvm-config11 - - CFLAGS:=$(CFLAGS) $(shell $(LLVM_CONFIG) --cxxflags --ldflags) - LDFLAGS:=$(LDFLAGS) $(shell $(LLVM_CONFIG) --libs core native --system-libs) -endif - all: debug demo demo: ./odin run examples/demo/demo.odin report: - ./odin report + ./odin.sh report debug: - $(CC) src/main.cpp src/libtommath.cpp $(DISABLED_WARNINGS) $(CFLAGS) -g $(LDFLAGS) -o odin + ./build_odin.sh debug release: - $(CC) src/main.cpp src/libtommath.cpp $(DISABLED_WARNINGS) $(CFLAGS) -O3 $(LDFLAGS) -o odin + ./build_odin.sh release release_native: - $(CC) src/main.cpp src/libtommath.cpp $(DISABLED_WARNINGS) $(CFLAGS) -O3 -march=native $(LDFLAGS) -o odin + ./build_odin.sh release-native nightly: - $(CC) src/main.cpp src/libtommath.cpp $(DISABLED_WARNINGS) $(CFLAGS) -DNIGHTLY -O3 $(LDFLAGS) -o odin + ./build_odin.sh nightly diff --git a/build_odin.sh b/build_odin.sh index a323782a1..dd2725f5d 100755 --- a/build_odin.sh +++ b/build_odin.sh @@ -41,6 +41,13 @@ config_darwin() { LDFLAGS="$LDFLAGS -lLLVM-C" } +config_freebsd() { + LLVM_CONFIG=/usr/local/bin/llvm-config11 + + CFLAGS="$CFLAGS $($LLVM_CONFIG --cxxflags --ldflags)" + LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)" +} + config_openbsd() { LLVM_CONFIG=/usr/local/bin/llvm-config @@ -108,6 +115,9 @@ Darwin) OpenBSD) config_openbsd ;; +FreeBSD) + config_freebsd + ;; *) panic "Platform unsupported!" esac From 34727f99e33c1503a2714653b0186a1a358a4a8c Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Mon, 14 Mar 2022 05:27:08 -0700 Subject: [PATCH 2/2] oops, fix report --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 77a30b46a..82150c6a2 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ demo: ./odin run examples/demo/demo.odin report: - ./odin.sh report + ./odin report debug: ./build_odin.sh debug