
-----------------------------------
abcdefghijklmnopqrstuvwxy
Thu Jan 18, 2007 11:33 pm

bash script or makefile question
-----------------------------------
whenever I want to compile a project that uses SDL functions I have to type this:  


[#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`?

-----------------------------------
wtd
Fri Jan 19, 2007 12:23 am

RE:bash script or makefile question
-----------------------------------
You would simply add that to a variable like CXX_FLAGS.

-----------------------------------
abcdefghijklmnopqrstuvwxy
Fri Jan 19, 2007 12:29 am

RE:bash script or makefile question
-----------------------------------
so like?

#makefile
###########
# build options
CXX_Flags = sdl-config --libs --cflags



-----------------------------------
rdrake
Fri Jan 19, 2007 12:46 am

RE:bash script or makefile question
-----------------------------------
something like the following is often used:
##########
# 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.cRemember the 8 spaces should be converted to a real tab.

-----------------------------------
abcdefghijklmnopqrstuvwxy
Fri Jan 19, 2007 12:46 am

RE:bash script or makefile question
-----------------------------------
the above didn't work.  instead i did

# rules
#

program.exec:
          g++ `sdl-config --libs --cflags`


-----------------------------------
rdrake
Fri Jan 19, 2007 12:47 am

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
Fri Jan 19, 2007 1:02 am

RE:bash script or makefile question
-----------------------------------
rdrake, first thanks, second you also need the `.  


CXX=g++
CXXFLAGS=`sdl-config --libs --cflags`


-----------------------------------
md
Fri Jan 19, 2007 1:42 am

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.

-----------------------------------
abcdefghijklmnopqrstuvwxy
Fri Jan 19, 2007 2:39 am

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
Fri Jan 19, 2007 11:09 am

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
Fri Jan 19, 2007 11:16 am

RE:bash script or makefile question
-----------------------------------
Yes, you do need the backticks as they take the commend inside, execute it, and return its output.
