[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Optimization in gcc



On Sat, Oct 07, 2000 at 04:52:17PM +0530, Madhu M. Kurup wrote:
> Hi,
> 
> 	I am stuck with an odd sort of problem and I was wondering if I could get some help. I need to be able to switch on optimizations without using either a makefile or using command line arguments. Is this possible, at all? the problem can be viewed as this. If I ship a file x1.cpp to a user and all he needs to type is
> 	make x1

make -p and looking for CXX:

CXX = g++
LINK.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c

%.o: %.cc
#  commands to execute (built-in):
	$(COMPILE.cc) $< $(OUTPUT_OPTION)

> make will automatically compile it. Now I want the compiled code to
> use as many optimizations as it can on the target machine. This is of
> course the equivalent of doing a
>	g++ -O2 x1.cpp -o x1
> or something similar.

CXXFLAGS = -O2 in your Makefile will do it.

	-Arun