From 40f3c997f92beb5cb6839cb700c12c433579ec6b Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 18 Sep 2009 15:23:16 -0300 Subject: [PATCH] Fix spelling, improve comments and update README --- Build.mak | 2 +- Config.mak | 2 +- Lib.mak | 42 ++++++++++++++++++++++++------------------ README | 14 ++++++-------- subproj/Build.mak | 2 +- subproj/Config.mak | 4 ++-- 6 files changed, 35 insertions(+), 31 deletions(-) diff --git a/Build.mak b/Build.mak index 872ea85..8e6acff 100644 --- a/Build.mak +++ b/Build.mak @@ -1,5 +1,5 @@ -# Create the include directory symlink +# Create the include directory symbolic link setup_include_dir__ := $(call symlink_include_dir,makeit) # General rule to install headers of this project diff --git a/Config.mak b/Config.mak index e76a8a9..6d27087 100644 --- a/Config.mak +++ b/Config.mak @@ -5,6 +5,6 @@ F := dbg # C compiler CC := gcc -# Use precompiled headers +# Use pre-compiled headers GCH := 1 diff --git a/Lib.mak b/Lib.mak index 6a6c9f9..5889b04 100644 --- a/Lib.mak +++ b/Lib.mak @@ -1,7 +1,7 @@ ifndef Lib.mak.included Lib.mak.included := 1 -# These variables should be provided by the includer Makefile: +# These variables should be provided by the Makefile that include us: # P should be the project name, mostly used to handle include directories # T should be the path to the top-level directory. # S should be sub-directory where the current makefile is, relative to $T. @@ -23,17 +23,17 @@ LINKER := $(CXX) # Default mode used to install files IMODE ?= 0644 -# Degault install flags +# Default install flags IFLAGS ?= -D -# Use precompiled headers if non-empty +# Use pre-compiled headers if non-empty GCH ?= # Directories ############## -# Base directory where to install files (can be overrided, should be absolute) +# Base directory where to install files (can be overridden, should be absolute) prefix ?= /usr/local # Path to a complete alternative environment, usually a jail, or an installed @@ -53,7 +53,7 @@ D ?= $T/build # Generated files top directory G ?= $D/$F -# Objects (and other garbage like precompiled headers and dependency files) +# Objects (and other garbage like pre-compiled headers and dependency files) # directory O ?= $G/obj @@ -82,11 +82,17 @@ C = $T/$S # returns empty. eq = $(if $(subst $1,,$2),,$1) -# Find sources files and get the corresponding object names -# The first argument should be the sources extension ("c" or "cpp" typically) -# It expects the variable $T and $O to be defined as commented previously in -# this file. -find_objects = $(patsubst $T/%.$1,$O/%.o,$(shell find $C -name '*.$1')) +# Find sources files and get the corresponding object names. The first +# argument should be the sources extension ("c" or "cpp" typically). The +# second argument is where to search for the sources ($C if omitted). The +# resulting files will always have the suffix "o" and the directory rewritten +# to match the directory structure (from $T) but in the $O directory. For +# example, if $T is "/usr/src", $O is "/tmp/obj", $C is "/usr/src/curr" and it +# have 2 C sources: "/usr/src/curr/1.c" and "/usr/src/curr/dir/2.c", the call: +# $(call find_objects,c) +# Will yield "/tmp/obj/curr/1.o" and "/tmp/obj/curr/dir/2.o". +find_objects = $(patsubst $T/%.$1,$O/%.o,$(shell \ + find $(if $2,$2,$C) -name '*.$1')) # Find sources files and get the corresponding object names # The first argument should be the sources extension ("c" or "cpp" typically) @@ -143,7 +149,7 @@ endef # Link object files to build an executable. The objects files are taken from # the prerequisite files ($O/%.o). If in the prerequisite files are shared # objects ($L/lib%.so), they are included as libraries to link to (-l%). This -# function is designed to be used as a command in a rule. The ouput name is +# function is designed to be used as a command in a rule. The output name is # taken from the rule automatic variables. If an argument is provided, it's # included in the link command line. The variable LINKER is used to link the # executable; for example, if you want to link a C++ executable, you should use @@ -184,8 +190,8 @@ replace = $(call exec,sed '$(foreach v,$1,s|@$v@|$($2$v)|$5;)' $(if $3,$3,$<) \ > $(if $4,$4,$@)) # Create a symbolic link to the project under the $(INCLUDE_DIR). The first -# argument is the name of symlink to create. The link is only created if it -# doesn't already exist. +# argument is the name of symbolic link to create. The link is only created if +# it doesn't already exist. symlink_include_dir = $(shell \ test -L $(INCLUDE_DIR)/$1 \ || ln -s $C $(INCLUDE_DIR)/$1 ) @@ -200,7 +206,7 @@ gen_rebuild_flags = $(shell if test x"$2" != x"`cat $1 2>/dev/null`"; then \ echo "$2" > $1 ; fi) -# Overrided flags +# Overridden flags ################## # Warn about everything @@ -212,7 +218,7 @@ override CPPFLAGS += -I$(INCLUDE_DIR) # Let the program know where it will be installed override CPPFLAGS += -DPREFIX=$(prefix) -# Be standard compilant +# Be standard compliant override CFLAGS += -std=c99 -pedantic override CXXFLAGS += -std=c++98 -pedantic @@ -301,7 +307,7 @@ uninstall: # sub-makes to add values to the special variables $(all), after this makefile # was read. .SECONDEXPANSION: - + # Phony rule to make all the targets (sub-makefiles can append targets to build # to the $(all) variable). .PHONY: all @@ -317,8 +323,8 @@ install: $$(install) ################################### # Create $O, $B, $L and $(INCLUDE_DIR) directories and replicate the directory -# structure of the project into $O. Create one symlink "last" to the current -# build directory. +# structure of the project into $O. Create one symbolic link "last" to the +# current build directory. # # NOTE: the second mkdir can yield no arguments if the project don't have any # subdirectories, that's why the current directory "." is included, so it diff --git a/README b/README index 083dea7..5616a45 100644 --- a/README +++ b/README @@ -7,15 +7,13 @@ build system through Config.mak, and specially to show how a project can be "embedded" into another tweaking the Config.mak. lib1 is a standalone C library compiled into a shared object. lib2 is another -shared library which uses lib1 and subproj, which is a standalone project -"embedded" into this one. subproj produces another standalone shared object. -Finally, prog is a program which uses lib1 and lib2. +shared library which uses lib1 and otherproj, which is a standalone project +(living in the "subproj" subdirectory) "embedded" into this one. otherproj +produces another standalone shared object. Finally, prog is a program which +uses lib1 and lib2. -Every project have it's copy of Lib.mak and it's own Toplevel.mak, which has -some global permanent configuration (which doesn't depends on users taste, it -just have information about the project, like it's name, and does the work to -include Lib.mak, etc.). Lib.mak shouldn't be modified ever (unless you're -hacking the build system) and Toplevel.mak should be changes very rarely. +Every project have it's copy of Lib.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/subproj/Build.mak b/subproj/Build.mak index b391b79..2d3f120 100644 --- a/subproj/Build.mak +++ b/subproj/Build.mak @@ -35,6 +35,6 @@ $I/include/otherproj/%.h: $C/%.h # XXX: we can't use += here, call will be resolved lazily if we do install := $(install) $(call find_headers,h,$I/include/otherproj) -# Create the include directory symlink and pkg-config flags file +# Create the include directory symbolic link and pkg-config flags file setup_include_dir__ := $(call symlink_include_dir,otherproj) diff --git a/subproj/Config.mak b/subproj/Config.mak index b02cae7..61e3900 100644 --- a/subproj/Config.mak +++ b/subproj/Config.mak @@ -2,9 +2,9 @@ # Use the container project top-level directory as ours T := .. -# Include the "parent" project config +# Include the "parent" project configuration sinclude $T/Config.mak -# Include the "parent" project config +# Define the default goal when doing make in this directory .DEFAULT_GOAL := otherproj -- 2.43.0