Skip to content

Instantly share code, notes, and snippets.

@sondr3

sondr3/Makefile Secret

Created September 25, 2019 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sondr3/50a418923f125dba94d1011b74c28d7d to your computer and use it in GitHub Desktop.
Save sondr3/50a418923f125dba94d1011b74c28d7d to your computer and use it in GitHub Desktop.
tasksCPP := task1.cpp task2.cpp task3.cpp
tasksHPP := $(subst .cpp,.hpp,$(tasksCPP))
tasksBin := $(subst .cpp,.o,$(tasksCPP))
ENVIRONMENT := $(shell basename $(abspath $(dir $$PWD)))
SEP := "==========================================================\\n==> "
LTHREAD =""
default: all
%.o : %.cpp
@echo "[-] Compiling: $<"
@if ! g++ -std=c++2a -pthread $< -o $@ $(LTHREAD) -Wfatal-errors -w ; then \
echo "[!] [ $(ENVIRONMENT) ] [ $< ] [ reason: G++ FAIL! ]";\
echo " Do the check:\\n $$ (cd $$PWD && g++ -std=c++2a -pthread $< -o $@)"; \
else \
echo "[-] Running "; \
if ! ./$@; then \
echo " [!] [ $(ENVIRONMENT) ] [ $< ] [ reason: Test FAIL! ]";\
echo " Do the check:\\n. $$ $$PWD/$@"; \
else echo "[OK] [ $(ENVIRONMENT) ] [ $< ] ";\
fi;\
fi;
.PHONY: clean
clean:
@find . -name "*.o" -delete -print
@rm -f $(ENVIRONMENT).zip
.PHONY: all
all : $(tasksCPP)
make $(tasksBin)
.PHONY: zip
zip:
zip -r $(ENVIRONMENT).zip . -x Makefile
# J.⏎
$ make
make task1.o task2.o task3.o
make[1]: Entering directory '/home/sondre/Code/UiB/INF214/oblig1'
[-] Compiling: task1.cpp
g++: error: : No such file or directory
g++: error: unrecognized command line option ‘-std=c++2a’; did you mean ‘-std=c++03’?
[!] [ oblig1 ] [ task1.cpp ] [ reason: G++ FAIL! ]
Do the check:\n $ (cd /home/sondre/Code/UiB/INF214/oblig1 && g++ -std=c++2a -pthread task1.cpp -o task1.o)
[-] Compiling: task2.cpp
g++: error: : No such file or directory
g++: error: unrecognized command line option ‘-std=c++2a’; did you mean ‘-std=c++03’?
[!] [ oblig1 ] [ task2.cpp ] [ reason: G++ FAIL! ]
Do the check:\n $ (cd /home/sondre/Code/UiB/INF214/oblig1 && g++ -std=c++2a -pthread task2.cpp -o task2.o)
[-] Compiling: task3.cpp
g++: error: : No such file or directory
g++: error: unrecognized command line option ‘-std=c++2a’; did you mean ‘-std=c++03’?
[!] [ oblig1 ] [ task3.cpp ] [ reason: G++ FAIL! ]
Do the check:\n $ (cd /home/sondre/Code/UiB/INF214/oblig1 && g++ -std=c++2a -pthread task3.cpp -o task3.o)
make[1]: Leaving directory '/home/sondre/Code/UiB/INF214/oblig1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment