Thread: Gnu Makefile help

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    1

    Gnu Makefile help

    I'm having an issue with my makefile. I'm new to building Makefiles, so forgive my ignorance. I have a project with several nested directories. The code in the directories are compiled into libraries, and then linked at the top level. Everything worked great when I output one executable.

    Now I want to create two different executables with different compiler options. Here's a snippet of the makefile:

    Code:
    BUILD_A_EXECUTABLE = mw_A_exec
    BUILD_B_EXECUTABLE = mw_B_exec
    
    all :
            $(MAKE) build_a build_b
    
    build_a : $(DIRS)
            $(MAKE) $(BUILD_A_EXECUTABLE)
    
    build_b : $(DIRS)
            $(MAKE) $(BUILD_B_EXECUTABLE)
    
    ...
    
    ############## BUILD A ##############
    ifeq ($(MW_TYPE_A),1)
    
    CPPFLAGS = -g -Wall $(INCLS) \
             -DDtHLA=1 -DRTI_USES_STD_FSTREAM 
    else ########## BUILD B ##############
    
    CPPFLAGS = -g -Wall $(INCLS) \
             -DDtDIS=1
    endif
    How can I define MW_TYPE_A = 1 only when I'm creating BUILD_A_EXECUTABLE and not when I'm building BUILD_B_EXECUTABLE?

    Any help would be great! Thanks.

    tjkrz

  2. #2
    Registered User
    Join Date
    May 2005
    Posts
    2
    Hi ,

    If I got ur problem correctly.....The solution would be...do this while running makefile

    $ make MW_TYPE_A = 1
    or
    $ make MW_TYPE_A = 2

    Bi....Hope it works....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with makefile
    By New_Programmer in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2009, 04:55 PM
  2. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 11:50 PM
  3. Simple GNU Makefile
    By OriginalCopy in forum Linux Programming
    Replies: 5
    Last Post: 05-14-2008, 12:17 PM
  4. makefile blues....
    By WaterNut in forum C Programming
    Replies: 6
    Last Post: 05-30-2005, 08:22 PM
  5. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM