Git Product home page Git Product logo

generic-makefile's Introduction

generic-makefile v3

For a better experience, please use the generic-CLI, a easy to use generic-technology manager.

Description

The Makefile that can be configured in under 30 seconds and adapts to almost all your C and C++ projects!
Intended for C and C++ under GNU/Linux.

This Makefile supports:

  • Fully autonomous configuration except basic directories.
  • automatic dynamic linking.
  • Automatic directories generation.
  • Transparent googletest integration.
  • gdb

Why?

So you don't have to make yours or configure another one for more than 30 seconds.

Implementation

Method 1: the developer's recommendation.

use the generic-CLI.

  • Clone the repository

      git clone https://github.com/riera90/generic-CLI.git
    
  • install the generic-CLI with the installation script

      cd generic-CLI
      ./install.sh
    
  • install the generic-makefile in your project directory!

      cd <project directory>
      generic-cli -c makefile
    

one line instalation command (for the first time only) then use the generic-cli utility

git clone https://github.com/riera90/generic-CLI.git && cd generic-CLI && sudo chmod +x ./install.sh && ./install.sh && generic-cli -c gmf

Method 2: the 'hard' way

  • Clone the repository in your project directory

      git clone https://github.com/riera90/generic-makefile.git
    
  • Remove the .git of this repository

  • Remove the .gitignore, all the example folders if you want

      rm -rf .git .gitignore example gtests
    
  • Move the license and readme to the make-files folder (the license is required to remain in the project)

      mv ./*.md ./make-files/
    
  • Move all the all the remaining content of the generic-makefile directory to your project directory

      mv ./* ./../
    
  • Configure the variables in the Makefile file

  • optional step: if you want googletest, clone it into the make-files directory and remove the .git

      cd make-files
      git clone https://github.com/google/googletest.git
      cd googletest
      rm -rf .git
    
  • apply the new configuration to the make-files/Makefile

      make config
    
  • hit make and enjoy!

      make
    

Usage

Commands

  • make config applies the new configuration to make-files/Makefile
  • make It builds the project and executes the binary (by default).
  • make run executes the binary.
  • make googletest It builds and executes (by default) the tests for the project.
  • make clean cleanup of the project temporal files.
  • make gdb fresh gdb compilation and execution (by default).

gmf usage

variables

variable definition restrictions
SRC_DIR Source directory Is a directory
GTEST_DIR googletest directory as in Is a directory
OUTPUT_DIR Directory where the binary will reside Is a directory
EXTRA_LIB_DIR Directory for extra external libraries Is a directory
TMP_DIR Temporal directory for objects and libraries Is a directory
SRC_CODE_EXT Extension for the source code Is an extension
SRC_HEADERS_EXT Extension for the source headers Is an extension
MAIN_FILE The file where the main resides, there is no need for the full path, just the filename and the extension is enough Is an existing filename
EXCLUDED_FILES excluded files from the project as a regular expression, various expressions are allowed, and must be separated by spaces
BIN_NAME The name the binary will receive
BIN_ARGUMENTS The arguments the binary will be executed with (if executed with the Makefile)
CXX The compiler [gcc/g++]
CXXFLAGS The compilation flags '-' or '--' is needed
EXECUTE_AFTER_COMPILATION Option for executing of the binary file after the compilation [YES/NO]
ALLOW_FOR_GDB Activates the GNU debugger [YES/NO]

Licence

Licensed under the BSD-3 licence

Want to collaborate?

Read CONTRIBUTING.md!

FAQ!

Q: I have just cloned a repository with the generic-makefile, but the googletest is not working, what do I do?

R: just use the generic-CLI utility, in the project directory, type the command

generic-cli -c make

When ask if you want googletest, say yes.

generic-makefile's People

Contributors

danitico avatar joel-milligan avatar riera90 avatar vpoulailleau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

generic-makefile's Issues

Google Test using all files on folder

While using google test, try to compile swp files using by vim.

	Compiling googletest library.
	Precompiling objects.
	Building library.
	Compiling googletests.
	Building .ClassroomUnittest.cpp.swp
/usr/bin/ld:./gtests/.ClassroomUnittest.cpp.swp: file format not recognized; treating as linker script
/usr/bin/ld:./gtests/.ClassroomUnittest.cpp.swp:1: syntax error
collect2: error: ld returned 1 exit status
	Building StudentUnittest.cpp
	Building DBControllerUnittest.cpp
	Building ClassroomUnittest.cpp
	Running googletests.

gtest not building properly when a second main is present in the project [BUG]

Description
When compiling and executing a gtest, and a second main is added in the / path of the project, this main is build under the name of the gtest and executed

Configuration

# DIRECTORIES
# src directory
SRC_DIR         :=./src
GTEST_DIR       :=./gtests
OUTPUT_DIR      :=./output
# aditional project libs directory
EXTRA_LIB_DIR   :=
# temporal files directory
TMP_DIR         :=./tmp
SRC_CODE_EXT    :=cpp
SRC_HEADERS_EXT :=hpp
MAIN_FILE       :=main.cpp
# excluded files from the project
EXCLUDED_FILES  :=


# binary file name
BIN_NAME:=bin.out
# binary arguments (if executed by the makefile).
BIN_ARGUMENTS:=
# compiler
CXX:=g++
# compilation flags
CXXFLAGS:=-Wpedantic -DNDEBUG

# [YES/NO]
EXECUTE_AFTER_COMPILATION:=YES
ALLOW_FOR_GNU_DEBUGGER:=YES

Tree output

.
โ”œโ”€โ”€ Doxyfile
โ”œโ”€โ”€ gtests
โ”‚ย ย  โ””โ”€โ”€ MonomioUnittest.cpp
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ make-files
โ”‚ย ย  โ”œโ”€โ”€ banner.txt
โ”‚ย ย  โ”œโ”€โ”€ config.sh
โ”‚ย ย  โ”œโ”€โ”€ CONTRIBUTING.md
โ”‚ย ย  โ”œโ”€โ”€ fancy_banner_short.txt
โ”‚ย ย  โ”œโ”€โ”€ fancy_banner.txt
โ”‚ย ย  โ”œโ”€โ”€ gmf.gif
โ”‚ย ย  โ”œโ”€โ”€ help.txt
โ”‚ย ย  โ”œโ”€โ”€ LICENSE.md
โ”‚ย ย  โ”œโ”€โ”€ logo.png
โ”‚ย ย  โ”œโ”€โ”€ Makefile
โ”‚ย ย  โ””โ”€โ”€ README.md
โ”œโ”€โ”€ output
โ”‚ย ย  โ””โ”€โ”€ MonomioUnittest.out
โ”œโ”€โ”€ Practica-1.pdf
โ”œโ”€โ”€ src
โ”‚ย ย  โ”œโ”€โ”€ Auxiliar
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ AuxiliarFunctions
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ funcionesAuxiliares.cpp
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ funcionesAuxiliares.hpp
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ macros.hpp
โ”‚ย ย  โ”œโ”€โ”€ Controller
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Monomio
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ auxiliarFunctions.cpp
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ auxiliarFunctions.hpp
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ operadoresExternosMonomios.cpp
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ operadoresExternosMonomios.hpp
โ”‚ย ย  โ”œโ”€โ”€ Entity
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Monomio
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ Monomio.cpp
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ Monomio.hpp
โ”‚ย ย  โ”œโ”€โ”€ main.cpp
โ”‚ย ย  โ””โ”€โ”€ testfile.cpp
โ””โ”€โ”€ tmp
    โ”œโ”€โ”€ Auxiliar
    โ”‚ย ย  โ””โ”€โ”€ AuxiliarFunctions
    โ”‚ย ย      โ””โ”€โ”€ funcionesAuxiliares.o
    โ”œโ”€โ”€ Controller
    โ”‚ย ย  โ””โ”€โ”€ Monomio
    โ”‚ย ย      โ”œโ”€โ”€ auxiliarFunctions.o
    โ”‚ย ย      โ””โ”€โ”€ operadoresExternosMonomios.o
    โ”œโ”€โ”€ Entity
    โ”‚ย ย  โ””โ”€โ”€ Monomio
    โ”‚ย ย      โ””โ”€โ”€ Monomio.o
    โ”œโ”€โ”€ gtest-all.o
    โ”œโ”€โ”€ gtest_main.o
    โ”œโ”€โ”€ libgtest.a
    โ”œโ”€โ”€ libproject.a
    โ””โ”€โ”€ testfile.o

Log


$ make clean
	Removing temporal files
	Removing binary files

$ make config
./make-files/config.sh

$ make googletest 
                     ___
                   /'___\
   __     ___ ___ /\ \__/
 /'_ `\ /' __` __`\ \ ,__\
/\ \L\ \/\ \/\ \/\ \ \ \_/
\ \____ \ \_\ \_\ \_\ \_\
 \/___L\ \/_/\/_/\/_/\/_/ 3.0
  /\____/
  \_/__/
	Precompiling googletest object for ./make-files/googletest/googletest/src/gtest_main.cc.
	Precompiling googletest object for ./make-files/googletest/googletest/src/gtest-all.cc
	Compiling googletest library.
	Precompiling object for ./src/Entity/Monomio/Monomio.cpp.
	Precompiling object for ./src/Auxiliar/AuxiliarFunctions/funcionesAuxiliares.cpp.
	Precompiling object for ./src/Controller/Monomio/operadoresExternosMonomios.cpp.
	Precompiling object for ./src/Controller/Monomio/auxiliarFunctions.cpp.
	Precompiling object for ./src/testfile.cpp.
	Building project library.
	Building googletest ./gtests/MonomioUnittest.cpp.

	Running ./output/MonomioUnittest.out
./output/MonomioUnittest.out
this is beeing executed when googletest should be
make: *** [make-files/Makefile:63: googletest] Error 1

Additional context
the name of the second main is not important, in this case is testfile.cpp

Bad english

So you dont have to make your owns
So you don't have to make yours

Desctiption
Description

get make clean to behave properly

Is your feature request related to a problem? Please describe.

When the application is dockerized, and a make clean is performed to make sure there is a clean compilation, the container is sometimes exited due to a non zero return value by the makefile when trying tom delete non existing files.

Describe the solution you'd like

get make clean to behave properly when there are no files left to delete

Cmake alternative

This project is awesome ๐Ÿ˜€. You should consider to create a generic cmake alternative too.

make run

implement a way for running the test with the execute after compilation flag disabled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.