Something went wrong. Try again.
🪄 dd's hex editor
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101# Makefile alternative to DUB for ddhx## Portable across GNU make and BSD makes (FreeBSD/NetBSD/OpenBSD).# Uses `!=` for shell assignment (supported by BSD makes and GNU make >=4.0)# instead of GNU-only `ifeq`/`endif` conditionals and `$(wildcard ...)`.
DC ?= dmdPREFIX ?= /usr/localBINDIR ?= $(PREFIX)/bin
SRCS != find src -name '*.d'TEST_SRCS_INPUT = $(SRCS) tests/input.dTEST_SRCS_COLOR = $(SRCS) tests/color.dTEST_SRCS_SIZE = $(SRCS) tests/size.dLIB_SRCS != find src -name '*.d' ! -path src/main.dBENCH_SRCS = $(LIB_SRCS) benchmark/src/main.d
# Compiler-specific flag mapping. DMD flags are the baseline; LDC and GDC# equivalents are selected by matching $(DC) against the compiler binary name.# Strip any directory prefix so absolute paths (e.g. /usr/pkg/gcc15/bin/gdc) match.# GDC comes in gdc, gdc-15, gcc-gdc, gcc-gdc-15, and egdc (OpenBSD) flavors, so catch them allDC_NAME != basename "$(DC)"OFLAG != case "$(DC_NAME)" in *gdc*) echo "-o" ;; *) echo "-of=" ;; esacRELEASE_FLAGS != case "$(DC_NAME)" in ldc2) echo "-O2 -release -boundscheck=off" ;; dmd) echo "-O -release -boundscheck=off" ;; *) echo "-O2 -frelease -fbounds-check=off" ;; esacDEBUG_FLAGS != case "$(DC_NAME)" in ldc2) echo "-g -d-debug" ;; dmd) echo "-g -debug" ;; *) echo "-g -fdebug" ;; esacDEBUGV_FLAGS != case "$(DC_NAME)" in ldc2) echo "-g -d-debug -d-version=verbose --vgc --vtls" ;; dmd) echo "-g -debug -version=verbose -vgc -vtls" ;; *) echo "-g -fdebug -fversion=verbose" ;; esacNATIVE_FLAGS != case "$(DC_NAME)" in ldc2) echo "-O2 -release -boundscheck=off -mcpu=native" ;; dmd) echo "-O -release -boundscheck=off -mcpu=native" ;; *) echo "-O2 -frelease -fbounds-check=off -march=native" ;; esacSTATIC_FLAG != case "$(DC_NAME)" in ldc2) echo "--static" ;; dmd) echo "-L=-static" ;; *) echo "-Wl,-static -static -static-libgcc" ;; esacUNITTEST_FLAG != case "$(DC_NAME)" in *gdc*) echo "-funittest" ;; *) echo "-unittest" ;; esacVERSION_FLAG != case "$(DC_NAME)" in ldc2) echo "-d-version" ;; dmd) echo "-version" ;; *) echo "-fversion" ;; esac
# Default targetall: release
# Build targetsddhx: release
release: $(SRCS) $(DC) $(RELEASE_FLAGS) $(OFLAG)ddhx $(SRCS)
debug: $(SRCS) $(DC) $(DEBUG_FLAGS) $(OFLAG)ddhx $(SRCS)
debugv: $(SRCS) $(DC) $(DEBUGV_FLAGS) $(OFLAG)ddhx $(SRCS)
native: $(SRCS) $(DC) $(NATIVE_FLAGS) $(OFLAG)ddhx $(SRCS)
# Static build targetsdebug-static: $(SRCS) $(DC) $(DEBUG_FLAGS) $(VERSION_FLAG)=Static $(STATIC_FLAG) $(OFLAG)ddhx $(SRCS)
release-static: $(SRCS) $(DC) $(RELEASE_FLAGS) $(VERSION_FLAG)=Static $(STATIC_FLAG) $(OFLAG)ddhx $(SRCS)
native-static: $(SRCS) $(DC) $(NATIVE_FLAGS) $(VERSION_FLAG)=Static $(STATIC_FLAG) $(OFLAG)ddhx $(SRCS)
# Benchmarkbenchmark: $(BENCH_SRCS) $(DC) $(RELEASE_FLAGS) $(OFLAG)ddhx-benchmark $(BENCH_SRCS)
# Teststest: $(SRCS) $(DC) $(DEBUG_FLAGS) $(UNITTEST_FLAG) $(OFLAG)ddhx-test-library $(SRCS) ./ddhx-test-library
test-input: $(TEST_SRCS_INPUT) $(DC) $(DEBUG_FLAGS) $(UNITTEST_FLAG) $(VERSION_FLAG)=TestInput $(OFLAG)ddhx-test-library $(TEST_SRCS_INPUT) ./ddhx-test-library
test-color: $(TEST_SRCS_COLOR) $(DC) $(DEBUG_FLAGS) $(UNITTEST_FLAG) $(VERSION_FLAG)=TestColor $(OFLAG)ddhx-test-library $(TEST_SRCS_COLOR) ./ddhx-test-library
test-large: $(SRCS) $(DC) $(DEBUG_FLAGS) $(UNITTEST_FLAG) $(VERSION_FLAG)=TestLargeFile $(OFLAG)ddhx-test-library $(SRCS) ./ddhx-test-library
test-size: $(TEST_SRCS_SIZE) $(DC) $(DEBUG_FLAGS) $(UNITTEST_FLAG) $(VERSION_FLAG)=TestSize $(OFLAG)ddhx-test-library $(TEST_SRCS_SIZE) ./ddhx-test-library
# Install/uninstallinstall: release install -d $(DESTDIR)$(BINDIR) install -m 755 ddhx $(DESTDIR)$(BINDIR)/ddhx
uninstall: rm -f $(DESTDIR)$(BINDIR)/ddhx
# Cleanclean: rm -f ddhx ddhx.o libddhx.a ddhx-benchmark ddhx-test-library ddhx-test-library.o
.PHONY: all ddhx release debug debugv native \ debug-static release-static native-static \ benchmark test test-input test-color test-large test-size \ install uninstall clean