ddat interop with dat js cable interop with cabal js ddat's frontend = dat-thang cable fe = cable-thang dillo support based on cel's dillo-dat bootstrap node xplatform support Signed-off-by: divo <418@cryspace.space>
151 lines
9.5 KiB
Makefile
151 lines
9.5 KiB
Makefile
CC := gcc
|
|
AR := ar
|
|
RANLIB := ranlib
|
|
WINDRES := windres
|
|
BUILD := build/windows
|
|
VERSION ?= $(shell tr -d '\r\n' < VERSION)
|
|
NETWORK_PROTOCOL := $(strip $(file < NETWORK_PROTOCOL))
|
|
CPPFLAGS := -I. -Iinc -Ilibcess/include -DSLEEP_SALT -DCESSPOOL_HAVE_SODIUM -DCESSPOOL_CONFIG_DIRECTORY=\"dat-gpt\" -DCESSPOOL_NETWORK_PROTOCOL=\"$(NETWORK_PROTOCOL)\" -include inc/win_compat.h -DDAT_BUILD_DIR=\"$(BUILD)\" -DDAT_NETWORK_PROTOCOL=\"$(NETWORK_PROTOCOL)\" $(shell pkg-config --cflags libcurl)
|
|
CFLAGS := -O2 -std=c99 -Wall -Wextra -Wpedantic
|
|
TEST_LDFLAGS := -Wl,--stack,8388608
|
|
SODIUM_LIBS := $(shell pkg-config --libs libsodium)
|
|
CURL_LIBS := $(shell pkg-config --libs libcurl)
|
|
SDL_CFLAGS := $(shell pkg-config --cflags sdl2 SDL2_ttf)
|
|
SDL_LIBS := $(shell pkg-config --libs sdl2 SDL2_ttf)
|
|
ENABLE_CABLE_MEDIA ?= 0
|
|
FFMPEG_MEDIA_AVAILABLE := $(shell pkg-config --exists 'libavcodec >= 59' 'libavformat >= 59' 'libavutil >= 57' 'libswresample >= 4' 'libswscale >= 6' 2>/dev/null && echo 1 || echo 0)
|
|
ifeq ($(ENABLE_CABLE_MEDIA),1)
|
|
ifneq ($(FFMPEG_MEDIA_AVAILABLE),1)
|
|
$(error Cable media needs FFmpeg 5.0+ development packages: libavcodec, libavformat, libavutil, libswresample, libswscale)
|
|
endif
|
|
FFMPEG_MEDIA_CFLAGS := -DCABLE_HAVE_FFMPEG $(shell pkg-config --cflags libavformat libavcodec libavutil libswresample libswscale)
|
|
FFMPEG_MEDIA_LIBS := $(shell pkg-config --libs libavformat libavcodec libavutil libswresample libswscale)
|
|
endif
|
|
LIBS := $(SODIUM_LIBS) $(CURL_LIBS) -lws2_32 -lm
|
|
|
|
LIB_SOURCES := base32768 cable cable_feed dat dat_browse dat_dns dat_walk dat_wire dat_session sleep sleep_tree sleep_bitfield sleep_proto sleep_crypto sleep_writer sleep_feed sleep_proof sleep_replication sleep_utp dat_s7 dat_scheme s7
|
|
LIB_OBJECTS := $(addprefix $(BUILD)/,$(addsuffix .o,$(LIB_SOURCES))) $(BUILD)/sleep_verify_lib.o
|
|
LIBCESS_OBJECTS := $(BUILD)/libcess/cess_net.o $(BUILD)/libcess/cesspool.o $(BUILD)/libcess/cess_identity.o
|
|
|
|
.PHONY: all clean test test-paths test-discovery test-version-bar test-gui-p2p test-gui-media package-assets
|
|
.PHONY: FORCE
|
|
WINDOWS_PROGRAMS := $(addprefix $(BUILD)/,dat.exe ddat.exe cable.exe cesspool-bootstrap.exe sleep-verify.exe ddat-scheme.exe dat-thang.exe cable-thang.exe)
|
|
all: $(BUILD)/libcess.a $(WINDOWS_PROGRAMS) package-assets
|
|
|
|
$(BUILD):
|
|
mkdir -p $(BUILD)
|
|
|
|
$(BUILD)/.network-protocol-$(NETWORK_PROTOCOL): NETWORK_PROTOCOL | $(BUILD)
|
|
@echo $(NETWORK_PROTOCOL) > "$@"
|
|
|
|
$(BUILD)/%.o: src/%.c inc/win_compat.h NETWORK_PROTOCOL $(BUILD)/.network-protocol-$(NETWORK_PROTOCOL) | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MP -c $< -o $@
|
|
|
|
$(BUILD)/libcess:
|
|
mkdir -p $@
|
|
|
|
$(BUILD)/libcess/%.o: libcess/src/%.c libcess/include/cesspool.h libcess/include/cess_net.h NETWORK_PROTOCOL $(BUILD)/.network-protocol-$(NETWORK_PROTOCOL) | $(BUILD)/libcess
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MP -c $< -o $@
|
|
|
|
$(BUILD)/libcess.a: $(LIBCESS_OBJECTS)
|
|
$(AR) rcs $@ $(LIBCESS_OBJECTS)
|
|
$(RANLIB) $@
|
|
|
|
$(BUILD)/s7.o: src/s7.c inc/win_compat.h | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -w -MMD -MP -c $< -o $@
|
|
|
|
$(BUILD)/dat_thang_icon.o: assets/dat-thang.rc assets/dat-thang.ico | $(BUILD)
|
|
$(WINDRES) -i $< -O coff -o $@
|
|
|
|
$(BUILD)/cable_media.o: src/cable_media.c inc/cable_media.h | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(FFMPEG_MEDIA_CFLAGS) -MMD -MP -c $< -o $@
|
|
|
|
$(BUILD)/cable_video.o: src/cable_video.c inc/cable_video.h | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(SDL_CFLAGS) $(FFMPEG_MEDIA_CFLAGS) -MMD -MP -c $< -o $@
|
|
|
|
$(BUILD)/sleep_verify_lib.o: src/sleep_verify.c | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -DSLEEP_VERIFY_NO_MAIN -MMD -MP -c $< -o $@
|
|
|
|
-include $(LIB_OBJECTS:.o=.d) $(LIBCESS_OBJECTS:.o=.d)
|
|
|
|
$(BUILD)/libdatgpt.a: $(LIB_OBJECTS) $(BUILD)/libcess.a
|
|
$(AR) rcs $@ $(LIB_OBJECTS)
|
|
$(RANLIB) $@
|
|
|
|
$(BUILD)/dat.exe: src/dat_cli.c $(BUILD)/libdatgpt.a
|
|
$(CC) $(CPPFLAGS) -DDAT_CLI_NAME=\"dat\" $(CFLAGS) $< $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) -o $@
|
|
|
|
$(BUILD)/ddat.exe: src/dat_cli.c $(BUILD)/libdatgpt.a
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) -o $@
|
|
|
|
$(BUILD)/cable.exe: src/cable_cli.c $(BUILD)/libdatgpt.a $(BUILD)/libcess.a
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) -o $@
|
|
|
|
$(BUILD)/cesspool-bootstrap.exe: libcess/tools/cesspool-bootstrap.c $(BUILD)/libcess.a
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(BUILD)/libcess.a $(SODIUM_LIBS) -lws2_32 -o $@
|
|
|
|
$(BUILD)/sleep-verify.exe: src/sleep_verify.c $(BUILD)/libdatgpt.a
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) -o $@
|
|
|
|
$(BUILD)/ddat-scheme.exe: src/dat_scheme_cli.c $(BUILD)/libdatgpt.a $(BUILD)/libcess.a
|
|
$(CC) $(CPPFLAGS) -DDAT_SCHEME_DIR=\"scheme\" $(CFLAGS) $< $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) -o $@
|
|
|
|
$(BUILD)/test-paths.exe: tests/test_paths.c inc/dat_paths.h inc/win_compat.h | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@
|
|
|
|
CORE_TESTS := tree bitfield base32768 proto wire dns replication writer
|
|
|
|
$(BUILD)/test-%.exe: tests/test_%.c $(BUILD)/libdatgpt.a | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(TEST_LDFLAGS) $< $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) -o $@
|
|
|
|
test: test-paths test-discovery test-version-bar test-gui-p2p $(addprefix $(BUILD)/test-,$(addsuffix .exe,$(CORE_TESTS)))
|
|
$(BUILD)/test-tree.exe
|
|
$(BUILD)/test-bitfield.exe
|
|
$(BUILD)/test-base32768.exe
|
|
$(BUILD)/test-proto.exe
|
|
$(BUILD)/test-wire.exe
|
|
$(BUILD)/test-dns.exe
|
|
$(BUILD)/test-replication.exe
|
|
$(BUILD)/test-writer.exe
|
|
|
|
test-paths: $(BUILD)/test-paths.exe
|
|
$(BUILD)/test-paths.exe
|
|
|
|
$(BUILD)/test-discovery.exe: tests/test_discovery.c $(BUILD)/libdatgpt.a | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(TEST_LDFLAGS) $< $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) -o $@
|
|
|
|
test-discovery: $(BUILD)/test-discovery.exe
|
|
$(BUILD)/test-discovery.exe
|
|
|
|
$(BUILD)/test-version-bar.exe: tests/test_version_bar.c $(BUILD)/cable_media.o $(BUILD)/cable_video.o $(BUILD)/libdatgpt.a | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(TEST_LDFLAGS) $(SDL_CFLAGS) $< $(BUILD)/cable_media.o $(BUILD)/cable_video.o $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) $(SDL_LIBS) $(FFMPEG_MEDIA_LIBS) -o $@
|
|
|
|
test-version-bar: $(BUILD)/test-version-bar.exe
|
|
$(BUILD)/test-version-bar.exe
|
|
|
|
$(BUILD)/test-gui-p2p.exe: tests/test_gui_p2p.c $(BUILD)/cable_media.o $(BUILD)/cable_video.o $(BUILD)/libdatgpt.a | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(TEST_LDFLAGS) $(SDL_CFLAGS) -DSDL_MAIN_HANDLED -Umain $< $(BUILD)/cable_media.o $(BUILD)/cable_video.o $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) $(SDL_LIBS) $(FFMPEG_MEDIA_LIBS) -mconsole -o $@
|
|
|
|
test-gui-p2p: $(BUILD)/test-gui-p2p.exe
|
|
$(BUILD)/test-gui-p2p.exe
|
|
|
|
$(BUILD)/test-gui-media.exe: tests/test_gui_p2p.c $(BUILD)/cable_media.o $(BUILD)/cable_video.o $(BUILD)/libdatgpt.a | $(BUILD)
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(TEST_LDFLAGS) $(SDL_CFLAGS) -DDAT_GUI_TEST_MEDIA -DSDL_MAIN_HANDLED -Umain $< $(BUILD)/cable_media.o $(BUILD)/cable_video.o $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) $(SDL_LIBS) $(FFMPEG_MEDIA_LIBS) -mconsole -o $@
|
|
|
|
test-gui-media: $(BUILD)/test-gui-media.exe
|
|
$(BUILD)/test-gui-media.exe
|
|
|
|
$(BUILD)/dat-thang.exe: src/ddat_gui.c $(BUILD)/cable_media.o $(BUILD)/cable_video.o $(BUILD)/libdatgpt.a $(BUILD)/dat_thang_icon.o
|
|
$(CC) $(CPPFLAGS) -DDAT_THANG_VERSION=\"v$(VERSION)\" $(CFLAGS) $(SDL_CFLAGS) src/ddat_gui.c $(BUILD)/cable_media.o $(BUILD)/cable_video.o $(BUILD)/dat_thang_icon.o $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) $(SDL_LIBS) $(FFMPEG_MEDIA_LIBS) -o $@
|
|
|
|
$(BUILD)/cable-thang.exe: src/ddat_gui.c $(BUILD)/cable_media.o $(BUILD)/cable_video.o $(BUILD)/libdatgpt.a $(BUILD)/dat_thang_icon.o
|
|
$(CC) $(CPPFLAGS) -DDAT_THANG_VERSION=\"v$(VERSION)\" $(CFLAGS) $(SDL_CFLAGS) src/ddat_gui.c $(BUILD)/cable_media.o $(BUILD)/cable_video.o $(BUILD)/dat_thang_icon.o $(BUILD)/libdatgpt.a $(BUILD)/libcess.a $(LIBS) $(SDL_LIBS) $(FFMPEG_MEDIA_LIBS) -o $@
|
|
|
|
package-assets: $(WINDOWS_PROGRAMS) | $(BUILD)
|
|
powershell.exe -NoProfile -Command "if (Test-Path -LiteralPath '$(BUILD)/cable_hyperswarm.js') { Remove-Item -LiteralPath '$(BUILD)/cable_hyperswarm.js' -Force }; if (Test-Path -LiteralPath '$(BUILD)/cable_bootstrap.js') { Remove-Item -LiteralPath '$(BUILD)/cable_bootstrap.js' -Force }"
|
|
powershell.exe -NoProfile -Command "Copy-Item -Path 'assets','scheme' -Destination '$(BUILD)' -Recurse -Force"
|
|
powershell.exe -NoProfile -Command "$$stage='dist/windows-x64'; if (Test-Path -LiteralPath $$stage) { Remove-Item -LiteralPath $$stage -Recurse -Force }; New-Item -ItemType Directory -Path $$stage | Out-Null; $$apps=@('dat.exe','ddat.exe','cable.exe','cesspool-bootstrap.exe','sleep-verify.exe','ddat-scheme.exe','dat-thang.exe','cable-thang.exe'); foreach ($$app in $$apps) { Copy-Item -LiteralPath (Join-Path '$(BUILD)' $$app) -Destination $$stage -Force }; Get-ChildItem -LiteralPath '$(BUILD)' -Filter '*.dll' -File | Copy-Item -Destination $$stage -Force; Copy-Item -Path 'assets','scheme' -Destination $$stage -Recurse -Force; New-Item -ItemType Directory -Path (Join-Path $$stage 'docs') -Force | Out-Null; Copy-Item -Path 'docs/windows-build.md','docs/dat-thang.1','docs/cable-thang.1','docs/cesspool-bootstrap.1','docs/dillo.md' -Destination (Join-Path $$stage 'docs') -Force; New-Item -ItemType Directory -Path 'dist/installers' -Force | Out-Null; $$zip='dist/installers/dat-gpt-v$(VERSION)-windows-x64.zip'; if (Test-Path -LiteralPath $$zip) { Remove-Item -LiteralPath $$zip -Force }; Compress-Archive -Path ($$stage + '/*') -DestinationPath $$zip -CompressionLevel Optimal"
|
|
|
|
clean:
|
|
powershell.exe -NoProfile -Command "if (Test-Path -LiteralPath '$(BUILD)') { Get-ChildItem -LiteralPath '$(BUILD)' -Recurse -File | Where-Object { $$_.Extension -in '.o','.d','.exe','.a','.dll','.so' -or $$_.Name -in '.network-protocol-cesspool','.network-protocol.tmp' } | Remove-Item -Force }"
|