Create better Makefile

This commit is contained in:
Cory Balaton 2023-09-24 14:40:59 +02:00
parent 47f332a66c
commit dfb14b5c4a
No known key found for this signature in database
GPG Key ID: 3E5FCEBFD80F432B

View File

@ -1,18 +1,34 @@
INCLUDE=../include
CC=g++
CCFLAGS=-larmadillo -llapack -std=c++11
LIBSRCS=utils.cpp matrix.cpp jacobi.cpp
LIBOBJS=$(LIBSRCS:.cpp=.o)
INCLUDE=../include
CFLAGS=-larmadillo -llapack -std=c++11
DEBUG ?= 0
ifeq ($(DEBUG), 1)
DBGFLAG=-DDBG
else
DBGFLAG=
endif
DEBUG=-DDBG
.PHONY: clean
test_suite: test_suite.o matrix.o jacobi.o
$(CC) $^ -o $@ $(CCFLAGS) $(DEBUG)
all: test_suite main
# Rules for executables
main: main.o $(LIBOBJS)
$(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE)
test_suite: test_suite.o $(LIBOBJS)
$(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE)
# Rule for object files
%.o: %.cpp
$(CC) -c $^ -o $@ -I $(INCLUDE) $(DEBUG)
$(CC) -c $^ -o $@ $(DBGFLAG) -I$(INCLUDE)
clean:
rm *.o