how to compile multiple programs using single Makefile?

Hello.

The following Makefile in LINUX should compile two unrelated programs. but for some reason it only complies my_uname1 but not my_uname2. I know the reason has to do with primary target which is my_uname1: but then how can i compile to saperate programs? how can i make it work?

That is not what I said :rolleyes: . The 'all' target is a separate rule additional to your existing rules, not in place of them. The dependencies of 'all' should be the other two targets, not the two object files. There are no commands associate with 'all'. Making the target 'all' will then force both my_uname targets to be evaluated. Just add the 'all' rule as I posted it, and leave the other rules as they were.

# you are not using the power of make.
# make is not a shell, it's a tool. it pourpose is to make IF there
# is something to make :)
# put in aaa.c:
#

Code:

int main(int argc,char **argv){ exit(printf("HALLO %s\n",*argv)); }

#
# bbb.c and ccc.c have to be present, maybe empty (does not matter)
# put the code below in [Mm]akefile and try twice 'make'
# the 1. time it compiles, the second NOT
# then touch bbb.c and retry 'make'
# to force remaking enter: make clean
#
# NOTA: this is a small exemple, i would use libs and other features.
# pay attentions on tabs '\t' they are significant in makefiles.
#

# you are not using the power of make.
# make is not a shell, it's a tool. it pourpose is to make IF there
# is something to make :)
# put in aaa.c:
#

Code:

int main(int argc,char **argv){ exit(printf("HALLO %s\n",*argv)); }

#
# bbb.c and ccc.c have to be present, maybe empty (does not matter)
# put the code below in [Mm]akefile and try twice 'make'
# the 1. time it compiles, the second NOT
# then touch bbb.c and retry 'make'
# to force remaking enter: make clean
#
# NOTA: this is a small exemple, i would use libs and other features.
# pay attentions on tabs '\t' they are significant in makefiles.
#