From: Leandro Lucarella Date: Fri, 29 Oct 2010 18:21:57 +0000 (-0300) Subject: Split configuration into project-wide and local X-Git-Url: https://git.llucax.com/software/makeit.git/commitdiff_plain/9d6ff85e4983acfed399383a792d4015b5b8e381?ds=inline Split configuration into project-wide and local If Toplevel.mak and Makeit.mak should not be edited by the user, and Config.mak is supposed to be a local configuration file, we are missing a place to have project-wide configuration, like default compiler flags and flavors. This patch make Config.mak a project-wide configuration file and adds Config.local.mak as a local user-wide configuration, to tweak local parameters as colors, or default compiler to use. --- diff --git a/Toplevel.mak b/Toplevel.mak index 8cffea4..5d16acf 100644 --- a/Toplevel.mak +++ b/Toplevel.mak @@ -1,9 +1,12 @@ ifndef Toplevel.mak.included Toplevel.mak.included := 1 -# Load top-level directory local configuration +# Load top-level directory project configuration sinclude $T/Config.mak +# Load top-level directory local configuration +sinclude $T/Config.local.mak + # Include the build system library include $T/Makeit.mak diff --git a/example/Config.local.mak b/example/Config.local.mak new file mode 100644 index 0000000..e3f5ce7 --- /dev/null +++ b/example/Config.local.mak @@ -0,0 +1,4 @@ + +# Use GCC as C compiler +CC := gcc + diff --git a/example/Config.mak b/example/Config.mak index c32caac..e48599d 100644 --- a/example/Config.mak +++ b/example/Config.mak @@ -1,22 +1,4 @@ -# Use debug flavor by default -F := dbg - -# C compiler -CC := gcc - -# Use pre-compiled headers -GCH := 1 - -# Warn about everything -override CPPFLAGS += -Wall -override LDFLAGS += -Wall - -# Be standard compliant -override CFLAGS += -std=c99 -pedantic -override CXXFLAGS += -std=c++98 -pedantic - - # Flavors (variants) flags ########################## @@ -33,3 +15,24 @@ override CPPFLAGS += -ggdb -pg --coverage override LDFLAGS += -pg --coverage endif +# Common flags +############## + +# Warn about everything +override CPPFLAGS += -Wall +override LDFLAGS += -Wall + +# Be standard compliant +override CFLAGS += -std=c99 -pedantic +override CXXFLAGS += -std=c++98 -pedantic + +# Other project configuration +############################# + +# Use debug flavor by default +F := dbg + +# Use pre-compiled headers +GCH := 1 + + diff --git a/example/README b/example/README index e3b8add..b0cc392 100644 --- a/example/README +++ b/example/README @@ -1,10 +1,16 @@ -This is a test/example for a nice Make based build system. +This is a test/example for the Makeit build system. -The Config.mak should not be saved to the repositories usually, but in this -case it is because part of this demonstration is to show how to customize the -build system through Config.mak, and specially to show how a project can be -"embedded" into another tweaking the Config.mak. +The Config.local.mak should not be saved to the repositories usually, it's +supposed to be user configuration not visible to other users, but in +this case it is because is part of this demonstration. Also, subproj's +Config.local.mak shows how to make another project using Makeit behave as it was +part of this project, as an "embedded" sub-project. + +This means you could copy subproj directory elsewhere, remove Config.local.mak +and that should be a standalone project using Makeit. Tweaking ours +Config.local.mak here, we integrate it into the build system, so doing make in +our parent project will make subproj too. lib1 is a standalone C library compiled into a shared object. lib2 is another shared library which uses lib1 and otherproj, which is a standalone project @@ -12,8 +18,8 @@ shared library which uses lib1 and otherproj, which is a standalone project produces another standalone shared object. Finally, prog is a program which uses lib1 and lib2. -Every project have it's copy of Makeit.mak and it's own Toplevel.mak. Both -files shouldn't be modified ever (unless you're hacking the build system). +Every standalone project have it's copy of Makeit.mak and it's own Toplevel.mak. +Both files shouldn't be modified ever (unless you're hacking the build system). Then each directory containing some library or program to build (or directories to include) has a Build.mak, which has only the logic to build the diff --git a/example/subproj/Config.local.mak b/example/subproj/Config.local.mak new file mode 100644 index 0000000..a8c1b96 --- /dev/null +++ b/example/subproj/Config.local.mak @@ -0,0 +1,12 @@ + +# Use the container project top-level directory as ours. +T := .. + +# Define the default goal to the main target of this subproject when doing make +# in this directory (you can use "all" to make the whole super-project). +.DEFAULT_GOAL := otherproj + +# Include the "parent" project and local configuration. +sinclude $T/Config.mak +sinclude $T/Config.local.mak + diff --git a/example/subproj/Config.mak b/example/subproj/Config.mak deleted file mode 100644 index dc4e4b4..0000000 --- a/example/subproj/Config.mak +++ /dev/null @@ -1,10 +0,0 @@ - -# Use the container project top-level directory as ours -T := .. - -# Define the default goal when doing make in this directory -.DEFAULT_GOAL := otherproj - -# Include the "parent" project configuration -sinclude $T/Config.mak -