Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Need help with a basic transportable Makefile

This thread is locked; no one can reply to it. rss feed Print
Need help with a basic transportable Makefile
Mark Oates
Member #1,146
March 2001
avatar

Hey all, I'm looking for something that is essentially a very boilerplate Makefile that should work on "most if not all" systems.

The Makefile should expect an "include" and "source" directory, and some program files at the base `.`. The source and include folders will have nested folders, but will not have any files with main()s or entry points. The entry points will only exist for the program files at the base. Would look something like this:

include/
   NestedA/
      NestedA2/
         ComponentFileA.hpp
   ComponentFileB.hpp
src/
   NestedA/
      NestedA2/
         ComponentFileA.cpp
   ComponentFileB.cpp
ProgramFileX.cpp
ProgramFileY.cpp

It doesn't need to be efficient or flexible, it should just "work" when invoking make. (It will need to include allegro and a few compiler flags like -c++17. I'm less worried about that).

Is there a typical boilerplate or convention for something like this?

My current build system has grown so complex I'm lost sight of what "typical" is :D

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Mark Oates
Member #1,146
March 2001
avatar

:'( :'( :'(

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

The sad truth is, makefiles aren't portable unless your target consumer only uses gcc. CMake will generate them for you, and then you could tweak it yourself.

I would be more than glad to teach you what I know of CMake. I've replaced Eagle's build system with CMake, and it's a breeze. No maintenance, no mess. They're really easy once you get the hang of it.

I also offer a CHM manual for CMake 3.14rc4, which is fairly recent and covers everything backwards compatibly.

https://bitbucket.org/bugsquasher/unofficial-allegro-5-binaries/downloads/CMake314rc4.chm

Mark Oates
Member #1,146
March 2001
avatar

Thanks Edgar. There's really no need for a new build system considering the circumstances. I managed to just create a simple Makefile. Looks like this:

SRC_FILES := $(shell find src -type f)
ALLEGRO_LIBS=-lallegro_color -lallegro_font -lallegro_ttf -lallegro_dialog -lallegro_audio -lallegro_acodec -lallegro_primitives -lallegro_image -lallegro -lallegro_main

main: $(SRC_FILES)
	g++ -std=c++17 $^ programs/LabyrinthOfLore.cpp -o LabyrinthOfLore -I./include $(ALLEGRO_LIBS)

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

RmBeer2
Member #16,660
April 2017
avatar

When the situation becomes so complex to make, use cmake.

🌈🌈🌈 🌟 BlackRook WebSite (Only valid from my installer) 🌟 C/C++ 🌟 GNU/Linux 🌟 IceCream/Cornet 🌟 🌈🌈🌈

Rm Beer for Emperor 2021! Rm Beer for Ruinous Slave Drained 2022! Rm Beer for Traveler From The Future Warning Not To Enter In 2023! Rm Beer are building a travel machine for Go Back from 2023! Rm Beer in an apocalyptic world burning hordes of Zombies in 2024!

Go to: