2020-11-08 07:33:02 +00:00
|
|
|
# crossfire: distributed brute force infrastructure
|
|
|
|
#
|
|
|
|
# Copyright (C) 2020 haskal
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
2020-12-13 02:25:01 +00:00
|
|
|
.PHONY: all clean mrproper local-racket
|
2020-11-08 07:33:02 +00:00
|
|
|
|
2020-11-15 07:28:09 +00:00
|
|
|
APP_NAME=crossfire-agent
|
2020-12-13 01:28:15 +00:00
|
|
|
RKT_NAME=$(APP_NAME).rkt
|
2020-11-08 07:33:02 +00:00
|
|
|
|
2020-11-15 07:28:09 +00:00
|
|
|
MONOCYPHER_VERSION=3.1.1
|
2020-12-13 02:25:01 +00:00
|
|
|
RACKET_VERSION=7.9
|
2020-11-08 07:33:02 +00:00
|
|
|
|
2020-11-15 23:54:03 +00:00
|
|
|
TARGET_ARCH=$(shell $(CC) -dumpmachine)
|
|
|
|
|
2020-11-08 07:33:02 +00:00
|
|
|
####################################################################################################
|
|
|
|
|
|
|
|
LIBS=-ldl -lm
|
2020-12-13 02:25:01 +00:00
|
|
|
ifneq (,$(findstring x86_64,$(TARGET_ARCH)))
|
|
|
|
LIBS+=-lpthread -lffi
|
|
|
|
endif
|
2020-11-08 07:33:02 +00:00
|
|
|
# for musl
|
2020-12-13 02:25:01 +00:00
|
|
|
# TODO autodetect musl or something
|
2020-11-08 07:33:02 +00:00
|
|
|
#LIBS=-lffi -lucontext
|
|
|
|
|
2020-11-15 23:54:03 +00:00
|
|
|
ARCH_DIR=arch_$(TARGET_ARCH)
|
|
|
|
CACHE_DIR=cache
|
|
|
|
VENDOR_DIR=$(ARCH_DIR)/vendor
|
2020-12-13 02:25:01 +00:00
|
|
|
|
2020-11-15 07:28:09 +00:00
|
|
|
MONOCYPHER_DIR=$(VENDOR_DIR)/monocypher-$(MONOCYPHER_VERSION)
|
|
|
|
MONOCYPHER_URL=https://monocypher.org/download/monocypher-$(MONOCYPHER_VERSION).tar.gz
|
2020-11-15 23:54:03 +00:00
|
|
|
MONOCYPHER_FILE=$(CACHE_DIR)/monocypher.tar.gz
|
2020-11-15 07:28:09 +00:00
|
|
|
|
2020-12-13 02:25:01 +00:00
|
|
|
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
|
|
|
|
|
2020-11-15 23:54:03 +00:00
|
|
|
all: $(ARCH_DIR)/$(APP_NAME)
|
2020-11-08 07:33:02 +00:00
|
|
|
|
|
|
|
# main build
|
2020-11-15 23:54:03 +00:00
|
|
|
$(ARCH_DIR)/$(APP_NAME): main_bc.c app.o $(MONOCYPHER_DIR)/lib/libmonocypher.a
|
|
|
|
[ -d $(ARCH_DIR) ] || mkdir -p $(ARCH_DIR)
|
2020-11-15 07:28:09 +00:00
|
|
|
$(CC) -o $@ -pipe -fPIC -O3 -DAPP_NAME='"$(APP_NAME)"' -I$(MONOCYPHER_DIR)/src -static $^ \
|
2020-11-16 00:46:29 +00:00
|
|
|
-DAPP_ARCH='"$(TARGET_ARCH)"' \
|
2020-12-13 02:25:01 +00:00
|
|
|
-L$(MONOCYPHER_DIR)/lib -L$(RACKET_DIR)/lib \
|
2020-11-15 07:28:09 +00:00
|
|
|
-lracket3m -lrktio -lmonocypher $(LIBS)
|
|
|
|
|
2020-12-13 02:25:01 +00:00
|
|
|
# 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)
|
|
|
|
|
|
|
|
|
2020-11-15 07:28:09 +00:00
|
|
|
$(MONOCYPHER_DIR)/lib/libmonocypher.a: $(MONOCYPHER_DIR)/.extracted
|
|
|
|
cd $(MONOCYPHER_DIR) && $(MAKE) USE_ED22519=true static-library
|
|
|
|
|
2020-11-15 23:54:03 +00:00
|
|
|
$(MONOCYPHER_DIR)/.extracted: $(MONOCYPHER_FILE)
|
|
|
|
[ -d $(MONOCYPHER_DIR) ] || mkdir -p $(MONOCYPHER_DIR)
|
2020-11-15 07:28:09 +00:00
|
|
|
tar xf $< -C $(VENDOR_DIR) && touch $@
|
|
|
|
|
2020-11-15 23:54:03 +00:00
|
|
|
$(MONOCYPHER_FILE):
|
|
|
|
[ -d $(CACHE_DIR) ] || mkdir -p $(CACHE_DIR)
|
2020-11-15 07:28:09 +00:00
|
|
|
wget -O $@ $(MONOCYPHER_URL) || curl -o $@ $(MONOCYPHER_URL)
|
2020-11-08 07:33:02 +00:00
|
|
|
|
|
|
|
|
2020-12-13 02:25:01 +00:00
|
|
|
local-racket: $(RACKET_DIR)/lib/libracket3m.a
|
2020-11-08 07:33:02 +00:00
|
|
|
|
2020-12-13 02:25:01 +00:00
|
|
|
$(RACKET_DIR)/lib/libracket3m.a: $(RACKET_DIR)/.extracted
|
|
|
|
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)
|