2020-03-05 20:12:58 +03:00
|
|
|
##### Options which a user might set before building go here #####
|
|
|
|
|
2020-05-11 12:55:22 +03:00
|
|
|
export PREFIX ?= ${HOME}/.idris2
|
2020-03-05 20:12:58 +03:00
|
|
|
|
|
|
|
# Add any optimisation/profiling flags for C here (e.g. -O2)
|
|
|
|
export OPT=
|
|
|
|
export CC=clang # clang compiles the output much faster than gcc!
|
|
|
|
|
|
|
|
##################################################################
|
|
|
|
|
2020-04-22 16:14:11 +03:00
|
|
|
export MACHINE := $(shell $(CC) -dumpmachine)
|
2020-03-06 09:32:16 +03:00
|
|
|
|
|
|
|
ifneq (, $(findstring darwin, $(MACHINE)))
|
|
|
|
OS := darwin
|
|
|
|
else ifneq (, $(findstring cygwin, $(MACHINE)))
|
2020-03-06 09:36:43 +03:00
|
|
|
OS := windows
|
2020-03-06 09:32:16 +03:00
|
|
|
else ifneq (, $(findstring mingw, $(MACHINE)))
|
2020-03-06 09:36:43 +03:00
|
|
|
OS := windows
|
2020-03-06 09:32:16 +03:00
|
|
|
else ifneq (, $(findstring windows, $(MACHINE)))
|
2020-03-06 09:36:43 +03:00
|
|
|
OS := windows
|
2020-04-22 16:14:11 +03:00
|
|
|
else ifneq (, $(findstring bsd, $(MACHINE)))
|
|
|
|
OS := bsd
|
2020-03-06 09:32:16 +03:00
|
|
|
else
|
2020-04-22 16:14:11 +03:00
|
|
|
OS := linux
|
2020-03-06 09:32:16 +03:00
|
|
|
endif
|
2020-04-22 16:14:11 +03:00
|
|
|
export OS
|
|
|
|
|
|
|
|
ifeq ($(OS),bsd)
|
|
|
|
MAKE := gmake
|
|
|
|
else
|
|
|
|
MAKE := make
|
|
|
|
endif
|
|
|
|
export MAKE
|
2020-03-06 09:32:16 +03:00
|
|
|
|
2019-08-29 09:43:34 +03:00
|
|
|
# current Idris2 version components
|
|
|
|
MAJOR=0
|
2020-04-01 00:41:15 +03:00
|
|
|
MINOR=1
|
2019-08-29 09:43:34 +03:00
|
|
|
PATCH=0
|
2019-09-27 19:26:04 +03:00
|
|
|
|
|
|
|
GIT_SHA1=
|
|
|
|
VER_TAG=
|
|
|
|
ifeq ($(shell git status >/dev/null 2>&1; echo $$?), 0)
|
|
|
|
# inside a git repo
|
|
|
|
ifneq ($(shell git describe --exact-match --tags >/dev/null 2>&1; echo $$?), 0)
|
|
|
|
# not tagged as a released version, so add sha1 of this build in between releases
|
|
|
|
GIT_SHA1 := $(shell git rev-parse --short=9 HEAD)
|
|
|
|
VER_TAG := -${GIT_SHA1}
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2020-05-11 12:55:22 +03:00
|
|
|
export IDRIS2_VERSION := ${MAJOR}.${MINOR}.${PATCH}
|
2020-02-26 10:00:25 +03:00
|
|
|
IDRIS2_VERSION_TAG := ${IDRIS2_VERSION}${VER_TAG}
|
2019-09-27 19:26:04 +03:00
|
|
|
|
2020-03-05 21:46:26 +03:00
|
|
|
export IDRIS2_PATH = ${CURDIR}/libs/prelude/build/ttc:${CURDIR}/libs/base/build/ttc:${CURDIR}/libs/network/build/ttc
|
2020-03-06 18:38:47 +03:00
|
|
|
export IDRIS2_LIBS = ${CURDIR}/libs/network
|
2019-05-07 17:06:00 +03:00
|
|
|
export IDRIS2_DATA = ${CURDIR}/support
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2019-09-27 19:26:04 +03:00
|
|
|
IDRIS_VERSION := $(shell idris --version)
|
|
|
|
VALID_IDRIS_VERSION_REGEXP = "1.3.2.*"
|
|
|
|
|
2019-07-10 01:45:33 +03:00
|
|
|
-include custom.mk
|
|
|
|
|
2020-03-05 20:12:58 +03:00
|
|
|
.PHONY: ttimp idris2 idris2-fromc prelude test base clean lib_clean check_version idris2c dist/idris2.c
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2019-07-09 10:31:35 +03:00
|
|
|
all: idris2 libs test
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2020-03-05 20:12:58 +03:00
|
|
|
# test requires an Idris install! Maybe we should do a version in Idris2?
|
|
|
|
all-fromc: idris2-fromc libs
|
|
|
|
|
2019-07-26 10:50:54 +03:00
|
|
|
check_version:
|
2019-09-27 19:26:04 +03:00
|
|
|
@echo "Using Idris 1 version: $(IDRIS_VERSION)"
|
2019-07-26 17:44:27 +03:00
|
|
|
@if [ $(shell expr $(IDRIS_VERSION) : $(VALID_IDRIS_VERSION_REGEXP)) -eq 0 ]; then echo "Wrong idris version, expected version matching $(VALID_IDRIS_VERSION_REGEXP)"; exit 1; fi
|
2019-07-26 10:50:54 +03:00
|
|
|
|
2020-03-05 20:12:58 +03:00
|
|
|
idris2: dist/idris2.c idris2-fromc
|
|
|
|
|
|
|
|
# Just build the C, assuming already built from Idris source.
|
|
|
|
# Separate rule to avoid having to build the C if Idris 1 isn't available.
|
|
|
|
# (Also replaces the first line of the generated C with the proper prefix)
|
|
|
|
#
|
|
|
|
idris2-fromc:
|
2020-03-06 09:32:16 +03:00
|
|
|
ifeq ($(OS), darwin)
|
|
|
|
@sed -i '' '1 s|^.*$$|char* idris2_prefix = "${PREFIX}";|' dist/idris2.c
|
|
|
|
else
|
|
|
|
@sed -i '1 s|^.*$$|char* idris2_prefix = "${PREFIX}";|' dist/idris2.c
|
|
|
|
endif
|
2020-04-22 16:14:11 +03:00
|
|
|
${MAKE} -C dist
|
2020-03-05 20:12:58 +03:00
|
|
|
@cp dist/idris2 ./idris2
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2020-03-05 20:12:58 +03:00
|
|
|
# bit of a hack here, to get the prefix into the generated C!
|
2020-02-26 10:00:25 +03:00
|
|
|
dist/idris2.c: src/YafflePaths.idr check_version
|
|
|
|
@echo "Building Idris 2 version: $(IDRIS2_VERSION_TAG)"
|
2020-03-05 20:12:58 +03:00
|
|
|
idris --build idris2.ipkg
|
|
|
|
@echo 'char* idris2_prefix = "${PREFIX}";' > idris2_prefix.c
|
|
|
|
@echo 'char* getIdris2_prefix() { return idris2_prefix; }' >> idris2_prefix.c
|
|
|
|
@cat idris2_prefix.c idris2.c dist/rts/idris_main.c > dist/idris2.c
|
|
|
|
@rm -f idris2.c idris2_prefix.c
|
2020-02-26 10:00:25 +03:00
|
|
|
|
|
|
|
idris2c: dist/idris2.c
|
2020-04-22 16:14:11 +03:00
|
|
|
${MAKE} -C dist
|
2020-02-26 10:00:25 +03:00
|
|
|
|
2019-05-07 12:42:45 +03:00
|
|
|
src/YafflePaths.idr:
|
2019-09-27 19:26:04 +03:00
|
|
|
echo 'module YafflePaths; export yversion : ((Nat,Nat,Nat), String); yversion = ((${MAJOR},${MINOR},${PATCH}), "${GIT_SHA1}")' > src/YafflePaths.idr
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2019-06-13 18:50:24 +03:00
|
|
|
prelude:
|
2020-04-22 16:14:11 +03:00
|
|
|
${MAKE} -C libs/prelude IDRIS2=../../idris2
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2019-06-15 13:54:22 +03:00
|
|
|
base: prelude
|
2020-04-22 16:14:11 +03:00
|
|
|
${MAKE} -C libs/base IDRIS2=../../idris2
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2019-07-22 18:21:38 +03:00
|
|
|
network: prelude
|
2020-04-22 16:14:11 +03:00
|
|
|
${MAKE} -C libs/network IDRIS2=../../idris2
|
|
|
|
${MAKE} -C libs/network test IDRIS2=../../idris2
|
2019-07-22 18:21:38 +03:00
|
|
|
|
2020-01-09 15:54:55 +03:00
|
|
|
contrib: prelude
|
2020-04-22 16:14:11 +03:00
|
|
|
${MAKE} -C libs/contrib IDRIS2=../../idris2
|
2020-01-09 15:54:55 +03:00
|
|
|
|
|
|
|
libs : prelude base network contrib
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2019-07-14 13:23:58 +03:00
|
|
|
clean: clean-libs
|
2020-04-22 16:14:11 +03:00
|
|
|
${MAKE} -C src clean
|
|
|
|
${MAKE} -C tests clean
|
|
|
|
${MAKE} -C dist clean
|
2019-05-07 12:42:45 +03:00
|
|
|
rm -f runtests
|
2020-02-26 10:00:25 +03:00
|
|
|
rm -f idris2 dist/idris2.c
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2019-07-14 13:23:58 +03:00
|
|
|
clean-libs:
|
2020-04-22 16:14:11 +03:00
|
|
|
${MAKE} -C libs/prelude clean
|
|
|
|
${MAKE} -C libs/base clean
|
|
|
|
${MAKE} -C libs/network clean
|
|
|
|
${MAKE} -C libs/contrib clean
|
2019-05-07 12:42:45 +03:00
|
|
|
|
|
|
|
test:
|
|
|
|
idris --build tests.ipkg
|
2020-04-22 16:14:11 +03:00
|
|
|
@${MAKE} -C tests only=$(only)
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2020-05-11 12:55:22 +03:00
|
|
|
support:
|
|
|
|
@${MAKE} -C support/c
|
|
|
|
|
2020-03-05 20:12:58 +03:00
|
|
|
install-all: install-exec install-support install-libs
|
|
|
|
|
|
|
|
install: all install-all
|
|
|
|
|
|
|
|
install-fromc: all-fromc install-all
|
2019-07-14 13:23:58 +03:00
|
|
|
|
2020-05-11 12:55:22 +03:00
|
|
|
install-support: support
|
2019-09-04 18:20:26 +03:00
|
|
|
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/support/chez
|
|
|
|
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/support/racket
|
2020-04-20 03:15:48 +03:00
|
|
|
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/support/gambit
|
2019-09-04 18:20:26 +03:00
|
|
|
install support/chez/* ${PREFIX}/idris2-${IDRIS2_VERSION}/support/chez
|
|
|
|
install support/racket/* ${PREFIX}/idris2-${IDRIS2_VERSION}/support/racket
|
2020-04-20 03:15:48 +03:00
|
|
|
install support/gambit/* ${PREFIX}/idris2-${IDRIS2_VERSION}/support/gambit
|
2020-05-11 12:55:22 +03:00
|
|
|
@${MAKE} -C support/c install
|
2019-07-12 14:04:36 +03:00
|
|
|
|
2020-03-05 20:12:58 +03:00
|
|
|
install-exec:
|
2019-09-28 20:10:14 +03:00
|
|
|
mkdir -p ${PREFIX}/bin
|
|
|
|
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/lib
|
|
|
|
install idris2 ${PREFIX}/bin
|
|
|
|
|
2019-07-12 14:04:36 +03:00
|
|
|
install-libs: libs
|
2020-04-22 16:14:11 +03:00
|
|
|
${MAKE} -C libs/prelude install IDRIS2=../../idris2
|
|
|
|
${MAKE} -C libs/base install IDRIS2=../../idris2
|
|
|
|
${MAKE} -C libs/network install IDRIS2=../../idris2 IDRIS2_VERSION=${IDRIS2_VERSION}
|
|
|
|
${MAKE} -C libs/contrib install IDRIS2=../../idris2
|