crossfire/agent-deployment/Makefile

83 lines
2.6 KiB
Makefile
Raw Normal View History

# 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-29 08:12:48 +00:00
.PHONY: all clean mrproper
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-15 07:28:09 +00:00
MONOCYPHER_VERSION=3.1.1
RACKET_VERSION=7.9
2020-12-29 11:24:23 +00:00
CC=$(CROSS_COMPILE)gcc
OBJCOPY=$(CROSS_COMPILE)objcopy
2020-11-15 23:54:03 +00:00
TARGET_ARCH=$(shell $(CC) -dumpmachine)
2020-12-29 11:24:23 +00:00
# change this if you're 32 bit. idk how to make this more automatic
TARGET_BITS=64
2020-11-15 23:54:03 +00:00
####################################################################################################
2020-11-15 23:54:03 +00:00
ARCH_DIR=arch_$(TARGET_ARCH)
2020-12-29 11:24:23 +00:00
APP_CFLAGS=-pipe -fPIC -O3 -DAPP_NAME='"$(APP_NAME)"' -DAPP_ARCH='"$(TARGET_ARCH)"' \
-DELF_BITS=$(TARGET_BITS)
2020-12-29 08:12:48 +00:00
APP_LDFLAGS=-static -ldl -lm -lpthread
2020-11-15 23:54:03 +00:00
all: $(ARCH_DIR)/$(APP_NAME)
2020-12-29 08:12:48 +00:00
include dependencies.mk
# main build
2020-12-29 11:24:23 +00:00
ifdef ENABLE_CS
CS_BOOT1=$(RACKET_CS_BOOT_FILES_DIR)/petite.boot
CS_BOOT2=$(RACKET_CS_BOOT_FILES_DIR)/scheme.boot
CS_BOOT3=$(RACKET_CS_BOOT_FILES_DIR)/racket.boot
$(ARCH_DIR)/$(APP_NAME): main_cs.c app.zo vnd-deps $(CS_BOOT1) $(CS_BOOT2) $(CS_BOOT3)
[ -d $(ARCH_DIR) ] || mkdir -p $(ARCH_DIR)
$(CC) -o $@ $(APP_CFLAGS) $(VND_CFLAGS) main_cs.c \
$(VND_LDFLAGS) $(APP_LDFLAGS)
$(OBJCOPY) \
--add-section .csboot1=$(CS_BOOT1) \
--set-section-flags .csboot1=noload,readonly \
--add-section .csboot2=$(CS_BOOT2) \
--set-section-flags .csboot2=noload,readonly \
--add-section .csboot3=$(CS_BOOT3) \
--set-section-flags .csboot3=noload,readonly \
--add-section .boot=app.zo \
--set-section-flags .boot=noload,readonly \
$@ $@.ext
mv -f $@.ext $@
else
2020-12-29 08:12:48 +00:00
$(ARCH_DIR)/$(APP_NAME): main_bc.c app.o vnd-deps
2020-11-15 23:54:03 +00:00
[ -d $(ARCH_DIR) ] || mkdir -p $(ARCH_DIR)
2020-12-29 08:12:48 +00:00
$(CC) -o $@ $(APP_CFLAGS) $(VND_CFLAGS) main_bc.c app.o \
$(VND_LDFLAGS) $(APP_LDFLAGS)
2020-11-15 07:28:09 +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 $@
2020-12-29 11:24:23 +00:00
endif
app.zo: $(RKT_NAME)
2020-12-29 11:24:23 +00:00
$(RACO) ctool --mods $@ ++lib racket/base $<
clean:
2020-12-29 08:12:48 +00:00
$(RM) $(ARCH_DIR)/$(APP_NAME) *.zo *.o
mrproper: clean