Skip to content

Commit 6a55a6f

Browse files
authored
Merge pull request #337 from davidgiven/dtrg-fixes
Miscellaneous fixes, mostly C23 related.
2 parents b22d9be + c2a185f commit 6a55a6f

File tree

281 files changed

+11985
-11483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

281 files changed

+11985
-11483
lines changed

.github/workflows/ccpp.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ jobs:
4747
flex
4848
zip
4949
git
50+
ninja
51+
diffutils
5052
- uses: actions/checkout@v3
5153
- name: build
5254
run: |
53-
make LDFLAGS="-s -static"
54-
- name: package
55-
run: |
56-
make ack-setup.exe
55+
make LDFLAGS="-s -static" ack-setup.exe
5756
- name: upload setup
5857
uses: actions/upload-artifact@v4
5958
with:

.github/workflows/release.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@ jobs:
3131
mingw-w64-ucrt-x86_64-pkg-config
3232
mingw-w64-ucrt-x86_64-python
3333
zip
34+
ninja
35+
diffutils
3436
3537
- uses: actions/checkout@v3
3638

3739
- name: build
3840
run: |
39-
make LDFLAGS="-s -static"
40-
41-
- name: package
42-
run: |
43-
make ack-setup.exe
41+
make LDFLAGS="-s -static" ack-setup.exe
4442
4543
- name: date
4644
run: |

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ HOSTCFLAGS = $(CFLAGS)
4747
ACKCFLAGS = -O
4848

4949
LDFLAGS ?= -g
50+
ACKLDFLAGS =
5051

5152
# Various commands.
5253

build/ab.mk

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
MAKENOT4 := $(if $(findstring 3.9999, $(lastword $(sort 3.9999 $(MAKE_VERSION)))),yes,no)
2-
MAKE4.3 := $(if $(findstring 4.3, $(firstword $(sort 4.3 $(MAKE_VERSION)))),yes,no)
3-
MAKE4.1 := $(if $(findstring no_no,$(MAKENOT4)_$(MAKE4.3)),yes,no)
42

53
ifeq ($(MAKENOT4),yes)
64
$(error You need GNU Make 4.x for this (if you're on OSX, use gmake).)
@@ -17,16 +15,17 @@ HOSTCC ?= gcc
1715
HOSTCXX ?= g++
1816
HOSTAR ?= ar
1917
HOSTCFLAGS ?= -g -Og
18+
HOSTCXXFLAGS ?= $(HOSTCFLAGS)
2019
HOSTLDFLAGS ?= -g
2120

2221
CC ?= $(HOSTCC)
2322
CXX ?= $(HOSTCXX)
2423
AR ?= $(HOSTAR)
2524
CFLAGS ?= $(HOSTCFLAGS)
25+
CXXFLAGS ?= $(CFLAGS)
2626
LDFLAGS ?= $(HOSTLDFLAGS)
2727

28-
export PKG_CONFIG
29-
export HOST_PKG_CONFIG
28+
NINJA ?= ninja
3029

3130
ifdef VERBOSE
3231
hide =
@@ -65,32 +64,33 @@ EXT ?=
6564

6665
CWD=$(shell pwd)
6766

68-
ifeq ($(AB_ENABLE_PROGRESS_INFO),true)
69-
ifeq ($(PROGRESSINFO),)
70-
# The first make invocation here has to have its output discarded or else it
71-
# produces spurious 'Leaving directory' messages... don't know why.
72-
rulecount := $(strip $(shell $(MAKE) --no-print-directory -q $(OBJ)/build.mk PROGRESSINFO=1 > /dev/null \
73-
&& $(MAKE) --no-print-directory -n $(MAKECMDGOALS) PROGRESSINFO=XXXPROGRESSINFOXXX | grep XXXPROGRESSINFOXXX | wc -l))
74-
ruleindex := 1
75-
PROGRESSINFO = "[$(ruleindex)/$(rulecount)]$(eval ruleindex := $(shell expr $(ruleindex) + 1)) "
76-
endif
77-
else
78-
PROGRESSINFO = ""
79-
endif
67+
define newline
68+
69+
70+
endef
71+
72+
define check_for_command
73+
$(shell command -v $1 >/dev/null || (echo "Required command '$1' missing" >&2 && kill $$PPID))
74+
endef
8075

81-
PKG_CONFIG_HASHES = $(OBJ)/.pkg-config-hashes/target-$(word 1, $(shell $(PKG_CONFIG) --list-all | md5sum))
82-
HOST_PKG_CONFIG_HASHES = $(OBJ)/.pkg-config-hashes/host-$(word 1, $(shell $(HOST_PKG_CONFIG) --list-all | md5sum))
76+
$(call check_for_command,ninja)
77+
$(call check_for_command,cmp)
78+
$(call check_for_command,$(PYTHON))
8379

84-
$(OBJ)/build.mk : $(PKG_CONFIG_HASHES) $(HOST_PKG_CONFIG_HASHES)
85-
$(PKG_CONFIG_HASHES) $(HOST_PKG_CONFIG_HASHES) &:
86-
$(hide) rm -rf $(OBJ)/.pkg-config-hashes
87-
$(hide) mkdir -p $(OBJ)/.pkg-config-hashes
88-
$(hide) touch $(PKG_CONFIG_HASHES) $(HOST_PKG_CONFIG_HASHES)
80+
pkg-config-hash = $(shell ($(PKG_CONFIG) --list-all && $(HOST_PKG_CONFIG) --list-all) | md5sum)
81+
build-files = $(shell find . -name .obj -prune -o \( -name 'build.py' -a -type f \) -print) $(wildcard build/*.py) $(wildcard config.py)
82+
build-file-timestamps = $(shell ls -l $(build-files) | md5sum)
8983

90-
include $(OBJ)/build.mk
84+
# Wipe the build file (forcing a regeneration) if the make environment is different.
85+
# (Conveniently, this includes the pkg-config hash calculated above.)
9186

92-
MAKEFLAGS += -r -j$(shell nproc)
93-
.DELETE_ON_ERROR:
87+
ignored-variables = MAKE_RESTARTS .VARIABLES MAKECMDGOALS MAKEFLAGS MFLAGS
88+
$(shell mkdir -p $(OBJ))
89+
$(file >$(OBJ)/newvars.txt,$(foreach v,$(filter-out $(ignored-variables),$(.VARIABLES)),$(v)=$($(v))$(newline)))
90+
$(shell touch $(OBJ)/vars.txt)
91+
#$(shell diff -u $(OBJ)/vars.txt $(OBJ)/newvars.txt >&2)
92+
$(shell cmp -s $(OBJ)/newvars.txt $(OBJ)/vars.txt || (rm -f $(OBJ)/build.ninja && echo "Environment changed --- regenerating" >&2))
93+
$(shell mv $(OBJ)/newvars.txt $(OBJ)/vars.txt)
9494

9595
.PHONY: update-ab
9696
update-ab:
@@ -105,9 +105,15 @@ clean::
105105
$(hide) rm -rf $(OBJ)
106106

107107
export PYTHONHASHSEED = 1
108-
build-files = $(shell find . -name 'build.py') $(wildcard build/*.py) $(wildcard config.py)
109-
$(OBJ)/build.mk: Makefile $(build-files) build/ab.mk
108+
$(OBJ)/build.ninja $(OBJ)/build.targets &:
110109
@echo "AB"
111-
@mkdir -p $(OBJ)
112-
$(hide) $(PYTHON) -X pycache_prefix=$(OBJ)/__pycache__ build/ab.py -o $@ build.py \
113-
|| rm -f $@
110+
$(hide) $(PYTHON) -X pycache_prefix=$(OBJ)/__pycache__ build/ab.py \
111+
-o $(OBJ) build.py \
112+
-v $(OBJ)/vars.txt \
113+
|| (rm -f $@ && false)
114+
115+
include $(OBJ)/build.targets
116+
.PHONY: $(ninja-targets)
117+
.NOTPARALLEL:
118+
$(ninja-targets): $(OBJ)/build.ninja
119+
+$(hide) $(NINJA) -f $(OBJ)/build.ninja $@

build/ab.ninja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rule rule
2+
command = $command

0 commit comments

Comments
 (0)