LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-16-2015, 03:55 AM   #1
poplinux
Member
 
Registered: May 2012
Posts: 111

Rep: Reputation: Disabled
Question for $(wildcard) on Makefile


Dear Sir.

I'm want to use the $(wildcard) on my Makefile.

But i have a problem use the $(wildcard)

My directory is see below
Code:
$ > ls
1.c 2.c 3.c
My Makefile is see below.
Code:
$ > vi Makefile

SRC1="1.c"
SRC2="2.c"
SRC3="3.c"

STRING1=$(wildcard 1.c 2.c 3.c)
STRING2=$(wildcard *.c)
STRING3=$(wildcard $(SRC1) $(SRC2) $(SRC3))

all:
  @echo "STRING1 $(STRING1)"
  @echo "STRING2 $(STRING2)"
  @echo "STRING3 $(STRING3)"
And execute my Makefile

Code:
$ > make
STRING1 1.c 2.c 3.c
STRING2 1.c 2.c 3.c
STRING3

Quesiton
1. Why can't see the STRING3 ?
2. How can see the STRING3 ?


Thank you.
 
Old 03-16-2015, 04:15 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
It's the "quotes". Fixed:
Code:
SRC1 = 1.c
SRC2 = 2.c
SRC3 = 3.c

STRING1 = $(wildcard 1.c 2.c 3.c)
STRING2 = $(wildcard *.c)
STRING3 = $(wildcard $(SRC1) $(SRC2) $(SRC3))

all:
	@echo "STRING1 $(STRING1)"
	@echo "STRING2 $(STRING2)"
	@echo "STRING3 $(STRING3)"
 
Old 03-16-2015, 04:24 AM   #3
poplinux
Member
 
Registered: May 2012
Posts: 111

Original Poster
Rep: Reputation: Disabled
Dear NevemTeve.

Thank's your advice. It is very helpful for me.

But, my Make file can't ignore "quotes".

So, I'm resolved use this way.

Code:
SRC1="1.c"
SRC2="2.c"
SRC3="3.c"

STRING1=$(wildcard 1.c 2.c 3.c)
STRING2=$(wildcard *.c)
STRING3=$(wildcard $(subst ",,$(SRC1)) $(subst ",,$(SRC2)) $(subst ",,$(SRC3)))

all:
  @echo "STRING1 $(STRING1)"
  @echo "STRING2 $(STRING2)"
  @echo "STRING3 $(STRING3)"
Thank you.
 
Old 03-16-2015, 04:55 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Certainly, make doesn't ignore quotes. You added quotes where they didn't belong. Another example:

Code:
WITHOUT = I do not have qoutes
WITH    = "I have quotes"

all:
	printf 'WITHOUT=%s\nWITH=%s\n' '${WITHOUT}' '${WITH}'
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Apache / wildcard DNS / vhost question Red Squirrel Linux - Software 4 07-04-2014 12:09 PM
Question about a makefile axelfc Programming 5 10-08-2010 06:40 AM
makefile question ryande Linux - General 5 04-30-2010 12:11 AM
makefile question ashwin.tanugula Programming 2 10-26-2005 03:08 PM
Question about makefile taureanyang Programming 1 03-25-2005 11:57 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration