LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Comparing 2 files in linux makefile system (https://www.linuxquestions.org/questions/linux-newbie-8/comparing-2-files-in-linux-makefile-system-741349/)

akkigupta 07-20-2009 04:32 AM

Comparing 2 files in linux makefile system
 
Hi all,

I want to copy one file from source folder to destination folder using Makefile in Linux enviornment. I want to make sure it happens only if destination folder doesnt have updated file.

Can you guide me how can i compare 2 files in makefile?

Tinkster 07-20-2009 04:53 AM

Hi,

Welcome to LQ!

And while this certainly could be achieved with make ...
why don't you use a tool that's designed for that task,
like for example rsync or unison?



Cheers,
Tink

akkigupta 07-20-2009 04:59 AM

Hi Tinkster, Thanks for your reply.

I was seeing the usage of the tools you mentioned. But it doesnt seems applicable to my enviornment. My enviornment already has the makefile system, which we are using to build a binary. In that we require to copy certain configuration file, if there is any updation. So looking for such kind of solution.

Can you tell me how we can achieve the same ?

Valery Reznic 07-21-2009 02:47 AM

Quote:

Originally Posted by akkigupta (Post 3613583)
Hi all,

I want to copy one file from source folder to destination folder using Makefile in Linux enviornment. I want to make sure it happens only if destination folder doesnt have updated file.

Can you guide me how can i compare 2 files in makefile?

After all make run regular commands.
You can use
Code:

cmp $(SRC_FILE) $(DST_FILE) 2>/dev/null || cp -f $(SRC_FILE) $(DST_FILE)


All times are GMT -5. The time now is 11:48 AM.