agent: enable local copy of racket for build
This commit is contained in:
parent
93be02c535
commit
da1e3f16bd
|
@ -15,28 +15,38 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean mrproper local-racket
|
||||||
|
|
||||||
APP_NAME=crossfire-agent
|
APP_NAME=crossfire-agent
|
||||||
RKT_NAME=$(APP_NAME).rkt
|
RKT_NAME=$(APP_NAME).rkt
|
||||||
|
|
||||||
MONOCYPHER_VERSION=3.1.1
|
MONOCYPHER_VERSION=3.1.1
|
||||||
|
RACKET_VERSION=7.9
|
||||||
|
|
||||||
TARGET_ARCH=$(shell $(CC) -dumpmachine)
|
TARGET_ARCH=$(shell $(CC) -dumpmachine)
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
LIBS=-ldl -lm
|
LIBS=-ldl -lm
|
||||||
|
ifneq (,$(findstring x86_64,$(TARGET_ARCH)))
|
||||||
|
LIBS+=-lpthread -lffi
|
||||||
|
endif
|
||||||
# for musl
|
# for musl
|
||||||
|
# TODO autodetect musl or something
|
||||||
#LIBS=-lffi -lucontext
|
#LIBS=-lffi -lucontext
|
||||||
|
|
||||||
ARCH_DIR=arch_$(TARGET_ARCH)
|
ARCH_DIR=arch_$(TARGET_ARCH)
|
||||||
CACHE_DIR=cache
|
CACHE_DIR=cache
|
||||||
VENDOR_DIR=$(ARCH_DIR)/vendor
|
VENDOR_DIR=$(ARCH_DIR)/vendor
|
||||||
|
|
||||||
MONOCYPHER_DIR=$(VENDOR_DIR)/monocypher-$(MONOCYPHER_VERSION)
|
MONOCYPHER_DIR=$(VENDOR_DIR)/monocypher-$(MONOCYPHER_VERSION)
|
||||||
MONOCYPHER_URL=https://monocypher.org/download/monocypher-$(MONOCYPHER_VERSION).tar.gz
|
MONOCYPHER_URL=https://monocypher.org/download/monocypher-$(MONOCYPHER_VERSION).tar.gz
|
||||||
MONOCYPHER_FILE=$(CACHE_DIR)/monocypher.tar.gz
|
MONOCYPHER_FILE=$(CACHE_DIR)/monocypher.tar.gz
|
||||||
|
|
||||||
|
RACKET_DIR=$(VENDOR_DIR)/racket-$(RACKET_VERSION)
|
||||||
|
RACKET_URL=https://mirror.racket-lang.org/installers/$(RACKET_VERSION)/racket-minimal-$(RACKET_VERSION)-src.tgz
|
||||||
|
RACKET_FILE=$(CACHE_DIR)/racket.tar.gz
|
||||||
|
|
||||||
all: $(ARCH_DIR)/$(APP_NAME)
|
all: $(ARCH_DIR)/$(APP_NAME)
|
||||||
|
|
||||||
# main build
|
# main build
|
||||||
|
@ -44,9 +54,24 @@ $(ARCH_DIR)/$(APP_NAME): main_bc.c app.o $(MONOCYPHER_DIR)/lib/libmonocypher.a
|
||||||
[ -d $(ARCH_DIR) ] || mkdir -p $(ARCH_DIR)
|
[ -d $(ARCH_DIR) ] || mkdir -p $(ARCH_DIR)
|
||||||
$(CC) -o $@ -pipe -fPIC -O3 -DAPP_NAME='"$(APP_NAME)"' -I$(MONOCYPHER_DIR)/src -static $^ \
|
$(CC) -o $@ -pipe -fPIC -O3 -DAPP_NAME='"$(APP_NAME)"' -I$(MONOCYPHER_DIR)/src -static $^ \
|
||||||
-DAPP_ARCH='"$(TARGET_ARCH)"' \
|
-DAPP_ARCH='"$(TARGET_ARCH)"' \
|
||||||
-L$(MONOCYPHER_DIR)/lib \
|
-L$(MONOCYPHER_DIR)/lib -L$(RACKET_DIR)/lib \
|
||||||
-lracket3m -lrktio -lmonocypher $(LIBS)
|
-lracket3m -lrktio -lmonocypher $(LIBS)
|
||||||
|
|
||||||
|
# this is faster than --c-mods by a lot
|
||||||
|
# it's potentially less portable but works on GNU ld and probably lld too
|
||||||
|
app.o: app.zo
|
||||||
|
$(LD) -r -b binary $< -o $@
|
||||||
|
|
||||||
|
app.zo: $(RKT_NAME)
|
||||||
|
raco ctool --mods $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(APP_NAME) *.zo *.o
|
||||||
|
|
||||||
|
mrproper: clean
|
||||||
|
$(RM) -r $(VENDOR_DIR) $(CACHE_DIR)
|
||||||
|
|
||||||
|
|
||||||
$(MONOCYPHER_DIR)/lib/libmonocypher.a: $(MONOCYPHER_DIR)/.extracted
|
$(MONOCYPHER_DIR)/lib/libmonocypher.a: $(MONOCYPHER_DIR)/.extracted
|
||||||
cd $(MONOCYPHER_DIR) && $(MAKE) USE_ED22519=true static-library
|
cd $(MONOCYPHER_DIR) && $(MAKE) USE_ED22519=true static-library
|
||||||
|
|
||||||
|
@ -58,13 +83,23 @@ $(MONOCYPHER_FILE):
|
||||||
[ -d $(CACHE_DIR) ] || mkdir -p $(CACHE_DIR)
|
[ -d $(CACHE_DIR) ] || mkdir -p $(CACHE_DIR)
|
||||||
wget -O $@ $(MONOCYPHER_URL) || curl -o $@ $(MONOCYPHER_URL)
|
wget -O $@ $(MONOCYPHER_URL) || curl -o $@ $(MONOCYPHER_URL)
|
||||||
|
|
||||||
# this is faster than --c-mods by a lot
|
|
||||||
# it's potentially less portable but works on GNU ld and probably lld too
|
|
||||||
app.o: app.zo
|
|
||||||
$(LD) -r -b binary $< -o $@
|
|
||||||
|
|
||||||
app.zo: $(RKT_NAME)
|
local-racket: $(RACKET_DIR)/lib/libracket3m.a
|
||||||
raco ctool --mods $@ $<
|
|
||||||
|
|
||||||
clean:
|
$(RACKET_DIR)/lib/libracket3m.a: $(RACKET_DIR)/.extracted
|
||||||
$(RM) $(APP_NAME) *.zo *.o
|
cd $(RACKET_DIR)/src && ./configure --enable-bconly --prefix=/usr --sysconfdir=/etc \
|
||||||
|
--disable-libffi
|
||||||
|
cd $(RACKET_DIR)/src && $(MAKE)
|
||||||
|
[ -d $(RACKET_DIR)/lib ] || mkdir $(RACKET_DIR)/lib
|
||||||
|
cp $(RACKET_DIR)/src/bc/rktio/librktio.a $(RACKET_DIR)/lib
|
||||||
|
cp $(RACKET_DIR)/src/bc/libracket3m.a $(RACKET_DIR)/lib
|
||||||
|
cp $(RACKET_DIR)/src/bc/foreign/libffi/.libs/libffi.a $(RACKET_DIR)/lib
|
||||||
|
|
||||||
|
|
||||||
|
$(RACKET_DIR)/.extracted: $(RACKET_FILE)
|
||||||
|
[ -d $(RACKET_DIR) ] || mkdir -p $(RACKET_DIR)
|
||||||
|
tar xf $< -C $(VENDOR_DIR) && touch $@
|
||||||
|
|
||||||
|
$(RACKET_FILE):
|
||||||
|
[ -d $(CACHE_DIR) ] || mkdir -p $(CACHE_DIR)
|
||||||
|
wget -O $@ $(RACKET_URL) || curl -o $@ $(RACKET_URL)
|
||||||
|
|
|
@ -8,15 +8,8 @@
|
||||||
(plumber-flush-all (current-plumber))
|
(plumber-flush-all (current-plumber))
|
||||||
(old-esc-handler)))
|
(old-esc-handler)))
|
||||||
;; execute agent-main
|
;; execute agent-main
|
||||||
; (require "../crossfire/agent.rkt")
|
(require "../crossfire/agent.rkt")
|
||||||
; (agent-main)
|
(agent-main)
|
||||||
(require "../crossfire/static-support.rkt")
|
|
||||||
(require ffi/unsafe)
|
|
||||||
(define _rktio (_cpointer 'rktio))
|
|
||||||
(define rktio-inst (get-ffi-obj/static "scheme_rktio" _rktio))
|
|
||||||
(define rktio-call (get-ffi-obj/static "rktio_processor_count" (_fun _rktio -> _int)))
|
|
||||||
|
|
||||||
(printf "num cpus: ~a\n" (rktio-call rktio-inst))
|
|
||||||
|
|
||||||
;; and if no error, also flush
|
;; and if no error, also flush
|
||||||
(plumber-flush-all (current-plumber))
|
(plumber-flush-all (current-plumber))
|
||||||
|
|
Loading…
Reference in New Issue