Project-3/src/Makefile
2023-10-13 15:37:26 +02:00

48 lines
862 B
Makefile

CC=g++
LIBSRCS=utils.cpp
LIBOBJS=$(LIBSRCS:.cpp=.o)
CLASSSRCS=PenningTrap.cpp Particle.cpp
CLASSOBJS=$(CLASSSRCS:.cpp=.o)
INCLUDE=../include
CFLAGS=-Wall -larmadillo -llapack -std=c++11 -O3
OPENMP=-fopenmp
# Add a debug flag when compiling (For the DEBUG macro in utils.hpp)
DEBUG ?= 0
ifeq ($(DEBUG), 1)
DBGFLAG=-DDBG
else
DBGFLAG=
endif
PROFILE ?= 0
ifeq ($(PROFILE), 1)
PROFFLAG=-pg
else
PROFFLAG=
endif
.PHONY: clean
all: test_suite main
# Rules for executables
main: main.o $(LIBOBJS) $(CLASSOBJS)
$(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP)
test_suite: test_suite.o $(LIBOBJS) $(CLASSOBJS)
$(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP)
# Rule for object files
%.o: %.cpp
$(CC) -c $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP)
clean:
rm *.o
rm test_suite
rm main