Article View: ahn.tech.linux
Article #128Re : ifdef FEATURE_1
From: Marc-Olivier SAMBO
Date: Sat, 06 Oct 2007 21:04
Date: Sat, 06 Oct 2007 21:04
50 lines
1644 bytes
1644 bytes
#ifdef FEATURE_1
Message envoyοΏ½ : lundi 2 aout 2004 01:34
> // Do feature 1 stuff
> #endif
> Is there a way to do this without manually specifying each feature
> flag as an environment variable and a -D flag separately? I'd like to
> avoid having to keep each thing in sync.
Try something like this:
# --- GNU Makefile ---
# invoke with e.g.
# make FEATURES="FEATURE_1 FEATURE_2"
OBJ = main.o
ifneq ($(filter FEATURE_1,$(FEATURES)),)
OBJ += feature1.o
endif
ifneq ($(filter FEATURE_2,$(FEATURES)),)
OBJ += feature2.o
endif
CFLAGS += $(patsubst %,-D%,$(FEATURES))
prog : $(OBJ)
$(CC) -o $@ $^
clean : ; rm -f prog *.o
# --- END ---
Marc-Olivier SAMBO
--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
Technical Details
Message-ID:
<4707f8b7$0$10639$426a74cc@news.free.fr>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!cleanfeed3-b.proxad.net!nnrp5-2.free.fr!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11033e,6e30dd4bb22e9ac,start X-Google-Attributes: gid11033e,public,usenet X-Google-Language: ENGLISH,ASCII Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!cleanfeed3-b.proxad.net!nnrp5-2.free.fr!not-for-mail From: "Marc-Olivier SAMBO" <mosambo@accenture.com> Subject: Re : ifdef FEATURE_1 Newsgroups: ahn.tech.linux Date: Sat, 6 Oct 2007 23:04:48 +0200 Lines: 51 Message-ID: <4707f8b7$0$10639$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 06 Oct 2007 23:05:59 MEST NNTP-Posting-Host: 82.243.237.163 X-Trace: 1191704759 news-3.free.fr 10639 82.243.237.163:54039 X-Complaints-To: abuse@proxad.net