RaphaelCausse / Makefile

Makefile template for small / medium C projects.
MIT License
2 stars 1 forks source link

Other Makefile project #2

Open Lecrapouille opened 5 months ago

Lecrapouille commented 5 months ago

Hi I also made a Makefile for Linux and Mac OS some years ago that I use for all my C++ projects. https://github.com/Lecrapouille/MyMakefile I'm currently not happy because I do not manage the creation of several libraries. I see your project, and I'll cherry-pick some ideas for the version 2. Please pick some of my rules :)

RaphaelCausse commented 5 months ago

Hi, thanks for your message, feel free to do what you want with my project. I will definitively check yours ! Thank you

Lecrapouille commented 5 months ago

If you know how to compile several libs (targets) within a single Makefile in a generic way. I'm welcome to get it. I can do it, but the Makefile does not recompiled dirty parts after the 1st compilation. I've to rethink.

RaphaelCausse commented 5 months ago

Haven't done it in a generic way, i try to keep things fairly simple, so i add rules specific to my needs when needed. Maybe you can try to list in a different file the name of the targets you want to build and their dependencies (improving my simple "sources.mk" file feature). What do you think ?

Lecrapouille commented 5 months ago

I think I get the idea, based on O'Reilly book "GNU Makefile": they know paths of folders holding the libs and holding their own Makefilfe. These pathes are used as rules and as dependencies.

Here is my prototype of top-level Makefile:

rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
DIRS_WITH_MAKEFILE := $(dir $(call rwildcard,src,Makefile))

.PHONY: all $(DIRS_WITH_MAKEFILE)
all: $(TARGET_NAME)

$(TARGET_NAME): $(OBJS) $(DIRS_WITH_MAKEFILE)
    linker command ...

%.o: %.cpp:
    compile command ...

$(DIRS_WITH_MAKEFILE):
    $(MAKE) --directory=$@
RaphaelCausse commented 5 months ago

Sounds great ! I can't wait to see the results to your work ! Keep me informed !

Lecrapouille commented 5 months ago

Here a functional code:

https://github.com/Lecrapouille/TimedPetriNetEditor/blob/93d38f55080f16f1aa9439213ccb8eef6f81d7c3/Makefile#L70-L87

This does not work yet with rwildcard maybe because of trailing '/'. Any on long term I'll refactorize my makefile

Lecrapouille commented 4 months ago

The V2 is almost here https://github.com/Lecrapouille/MyMakefile/tree/version-2 :) I'm almost done testing it. I need to write the API and update all my projects using it

RaphaelCausse commented 4 months ago

Hi, I really like what you've came up with ! Even though I don't use C++, I will definitely try your v2. Have you tested it on all Windows, Unix/Linux and Mac ?

Lecrapouille commented 4 months ago

It compiles C files. I'm finishing validations on Linux, Mac, Emscripten, ExaequOS. I'm passing my first CIs on some project of mine but I'll have some minor regressions for sure ;) I do not have Windows and since I'm using bash or Unix command not sure it will work (probably on Cygwin stuffs)