Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve makefile #597

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,53 +1,64 @@
PREFIX = /usr/local

SRC := $(shell find src -name "*.d") \
$(shell find libdparse/src -name "*.d") \
$(shell find stdx-allocator/source -name "*.d")
INCLUDE_PATHS := -Ilibdparse/src -Istdx-allocator/source -Isrc -Jbin
DMD_COMMON_FLAGS := -dip25 -w $(INCLUDE_PATHS)
IMPORTS := -Ilibdparse/src -Istdx-allocator/source -Isrc -Jbin

DC ?= dmd
LDC ?= ldc2
GDC ?= gdc

DMD_COMMON_FLAGS := -w $(IMPORTS)
DMD_DEBUG_FLAGS := -debug -g $(DMD_COMMON_FLAGS)
DMD_FLAGS := -O -inline $(DMD_COMMON_FLAGS)
DMD_TEST_FLAGS := -unittest -g $(DMD_COMMON_FLAGS)
LDC_FLAGS := -g -w -oq $(INCLUDE_PATHS)
GDC_FLAGS := -g -w -oq $(INCLUDE_PATHS)
LDC_FLAGS := -g -w -oq $(IMPORTS)
GDC_FLAGS := -g -w -oq $(IMPORTS)
override DMD_FLAGS += $(DFLAGS)
override LDC_FLAGS += $(DFLAGS)
override GDC_FLAGS += $(DFLAGS)
DC ?= dmd
LDC ?= ldc2
GDC ?= gdc

.PHONY: dmd ldc gdc test
.PHONY: all clean install debug dmd ldc gdc pkg release test

dmd: bin/dfmt
all: bin/dfmt

githash:
bin/githash.txt:
mkdir -p bin
git describe --tags > bin/githash.txt

ldc: githash
dmd: bin/dfmt

ldc: bin/githash.txt
$(LDC) $(SRC) $(LDC_FLAGS) -ofbin/dfmt
-rm -f *.o

gdc:githash
gdc: bin/githash.txt
$(GDC) $(SRC) $(GDC_FLAGS) -obin/dfmt

test: debug
cd tests && ./test.d

bin/dfmt-test: githash $(SRC)
bin/dfmt-test: bin/githash.txt $(SRC)
$(DC) $(DMD_TEST_FLAGS) $^ -of$@

bin/dfmt: githash $(SRC)
bin/dfmt: bin/githash.txt $(SRC)
$(DC) $(DMD_FLAGS) $(filter %.d,$^) -of$@

debug: githash $(SRC)
debug: bin/githash.txt $(SRC)
$(DC) $(DMD_DEBUG_FLAGS) $(filter %.d,$^) -ofbin/dfmt

pkg: dmd
$(MAKE) -f makd/Makd.mak pkg

clean:
$(RM) bin/dfmt
$(RM) bin/dfmt bin/dfmt-test bin/githash.txt

install:
chmod +x bin/dfmt
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f bin/dfmt $(DESTDIR)$(PREFIX)/bin/dfmt

release:
./release.sh
githash
$(MAKE) bin/githash.txt
Loading