Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 657403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:49:12+00:00 2026-05-13T22:49:12+00:00

I am writing a makefile. However except for the path expansion and restrictions on

  • 0

I am writing a makefile. However except for the path expansion and restrictions on what I can do, this is basically a shell scripting question. As part of the make process, I want to copy a directory to the destination. My source directory and destination directory are variables, so I can’t assume a lot about them. They may be fully qualified, they may be relative.

But I want to copy the directory $(A) to the destination $(B). $(B) is the name I want the directory to have at the destination, not the directory I want to copy $(A) to (i.e. the resulting directory name will be $(B), not $(A)/$(B)), it might be the same path for source and dest, so I check with an ifneq ($(A),$(B)) before doing anything. But the question is, what do I do in the block.

If I do

cp -r $(A) $(B)

it will work the first time. $(A) is copied to $(B). But if the rule triggers again later, it will make a new copy of $(A) inside $(B) (i.e. $(B)/$(A)).

And before you ask, I’d rather not rm -r $(B) before doing this if at all possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:49:12+00:00Added an answer on May 13, 2026 at 10:49 pm

    cp -r $(A)/ $(B)

    Adding the slash will copy the contents of $(A) into $(B), and create $(B) if it does not exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing this question in part based on a related question on helper-scripts
I m writing a simple Makefile which looks like this CC=gcc CXX=g++ DEBUG=-g COMPILER=${CXX}
I have a newbie question for writing makefile for java in Linux I have
How would I go about writing a Makefile that would call, say, gedit hashtable.cpp
I'm new to the world of Makefile writing. I have a C project which
I'm writing a custom makefile project using QtCreator and I want to delete a
I am writing python scripts and execute them in a Makefile. The python script
Writing a python program, and I came up with this error while using the
I am writing installation in a Makefile in which I need to set the
I'm writing a makefile that compiles a .java file in a different directory, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.