Skip to content

Instantly share code, notes, and snippets.

@wilzbach
Created December 2, 2017 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilzbach/7887df5e821aff4902939484c1197883 to your computer and use it in GitHub Desktop.
Save wilzbach/7887df5e821aff4902939484c1197883 to your computer and use it in GitHub Desktop.
Makefile with D compiler bootstrapping
DMD=bin/dmd2/linux/bin64/dmd
DMD_VERSION=2.074.0
LDC=bin/ldc2-$(LDC_VERSION)-linux-$(PLATFORM)/bin/ldc2
LDC_VERSION=1.2.0
DFLAGS=-g
PLATFORM=x86_64
################################################################################
# Auto-bootstrap DMD & LDC for outdated Debian/Ubuntu
################################################################################
bin:
mkdir -p $@
bin/dmd2: | bin
curl -fSL --retry 3 "http://downloads.dlang.org/releases/2.x/$(DMD_VERSION)/dmd.$(DMD_VERSION).linux.tar.xz" | tar -Jxf - -C $|
bin/dmd2/linux/bin64/dmd: | bin/dmd2
bin/ldc2-$(LDC_VERSION)-linux-$(PLATFORM): | bin
curl -fSL --retry 3 "https://github.com/ldc-developers/ldc/releases/download/v$(LDC_VERSION)/ldc2-$(LDC_VERSION)-linux-$(PLATFORM).tar.xz" \
| tar -Jxf - -C $|
bin/ldc2-$(LDC_VERSION)-linux-$(PLATFORM)/bin/ldc2: | bin/ldc2-$(LDC_VERSION)-linux-$(PLATFORM)
################################################################################
# Single-file programs
################################################################################
bin/main: main.d $(DMD) | bin
$(DMD) $(DFLAGS) $< -of$@
bin/main_opt: main.d $(LDC) | bin
$(LDC) -g -O4 -mcpu=native -release $(DFLAGS) $< -of$@
################################################################################
# Complex programs
################################################################################
D_FILES = $(addsuffix .d, $(addprefix lib/, utils database synonyms gennames input))
bin/postprocess: $(D_FILES) $(DMD) | bin
$(DMD) $(DFLAGS) $(DMD_DEBUG_FLAGS) postprocess.d $(D_FILES) -of$@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment