# retoor <retoor@molodetz.nl>
CC = gcc
CFLAGS = -Ofast -Werror -Wall -I./include
LDFLAGS = -lreadline -lncurses -lcurl -ljson-c -lsqlite3 -lm -lpthread -lssl -lcrypto
SRCDIR = src
TOOLSDIR = src/tools
BUILDDIR = build
BINDIR = bin
SRC_CORE = $(SRCDIR)/r_error.c \
$(SRCDIR)/r_config.c \
$(SRCDIR)/tool_registry.c \
$(SRCDIR)/db.c \
$(SRCDIR)/http_client.c \
$(SRCDIR)/messages.c \
$(SRCDIR)/agent.c \
$(SRCDIR)/bash_executor.c \
$(SRCDIR)/context_manager.c \
$(SRCDIR)/r_diff.c \
$(SRCDIR)/main.c
SRC_TOOLS = $(TOOLSDIR)/tools_init.c \
$(TOOLSDIR)/tool_terminal.c \
$(TOOLSDIR)/tool_file.c \
$(TOOLSDIR)/tool_db.c \
$(TOOLSDIR)/tool_http.c \
$(TOOLSDIR)/tool_python.c \
$(TOOLSDIR)/tool_indexer.c \
$(TOOLSDIR)/tool_code.c \
$(TOOLSDIR)/tool_file_edit.c \
$(TOOLSDIR)/tool_system.c \
$(TOOLSDIR)/tool_network.c \
$(TOOLSDIR)/tool_dns.c \
$(TOOLSDIR)/tool_automation.c \
$(TOOLSDIR)/tool_csv.c \
$(TOOLSDIR)/tool_agent.c
SRC = $(SRC_CORE) $(SRC_TOOLS)
OBJ_CORE = $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRC_CORE))
OBJ_TOOLS = $(patsubst $(TOOLSDIR)/%.c,$(BUILDDIR)/tools/%.o,$(SRC_TOOLS))
OBJ = $(OBJ_CORE) $(OBJ_TOOLS)
.PHONY: all clean build build_legacy run
all: build
build: $(BINDIR)/r
cp $(BINDIR)/r r
$(BINDIR)/r: $(OBJ)
@mkdir -p $(BINDIR)
$(CC) $(OBJ) $(LDFLAGS) -o $@
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILDDIR)/tools/%.o: $(TOOLSDIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
build_legacy:
@mkdir -p $(BINDIR)
$(CC) main.c $(CFLAGS) $(LDFLAGS) -o $(BINDIR)/r_legacy
cp $(BINDIR)/r_legacy r
build_rpylib:
$(CC) -shared -o rpylib.so -fPIC rpylib.c -lpython3.12 `python3-config --includes` -I/usr/include/CL -ljson-c -lcurl -lsqlite3
run: build
./r --verbose
install:
cp ./r /usr/local/bin/r
clean:
rm -rf $(BUILDDIR) $(BINDIR)
rm -f r
appimage: build
-@rm -rf AppImage
mkdir -p AppImage/usr/bin
mkdir -p AppImage/lib
cp AppRun AppImage/AppRun
cp r.desktop AppImage/r.desktop
cp r.png AppImage/r.png
cp $(BINDIR)/r AppImage/usr/bin/r
./collect_so_files.sh
appimagetool-x86_64.AppImage AppImage
mv r-x86_64.AppImage r
docker: docker_make docker_run
docker_make:
docker build -t r .
docker_run:
docker run -v .:/app --rm -it r
build_deb:
dpkg-deb --build r_package