$ wget https://git.io/v1TDX -O Makefile
Last active
November 26, 2016 10:47
-
-
Save je3f0o/b56e0b1f06d19aed23e5c54b49a1007b to your computer and use it in GitHub Desktop.
Simple makefile for C++ program
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
SHELL = /bin/bash | |
TARGET = a.exe | |
SOURCES = $(shell find src -name "*.cpp") | |
HEADERS = include # current project's headers directory | |
OBJECTS = $(patsubst %.cpp, .objects/%.o, $(SOURCES)) | |
CC = g++ | |
FLAGS = | |
CFLAGS = -std=c++11 -W -Wall -Werror -O3 | |
LIBS = `pkg-config --static --libs glfw3 glew` # example libs for reminder : glfw3 glew, you can change this | |
LDFLAGS = `pkg-config --cflags glfw3 glew` # example includes for reminder : glfw3 glew, you can change this | |
all : link | |
./$(TARGET) | |
$(OBJECTS) : .objects/%.o : %.cpp | |
@mkdir -p $(dir $@) | |
$(CC) $(FLAGS) $(CFLAGS) -I $(HEADERS) -c $< -o $@ | |
assemble : $(OBJECTS) | |
link : assemble | |
$(CC) $(FLAGS) $(CFLAGS) $(LIBS) $(LDFLAGS) $(OBJECTS) -o $(TARGET) | |
# .PHONY : clean | |
clean : | |
rm -rf $(TARGET) .objects | |
# Only for debug purpose | |
print : | |
@echo $(HEADERS) | |
@echo $(SOURCES) | |
@echo $(OBJECTS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment