creating two binary from 1 makefile

This is a discussion on creating two binary from 1 makefile within the C Programming forums, part of the General Programming Boards category; below is the code I have: Code: receiver: receiver.o gcc -Wall receiver.o -o receiver receiver.o: receiver.c gcc -Wall -c receiver.c ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    569

    creating two binary from 1 makefile

    below is the code I have:

    Code:
    receiver: receiver.o
    	gcc -Wall receiver.o -o receiver
    receiver.o: receiver.c
    	gcc -Wall -c receiver.c
    sender: sender.o
    	gcc -Wall sender.o -o sender
    sender.o: sender.c
    	gcc -Wall -c sender.c
    
    clean:
    	/bin/rm -rf *.o sender receiver
    I want to create sender and receiver at the same time when I type in make, how can I do this?

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    just add another target like all
    if you put it before all the other targets it will become the default target
    Code:
    all: receiver sender
    
    receiver: receiver.o
    	gcc -Wall receiver.o -o receiver
    receiver.o: receiver.c
    	gcc -Wall -c receiver.c
    sender: sender.o
    	gcc -Wall sender.o -o sender
    sender.o: sender.c
    	gcc -Wall -c sender.c
    
    clean:
    	/bin/rm -rf *.o sender receiver
    Kurt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a Makefile
    By Tom_Arch in forum C Programming
    Replies: 1
    Last Post: 04-26-2009, 05:51 AM
  2. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 08:40 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21