Author |
Message |
abcdefghijklmnopqrstuvwxy
|
Posted: Thu Jan 18, 2007 11:33 pm Post subject: bash script or makefile question |
|
|
whenever I want to compile a project that uses SDL functions I have to type this:
code: |
[#user@machine program] g++ `sdl-config --libs --cflags` program.cpp -o program
|
using a makefile or a script is there a pragmatic way to compile without the `sdl-config --libs --clfags`? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
wtd
|
Posted: Fri Jan 19, 2007 12:23 am Post subject: RE:bash script or makefile question |
|
|
You would simply add that to a variable like CXX_FLAGS. |
|
|
|
|
|
abcdefghijklmnopqrstuvwxy
|
Posted: Fri Jan 19, 2007 12:29 am Post subject: RE:bash script or makefile question |
|
|
so like?
code: |
#makefile
###########
# build options
CXX_Flags = sdl-config --libs --cflags
|
|
|
|
|
|
|
rdrake
|
Posted: Fri Jan 19, 2007 12:46 am Post subject: RE:bash script or makefile question |
|
|
something like the following is often used:
code: | ##########
# Variables
CXX=g++
CXXFLAGS=sdl-config --libs --cflags
##########
# Make it all
all : program.o
$(CXX) program.o -c program.exe
program.o :
$(CXX) $(CXXFLAGS) program.c | Remember the 8 spaces should be converted to a real tab. |
|
|
|
|
|
abcdefghijklmnopqrstuvwxy
|
Posted: Fri Jan 19, 2007 12:46 am Post subject: RE:bash script or makefile question |
|
|
the above didn't work. instead i did
[EDIT: When i say the above I meant my post.]
code: |
# rules
#
program.exec:
g++ `sdl-config --libs --cflags`
|
|
|
|
|
|
|
rdrake
|
Posted: Fri Jan 19, 2007 12:47 am Post subject: RE:bash script or makefile question |
|
|
Since my post had just been replied to, I cannot change it. The "-c" option in my example should be "-o". |
|
|
|
|
|
abcdefghijklmnopqrstuvwxy
|
Posted: Fri Jan 19, 2007 1:02 am Post subject: RE:bash script or makefile question |
|
|
rdrake, first thanks, second you also need the `.
code: |
CXX=g++
CXXFLAGS=`sdl-config --libs --cflags`
|
|
|
|
|
|
|
md
|
Posted: Fri Jan 19, 2007 1:42 am Post subject: RE:bash script or makefile question |
|
|
Yes, you still need the quotes for it to work; but you can easily add it to your CXX_FLAGS. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
abcdefghijklmnopqrstuvwxy
|
Posted: Fri Jan 19, 2007 2:39 am Post subject: RE:bash script or makefile question |
|
|
They aren't quotes. As someone not too savy with bash I dont know exactly what they do, but I know that they are accents (the tild key) and that single quotes will NOT work. |
|
|
|
|
|
md
|
Posted: Fri Jan 19, 2007 11:09 am Post subject: RE:bash script or makefile question |
|
|
Yes, whatever; I call them quotes You should split it up though `sdl-config --cflags` goes in CXX_FLAGS and `sdl-config --libs` goes in LD_FLAGS.
LD_FLAGS would be used where you take your object files and create an executable. |
|
|
|
|
|
wtd
|
Posted: Fri Jan 19, 2007 11:16 am Post subject: RE:bash script or makefile question |
|
|
Yes, you do need the backticks as they take the commend inside, execute it, and return its output. |
|
|
|
|
|
|