나는 자신의 디렉토리에 여러 개의 FPGA 빌드를 관리하는 Makefile이있다. 각 변수의 이름은 CS_FPGA_FETCH
입니다. 내 프로젝트의 많은 하위 폴더는이 이름을 기반으로합니다.목록에서 만들어진 Makefile 타겟에서 기본 변수를 얻는다
각 FPGA에 대한 타겟을 추가하는 방법을 깨끗하게 정리하고 싶습니다. 내가 생각해내는 것은 addprefix
이며 접두어를 제거하는 것입니다.
# Every FPGA
CS_FPGAS_FETCH := cs00 cs01 cs02 cs03 cs10 cs11 cs12 cs13 cs20 cs21 cs22 cs23 cs30 cs31 cs32 cs33
# this is a list of variables that has the words copy_official_ prefixed
# to all of the cs00, cs01
COPY_OFFICIAL_CS_TARGETS=$(addprefix copy_official_,$(CS_FPGAS_FETCH))
# because we use add prefix, we HAVE to strip it off
# this replases $(@) for guys with a prefix, so we can access the base variable inside the loop below
COPY_TARGET_FPGA_NAME=$(@:copy_official_%=%)
# this evaluates out to targets named:
# copy_official_cs00, copy_official_cs01 etc
$(COPY_OFFICIAL_CS_TARGETS):
@echo In $(@) target. Here i copy file $(COPY_TARGET_FPGA_NAME)
cp build/$(COPY_TARGET_FPGA_NAME)/file.bit install/$(COPY_TARGET_FPGA_NAME)
이 방법은 나에게 뒤떨어져 있습니다. 사용할 각 접두사에 대해 COPY_TARGET_FPGA_NAME
을 만들어야합니다. 이것은 매우 혼란스러워 보입니다. 다른 접두어가있는 많은 대상을 많이 추가해야합니다.
귀하의 도움에 감사 드리며 접두사는'copy_official_'입니다! – portforwardpodcast