lmariscal icon

makefile

lmariscal | PRO | 12/16/16 04:23:59 AM UTC | 0 ⭐ | 7939 👁️ | Never ⏰ | []
Make |

2.61 KB

|

None

|

0 👍

/

0 👎

# ===========================
# Project:                  #
# Author:                   #
# ===========================
 
# Compiler and User Settings
CC      := g++
CFLAGS  := -c -Wall
LDFLAGS :=
_LIBS := #None
 
# Directories
SRC_DIR := src
OBJ_DIR := obj
INC_DIR := include
LIB_DIR := lib
DLL_DIR := dll
BIN_DIR := bin
 
SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
OBJECTS := $(patsubst $(SRC_DIR)/%,$(OBJ_DIR)/%,$(SOURCES:.cpp=.o))
 
BIN_EXE := $(BIN_DIR)/foo
 
LIBS  := -L$(LIB_DIR) $(_LIBS)
 
INCLUDE_DIRS := $(INC_DIR:%=-I%)
 
all: header-banner $(SRC_DIR) default
    $(info )
    $(info --------- Done [all] ------------------------------)
    $(info )
 
default: prebuild build postbuild
 
prebuild:
 
build-compile: compile-banner $(OBJECTS)
build-link: link-banner $(BIN_EXE)
build: build-compile build-link
 
postbuild:
 
$(BIN_EXE): $(OBJECTS)
    $(foreach O,$(OBJECTS),$(info [OBJ] ${O}))
    @$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
    $(info [EXE] $@)
 
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
    $(info [SRC] $<)
    @$(CC) $(CFLAGS) $(INCLUDE_DIRS) -o $@ -c $<
 
$(SRC_DIR):
    @mkdir $(SRC_DIR)
    @mkdir $(OBJ_DIR)
    @mkdir $(INC_DIR)
    @mkdir $(LIB_DIR)
    @mkdir $(DLL_DIR)
    @mkdir $(BIN_DIR)
 
.PHONY: header-banner
header-banner:
    $(info )
    $(info ===============================================)
    $(info #   _____                      _      __   __ #)
    $(info #  / ____|                    {_}     \ \ / / #)
    $(info # | |     __ ___   ____ _ _ __ _ _   _ \ V /  #)
    $(info # | |    / _` \ \ / / _` | `__| | | | | > <   #)
    $(info # | |___| {_| |\ V / {_| | |  | | |_| |/ . \  #)
    $(info #  \_____\__,_| \_/ \__,_|_|  |_|\__,_/_/ \_\ #)
    $(info #                                             #)
    $(info #      Copyright 2016 Leonardo Mariscal.      #)
    $(info #                                             #)
    $(info ===============================================)
    $(info )
 
.PHONY: link-banner
link-banner:
    $(info )
    $(info --------- Link [build-link] ------------------------------)
    $(info )
 
.PHONY: compile-banner
compile-banner:
    $(info )
    $(info --------- Compile [build-compile] ------------------------------)
    $(info )
 
.PHONY: clean
clean: header-banner
    $(info )
    $(info --------- Clean [clean] ------------------------------)
    $(info )
    $(foreach O,$(wildcard $(OBJ_DIR)/*),$(info [RM] ${O}))
    $(foreach O,$(wildcard $(BIN_DIR)/*),$(info [RM] ${O}))
    @rm -r $(OBJ_DIR)/* $(BIN_DIR)/*
    $(info )
    $(info --------- Done [clean] ------------------------------)
    $(info )
 
.PHONY: run
run:
    $(info )
    $(info --------- Run [run] ------------------------------)
    $(info )
    @./$(BIN_EXE)

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎