I have the following makefile which I run to compile the mex functions:

```
    SRC:=$(wildcard ./source/*.c)
    all: $(SRC)
            for file in $^ ; do \
            mex -outdir matlab/ -output $@ $$file CC=mpicc CXX=mpicxx COPTIMFLAGS="-O2 -DNDEBUG" LDOPTIMFLAGS="-O2"; \
            done
    .PHONY: clean
    clean:
            rm ./matlab/*.mexa64

```

The code compiles all the files even if I modified one.  

I had created a makefile thinking only the modified files would be compiled and not all of them.
I am presently unable to find a way to do this. Compiling all files for the slightest change made to one of them is highly time consuming as I have around 50 files to compile.  

Any help is appreciated.  

Let me know if I am being unclear anywhere.