Talk:Makefile: Difference between revisions

Content deleted Content added
→‎Proper use of CFLAGS: use of += instead of =
Combuster (talk | contribs)
Re: CFLAGS
Line 122:
I know that using CFLAGS like I did is frowned upon, as it overwrites any environment variable the user might have set. Since I don't feel the pressure in PDCLib, and don't have any other C/C++ project using Makefiles at the moment... does anyone have a canon / working alternative? -- [[User:Solar|Solar]] 03:01, 25 May 2012 (CDT)
 
:My personal solution is to have a different named set of flags and append CFLAGS as appropriate:
:How about CFLAGS += ...? e.g.
<pre>
CFLAGS += -g -Wall
 
CPARAMS := "-m32 -DNEEDED_DEFINE -DOTHER_DEFINE -Wall -Wextra -fno-omit-frame-pointer"
make
(...)
gcc -g -Wall -o test test.c
%.o: %.c
$(CC) $(CFLAGS) $(CPARAMS) -c -o $@ $<
 
:Which under many circumstances has exactly the intended effect, but it does little to prevent conflicting params/flagsets other than hoping they override in order. - [[User:Combuster|Combuster]] 15:00, 25 May 2012 (CDT)
CFLAGS=-O3 make
gcc -O3 -g -Wall -o test test.c
</pre>
:Obviously this can lead to errors if the user-specified flags conflict with those you specify. [[User:Jnc100|John]] 06:02, 25 May 2012 (CDT)
Return to "Makefile" page.