makefile - How should I link libraries in automake normally linked with pkg-config? -
i'm trying project buildable automake. while using allegro5.
i can build code using following command fine
g++ -std=c++0x *.cpp -o mygame $(pkg-config --libs allegro-5.0 \ allegro_acodec-5.0 allegro_audio-5.0 allegro_color-5.0 allegro_dialog-5.0 \ allegro_font-5.0 allegro_image-5.0 allegro_main-5.0 allegro_memfile-5.0 \ allegro_physfs-5.0 allegro_primitives-5.0 allegro_ttf-5.0)
but makefile not work.
here src/makefile.am
bin_programs = mygame am_cxxflags = "-std=c++0x" mygame_sources = animation.cpp body.cpp gameobject.cpp menu.cpp vector3.cpp \ arena.cpp button.cpp keyboard.cpp mesh.cpp assets.cpp character.cpp \ main.cpp mouse.cpp barrier.cpp environment.cpp manager.cpp titlemenu.cpp mygame_ldadd = allegro-5.0 allegro_acodec-5.0 allegro_audio-5.0 \ allegro_color-5.0 allegro_dialog-5.0 allegro_font-5.0 allegro_image-5.0 \ allegro_main-5.0 allegro_memfile-5.0 allegro_physfs-5.0 \ allegro_primitives-5.0 allegro_ttf-5.0 cleanfiles = mygame *.o
and here configure.ac
ac_init(bayou, 0.1.0) am_init_automake ac_lang_cplusplus ac_prog_cxx lt_init ac_output( makefile \ src/makefile\ )
running first command works fine. running make gives me
make: *** no rule make target `allegro-5.0', needed 'mygame'. stop.
so how should set configure.ac , makefile.am's can use libraries link pkg-config?
pkg-config
there tell dynamically paths/flags use. meant used dynamically, rather run on development machine , copy'n'paste makefile , expect run on deployment machine.
here's updated makefile.am
, based on own answer:
bin_programs = mygame am_cxxflags = "-std=c++0x" pkglibs=allegro-5.0 \ allegro_acodec-5.0 allegro_audio-5.0 allegro_color-5.0 allegro_dialog-5.0 \ allegro_font-5.0 allegro_image-5.0 allegro_main-5.0 allegro_memfile-5.0 \ allegro_physfs-5.0 allegro_primitives-5.0 allegro_ttf-5.0 mygame_cxxflags = $(shell pkg-config --cflags $(pkglibs)) $(am_cxxflags) mygame_ldadd = $(shell pkg-config --libs $(pkglibs)) mygame_sources = animation.cpp body.cpp gameobject.cpp menu.cpp vector3.cpp \ arena.cpp button.cpp keyboard.cpp mesh.cpp assets.cpp character.cpp \ main.cpp mouse.cpp barrier.cpp environment.cpp manager.cpp titlemenu.cpp
it might in setup, entire allegro-foo doesn't need special compiler-flags, might need some. therefore example sets compiler-flags program (mygame_cxxflags
). finally, get's rid of unneeded cleanfiles
.
also, go autotools route, , use pkg_check_modules
macro in configure.ac
Comments
Post a Comment