Skip to content

Instantly share code, notes, and snippets.

@sharynneazhar
Last active February 27, 2017 15:39
Show Gist options
  • Save sharynneazhar/d3b9d86024502faec46ae205ac3d1e2b to your computer and use it in GitHub Desktop.
Save sharynneazhar/d3b9d86024502faec46ae205ac3d1e2b to your computer and use it in GitHub Desktop.
Makefile Template
#######################################################################
# General Makefile for compiling c++ programs
# Author : Sharynne Azhar
#######################################################################
# Specify the lab number
LAB_NUM=X
# Specify the folder name pattern
FOLDER_NAME := Azhar_Lab$(LAB_NUM)
# Specify the name of the program to build
PROG_NAME := lab$(LAB_NUM)
# Specify the files needed for compilation
SRC_FILES = $(filter-out ./test.txt, $(wildcard ./*))
# TODO: Make more generic by loading files in dynamically
# A generalized rule for compiling the executable object
$(PROG_NAME): main.o
g++ -Wall -g -std=c++11 main.o -o $(PROG_NAME)
# TODO: Make more generic by loading files in dynamically
# A generalized rule for compiling c++ source files
main.o: main.cpp
g++ -Wall -g -std=c++11 -c main.cpp
# Target for testing the program with a series of inputs
test:
./$(PROG_NAME) < test.txt
# Target for cleaning the generated files
clean:
@rm -rf *.o $(PROG_NAME)
echo clean done
# Target for compressing the files into archive
zip:
make clean
zip -r $(FOLDER_NAME).zip $(SRC_FILES)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment