bodokaiser
bodokaiser

Reputation: 15752

Cannot copy files of directory into other directory

I have a Makefile which should copy all dot files for me into the home directory. Unfortunately GNUMake does not support wildcards as used in bash and the common wildcards $(wildcard *.c) are limited to special file types.

My Makefile is:

SHELL := /bin/bash

profile:
    @cp -r profile/ $(HOME)/

.PHONY: profile

Other variations I tried so far:

  1. cp -r profile/* $(HOME) => cp: cannot stat profile/*: No such file or directory
  2. cp -r profile/$(wildcard *) $(HOME) => tries to copies all files in the current directory
  3. cp -r $(wildcard profile/*) $(HOME)/ => cp: missing destination file operand after /home/foobar
  4. cp -r $(wildcard profile/*) $(HOME)/$(wildcard profile/*) =>cp: missing destination file operand after /home/foobar`

Upvotes: 2

Views: 2050

Answers (1)

Sagar Sakre
Sagar Sakre

Reputation: 2426

Try The shell Function using direct shell commands in makefile

profile:
    $shell(cp -r profile/* $(HOME)/)

.PHONY: profile

Otherwise set HOME variable at the beggining like this

SHELL := /bin/bash
HOME  := $(shell echo $HOME)
profile:
    @cp -r profile/* $(HOME)/

.PHONY: profile

Upvotes: 3

Related Questions