Skip to content

Commit 0062ec4

Browse files
sshi-amdclaude
andauthored
Makefile testing Add Makefile CI: configure-based dependency detection, build, and test (#442)
Add Makefile build path to CI with configure-based dependency detection Adds a parallel Makefile build to CI alongside the existing CMake/CTest flow, so the standalone `make` workflow stays exercised on every commit. ## What's added - **`Scripts/configure.sh`** — autoconf-style probe for external dependencies (FFmpeg, OpenCV, GLFW3, Vulkan, libdw, amd_comgr, glslangValidator) via `pkg-config` + link tests. Writes `config.mk` at the repo root. - **`Common/require_deps.mk`** — leaf Makefiles declare `REQUIRED_DEPS := GLFW3` (etc.) and include this. If a dependency is missing, `SKIP_BUILD` is set and the leaf's main rules collapse to no-ops, so parent cascades don't error. - **`Common/find_filesystem.mk`** — probes whether `-lstdc++fs` is needed (older GCC like SLES 15.7's default) or whether `std::experimental::filesystem` is in libstdc++ proper (Ubuntu 22 / AlmaLinux 8 + gcc-toolset-13). Mirrors the existing `Common/FindFilesystem.cmake` for the Make path. ## Leaf Makefiles - ~390 leaf Makefiles updated. 28 examples with external deps gain `REQUIRED_DEPS := …` + the `ifneq ($(SKIP_BUILD),1) … else … endif` wrapper. Examples without external deps are unchanged in behavior. - All hard-coded `-lstdc++fs` (29 leaves total: 10 rocDecode + 19 others in Applications, HIP-Basic, HIP-Doc, rocJPEG, rocProfiler-SDK) converted to `$(CXX_FS_LIB)` from the new probe. - 48 leaves still using `ROCM_PATH := /opt/rocm` (hard `:=`) flipped to `?= /opt/rocm` so the env-provided path wins. Same fix that upstream PR #440 applied to the rest of the tree. - `Tools/ROCgdb/.gitignore` added; mismatched per-directory `.gitignore` entries fixed in two `warp_size_reduction` dirs. - Five previously committed binary artifacts removed. - One `EXAMPLE := <wrong>` typo fixed in `identifying_host_device_compilation_pass/Makefile`. ## CI workflow - Adds **Makefile build**, **Collect Makefile build artifacts**, and **Upload Makefile build artifacts** steps to the reusable workflow. - CMake configure / build are gated with `if: !cancelled()` so the CMake side still runs to completion when the Makefile build fails (for visibility). - AlmaLinux 8 Dockerfile picks up `pkgconf-pkg-config` (it was missing, which broke every `pkg-config` probe on AlmaLinux) and extends `PKG_CONFIG_PATH` to discover source-built FFmpeg / GLFW. ## Out of scope (deferred to follow-up PR) - Make-native `test` target (per-leaf `test:` depending on the build target, cascading from root via `make test`, with per-parent `SKIP_FROM_TEST` filter) — opened separately as a stacked PR. - Per-GPU-arch test skipping for the Make path. - Wiring up rocDecode's conditional test-data probing. Signed-off-by: zichguan-amd <zichuan.guan@amd.com> Co-authored-by: Claude (Anthropic) <noreply@anthropic.com>
1 parent fd4b3a6 commit 0062ec4

81 files changed

Lines changed: 948 additions & 132 deletions

File tree

Some content is hidden

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

.github/workflows/build-rocm-examples-reusable.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ jobs:
7474
echo "PATH=${ROCM_PATH}/bin:${ROCM_PATH}/llvm/bin:${PATH}" >> $GITHUB_ENV
7575
echo "LD_LIBRARY_PATH=${ROCM_PATH}/lib:${ROCM_PATH}/llvm/lib:${ROCM_PATH}/lib/rocprofiler-systems" >> $GITHUB_ENV
7676
echo "ENABLE_OPENMP=OFF" >> $GITHUB_ENV
77+
echo "HIPCC_COMPILE_FLAGS_APPEND=--offload-arch=${{ matrix.gpu_config.gpu_target }}" >> $GITHUB_ENV
7778
7879
- name: Install TheRock tarball
7980
if: ${{ matrix.install_method == 'tarball' }}
@@ -104,8 +105,15 @@ jobs:
104105
echo "PATH=${ROCM_PATH}/bin:${ROCM_PATH}/llvm/bin:${PATH}" >> $GITHUB_ENV
105106
echo "LD_LIBRARY_PATH=${ROCM_PATH}/lib:${ROCM_PATH}/llvm/lib:${ROCM_PATH}/lib/rocprofiler-systems" >> $GITHUB_ENV
106107
echo "ENABLE_OPENMP=ON" >> $GITHUB_ENV
108+
echo "HIPCC_COMPILE_FLAGS_APPEND=--offload-arch=${{ matrix.gpu_config.gpu_target }}" >> $GITHUB_ENV
109+
110+
- name: Makefile build
111+
run: |
112+
./Scripts/configure.sh --rocm-path="${ROCM_PATH}"
113+
make -j HIP_ARCHITECTURES="${{ matrix.gpu_config.gpu_target }}"
107114
108115
- name: CMake configure
116+
if: ${{ !cancelled() }}
109117
run: |
110118
cmake -S . -B build -DCMAKE_HIP_ARCHITECTURES="${{ matrix.gpu_config.gpu_target }}" -DCMAKE_BUILD_RPATH="${ROCM_PATH}/lib" -DROCM_EXAMPLES_ENABLE_OPENMP="${ENABLE_OPENMP}" 2> >(tee cmake_error.log >&2)
111119
@@ -141,17 +149,39 @@ jobs:
141149
fi
142150
143151
- name: CMake build
152+
if: ${{ !cancelled() }}
144153
run: |
145154
cmake --build build -j
146155
147-
- name: Upload build artifacts
148-
if: success()
156+
- name: Collect Makefile build artifacts
157+
if: ${{ !cancelled() }}
158+
run: |
159+
mkdir -p /tmp/makefile_build
160+
find . -name Makefile -not -path './build/*' | while IFS= read -r makefile; do
161+
dir=$(dirname "$makefile")
162+
example_name=$(grep '^EXAMPLE := ' "$makefile" 2>/dev/null | head -1 | sed 's/^EXAMPLE := //' || true)
163+
if [ -n "${example_name}" ] && [ -x "${dir}/${example_name}" ]; then
164+
mkdir -p "/tmp/makefile_build/${dir}"
165+
cp "${dir}/${example_name}" "/tmp/makefile_build/${dir}/"
166+
fi
167+
done
168+
169+
- name: Upload CMake build artifacts
170+
if: ${{ !cancelled() }}
149171
uses: actions/upload-artifact@v4
150172
with:
151173
name: rocm-examples-build-${{ inputs.distro }}-${{ matrix.gpu_config.gpu_target }}-${{ steps.sanity-check.outputs.rocm_version || steps.install-tarball.outputs.rocm_version }}-${{ matrix.install_method }}
152174
path: build/
153175

176+
- name: Upload Makefile build artifacts
177+
if: ${{ !cancelled() }}
178+
uses: actions/upload-artifact@v4
179+
with:
180+
name: makefile-build-${{ inputs.distro }}-${{ matrix.gpu_config.gpu_target }}-${{ steps.sanity-check.outputs.rocm_version || steps.install-tarball.outputs.rocm_version }}-${{ matrix.install_method }}
181+
path: /tmp/makefile_build/
182+
154183
- name: Run tests
184+
if: ${{ !cancelled() }}
155185
run: |
156186
python3 .github/build_tools/generate_skip_tests.py --target ${{ matrix.gpu_config.gpu_target }} --distro ${{ inputs.distro }}
157187
@@ -196,7 +226,7 @@ jobs:
196226
echo "<details><summary>Failed tests output</summary>" >> $GITHUB_STEP_SUMMARY
197227
echo "" >> $GITHUB_STEP_SUMMARY
198228
echo '```' >> $GITHUB_STEP_SUMMARY
199-
229+
200230
awk '
201231
/^[0-9]+\/[0-9]+ Testing: / { if (inblock && failed) print block; block = $0; inblock = 1; failed = 0; seen_result = 0; next }
202232
inblock { block = block "\n" $0 }
@@ -205,7 +235,7 @@ jobs:
205235
/^-+$/ { if (inblock && seen_result) { if (failed) print block; inblock = 0 } }
206236
END { if (inblock && failed) print block }
207237
' "${LAST_TEST_LOG}" >> $GITHUB_STEP_SUMMARY
208-
238+
209239
echo '```' >> $GITHUB_STEP_SUMMARY
210240
echo "</details>" >> $GITHUB_STEP_SUMMARY
211241
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
*.pdb
88
CMakeUserPresets.json
99
.cline_storage
10+
config.mk

Applications/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ EXAMPLES := \
2626
fdtd \
2727
floyd_warshall \
2828
histogram \
29-
prefix_sum \
30-
sobel_filter
29+
prefix_sum
30+
31+
ifneq ($(wildcard /usr/include/GLFW/glfw3.h),)
32+
EXAMPLES += sobel_filter
33+
endif
3134

3235
ifneq ($(GPU_RUNTIME), CUDA)
3336
EXAMPLES += \

Applications/sobel_filter/Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ COMMON_INCLUDE_DIR := ../../Common
2525
EXTERNAL_DIR := ../../External
2626
GPU_RUNTIME ?= HIP
2727

28+
# Dependency checking
29+
REQUIRED_DEPS := GLFW3
30+
include $(COMMON_INCLUDE_DIR)/require_deps.mk
31+
32+
ifneq ($(SKIP_BUILD),1)
33+
2834
# HIP variables
2935
ROCM_PATH ?= /opt/rocm
3036
HIP_INCLUDE_DIR := $(ROCM_PATH)/include
@@ -34,9 +40,9 @@ HIPCXX ?= $(ROCM_PATH)/bin/hipcc
3440
# Common variables and flags
3541
CXX_STD := c++17
3642
ICXXFLAGS := -std=$(CXX_STD)
37-
ICPPFLAGS := -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) $(shell pkg-config --cflags glfw3)
43+
ICPPFLAGS := -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) $(GLFW3_CFLAGS)
3844
ILDFLAGS :=
39-
ILDLIBS := $(shell pkg-config --libs glfw3) -ldl
45+
ILDLIBS := $(GLFW3_LIBS) -ldl
4046

4147
ifeq ($(GPU_RUNTIME), CUDA)
4248
ICXXFLAGS += -x cu
@@ -63,3 +69,9 @@ clean:
6369
$(RM) $(EXAMPLE)
6470

6571
.PHONY: clean
72+
73+
else
74+
all:
75+
clean:
76+
.PHONY: all clean
77+
endif

Common/find_filesystem.mk

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
# Detect whether linking std::experimental::filesystem requires -lstdc++fs.
24+
# Older toolchains (GCC <= 8 / SLES default) ship the implementation in a
25+
# separate static library; GCC >= 9 has it merged into libstdc++ proper.
26+
#
27+
# Mirrors the behavior of Common/FindFilesystem.cmake for the Make build path.
28+
#
29+
# Usage in leaf Makefiles:
30+
# include $(COMMON_INCLUDE_DIR)/find_filesystem.mk
31+
# ...
32+
# ILDLIBS := -lrocdecode ... $(CXX_FS_LIB)
33+
#
34+
# Output variable:
35+
# CXX_FS_LIB - either "-lstdc++fs" or empty.
36+
37+
_FS_OK_BARE := $(shell { echo '#include <experimental/filesystem>'; echo 'int main(){std::experimental::filesystem::path p; return 0;}'; } | $${CXX:-c++} -x c++ -std=c++17 - -o /dev/null 2>/dev/null && echo 1 || echo 0)
38+
ifeq ($(_FS_OK_BARE),0)
39+
_FS_OK_WITH_LIB := $(shell { echo '#include <experimental/filesystem>'; echo 'int main(){std::experimental::filesystem::path p; return 0;}'; } | $${CXX:-c++} -x c++ -std=c++17 - -lstdc++fs -o /dev/null 2>/dev/null && echo 1 || echo 0)
40+
ifeq ($(_FS_OK_WITH_LIB),1)
41+
CXX_FS_LIB := -lstdc++fs
42+
endif
43+
endif

Common/require_deps.mk

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
# Dependency checker for rocm-examples Makefile build system
24+
#
25+
# Usage in example Makefiles:
26+
# REQUIRED_DEPS := FFMPEG OPENCV
27+
# include $(COMMON_INCLUDE_DIR)/require_deps.mk
28+
#
29+
# Before including, set COMMON_INCLUDE_DIR (already standard in all examples).
30+
#
31+
# This file works in two modes:
32+
# 1. Fast path: includes config.mk (generated by configure.sh) from the repo root
33+
# 2. Fallback: uses inline pkg-config checks for standalone builds
34+
#
35+
# After including, check SKIP_BUILD. This composes with filter_hip_architectures.mk
36+
# which also sets SKIP_BUILD.
37+
#
38+
# Output variables:
39+
# SKIP_BUILD - set to 1 if any required dependency is missing
40+
# MISSING_DEPS - list of missing dependency names
41+
42+
# Locate the repository root relative to COMMON_INCLUDE_DIR
43+
_REPO_ROOT := $(dir $(COMMON_INCLUDE_DIR))
44+
45+
# Try to include the pre-generated config.mk (silent if absent)
46+
-include $(_REPO_ROOT)/config.mk
47+
48+
# If config.mk was not found, run inline fallback detection.
49+
# We detect this by checking if HAVE_FFMPEG is defined (it's always written by configure.sh).
50+
ifndef HAVE_FFMPEG
51+
# Fallback: detect dependencies via pkg-config / file existence
52+
53+
# FFmpeg (pkg-config + link test to catch missing -dev packages)
54+
_FFMPEG_CHECK := $(shell pkg-config --exists libavcodec libavformat libavutil 2>/dev/null \
55+
&& echo 'int main(){return 0;}' | $${CC:-cc} -x c - $$(pkg-config --libs libavcodec libavformat libavutil) -o /dev/null 2>/dev/null \
56+
&& echo 1 || echo 0)
57+
HAVE_FFMPEG := $(_FFMPEG_CHECK)
58+
ifeq ($(HAVE_FFMPEG),1)
59+
FFMPEG_CFLAGS := $(shell pkg-config --cflags libavcodec libavformat libavutil 2>/dev/null)
60+
FFMPEG_LIBS := $(shell pkg-config --libs libavcodec libavformat libavutil 2>/dev/null || echo "-lavcodec -lavformat -lavutil")
61+
else
62+
FFMPEG_CFLAGS :=
63+
FFMPEG_LIBS :=
64+
endif
65+
66+
# OpenCV (pkg-config + link test)
67+
_OPENCV_CHECK := $(shell (pkg-config --exists opencv4 2>/dev/null && echo 'int main(){return 0;}' | $${CC:-cc} -x c - $$(pkg-config --libs opencv4) -o /dev/null 2>/dev/null && echo 1) \
68+
|| (pkg-config --exists opencv 2>/dev/null && echo 'int main(){return 0;}' | $${CC:-cc} -x c - $$(pkg-config --libs opencv) -o /dev/null 2>/dev/null && echo 1) \
69+
|| echo 0)
70+
HAVE_OPENCV := $(_OPENCV_CHECK)
71+
ifeq ($(HAVE_OPENCV),1)
72+
OPENCV_CFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv)
73+
OPENCV_LIBS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv)
74+
else
75+
OPENCV_CFLAGS :=
76+
OPENCV_LIBS :=
77+
endif
78+
79+
# GLFW3 (pkg-config + link test)
80+
_GLFW3_CHECK := $(shell pkg-config --exists glfw3 2>/dev/null \
81+
&& echo 'int main(){return 0;}' | $${CC:-cc} -x c - $$(pkg-config --libs glfw3) -o /dev/null 2>/dev/null \
82+
&& echo 1 || echo 0)
83+
HAVE_GLFW3 := $(_GLFW3_CHECK)
84+
ifeq ($(HAVE_GLFW3),1)
85+
GLFW3_CFLAGS := $(shell pkg-config --cflags glfw3 2>/dev/null)
86+
GLFW3_LIBS := $(shell pkg-config --libs glfw3 2>/dev/null)
87+
else
88+
GLFW3_CFLAGS :=
89+
GLFW3_LIBS :=
90+
endif
91+
92+
# Vulkan (pkg-config + link test)
93+
_VULKAN_CHECK := $(shell pkg-config --exists vulkan 2>/dev/null \
94+
&& echo 'int main(){return 0;}' | $${CC:-cc} -x c - $$(pkg-config --libs vulkan) -o /dev/null 2>/dev/null \
95+
&& echo 1 || echo 0)
96+
HAVE_VULKAN := $(_VULKAN_CHECK)
97+
ifeq ($(HAVE_VULKAN),1)
98+
VULKAN_CFLAGS := $(shell pkg-config --cflags vulkan 2>/dev/null)
99+
VULKAN_LIBS := $(shell pkg-config --libs vulkan 2>/dev/null || echo "-lvulkan")
100+
else
101+
VULKAN_CFLAGS :=
102+
VULKAN_LIBS :=
103+
endif
104+
105+
# libdw (elfutils)
106+
_LIBDW_CHECK := $(shell pkg-config --exists libdw 2>/dev/null && echo 1 || echo 0)
107+
ifeq ($(_LIBDW_CHECK),0)
108+
_LIBDW_CHECK := $(if $(or $(wildcard /usr/include/elfutils/libdw.h),$(wildcard /usr/include/dwarf.h)),1,0)
109+
endif
110+
HAVE_LIBDW := $(_LIBDW_CHECK)
111+
112+
# amd_comgr
113+
ROCM_PATH ?= /opt/rocm
114+
_AMD_COMGR_CHECK := $(if $(or $(wildcard $(ROCM_PATH)/include/amd_comgr/amd_comgr.h),$(wildcard $(ROCM_PATH)/lib/libamd_comgr.so)),1,0)
115+
ifeq ($(_AMD_COMGR_CHECK),0)
116+
_AMD_COMGR_CHECK := $(shell pkg-config --exists amd_comgr 2>/dev/null && echo 1 || echo 0)
117+
endif
118+
HAVE_AMD_COMGR := $(_AMD_COMGR_CHECK)
119+
120+
# glslangValidator
121+
_GLSLANG_CHECK := $(shell command -v glslangValidator >/dev/null 2>&1 && echo 1 || echo 0)
122+
HAVE_GLSLANG_VALIDATOR := $(_GLSLANG_CHECK)
123+
124+
endif # ifndef HAVE_FFMPEG
125+
126+
# Check REQUIRED_DEPS against HAVE_<dep> flags
127+
MISSING_DEPS :=
128+
$(foreach dep,$(REQUIRED_DEPS),\
129+
$(if $(filter 1,$(HAVE_$(dep))),,\
130+
$(eval MISSING_DEPS += $(dep))))
131+
132+
ifneq ($(MISSING_DEPS),)
133+
SKIP_BUILD := 1
134+
$(info $(EXAMPLE): Skipping build — missing dependencies: $(MISSING_DEPS))
135+
endif

Dockerfiles/almalinux-8.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RUN dnf install -y dnf-plugins-core && \
2222
git \
2323
curl \
2424
nasm \
25+
pkgconf-pkg-config \
2526
python3.11 \
2627
python3.11-pip \
2728
elfutils-devel \
@@ -86,7 +87,7 @@ RUN mkdir -p /opt/vulkan-sdk && \
8687
ENV PATH="${VULKAN_SDK}/bin:${PATH}"
8788
ENV LD_LIBRARY_PATH="${VULKAN_SDK}/lib:${LD_LIBRARY_PATH}"
8889
ENV VK_ADD_LAYER_PATH="${VULKAN_SDK}/share/vulkan/explicit_layer.d"
89-
ENV PKG_CONFIG_PATH="${VULKAN_SDK}/share/pkgconfig:${VULKAN_SDK}/lib/pkgconfig"
90+
ENV PKG_CONFIG_PATH="${VULKAN_SDK}/share/pkgconfig:${VULKAN_SDK}/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig"
9091

9192
# Build FFmpeg from source (not available in RHEL 8 repos)
9293
WORKDIR /tmp

HIP-Basic/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,21 @@ EXAMPLES := \
3636
moving_average \
3737
multi_gpu_data_transfer \
3838
occupancy \
39-
opengl_interop \
4039
runtime_compilation \
4140
saxpy \
4241
shared_memory \
4342
streams \
4443
static_host_library \
4544
texture_management \
46-
vulkan_interop \
4745
warp_shuffle
4846

47+
ifneq ($(wildcard /usr/include/GLFW/glfw3.h),)
48+
EXAMPLES += opengl_interop
49+
ifneq ($(wildcard /usr/include/vulkan/vulkan.h),)
50+
EXAMPLES += vulkan_interop
51+
endif
52+
endif
53+
4954
# Only supported on HIP (not CUDA).
5055
ifneq ($(GPU_RUNTIME), CUDA)
5156
EXAMPLES += \

HIP-Basic/opengl_interop/Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ COMMON_INCLUDE_DIR := ../../Common
2525
EXTERNAL_DIR := ../../External
2626
GPU_RUNTIME ?= HIP
2727

28+
# Dependency checking
29+
REQUIRED_DEPS := GLFW3
30+
include $(COMMON_INCLUDE_DIR)/require_deps.mk
31+
32+
ifneq ($(SKIP_BUILD),1)
33+
2834
# HIP variables
2935
ROCM_PATH ?= /opt/rocm
3036
HIP_INCLUDE_DIR := $(ROCM_PATH)/include
@@ -34,9 +40,9 @@ HIPCXX ?= $(ROCM_PATH)/bin/hipcc
3440
# Common variables and flags
3541
CXX_STD := c++17
3642
ICXXFLAGS := -std=$(CXX_STD)
37-
ICPPFLAGS := -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) $(shell pkg-config --cflags glfw3)
43+
ICPPFLAGS := -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) $(GLFW3_CFLAGS)
3844
ILDFLAGS :=
39-
ILDLIBS := $(shell pkg-config --libs glfw3) -ldl
45+
ILDLIBS := $(GLFW3_LIBS) -ldl
4046

4147
ifeq ($(GPU_RUNTIME), CUDA)
4248
ICXXFLAGS += -x cu
@@ -65,3 +71,9 @@ clean:
6571
$(RM) $(EXAMPLE)
6672

6773
.PHONY: clean
74+
75+
else
76+
all:
77+
clean:
78+
.PHONY: all clean
79+
endif

0 commit comments

Comments
 (0)