* Tracked down the mkdepend tool which Ingo used in his updated makefile-engine
which auto-generates dependencies. It was written by Lars Duening for BeOS and uses libglob, which is also part of make. To re-use libglob and since make is already part of the Haiku tree, I added mkdepend to the bin tools. * Added Lars Duening's copyright to AboutSystem. * Added skeleton makefile and makefile-engine to data/develop. * Added mkdepend and makefile-engine files to the Development optional package. It could be argued to move the make bin command there too, from it's current location in the HaikuImage file. However, make could be useful to always have available. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29609 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
## BeOS Generic Makefile v2.2 ##
|
||||
|
||||
## Fill in this file to specify the project being created, and the referenced
|
||||
## makefile-engine will do all of the hard work for you. This handles both
|
||||
## Intel and PowerPC builds of the BeOS and Haiku.
|
||||
|
||||
## Application Specific Settings ---------------------------------------------
|
||||
|
||||
# specify the name of the binary
|
||||
NAME=
|
||||
|
||||
# specify the type of binary
|
||||
# APP: Application
|
||||
# SHARED: Shared library or add-on
|
||||
# STATIC: Static library archive
|
||||
# DRIVER: Kernel Driver
|
||||
TYPE=
|
||||
|
||||
# add support for new Pe and Eddie features
|
||||
# to fill in generic makefile
|
||||
|
||||
#%{
|
||||
# @src->@
|
||||
|
||||
# specify the source files to use
|
||||
# full paths or paths relative to the makefile can be included
|
||||
# all files, regardless of directory, will have their object
|
||||
# files created in the common object directory.
|
||||
# Note that this means this makefile will not work correctly
|
||||
# if two source files with the same name (source.c or source.cpp)
|
||||
# are included from different directories. Also note that spaces
|
||||
# in folder names do not work well with this makefile.
|
||||
SRCS=
|
||||
|
||||
# specify the resource files to use
|
||||
# full path or a relative path to the resource file can be used.
|
||||
RSRCS=
|
||||
|
||||
# @<-src@
|
||||
#%}
|
||||
|
||||
# end support for Pe and Eddie
|
||||
|
||||
# specify additional libraries to link against
|
||||
# there are two acceptable forms of library specifications
|
||||
# - if your library follows the naming pattern of:
|
||||
# libXXX.so or libXXX.a you can simply specify XXX
|
||||
# library: libbe.so entry: be
|
||||
#
|
||||
# - if your library does not follow the standard library
|
||||
# naming scheme you need to specify the path to the library
|
||||
# and it's name
|
||||
# library: my_lib.a entry: my_lib.a or path/my_lib.a
|
||||
LIBS=
|
||||
|
||||
# specify additional paths to directories following the standard
|
||||
# libXXX.so or libXXX.a naming scheme. You can specify full paths
|
||||
# or paths relative to the makefile. The paths included may not
|
||||
# be recursive, so include all of the paths where libraries can
|
||||
# be found. Directories where source files are found are
|
||||
# automatically included.
|
||||
LIBPATHS=
|
||||
|
||||
# additional paths to look for system headers
|
||||
# thes use the form: #include <header>
|
||||
# source file directories are NOT auto-included here
|
||||
SYSTEM_INCLUDE_PATHS =
|
||||
|
||||
# additional paths to look for local headers
|
||||
# thes use the form: #include "header"
|
||||
# source file directories are automatically included
|
||||
LOCAL_INCLUDE_PATHS =
|
||||
|
||||
# specify the level of optimization that you desire
|
||||
# NONE, SOME, FULL
|
||||
OPTIMIZE=
|
||||
|
||||
# specify any preprocessor symbols to be defined. The symbols will not
|
||||
# have their values set automatically; you must supply the value (if any)
|
||||
# to use. For example, setting DEFINES to "DEBUG=1" will cause the
|
||||
# compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG"
|
||||
# would pass "-DDEBUG" on the compiler's command line.
|
||||
DEFINES=
|
||||
|
||||
# specify special warning levels
|
||||
# if unspecified default warnings will be used
|
||||
# NONE = supress all warnings
|
||||
# ALL = enable all warnings
|
||||
WARNINGS =
|
||||
|
||||
# specify whether image symbols will be created
|
||||
# so that stack crawls in the debugger are meaningful
|
||||
# if TRUE symbols will be created
|
||||
SYMBOLS =
|
||||
|
||||
# specify debug settings
|
||||
# if TRUE will allow application to be run from a source-level
|
||||
# debugger. Note that this will disable all optimzation.
|
||||
DEBUGGER =
|
||||
|
||||
# specify additional compiler flags for all files
|
||||
COMPILER_FLAGS =
|
||||
|
||||
# specify additional linker flags
|
||||
LINKER_FLAGS =
|
||||
|
||||
# specify the version of this particular item
|
||||
# (for example, -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL")
|
||||
# This may also be specified in a resource.
|
||||
APP_VERSION =
|
||||
|
||||
# (for TYPE == DRIVER only) Specify desired location of driver in the /dev
|
||||
# hierarchy. Used by the driverinstall rule. E.g., DRIVER_PATH = video/usb will
|
||||
# instruct the driverinstall rule to place a symlink to your driver's binary in
|
||||
# ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will appear at
|
||||
# /dev/video/usb when loaded. Default is "misc".
|
||||
DRIVER_PATH =
|
||||
|
||||
## include the makefile-engine
|
||||
include $(BUILDHOME)/etc/makefile-engine
|
||||
@@ -0,0 +1,361 @@
|
||||
## BeOS and Haiku Generic Makefile Engine v2.2.0
|
||||
## Does all the hard work for the Generic Makefile
|
||||
## which simply defines the project parameters
|
||||
|
||||
## Supports Generic Makefile v2.0, 2.01, 2.1, 2.2
|
||||
|
||||
# determine wheather running on x86 or ppc
|
||||
MACHINE=$(shell uname -m)
|
||||
ifeq ($(MACHINE), BePC)
|
||||
CPU = x86
|
||||
else
|
||||
CPU = ppc
|
||||
endif
|
||||
|
||||
# set the directory where object files and binaries will be created
|
||||
OBJ_DIR := obj.$(CPU)
|
||||
|
||||
# create some default settings
|
||||
ifeq ($(NAME), )
|
||||
NAME = NameThisApp
|
||||
endif
|
||||
|
||||
ifeq ($(TYPE), )
|
||||
TYPE = APP
|
||||
endif
|
||||
|
||||
ifeq ($(DRIVER_PATH), )
|
||||
DRIVER_PATH = misc
|
||||
endif
|
||||
|
||||
# specify that the binary should be created in the object directory
|
||||
# NOTE: make doesn't find the target if its name is enclosed in
|
||||
# quotation marks
|
||||
# TARGET := "$(OBJ_DIR)/$(NAME)"
|
||||
TARGET := $(OBJ_DIR)/$(NAME)
|
||||
|
||||
# specify the mimeset tool
|
||||
MIMESET := mimeset
|
||||
|
||||
# specify the tools for adding and removing resources
|
||||
XRES = xres
|
||||
|
||||
|
||||
# platform specific settings
|
||||
|
||||
# x86 Settings
|
||||
ifeq ($(CPU), x86)
|
||||
# set the compiler and compiler flags
|
||||
CC = gcc
|
||||
|
||||
# SETTING: set the CFLAGS for each binary type
|
||||
ifeq ($(TYPE), DRIVER)
|
||||
CFLAGS += -D_KERNEL_MODE=1 -no-fpic
|
||||
else
|
||||
CFLAGS +=
|
||||
endif
|
||||
|
||||
# SETTING: set the proper optimization level
|
||||
ifeq ($(OPTIMIZE), FULL)
|
||||
OPTIMIZER = -O3
|
||||
else
|
||||
ifeq ($(OPTIMIZE), SOME)
|
||||
OPTIMIZER = -O1
|
||||
else
|
||||
ifeq ($(OPTIMIZE), NONE)
|
||||
OPTIMIZER = -O0
|
||||
else
|
||||
# OPTIMIZE not set so set to full
|
||||
OPTIMIZER = -O3
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
||||
# SETTING: set proper debugger flags
|
||||
ifeq ($(DEBUGGER), TRUE)
|
||||
DEBUG += -g
|
||||
OPTIMIZER = -O0
|
||||
endif
|
||||
|
||||
CFLAGS += $(OPTIMIZER) $(DEBUG)
|
||||
|
||||
# SETTING: set warning level
|
||||
ifeq ($(WARNINGS), ALL)
|
||||
CFLAGS += -Wall -Wno-multichar -Wno-ctor-dtor-privacy
|
||||
else
|
||||
ifeq ($(WARNINGS), NONE)
|
||||
CFLAGS += -w
|
||||
endif
|
||||
endif
|
||||
|
||||
# set the linker and linker flags
|
||||
LD = gcc
|
||||
LDFLAGS += $(DEBUG)
|
||||
|
||||
# SETTING: set linker flags for each binary type
|
||||
ifeq ($(TYPE), APP)
|
||||
LDFLAGS += -Xlinker -soname=_APP_
|
||||
else
|
||||
ifeq ($(TYPE), SHARED)
|
||||
LDFLAGS += -nostart -Xlinker -soname=$(NAME)
|
||||
else
|
||||
ifeq ($(TYPE), DRIVER)
|
||||
LDFLAGS += -nostdlib /boot/develop/lib/x86/_KERNEL_
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
else
|
||||
|
||||
# ppc Settings
|
||||
ifeq ($(CPU), ppc)
|
||||
# set the compiler and compiler flags
|
||||
CC = mwcc
|
||||
CFLAGS +=
|
||||
|
||||
# SETTING: set the proper optimization level
|
||||
ifeq ($(OPTIMIZE), FULL)
|
||||
OPTIMIZER = -O7
|
||||
else
|
||||
ifeq ($(OPTIMIZE), SOME)
|
||||
OPTIMIZER = -O3
|
||||
else
|
||||
ifeq ($(OPTIMIZE), NONE)
|
||||
OPTIMIZER = -O0
|
||||
else
|
||||
# OPTIMIZE not set so set to full
|
||||
OPTIMIZER = -O7
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
#set the proper debugger settings
|
||||
ifeq ($(DEBUGGER), TRUE)
|
||||
DEBUG += -g
|
||||
endif
|
||||
|
||||
CFLAGS += $(OPTIMIZER) $(DEBUG)
|
||||
|
||||
# SETTING: set warning level
|
||||
ifeq ($(WARNINGS), ALL)
|
||||
CFLAGS += -w on -requireprotos
|
||||
else
|
||||
ifeq ($(WARNINGS), NONE)
|
||||
CFLAGS += -w off
|
||||
endif
|
||||
endif
|
||||
|
||||
# clear the standard environment variable
|
||||
# now there are no standard libraries to link against
|
||||
BELIBFILES=
|
||||
|
||||
# set the linker and linker flags
|
||||
LD = mwldppc
|
||||
|
||||
# SETTING: set linker flags for each binary type
|
||||
ifeq ($(TYPE), APP)
|
||||
LDFLAGS +=
|
||||
else
|
||||
ifeq ($(TYPE), SHARED)
|
||||
LDFLAGS += -xms
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TYPE), DRIVER)
|
||||
LDFLAGS += -nodefaults \
|
||||
-export all \
|
||||
-G \
|
||||
/boot/develop/lib/ppc/glue-noinit.a \
|
||||
/boot/develop/lib/ppc/_KERNEL_
|
||||
else
|
||||
LDFLAGS += -export pragma \
|
||||
-init _init_routine_ \
|
||||
-term _term_routine_ \
|
||||
-lroot \
|
||||
/boot/develop/lib/ppc/glue-noinit.a \
|
||||
/boot/develop/lib/ppc/init_term_dyn.o \
|
||||
/boot/develop/lib/ppc/start_dyn.o
|
||||
endif
|
||||
|
||||
|
||||
# SETTING: output symbols in an xMAP file
|
||||
ifeq ($(SYMBOLS), TRUE)
|
||||
LDFLAGS += -map $(TARGET).xMAP
|
||||
endif
|
||||
|
||||
# SETTING: output debugging info to a .SYM file
|
||||
ifeq ($(DEBUGGER), TRUE)
|
||||
LDFLAGS += -g -osym $(TARGET).SYM
|
||||
endif
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# psuedo-function for converting a list of source files in SRCS variable
|
||||
# to a corresponding list of object files in $(OBJ_DIR)/xxx.o
|
||||
# The "function" strips off the src file suffix (.ccp or .c or whatever)
|
||||
# and then strips of the directory name, leaving just the root file name.
|
||||
# It then appends the .o suffix and prepends the $(OBJ_DIR)/ path
|
||||
define SRCS_LIST_TO_OBJS
|
||||
$(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(SRCS), \
|
||||
$(basename $(notdir $(file))))))
|
||||
endef
|
||||
|
||||
define SRCS_LIST_TO_DEPENDS
|
||||
$(addprefix $(OBJ_DIR)/, $(addsuffix .d, $(foreach file, $(SRCS), \
|
||||
$(basename $(notdir $(file))))))
|
||||
endef
|
||||
|
||||
OBJS = $(SRCS_LIST_TO_OBJS)
|
||||
DEPENDS = $(SRCS_LIST_TO_DEPENDS)
|
||||
|
||||
# create a unique list of paths to our sourcefiles
|
||||
SRC_PATHS += $(sort $(foreach file, $(SRCS), $(dir $(file))))
|
||||
|
||||
# add source paths to VPATH if not already present
|
||||
VPATH :=
|
||||
VPATH += $(addprefix :, $(subst ,:, $(filter-out $($(subst, :, ,$(VPATH))), $(SRC_PATHS))))
|
||||
|
||||
# SETTING: build the local and system include paths
|
||||
ifeq ($(CPU), x86)
|
||||
LOC_INCLUDES = $(foreach path, $(SRC_PATHS) $(LOCAL_INCLUDE_PATHS), $(addprefix -I, $(path)))
|
||||
SYS_INCLUDES += -I-
|
||||
SYS_INCLUDES += $(foreach path, $(SYSTEM_INCLUDE_PATHS), $(addprefix -I, $(path)))
|
||||
else
|
||||
ifeq ($(CPU), ppc)
|
||||
LOC_INCLUDES = $(foreach path, $(SRC_PATHS) $(LOCAL_INCLUDE_PATHS), $(addprefix -I, $(path)))
|
||||
SYS_INCLUDES += -i-
|
||||
SYS_INCLUDES += $(foreach path, $(SYSTEM_INCLUDE_PATHS), $(addprefix -i , $(path)))
|
||||
endif
|
||||
endif
|
||||
|
||||
INCLUDES = $(LOC_INCLUDES) $(SYS_INCLUDES)
|
||||
|
||||
# SETTING: add the -L prefix to all library paths to search
|
||||
LINK_PATHS = $(foreach path, $(SRC_PATHS) $(LIBPATHS), \
|
||||
$(addprefix -L, $(path)))
|
||||
|
||||
# SETTING: specify the additional libraries to link against
|
||||
# if the libraries have a .so or .a prefix, or if they are _APP_ or _KERNEL_
|
||||
# simply add them to the list
|
||||
LINK_LIBS += $(filter %.so %.a _APP_ _KERNEL_, $(LIBS))
|
||||
# if the libraries do not have suffixes and are not _APP_ or _KERNEL_
|
||||
# prepend -l to each name: be becomes -lbe
|
||||
LINK_LIBS += $(foreach lib, $(filter-out %.so %.a _APP_ _KERNEL_, $(LIBS)), $(addprefix -l, $(lib)))
|
||||
|
||||
# add to the linker flags
|
||||
LDFLAGS += $(LINK_PATHS) $(LINK_LIBS)
|
||||
|
||||
# SETTING: add the defines to the compiler flags
|
||||
CFLAGS += $(foreach define, $(DEFINES), $(addprefix -D, $(define)))
|
||||
|
||||
# SETTING: add the additional compiler flags
|
||||
CFLAGS += $(COMPILER_FLAGS)
|
||||
|
||||
# SETTING: add the additional linker flags
|
||||
LDFLAGS += $(LINKER_FLAGS)
|
||||
|
||||
# SETTING: use the archive tools if building a static library
|
||||
# otherwise use the linker
|
||||
ifeq ($(TYPE), STATIC)
|
||||
BUILD_LINE = ar -cru "$(TARGET)" $(OBJS)
|
||||
else
|
||||
BUILD_LINE = $(LD) -o $@ $(OBJS) $(LDFLAGS)
|
||||
endif
|
||||
|
||||
# create the resource instruction
|
||||
ifeq ($(RSRCS), )
|
||||
DO_RSRCS :=
|
||||
else
|
||||
DO_RSRCS := $(XRES) -o "$(TARGET)" $(RSRCS)
|
||||
endif
|
||||
|
||||
|
||||
# define the actual work to be done
|
||||
default: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJ_DIR) $(OBJS) $(RSRCS)
|
||||
$(BUILD_LINE)
|
||||
$(DO_RSRCS)
|
||||
$(MIMESET) -f $@
|
||||
|
||||
|
||||
# rule to create the object file directory if needed
|
||||
$(OBJ_DIR)::
|
||||
@[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1
|
||||
|
||||
# rules to make the dependency files
|
||||
$(OBJ_DIR)/%.d : %.c
|
||||
[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1; \
|
||||
mkdepend $(LOC_INCLUDES) -p .c:$(OBJ_DIR)/%n.o -m -f $@ $<
|
||||
$(OBJ_DIR)/%.d : %.cpp
|
||||
[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1; \
|
||||
mkdepend $(LOC_INCLUDES) -p .cpp:$(OBJ_DIR)/%n.o -m -f $@ $<
|
||||
$(OBJ_DIR)/%.d : %.cp
|
||||
[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1; \
|
||||
mkdepend $(LOC_INCLUDES) -p .cp:$(OBJ_DIR)/%n.o -m -f $@ $<
|
||||
$(OBJ_DIR)/%.d : %.cc
|
||||
[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1; \
|
||||
mkdepend $(LOC_INCLUDES) -p .cc:$(OBJ_DIR)/%n.o -m -f $@ $<
|
||||
$(OBJ_DIR)/%.d : %.C
|
||||
[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1; \
|
||||
mkdepend $(LOC_INCLUDES) -p .C:$(OBJ_DIR)/%n.o -m -f $@ $<
|
||||
$(OBJ_DIR)/%.d : %.CC
|
||||
[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1; \
|
||||
mkdepend $(LOC_INCLUDES) -p .CC:$(OBJ_DIR)/%n.o -m -f $@ $<
|
||||
$(OBJ_DIR)/%.d : %.CPP
|
||||
[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1; \
|
||||
mkdepend $(LOC_INCLUDES) -p .CPP:$(OBJ_DIR)/%n.o -m -f $@ $<
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
# rules to make the object files
|
||||
$(OBJ_DIR)/%.o : %.c
|
||||
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
|
||||
$(OBJ_DIR)/%.o : %.cpp
|
||||
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
|
||||
$(OBJ_DIR)/%.o : %.cp
|
||||
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
|
||||
$(OBJ_DIR)/%.o : %.cc
|
||||
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
|
||||
$(OBJ_DIR)/%.o : %.C
|
||||
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
|
||||
$(OBJ_DIR)/%.o : %.CC
|
||||
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
|
||||
$(OBJ_DIR)/%.o : %.CPP
|
||||
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
|
||||
|
||||
# rules to handle lex/flex and yacc/bison files
|
||||
|
||||
$(OBJ_DIR)/%.o: %.l
|
||||
flex $<
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) lex.yy.c -o $@
|
||||
$(OBJ_DIR)/%.o: %.y
|
||||
bison -d -y $<
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) y.tab.c -o $@
|
||||
|
||||
# empty rule. Things that depend on this rule will always get triggered
|
||||
FORCE:
|
||||
|
||||
# The generic clean command. Delete everything in the object folder.
|
||||
clean :: FORCE
|
||||
-rm -rf $(OBJ_DIR)
|
||||
|
||||
# remove just the application from the object folder
|
||||
rmapp ::
|
||||
-rm -f $(TARGET)
|
||||
|
||||
# make it easy to install drivers for testing
|
||||
USER_BIN_PATH = /boot/home/config/add-ons/kernel/drivers/bin
|
||||
USER_DEV_PATH = /boot/home/config/add-ons/kernel/drivers/dev
|
||||
|
||||
driverinstall ::
|
||||
ifeq ($(TYPE), DRIVER)
|
||||
copyattr --data $(OBJ_DIR)/$(NAME) $(USER_BIN_PATH)/$(NAME)
|
||||
mkdir -p $(USER_DEV_PATH)/$(DRIVER_PATH)
|
||||
ln -sf $(USER_BIN_PATH)/$(NAME) $(USER_DEV_PATH)/$(DRIVER_PATH)/$(NAME)
|
||||
endif
|
||||
Reference in New Issue
Block a user