diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Restyle the sources and fix the audit's findings
Diffstat (limited to 'source/cgit.mk')
| -rw-r--r-- | source/cgit.mk | 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 30 insertions, 31 deletions
diff --git a/source/cgit.mk b/source/cgit.mk index e0a3312..1cee1fb 100644 --- a/source/cgit.mk +++ b/source/cgit.mk @@ -1,34 +1,30 @@ -# This Makefile runs inside the bundled Git tree (vendor/git) so that it -# can reuse Git's build variables and platform detection. The top-level -# Makefile invokes it as: +# The rules that compile and link cgit itself. They run with the bundled Git +# tree as the working directory so that Git's build variables and platform +# detection can be reused, which is why every path back into the project leads +# through CGIT_ROOT. The top level Makefile invokes it roughly as # # make -C vendor/git -f ../../source/cgit.mk ../../build/cgit # -# so every path back into the project reaches through CGIT_ROOT ("../.."): -# sources come from ../../source and all build output goes to ../../build. +# so sources are read from ../../source and all output is written to +# ../../build. include Makefile -# Locations relative to vendor/git, where this file is run. SRCDIR and -# BUILDDIR name the root-relative subdirs (matching the top-level Makefile and -# used by the version recipe, which cds to the root); CGIT_SRC and CGIT_BUILD -# are their full paths from here. +# SRCDIR and BUILDDIR are named relative to the project root, matching the top +# level Makefile, because the version recipe changes into the root before using +# them. CGIT_SRC and CGIT_BUILD are the same two directories reached from +# vendor/git, where everything else here runs. CGIT_ROOT = ../.. SRCDIR = source BUILDDIR = build CGIT_SRC = $(CGIT_ROOT)/$(SRCDIR) CGIT_BUILD = $(CGIT_ROOT)/$(BUILDDIR) -# Emit zero-initialised globals as plain definitions instead of common -# symbols, the default everywhere but Apple clang. ld64 otherwise derives -# a 32 KB alignment from the size of git's 64 KB packet_buffer and warns -# about reducing it on every macOS link. Use override so a command-line -# CFLAGS (as tools/release-build.sh passes) still keeps the flag. -override CFLAGS += -fno-common - +# Read again here because a sub make inherits only the variables the top level +# Makefile exports, which leaves out the build options this file reads. -include $(CGIT_ROOT)/cgit.conf -# The CGIT_* variables are inherited from the top-level Makefile. - +# CGIT_VERSION and the other CGIT_ values used below come from the top level +# Makefile, which exports them, rather than being defined in this file. $(CGIT_BUILD)/VERSION: force-version @mkdir -p $(CGIT_BUILD)/ @cd $(CGIT_ROOT) && '$(SHELL_PATH_SQ)' $(SRCDIR)/gen-version.sh "$(CGIT_VERSION)" $(BUILDDIR)/VERSION @@ -37,12 +33,12 @@ $(CGIT_BUILD)/VERSION: force-version # The language the cgit sources are written in. Both GCC and Clang default to # this today, so pinning it changes nothing now and stops the meaning of the -# sources drifting when a compiler moves its default on (GCC 15 defaults to -# gnu23). The GNU dialect rather than plain c17 because git's headers use GNU -# extensions, and because dlsym cannot be used through a conforming cast. -# -# Only the cgit objects are held to this. Git keeps whatever its own build -# decides, which on some platforms is a different standard again. +# sources drifting when a compiler moves its default on, as GCC 15 did by +# defaulting to gnu23. The GNU dialect rather than plain c17 because git's +# headers use GNU extensions, and because dlsym cannot be used through a +# conforming cast. Only the cgit objects are held to this, and Git keeps +# whatever its own build decides, which on some platforms is a different +# standard again. CGIT_STD ?= gnu17 # CGIT_CFLAGS is tracked separately so that changing it does not force a @@ -52,8 +48,8 @@ CGIT_CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' CGIT_CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' CGIT_CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' -# Reaches only the cgit objects, so a caller can tighten the build (CI passes -# -Werror) without holding git's own sources to the same standard. +# Reaches only the cgit objects, so a caller can tighten the build, the way CI +# passes -Werror, without holding git's own sources to the same standard. CGIT_CFLAGS += $(CGIT_EXTRA_CFLAGS) PKG_CONFIG ?= pkg-config @@ -88,12 +84,15 @@ endif endif -# Add -ldl to linker flags on systems that commonly use GNU libc. +# The filters reach libc's write through dlsym, which lives in a library of its +# own on the systems that use GNU libc. ifneq (,$(filter $(uname_S),Linux GNU GNU/kFreeBSD)) CGIT_LIBS += -ldl endif -# glibc 2.1+ offers sendfile which the most common C library on Linux +# The cache sends a stored page straight to stdout with sendfile where it can. +# Only Linux is assumed to offer it, so everywhere else falls back to reading +# and writing the file by hand. ifeq ($(uname_S),Linux) HAVE_LINUX_SENDFILE = YesPlease endif @@ -105,7 +104,7 @@ endif CGIT_OBJ_NAMES += cgit.o CGIT_OBJ_NAMES += cache.o CGIT_OBJ_NAMES += cmd.o -CGIT_OBJ_NAMES += configfile.o +CGIT_OBJ_NAMES += config.o CGIT_OBJ_NAMES += filter.o CGIT_OBJ_NAMES += html.o CGIT_OBJ_NAMES += parsing.o @@ -140,8 +139,8 @@ $(CGIT_VERSION_OBJS): $(CGIT_BUILD)/VERSION $(CGIT_VERSION_OBJS): EXTRA_CPPFLAGS = \ -DCGIT_VERSION='"$(CGIT_VERSION)"' -# Git handles dependencies using ":=" so dependencies in CGIT_OBJS are not -# handled by that and we must handle them ourselves. +# Git builds its list of dependency files with := before this file adds the +# cgit objects, so those are missing from it and have to be picked up here. cgit_dep_files := $(foreach f,$(CGIT_OBJS),$(dir $f).depend/$(notdir $f).d) cgit_dep_files_present := $(wildcard $(cgit_dep_files)) ifneq ($(cgit_dep_files_present),) |
