Makefiles are a simple way to organize code compilation. Make is a Unix tool to simplify building program executables from many modules. make reads in rules (specified as a list of target entries) from a user created Makefile. make will only re-build things that need to be re-built (object or executables that depend on files that have been modified since the last time the objects or executables were built).
The following code snippet is an example of a makefile + makefile.conf. You can find the source code as well as some examples here.
(info - Makefile.conf loaded) # find project files H_FILES :=
(shell find ./ -name '*.c' -type f | sed 's/ /\\ /g' | uniq) CXX_FILES :=
(C_FILES:.c=.o) O_FILES +=
(notdir
(notdir
(notdir
(H_FILES:%=-I%)
(DEBUG),yes)
(CFLAGS) endif ifeq (
(info - Set Parameters for Shared Library build process) ALL_PARAMETERS = lib
(PROJECT_VERSION) clean ALL_TYPE = lib
(PROJECT_VERSION):
(PROJECT_NAME).so CFLAGS := -fPIC
(CXXFLAGS) else
(PROJECT_NAME) clean ALL_TYPE =
(O_FILES) LIBFLAGS = endif # Build Process all:
(ALL_TYPE) @echo - [OUTPUT][CXX]
(BIN_DIRECTORY)] @
(CFLAGS)
(LDFLAGS)
(BIN_DIRECTORY)/
^
@ @
(CFLAGS) -c
@
(LFLAGS) %.o: %.cpp @echo - [CXX]
(CXX)
(INCLUDES) -o
<
(info - Remove all .o [object] files) @find . -name \*.o -type f -delete # Clear Objects & Executables cleanall:
(info - Remove all files in
(BIN_DIRECTORY) -name \*.* -type f -delete
# Project Configurations
# Project Name
PROJECT_NAME = sharedtest
# Project Version
PROJECT_VERSION = 0.1
# Program or Shared Library
IS_LIBRARY = yes
# Source Files Directory
SRC_DIRECTORY = src
# Header Files Directory
INC_DIRECTORY = inc
# Library Header Files Directory
LIB_DIRECTORY = lib
# Build Output Directory
BIN_DIRECTORY = ../Executable
# Installation Directory Exec
INS_DIRECTORY = /usr/bin/
# Installation Directory Headers
INS_HEARERS_DIRECTORY = /usr/include/
# Installation Directory SO
INS_SO_DIRECTORY = /usr/lib/
# C Flags
CFLAGS = -O3 -D_GNU_SOURCE -Wfatal-errors
# C++ Flags
CXXFLAGS =
(shell dpkg-buildflags --get LDFLAGS)
# Linker Libraries
LDLIBS = -fno-inline
# Debug Yes / No
DEBUG = no
# C Compiler
CC = gcc
# C++ Compiler
CXX = g++

(info - Makefile.conf loaded)
# find project files
H_FILES :=
(shell find ./ -name '*.c' -type f | sed 's/ /\\ /g' | uniq)
CXX_FILES :=
(C_FILES:.c=.o)
O_FILES +=
(info - Remove all .o [object] files)
@find . -name \*.o -type f -delete
# Clear Objects & Executables
cleanall:
(shell dpkg-buildflags --get LDFLAGS)
# Linker Libraries
LDLIBS = -fno-inline
# Debug Yes / No
DEBUG = no
# C Compiler
CC = gcc
# C++ Compiler
CXX = g++




