- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Makefile Error
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2007 01:21 AM
тАО07-31-2007 01:21 AM
Makefile Error
1)I have written a small C- Program and wtitten the following makefile.
CC = cc
CFLAGS = -o
OBJS = Test.o
TARGET = Test
Test : $(OBJS)
# echo "Hello"
$(CC) -o $@ $+
%.o : Test.c
#echo $+
$(CC) -c $+
clean : Test Test.o
rm Test Test.o
If i run the Makefile i m not able to
get the exe Test.
It says
bash-2.04$ make -f TestMakefile
cc -o -c Test.c
cc: error 1410: Illegal name for output file: "-c".
*** Error exit code 8
I am not understanding what i have missed here.
2)Also i want to write a Makefile wherein i can test the conditions
for ex- if ($Var1)
CC Test.c
else($Var2)
GCC Test.c
I know (please correct me if i m wrong) i cant write the if loops in Makefile .
But, i want to know how can i achieve the above goal in Makefile.
Please suggest some solutions to these problems .
thanks and regards
Vikram
- Tags:
- make
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2007 01:29 AM
тАО07-31-2007 01:29 AM
Re: Makefile Error
Doesn't -o need to be followed immediately with the output filename? Something like cc -o test -c test.c
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2007 04:36 AM
тАО07-31-2007 04:36 AM
Re: Makefile Error
> with the output filename? [...]
Exactly. Typically, when "cc -c" isn't good
enough, the "make" file will include an
explict rule which includes the "-o" option.
For example, to create both fred.o and
fred_.o from fred.c (using an additional
"-DUTIL" for fred_.o):
.SUFFIXES:
.SUFFIXES: _.o .o .c
.c_.o:
$(CC) -c $(CFLAGS) -DUTIL -o $@ $<
.c.o:
$(CC) -c $(CFLAGS) $<
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2007 09:05 PM
тАО07-31-2007 09:05 PM
Re: Makefile Error
CC can be set in the environment variable
export CC=aCC
or
export CC=cc
[code]
#CC=cc This is commented here.
SOURCE=Test.c
OBJS=$(SOURCE:.c=.o)
BUILD=$(OBJS:.o=)
$(BUILD): $(OBJS)
@[[ "$$CC" != "cc" ]] ; \
echo SOURCE set ; \
echo $(SOURCE) ; \
echo "BUILDING ... " $@
$(CC) $(OBJS) -o Test
$(OBJS): $(SOURCE)
$(CC) +DAportable -c $(SOURCE)
clean:
rm -f $(BUILD) $(OBJS)
[/code]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2007 12:10 AM
тАО08-01-2007 12:10 AM
Re: Makefile Error
Perhaps you have a typo and mean the typically CFLAGS default of -O, for optimization?
>2)Also i want to write a Makefile wherein i can test the conditions
You can only do that in gmake.
>MurugesanGCT: CC can be set in the environment variable
Typically this is not a good practice. It is better if you put it on the make command line:
$ make CC=cc
(And don't even think of using -e. ;-)