-1

I already could compile different targets or flavours(debug release), but the problem is when I make: make debug or make release this generate objects and the library in the respective folder folder.

This is the Makefile.am:

AM_CXXFLAGS = @AM_CXXFLAGS@

ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}

lib_LIBRARIES = libInitDB.a

libInitDB_a_SOURCES = \
InitDB.cpp

.PHONY: debug release

debug:
    make CXXFLAGS='$(CXX_DEBUG_FLAGS) $(CXXFLAGS)'
    mkdir -p $(DEBUG_DIR)
    mv $(lib_LIBRARIES) $(DEBUG_DIR)/$(lib_LIBRARIES)
    mv *.o $(DEBUG_DIR)

release:
    make CXXFLAGS='$(CXX_RELEASE_FLAGS) $(CXXFLAGS)'
    mkdir -p $(RELEASE_DIR)
    mv $(lib_LIBRARIES) $(RELEASE_DIR)/$(lib_LIBRARIES)
    mv *.o $(RELEASE_DIR)    

but the problem is when I make: make debug or make release again, as I move the objects and the library, that generates again the objects and the library that already stored in the debug or release folder.

Could someone help me to find how to avoid this and when I compile that search in the correct folder?

kaiz.net
  • 1,984
  • 3
  • 23
  • 31

1 Answers1

2

Instead of having one Makefile generating both flavours of your targets, you could have two separate build directories configured with different options.

For example:

mkdir debug
(cd debug && ../configure --enable-debug)

mkdir release
(cd release && ../configure --enable-release)

This way, you can go to either directory and recompile only what is needed simply typing make.

François Févotte
  • 19,520
  • 4
  • 51
  • 74
  • Hi there, thanks for the answer, but would be possible that make something in the Makefile.am instead to call 2 times to configure.ac?, that would be really helpful for me. – arimaujinn Mar 23 '12 at 13:01
  • @arimaujinn No, I don't know of any way to do that and I actually do not want to know. Think about what you want: two different builds of the same sources, using different configuration options, each one with its own intermediate files (*.o) and final targets (libs and executables). This is exactly what build directories are for. Now nothing prevents you to automate the creation/configuration of your build directories using a `Makefile` in a directory above. – François Févotte Mar 23 '12 at 13:09