GNU install -d recursive

coreutilsmake

I have 3 commands to create the folders necessary in a Makefile:

    install -d $(DESTDIR)/usr/lib/app
    install -d $(DESTDIR)/usr/lib/app/scripts
    install -d $(DESTDIR)/usr/lib/app/scripts/network-service

Is there a flag I can use to put this into a single line?

Best Answer

Only the last command should be necessary. install -d will create the missing intermediate directories:

install -d "$(DESTDIR)/usr/lib/app/scripts/network-service"

From the GNU install manual:

-d, --directory

treat all arguments as directory names; create all components of the specified directories

For what it's worth, BSD install also works like this:

-d

Create directories. Missing parent directories are created as required. This option cannot be used with the -B, -b, -C, -c, -f, -p, -S, or -s options.

Related Question