labs-edaf30/lab1/Makefile
2024-11-12 12:53:50 +01:00

58 lines
1.4 KiB
Makefile

# Define the compiler and the linker. The linker must be defined since
# the implicit rule for linking uses CC as the linker. g++ can be
# changed to clang++.
CXX = g++
CC = $(CXX)
# Generate dependencies in *.d files
DEPFLAGS = -MT $@ -MMD -MP -MF $*.d
# Define preprocessor, compiler, and linker flags. Uncomment the # lines
# if you use clang++ and wish to use libc++ instead of GNU's libstdc++.
# -g is for debugging.
CPPFLAGS = -std=c++11 -I.
CXXFLAGS = -O2 -Wall -Wextra -pedantic-errors -Wold-style-cast
CXXFLAGS += -std=c++11
CXXFLAGS += -g
CXXFLAGS += $(DEPFLAGS)
LDFLAGS = -g
#CPPFLAGS += -stdlib=libc++
#CXXFLAGS += -stdlib=libc++
#LDFLAGS += -stdlib=libc++
# Targets
PROGS = test_editor test_coding print_argv hello encode decode
all: $(PROGS)
test: test_coding test_editor
./test_coding
./test_editor
./hello
test_encode_decode: encode decode
@echo "Running encode-decode tests"
./encode testfile.txt
./decode testfile.txt.enc
# Targets rely on implicit rules for compiling and linking
print_argv: print_argv.o
test_editor: test_editor.o editor.o
test_coding: test_coding.o coding.o
encode: encode.o coding.o
decode: decode.o coding.o
# Phony targets
.PHONY: all test test_encode_decode clean distclean
# Standard clean
clean:
rm -f *.o $(PROGS)
distclean: clean
rm *.d
# Include the *.d files
SRC = $(wildcard *.cc)
-include $(SRC:.cc=.d)