[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Running specific part of a Makefile under a specific shell
From: |
peter0x44 |
Subject: |
Re: Running specific part of a Makefile under a specific shell |
Date: |
Fri, 11 Feb 2022 22:08:09 +0000 |
Try the following:
$(if $(filter $(HOSTOS),linux windows),,$(error HostOS not set to
(linux | windows)))
clean: clean_$(HOSTOS)
@echo "Cleaned";
clean_windows: SHELL:=cmd.exe
clean_windows:
@echo "$@: SHELL is set to '$(SHELL)'"
clean_linux:
@echo "$@: SHELL is set to '$(SHELL)'"
Thanks, this worked for me quite well.
However, this Makefile also reportedly handles bsd, and osx too, with
what seems like the same commands.
Is there way I can make multiple targets have the same recipe, to avoid
duplication?
clean: clean_$(PLATFORM_OS)
@echo Removed all generated files
clean_WINDOWS: SHELL:=cmd.exe
clean_WINDOWS:
del *.o /s
del $(RAYLIB_RELEASE_PATH)\lib$(RAYLIB_LIB_NAME).a /s
del $(RAYLIB_RELEASE_PATH)\lib$(RAYLIB_LIB_NAME)dll.a /s
del $(RAYLIB_RELEASE_PATH)\lib$(RAYLIB_LIB_NAME)dll /s
clean_LINUX:
clean_BSD: < -- I want these 3 targets to all execute the same recipe
clean_OSX:
rm -fv $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a
$(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc
$(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so*
I would like clean_LINUX, BSD, and OSX to all execute the same recipe
Best wishes,
Peter D.> Try the following:
$(if $(filter $(HOSTOS),linux windows),,$(error HostOS not set to
(linux | windows)))
clean: clean_$(HOSTOS)
@echo "Cleaned";
clean_windows: SHELL:=cmd.exe
clean_windows:
@echo "$@: SHELL is set to '$(SHELL)'"
clean_linux:
@echo "$@: SHELL is set to '$(SHELL)'"
Thanks, this worked for me quite well.
However, this Makefile also reportedly handles bsd, and osx too, with
what seems like the same commands.
Is there way I can make multiple targets have the same recipe, to avoid
duplication?
clean: clean_$(PLATFORM_OS)
@echo Removed all generated files
clean_WINDOWS: SHELL:=cmd.exe
clean_WINDOWS:
del *.o /s
del $(RAYLIB_RELEASE_PATH)\lib$(RAYLIB_LIB_NAME).a /s
del $(RAYLIB_RELEASE_PATH)\lib$(RAYLIB_LIB_NAME)dll.a /s
del $(RAYLIB_RELEASE_PATH)\lib$(RAYLIB_LIB_NAME)dll /s
clean_LINUX:
clean_BSD: < -- I want these 3 targets to all execute the same recipe
clean_OSX:
rm -fv $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a
$(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc
$(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so*
I would like clean_LINUX, BSD, and OSX to all execute the same recipe
Best wishes,
Peter D.