Skip to content
Advertisement

Transform a Commande Line Linux to a makefile [closed]

Is there anyone who can help me to transform this command line to a makefile :

gcc -o hello_ps hello_ps.c -DMODELDIR=”pkg-config –variable=modeldir pocketsphinx” pkg-config –cflags –libs pocketsphinx sphinxbase

THANK YOU.

Advertisement

Answer

Creating a dependency between the source and the executable you can have :

hello_ps: hello_ps.c
    gcc -o hello_ps hello_ps.c -DMODELDIR="pkg-config --variable=modeldir pocketsphinx" pkg-config --cflags --libs pocketsphinx sphinxbase

warning there is a tab before gcc, not spaces

Example (I do not have the environment to compile with these options) :

pi@raspberrypi:/tmp $ echo "whatever I do not compile" > hello_ps.c
pi@raspberrypi:/tmp $ make -n
gcc -o hello_ps hello_ps.c -DMODELDIR="pkg-config --variable=modeldir pocketsphinx" pkg-config --cflags --libs pocketsphinx sphinxbase
pi@raspberrypi:/tmp $ touch hello_ps
pi@raspberrypi:/tmp $ make -n
make: « hello_ps » is up to date.
pi@raspberrypi:/tmp $ touch hello_ps.c 
pi@raspberrypi:/tmp $ make -n
gcc -o hello_ps hello_ps.c -DMODELDIR="pkg-config --variable=modeldir pocketsphinx" pkg-config --cflags --libs pocketsphinx sphinxbase

Of course you can add more dependencies, with included header file(s), with libs etc.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement