Find the answer to your Linux question:
Results 1 to 1 of 1
Hi there. I'm trying to write a makefile for a sample program i'm writing. I wanted to use a dependency list, for it to correctly recompile any source code when ...
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Posts
    1

    Makefile help

    Hi there. I'm trying to write a makefile for a sample program i'm writing.
    I wanted to use a dependency list, for it to correctly recompile any source code when it's outdated.
    Unfortunately, something here is not working.

    This is the makefile. As you can see, it's quite simple

    Code:
    CC=g++
    PROJECT=DatabaseTest
    TESTAPP=Output/$(PROJECT)
    
    DATABASE_SOURCES=SimpleDatabase.cpp
    DATABASE_HEADERS=SimpleDatabase.h
    DATABASE_OBJECTS=Output/SimpleDatabase.o
    
    TEST_SOURCES=$(PROJECT).cpp
    TEST_OBJECTS=Output/$(PROJECT).o
    OPTS=-g -I ../Common
    
    default: test
    
    include Dependencies
    
    database : $(DATABASE_OBJECTS)
    test : $(TESTAPP)
    
    deps:
    	@g++ $(OPTS) -MM Source/*.cpp > Dependencies
    	@g++ $(OPTS) -MM Test/*.cpp >> Dependencies
    
    $(TESTAPP) : $(TEST_OBJECTS) $(DATABASE_OBJECTS)
    	@echo ------------
    	@echo LINKING TEST
    	@echo ------------
    	$(CC) $(OPTS) $(DATABASE_OBJECTS) $(TEST_OBJECTS) -o $(TESTAPP)
    
    %.o: %.cpp %.h
    	@echo Compiling $< into $*
    	$(CC) $(OPTS) -c $< -o $*.o
    
    clean:
    	@echo Cleaning up $(PROJECT)
    	@rm -f Output/*
    	@rm -f *.o
    
    
    clean_backup:
    	@echo Cleaning up backups
    	@rm -f Source/*.bak
    Attached is my current makefile and source.
    The problem is that it doesn't even try to compile the code.

    I wanted the code to be in one folder, and the output of it on another. Source on ./Source, and the output in ./Output. Is that too much???
    Thanks for any help.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...