[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Conditionally add parameters to CXXFLAGS
From: |
N Galpin |
Subject: |
Conditionally add parameters to CXXFLAGS |
Date: |
Sun, 2 Dec 2007 00:41:03 -0700 |
Hi
I'd like to define multiple build targets in my makefile, and depending
on which target I pass to make, add different flags to $(CXXFLAGS).
For example, if i run `make release` I'd like this target to append
-O3 onto CXXFLAGS, or if I run `make debug`, I'd like to append
-g etc.
I've spent some time searching through the man pages and the
archives, but I haven't found anything.
This is the makefile I've built. (No it's not a school assignment
despite what it looks like. It's actually a toy program I'm writing
to experiment with some things I'm not familiar with.)
CXXFLAGS = -Wall -pedantic-errors -ansi
CXX = g++
OBJS = unittest.o csudokupoint.o csudokupuzzle.o
RELEASE = SudokuSolver
DEBUG = SudokuSolverD
AUTOTEST = SudokuSolverUnitTest
RELEASE_DIR = ../release
DEBUG_DIR = ../debug
AUTOTEST_DIR = ../test
release: $(RELEASE)
debug: $(DEBUG)
autotest: $(AUTOTEST)
clean:
rm -f $(RELEASE_DIR)/*
rm -f $(DEBUG_DIR)/*
rm -f $(AUTOTEST_DIR)/*
clean-release:
rm -f $(RELEASE_DIR)/*
clean-debug:
rm -f $(DEBUG_DIR)/*
clean-autotest:
rm -f $(AUTOTEST_DIR)/*
$(RELEASE): $(OBJS)
$(CXX) $(OBJS) -o $(RELEASE)
mv $(OBJS) $(RELEASE) $(RELEASE_DIR)
$(DEBUG): $(OBJS)
$(CXX) $(OBJS) -o $(DEBUG)
mv $(OBJS) $(DEBUG) $(DEBUG_DIR)
$(AUTOTEST): $(OBJS)
$(CXX) $(OBJS) -o $(AUTOTEST)
mv $(OBJS) $(AUTOTEST) $(AUTOTEST_DIR)
unittest.o: unittest.cpp csudokupoint.cpp csudokupoint.h
csudokupoint.o: csudokupoint.cpp csudokupoint.h
csudokupuzzle.o: csudokupuzzle.cpp csudokupuzzle.h csudokupoint.cpp
csudokupoint.h
.PHONY: release debug test clean clean-release clean-debug clean-autotest
Thanks,
Nathanael
_________________________________________________________________
Discover new ways to stay in touch with Windows Live! Visit the City @ Live
today!
http://getyourliveid.ca/?icid=LIVEIDENCA006
- Conditionally add parameters to CXXFLAGS,
N Galpin <=