Created
November 5, 2013 19:41
-
-
Save kensaggy/7324900 to your computer and use it in GitHub Desktop.
Generic all purpose Makefile for SPL course (@bgu)
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
################################################################################################################### | |
# | |
# Dynamic makefile, by Ken Saggy and Lidan Hifi | |
# Will automatically search for files ending with SRCEXT (source extension) in SRCDIR (source directory) | |
# | |
# MAKE FILE DOCUMENTATION: | |
# ======================== | |
# CC = C Compiler [g++] | |
# CFLAGS = Flags used during compilation | |
# SRCDIR = Source Directory [src] | |
# BUILDDIR = Where the object files will be placed [bin] | |
# TARGET = Name of the final target executable | |
# SRCEXT = File extension to look for of source code files [.cpp] | |
# OBJECTS = Objects files (searched for in BUILDDIR) | |
# INC = Flags used to include "include" directory duing compilation | |
# LFLAGS = Flags used for linkning | |
# | |
#################################################################################################################### | |
CC := g++ | |
SRCDIR := src | |
BUILDDIR := bin | |
TARGET := bin/UniCoffeeShop | |
SRCEXT := cpp | |
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT)) | |
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) | |
CFLAGS := -g -Wall -Weffc++ | |
LFLAGS := -L/usr/lib | |
INC := -Linclude | |
$(TARGET): $(OBJECTS) | |
@echo " Linking..." | |
@echo " $(CC) $^ -o $(TARGET) $(LFLAGS)"; $(CC) $^ -o $(TARGET) $(LFLAGS) | |
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) | |
@mkdir -p $(BUILDDIR) | |
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $< | |
clean: | |
@echo " Cleaning..."; | |
@echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment