Git Product home page Git Product logo

theonemakefile's Introduction

One makefile to rule them all

A makefile that aims to simplify development for small to medium scale C/C++ programs and University assignments.

Warning! There is a serious Bug on this version - Directory Name Variables appear empty

I don't suggest using it on this state (Unless you know how to fix it yourself) I will try to fix it when I have time.

Contents

Features

  • Automatic file detection ( source, header and lib )
  • Built-in Project Directory Organization
  • Built-in Debugging tools
  • One-Command Deliverable Generation
  • Plug and Play with minimal set-up hassle
  • Easy to use and Beginner Friendly

Setup Options

The makefile is "broken" into 5 sections for better organisation. The only Sections that you may need to edit are the "Makefile Arguments" and the "Run and Test" Sections.

Makefile Arguments: Here you can edit all the project parameters to fit your needs. You can set:

  • The file types (CODE : .c/.cpp | HEAD : .h/.hpp)
  • The compiler ( CC : gcc / g++ )
  • The compilation, execution and debugging arguments ( CFLAGS, RUNFLAGS, VGFLAGS )
  • Any libraries that need to be included by the linker ( LINKFLAGS )
  • The final executable's name ( OUT )

Before you start using your makefile, you should first make sure that you have selected the correct options for your needs (compiler, file types, ... )

Run and Test: This section contains the running and debugging rules - the "one line commands". Here you can add your own rules to expand this makefile, but you can probably make do with the existing ones. So you probably won't need to make any changes on this section in the beginning.

To learn more about each section, take a look in the makefile comments.

How to Use

  1. Start by moving the makefile inside your project's root directory.

  2. If your project is already organized in the supported directory structure ( src, include, obj, bin, lib ) you can skip this step. Else, if your project is not organized in directories ( all the files are on the same directory ), you will need to first "organize" your project:

make org

This command creates the needed directories and moves all the files on their corresponding directories

  1. Don't forget to make sure that the arguments in the "Makefile Arguments'' section of the makefile, like the selected compiler, are the correct ones for your project.

  2. You are ready!

Now you can compile and run your project just by using the command:

make run

Also you can compile and run using Valgrind with

make vg

To see all the available "one line commands", check the "Run and Test" section of the makefile and its comments.

Description

This is a makefile that I built gradually throughout my years in college, based on my own development style and needs for my projects. It aims to make basic C and C++ projects as hassle free to start and develop as possible, while keeping everything organized. My goal was to have a makefile, that with practically no setup/changes, would allow me to compile, run, debug and pack my project into a deliverable using only a small set of "one line commands".

The Automatic Project Directory Organization feature was added to make this makefile Plug and Play for most of the small to medium sized C/C++ projects.

Disclaimer: I am by no means an expert in makefiles so there is a chance that there are bugs or mistakes that I missed. Any feedback is more than welcome! I would love to find ways to keep improving this makefile and fill any gaps in my knowledge.

This is a personal project and it might not fit everyone's needs, so feel free to go rogue and play around with it as much as you want. Add your own rules according to your own needs.

Future Updates

Although makefiles are not the optimal way of unit testing your code, i would like to include a simple way to run unit tests on my libraries and structs with minimal effort.

theonemakefile's People

Contributors

rvthak avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.