Created
October 28, 2016 14:17
-
-
Save Clumsy-Coder/4de8cae3e845728c2d169aaa3e1e429d to your computer and use it in GitHub Desktop.
Makefile for compiling one C++ file. Used for compiling problems from uva or uhunt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC = g++ | |
CFLAGS = -Wall -g | |
MAKECMDGOALS := $(filter-out clean, $(MAKECMDGOALS)) | |
INCLUDE = -I./$(MAKECMDGOALS) | |
OBJS = $(MAKECMDGOALS).o | |
.PHONY: $(MAKECMDGOALS) clean | |
# command for compiling source file, removing any junk files | |
# and running the compiled file | |
# to use command, type the following | |
# make <filename> | |
# | |
# note: the command does not take file extentions. | |
# example: | |
# make helloWorld | |
# | |
# Assumes the source file is .cpp | |
$(MAKECMDGOALS): $(OBJS) | |
$(CC) $(CFLAGS) $^ -o Main-$@ | |
rm -rf *.o *~ *% *# .#* | |
./Main-$(MAKECMDGOALS) | |
%.o : %.cpp | |
$(CC) -c $(CFLAGS) $< | |
# for cleaning up the compiled file and any junk files. | |
# to use command, type the following: | |
# make clean | |
clean: | |
rm -rf *.o *~ *% *# .#* | |
rm Main-* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment