Last active
December 10, 2015 11:19
-
-
Save satishgoda/4427215 to your computer and use it in GitHub Desktop.
A simple Makefile that I have written and use for my toy projects. http://www.gnu.org/software/make/
http://www.gnu.org/software/make/manual/make.html
This file contains 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
# Name of the project | |
# The binary file will use the name of the project! | |
PROJECT := $(shell basename $(shell pwd)) | |
# Header files | |
HEADERS = -I../../util/ | |
# C++ source files | |
SOURCES := $(shell find ./ -name "*.cpp") | |
# Object files corresponsing to the source files | |
OBJECTS := $(SOURCES:.cpp=.o) | |
# Compiler to use | |
CC = g++ | |
# Flags to use while compiling | |
CFLAGS = -Wno-deprecated -c | |
# Compile, Link and Run the Project | |
all: $(PROJECT) | |
./$(<).exe | |
# Create the binary ($@) by linking the object files ($<) after compilation is done. | |
$(PROJECT): $(OBJECTS) | |
$(CC) $< -o $@ | |
# Compile the source files ($<) into object files ($@) | |
.cpp.o: | |
$(CC) $(HEADERS) $(CFLAGS) $< -o $@ | |
# Cleanup object and binary files. | |
clean: | |
@rm -fv *.o | |
@rm -fv *.exe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment