@@ -26,7 +26,8 @@ DD:=$(CB_DIR)/crossbuild
2626DOCKER_TMPL: =$(CB_DIR ) /m4/Dockerfile.m4
2727
2828# List of all the docker images (sorted for "crossbuild.info")
29- CB_IMAGES: =$(sort $(patsubst $(DT ) /% ,% ,$(wildcard $(DT ) /* ) ) )
29+ CB_IMAGES := $(sort $(filter-out profiling,\
30+ $(patsubst $(DT ) /% /,% ,$(wildcard $(DT ) /* /) ) ) )
3031
3132# Location of the .git dir (may be different for e.g. submodules)
3233GITDIR: =$(shell perl -MCwd -e 'print Cwd::abs_path shift' $$(git rev-parse --git-dir ) )
4041CB_IPREFIX: =freeradius40x-build
4142CB_CPREFIX: =fr40x-crossbuild-
4243
44+ PROFILE ?= profiling1
45+
4346#
4447# This Makefile is included in-line, and not via the "boilermake"
4548# wrapper. But it's still useful to use the same process for
@@ -90,6 +93,23 @@ crossbuild.help: crossbuild.info
9093 @echo " crossbuild.IMAGE.clean - stop container and tidy up"
9194 @echo " crossbuild.IMAGE.wipe - remove Docker image"
9295 @echo " "
96+ @echo " Profiling targets:"
97+ @echo " crossbuild.IMAGE.profregen - regenerate Dockerfile.prof using default profile ($( PROFILE) )"
98+ @echo " crossbuild.IMAGE.profregen PROFILE=<name> - regenerate using a specific profile"
99+ @echo " crossbuild.IMAGE.profbuild - build profiling image using default profile ($( PROFILE) )"
100+ @echo " crossbuild.IMAGE.profbuild PROFILE=<name> - build using a specific profile"
101+ @echo " "
102+ @echo " Available profiling profiles (scripts/docker/profiling/profiles/):"
103+ @echo " valgrind-callgrind - callgrind call graph and instruction profiling"
104+ @echo " valgrind-massif - FUTURE: massif heap memory profiling"
105+ @echo " gperftools-cpu - FUTURE: gperftools CPU profiling"
106+ @echo " "
107+ @echo " Profiling examples:"
108+ @echo " make crossbuild.ubuntu24.profregen"
109+ @echo " make crossbuild.ubuntu24.profregen PROFILE=valgrind-callgrind"
110+ @echo " make crossbuild.ubuntu24.profbuild"
111+ @echo " make crossbuild.ubuntu24.profbuild PROFILE=gperftools-cpu"
112+ @echo " "
93113 @echo " Use 'make NOCACHE=1 ...' to disregard the Docker cache on build"
94114
95115#
@@ -140,6 +160,20 @@ $(DD)/stamp-image.${1}:
140160 ${Q}docker build $(DOCKER_BUILD_OPTS ) $(DT ) /${1} -f $(DT ) /${1}/Dockerfile.cb -t $(CB_IPREFIX ) /${1} >$(DD ) /build.${1} 2>&1
141161 ${Q}touch $(DD ) /stamp-image.${1}
142162
163+ #
164+ # Build the profiling image
165+ #
166+ .PHONY: crossbuild.${1}.profbuild
167+ crossbuild.${1}.profbuild: $(DD ) /stamp-image.${1}-profbuild
168+
169+ $(DD ) /stamp-image.${1}-profbuild: $(DT ) /${1}/Dockerfile.prof
170+ ${Q}echo "BUILD ${1} ($(CB_IPREFIX ) /${1}-prof) > $(DD ) /build.${1}-profbuild"
171+ ${Q}docker build $(DOCKER_BUILD_OPTS ) . \
172+ -f $(DT ) /${1}/Dockerfile.prof \
173+ -t $(CB_IPREFIX ) /${1}-prof \
174+ >$(DD ) /build.${1}-profbuild 2>&1
175+ ${Q}touch $(DD ) /stamp-image.${1}-profbuild
176+
143177#
144178# Start up the docker container
145179#
@@ -249,6 +283,21 @@ $(DT)/${1}/Dockerfile.cb: $(DOCKER_TMPL) $(CB_DIR)/m4/crossbuild.deb.m4 $(CB_DIR
249283 ${Q}echo REGEN ${1}
250284 ${Q}m4 -I $(CB_DIR ) /m4 -D D_NAME=${1} -D D_TYPE=crossbuild $$< > $$@
251285
286+ #
287+ # Regenerate Dockerfile.prof from m4 template
288+ #
289+ .PHONY: crossbuild.${1}.profregen
290+ crossbuild.${1}.profregen: $(DT ) /${1}/Dockerfile.prof
291+
292+ $(DT ) /${1}/Dockerfile.prof: $(DOCKER_TMPL ) $(CB_DIR ) /m4/profiling.deb.m4 $(CB_DIR ) /m4/profiling.rpm.m4
293+ ${Q}echo REGEN ${1}
294+ ${Q}m4 -I $(CB_DIR ) /m4 \
295+ -D D_NAME=${1} \
296+ -D D_TYPE=profiling \
297+ -D CB_IMAGE=$(CB_IPREFIX ) /${1} \
298+ -D PROFILE_NAME=$(PROFILE ) \
299+ $$< > $$@
300+
252301#
253302# Run the build test
254303#
0 commit comments