From 09d3ab0aef589ffb2bf795faa9c6a00116d1f4b0 Mon Sep 17 00:00:00 2001 From: harsh Date: Wed, 19 Feb 2025 01:44:42 +0530 Subject: [PATCH] Fixed issue #136 - Updated Makefile of 6_morphology --- 4_cv_basics/6_morphology/Makefile | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/4_cv_basics/6_morphology/Makefile b/4_cv_basics/6_morphology/Makefile index f34bc2e..9115ef3 100644 --- a/4_cv_basics/6_morphology/Makefile +++ b/4_cv_basics/6_morphology/Makefile @@ -6,20 +6,26 @@ PROJECT = morphology # Here Include specifies which directories can be added in the include path of the main.cpp CFLAGS = -std=c++11 $(shell pkg-config --cflags opencv4) -Iinclude/ -# What libraries to be imported here it is opencv +# What libraries to be imported here it is opencv LIBS = $(shell pkg-config --libs opencv4) -# Similar to how we used to link ad make object files in the terminal -# the command make build should build the executable +# Source file for morphology operations link = src/morphology.cpp + +# Similar to how we used to link and make object files in the terminal +# The command make build SRC= should build the executable in the subfolder .PHONY: build +ifeq ($(SRC), $(link), ) +build: + $(error "SRC is not set") +else build: @echo "Building..." - @$(CC) $(filter-out $@,$(MAKECMDGOALS))/main.cpp $(link) -o _$(filter-out $@,$(MAKECMDGOALS)) $(CFLAGS) $(LIBS) -%:: - @true -# if folder is not set, clean all build files all subfolders + @$(CC) $(SRC) $(link) -o $(PROJECT) $(CFLAGS) $(LIBS) +endif + +# If folder is not set, clean all build files in all subfolders .PHONY: clean clean: @echo "Cleaning..." - @rm -rf _$(filter-out $@,$(MAKECMDGOALS)) \ No newline at end of file + @rm -rf $(PROJECT) \ No newline at end of file