title: Makefile, using mpiCC compiler for main.cpp and g++ for other functions of the src code
body: <p>I have created a source code in C++ and I want to compile it by using <strong>makefiles</strong>. The problem is that I want my main functions to compile with <strong>mpiCC</strong> and the other functions to compile with <strong>g++</strong>. Is this possible?</p>
  
  <p>What should I change in the following makefile?</p>
  
  <p>Thanks in advance, </p>
  
  <p>Ilias</p>
  
  <pre><code>.PHONY: all clean
  
  CC=mpiCC #g++
  CFLAGS=-c -O3
  
  LOCAL_INC_PATH = ../include
  
  SOURCES= main.cpp \
           f1.cpp \
           f2.cpp 
  
  OBJECTS=$(patsubst %.cpp,%.o,$(SOURCES))
  
  LIP = $(LOCAL_INC_PATH)
  
  HEADERS = $(LIP)/func_all.h
  
  all: $(OBJECTS)
      $(CC) $^ -o MIE -I$(LOCAL_INC_PATH)
  
  %.o: %.cpp
      $(CC) $(CFLAGS) $^ -I$(LOCAL_INC_PATH)
  
  clean:
      rm *.$(OBJECTS)
  </code></pre>