Skip to content

Commit

Permalink
improve makefile
Browse files Browse the repository at this point in the history
 o  add 'install' target
 o  shorten the name of INCLUDE_PATHS to IMPORTS
 o  use filename prerequisities and targets rather than phony keywords
 o  add a dependency on .git/refs/tags for the githash target
 o  add githash.txt and dfmt-test to the clean target
 o  add more targets to .PHONY
  • Loading branch information
jtbx committed Feb 12, 2024
1 parent 2ea6c43 commit 62ec52f
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
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 githash pkg release test

dmd: bin/dfmt
all: bin/dfmt

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

dmd: bin/dfmt

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

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

test: debug
Expand All @@ -46,8 +52,13 @@ 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) githash

0 comments on commit 62ec52f

Please sign in to comment.