Skip to content

Commit

Permalink
build: Remove gen/deps.mk
Browse files Browse the repository at this point in the history
Since commit 3552b79 ("build/flags: Infrastructure to detect compiler
flag support"), this file only listed a bunch of lines like

    -include obj/src/alloc.d
    -include obj/src/bar.d
    ...

We can do that just as well from the main Makefile, and in one line too:

    -include ${OBJS:.o=.d}

This lets us pull the list of all objects out of build/prelude.mk and
put it closer to where those objects are actually used.
  • Loading branch information
tavianator committed Sep 14, 2024
1 parent 19ed06e commit 170aa3d
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 84 deletions.
86 changes: 68 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,43 @@ BINS := \
all: ${BINS}
.PHONY: all

# All object files except the entry point
LIBBFS := \
obj/src/alloc.o \
obj/src/bar.o \
obj/src/bfstd.o \
obj/src/bftw.o \
obj/src/color.o \
obj/src/ctx.o \
obj/src/diag.o \
obj/src/dir.o \
obj/src/dstring.o \
obj/src/eval.o \
obj/src/exec.o \
obj/src/expr.o \
obj/src/fsade.o \
obj/src/ioq.o \
obj/src/mtab.o \
obj/src/opt.o \
obj/src/parse.o \
obj/src/printf.o \
obj/src/pwcache.o \
obj/src/sighook.o \
obj/src/stat.o \
obj/src/thread.o \
obj/src/trie.o \
obj/src/typo.o \
obj/src/version.o \
obj/src/xregex.o \
obj/src/xspawn.o \
obj/src/xtime.o

# All object files
OBJS := ${LIBBFS}

# The main binary
bin/bfs: ${LIBBFS} obj/src/main.o
bin/bfs: obj/src/main.o ${LIBBFS}
OBJS += obj/src/main.o

${BINS}:
@${MKDIR} ${@D}
Expand All @@ -61,11 +96,6 @@ ${BINS}:
# Get the .c file for a .o file
CSRC = ${@:obj/%.o=%.c}

# Rebuild when the configuration changes
${OBJS}: gen/config.mk
@${MKDIR} ${@D}
${MSG} "[ CC ] ${CSRC}" ${CC} ${_CPPFLAGS} ${_CFLAGS} -c ${CSRC} -o $@

# Save the version number to this file, but only update version.c if it changes
gen/version.i.new::
${MKDIR} ${@D}
Expand Down Expand Up @@ -103,12 +133,24 @@ unit-tests: ${UTEST_BINS}
${MSG} "[TEST] tests/units" bin/tests/units
.PHONY: unit-tests

bin/tests/units: \
${UNIT_OBJS} \
${LIBBFS}

bin/tests/xspawnee: \
obj/tests/xspawnee.o
# Unit test objects
UNIT_OBJS := \
obj/tests/alloc.o \
obj/tests/bfstd.o \
obj/tests/bit.o \
obj/tests/ioq.o \
obj/tests/list.o \
obj/tests/main.o \
obj/tests/sighook.o \
obj/tests/trie.o \
obj/tests/xspawn.o \
obj/tests/xtime.o

bin/tests/units: ${UNIT_OBJS} ${LIBBFS}
OBJS += ${UNIT_OBJS}

bin/tests/xspawnee: obj/tests/xspawnee.o
OBJS += obj/tests/xspawnee.o

# The different flag combinations we check
INTEGRATIONS := default dfs ids eds j1 j2 j3 s
Expand All @@ -133,13 +175,11 @@ check-j1 check-j2 check-j3 check-s: bin/bfs ${ITEST_BINS}
integration-tests: ${INTEGRATION_TESTS}
.PHONY: integration-tests

bin/tests/mksock: \
obj/tests/mksock.o \
${LIBBFS}
bin/tests/mksock: obj/tests/mksock.o ${LIBBFS}
OBJS += obj/tests/mksock.o

bin/tests/xtouch: \
obj/tests/xtouch.o \
${LIBBFS}
bin/tests/xtouch: obj/tests/xtouch.o ${LIBBFS}
OBJS += obj/tests/xtouch.o

# `make distcheck` configurations
DISTCHECKS := \
Expand Down Expand Up @@ -173,6 +213,16 @@ ${DISTCHECKS}::
&& ../configure MAKE="${MAKE}" ${DISTCHECK_CONFIG_${@:distcheck-%=%}} \
&& ${MAKE} check TEST_FLAGS="--sudo --verbose=skipped"

## Automatic dependency tracking

# Rebuild when the configuration changes
${OBJS}: gen/config.mk
@${MKDIR} ${@D}
${MSG} "[ CC ] ${CSRC}" ${CC} ${_CPPFLAGS} ${_CFLAGS} -c ${CSRC} -o $@

# Include any generated dependency files
-include ${OBJS:.o=.d}

## Packaging (`make install`)

DEST_PREFIX := ${DESTDIR}${PREFIX}
Expand Down
6 changes: 0 additions & 6 deletions build/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ config: gen/config.mk
MKS := \
gen/vars.mk \
gen/flags.mk \
gen/deps.mk \
gen/pkgs.mk

# The main configuration file, which includes the others
Expand Down Expand Up @@ -47,11 +46,6 @@ gen/flags.mk: gen/vars.mk
@+XMAKEFLAGS="$$MAKEFLAGS" ${MAKE} -sf build/flags.mk $@
.PHONY: gen/flags.mk

# Check for dependency generation support
gen/deps.mk: gen/flags.mk
@+XMAKEFLAGS="$$MAKEFLAGS" ${MAKE} -sf build/deps.mk $@
.PHONY: gen/deps.mk

# Auto-detect dependencies and their build flags
gen/pkgs.mk: gen/flags.mk
@+XMAKEFLAGS="$$MAKEFLAGS" ${MAKE} -sf build/pkgs.mk $@
Expand Down
15 changes: 0 additions & 15 deletions build/deps.mk

This file was deleted.

1 change: 0 additions & 1 deletion build/header.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
include build/prelude.mk
include gen/vars.mk
include gen/flags.mk
include gen/deps.mk
include gen/pkgs.mk
include build/exports.mk

Expand Down
44 changes: 0 additions & 44 deletions build/prelude.mk
Original file line number Diff line number Diff line change
Expand Up @@ -71,50 +71,6 @@ ALL_PKGS := \

# List all object files here, as they're needed by both `./configure` and `make`

# All object files except the entry point
LIBBFS := \
obj/src/alloc.o \
obj/src/bar.o \
obj/src/bfstd.o \
obj/src/bftw.o \
obj/src/color.o \
obj/src/ctx.o \
obj/src/diag.o \
obj/src/dir.o \
obj/src/dstring.o \
obj/src/eval.o \
obj/src/exec.o \
obj/src/expr.o \
obj/src/fsade.o \
obj/src/ioq.o \
obj/src/mtab.o \
obj/src/opt.o \
obj/src/parse.o \
obj/src/printf.o \
obj/src/pwcache.o \
obj/src/sighook.o \
obj/src/stat.o \
obj/src/thread.o \
obj/src/trie.o \
obj/src/typo.o \
obj/src/version.o \
obj/src/xregex.o \
obj/src/xspawn.o \
obj/src/xtime.o \

# Unit test objects
UNIT_OBJS := \
obj/tests/alloc.o \
obj/tests/bfstd.o \
obj/tests/bit.o \
obj/tests/ioq.o \
obj/tests/list.o \
obj/tests/main.o \
obj/tests/sighook.o \
obj/tests/trie.o \
obj/tests/xspawn.o \
obj/tests/xtime.o

# All object files
OBJS := \
obj/src/main.o \
Expand Down

0 comments on commit 170aa3d

Please sign in to comment.