Makefile Syntax – What Does $(number) Mean in a Makefile?

make

I have some script and I didn't understand a line which contains $(1):

wget --retry-connrefused --waitretry=5 --read-timeout=30 --tries=50 --no-dns-cache https://dataverse.harvard.edu/api/access/datafile/:persistentId?persistentId=doi:$(1) -O data/tmp.tar.gz

What does $(1) represent?

Best Answer

$(1) is the first argument to a GNU make “function”, which is a variable interpreted by the call function:

define dataverse_download
    wget --retry-connrefused --waitretry=5 --read-timeout=30 --tries=50 --no-dns-cache https://dataverse.harvard.edu/api/access/datafile/:persistentId?persistentId=doi:$(1) -O data/tmp.tar.gz
    cd data && tar -xzf tmp.tar.gz
    rm -f data/tmp.tar.gz
endef

download_wget:
    mkdir -p data
    $(call dataverse_download,10.7910/DVN/IA8UOS/URG8XN)
    $(call dataverse_download,10.7910/DVN/IA8UOS/1DBE7K)
    $(call dataverse_download,10.7910/DVN/IA8UOS/34QRHK)

This defines a function, dataverse_download, which downloads the datafile matching the DOI given as the first argument; the download_wget target shows how to use this with the $(call) function.