2015-06-22 19:18:44 +03:00
|
|
|
## Haiku Generic Makefile Engine v2.6 ##
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
## Does all the hard work for the Generic Makefile, which only has to specify
|
|
|
|
## the project parameters.
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
## Supports Generic Makefile v2.6.
|
|
|
|
## Probably works with Generic Makefile v2.0+, but support is not guaranteed.
|
|
|
|
|
|
|
|
# Determine the CPU type
|
2009-03-19 15:19:41 +03:00
|
|
|
MACHINE=$(shell uname -m)
|
|
|
|
ifeq ($(MACHINE), BePC)
|
|
|
|
CPU = x86
|
|
|
|
else
|
2009-08-04 20:34:30 +04:00
|
|
|
CPU = $(MACHINE)
|
2009-03-19 15:19:41 +03:00
|
|
|
endif
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Set up defaults.
|
2009-03-19 15:19:41 +03:00
|
|
|
ifeq ($(NAME), )
|
|
|
|
NAME = NameThisApp
|
|
|
|
endif
|
2009-05-21 19:04:37 +04:00
|
|
|
|
2009-03-19 15:19:41 +03:00
|
|
|
ifeq ($(TYPE), )
|
|
|
|
TYPE = APP
|
|
|
|
endif
|
|
|
|
|
2011-02-28 23:38:05 +03:00
|
|
|
ifeq ($(APP_MIME_SIG), )
|
|
|
|
APP_MIME = x.vnd-Haiku-$(NAME)
|
|
|
|
endif
|
|
|
|
|
2009-03-19 15:19:41 +03:00
|
|
|
ifeq ($(DRIVER_PATH), )
|
|
|
|
DRIVER_PATH = misc
|
|
|
|
endif
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Set the core tools if they're not already specified.
|
|
|
|
MIMESET := mimeset
|
|
|
|
XRES := xres
|
|
|
|
RESCOMP := rc
|
|
|
|
CC := gcc
|
|
|
|
C++ := g++
|
|
|
|
|
|
|
|
# Set up CFLAGS.
|
|
|
|
ifeq ($(strip $(TYPE)), DRIVER)
|
|
|
|
CFLAGS += -D_KERNEL_MODE=1 -fno-pic
|
|
|
|
else
|
|
|
|
CFLAGS +=
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Set up optimization flags.
|
|
|
|
ifeq ($(strip $(OPTIMIZE)), FULL)
|
|
|
|
OPTIMIZER = -O3
|
|
|
|
else
|
|
|
|
ifeq ($(strip $(OPTIMIZE)), SOME)
|
|
|
|
OPTIMIZER = -O1
|
|
|
|
else
|
|
|
|
ifeq ($(strip $(OPTIMIZE)), NONE)
|
|
|
|
OPTIMIZER = -O0
|
|
|
|
else
|
|
|
|
# OPTIMIZE isn't set, so set it to FULL
|
|
|
|
OPTIMIZER = -O3
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Set up debug information flags.
|
|
|
|
ifeq ($(strip $(DEBUGGER)), TRUE)
|
|
|
|
DEBUG += -g
|
|
|
|
OPTIMIZER = -O0
|
|
|
|
endif
|
|
|
|
CFLAGS += $(OPTIMIZER) $(DEBUG)
|
|
|
|
|
|
|
|
# Set up the warning flags.
|
|
|
|
ifeq ($(strip $(WARNINGS)), ALL)
|
|
|
|
CFLAGS += -Wall -Wno-multichar -Wno-ctor-dtor-privacy
|
|
|
|
else
|
|
|
|
ifeq ($(strip $(WARNINGS)), NONE)
|
|
|
|
CFLAGS += -w
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Set up the linker & linker flags.
|
2011-02-28 22:17:55 +03:00
|
|
|
ifeq ($(origin LD), default)
|
|
|
|
LD := gcc
|
|
|
|
endif
|
2015-06-22 19:18:44 +03:00
|
|
|
LDFLAGS += $(DEBUG)
|
|
|
|
|
|
|
|
# Binary-type-specific linker flags.
|
|
|
|
ifeq ($(strip $(TYPE)), APP)
|
|
|
|
LDFLAGS += -Xlinker -soname=_APP_
|
|
|
|
else
|
|
|
|
ifeq ($(strip $(TYPE)), SHARED)
|
|
|
|
LDFLAGS += -shared -Xlinker -soname=$(NAME)
|
|
|
|
else
|
|
|
|
ifeq ($(strip $(TYPE)), DRIVER)
|
|
|
|
LDFLAGS += -nostdlib /boot/system/develop/lib/_KERNEL_ \
|
|
|
|
/boot/system/develop/lib/haiku_version_glue.o
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Get the compiler version.
|
|
|
|
CC_VER = $(word 1, $(subst -, , $(subst ., , $(shell $(CC) -dumpversion))))
|
|
|
|
|
|
|
|
# Set the object directory if it isn't already.
|
|
|
|
OBJ_DIR := objects.$(CPU)-$(CC)$(CC_VER)-$(if $(DEBUGGER),debug,release)
|
|
|
|
|
|
|
|
# Output the binary alongside the objects unless another directory is specified.
|
2010-06-19 13:39:04 +04:00
|
|
|
ifeq ($(TARGET_DIR), )
|
|
|
|
TARGET_DIR := $(OBJ_DIR)
|
|
|
|
endif
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# NOTE: make doesn't find the target if its name is enclosed in quotes.
|
2011-11-06 17:15:57 +04:00
|
|
|
ifeq ($(strip $(TYPE)), STATIC)
|
|
|
|
TARGET := $(TARGET_DIR)/$(NAME).a
|
2014-03-26 02:35:18 +04:00
|
|
|
else
|
2010-06-19 13:39:04 +04:00
|
|
|
TARGET := $(TARGET_DIR)/$(NAME)
|
2011-11-06 17:15:57 +04:00
|
|
|
endif
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# 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 off the
|
|
|
|
# off the directory name, leaving just the root file name. It then appends the
|
|
|
|
# .o suffix and prepends the $(OBJ_DIR)/ path
|
2009-03-19 15:19:41 +03:00
|
|
|
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)
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Create a unique list of paths to our sourcefiles and resources.
|
2014-08-13 10:05:13 +04:00
|
|
|
SRC_PATHS += $(sort $(foreach file, $(SRCS) $(RSRCS) $(RDEFS), $(dir $(file))))
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Add source paths to VPATH if not already present.
|
2009-03-19 15:19:41 +03:00
|
|
|
VPATH :=
|
|
|
|
VPATH += $(addprefix :, $(subst ,:, $(filter-out $($(subst, :, ,$(VPATH))), $(SRC_PATHS))))
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Set up the local & system include paths and C++ stdlibs.
|
2013-01-09 22:32:35 +04:00
|
|
|
ifneq (,$(filter $(CPU),x86 x86_64))
|
2009-03-19 15:19:41 +03:00
|
|
|
LOC_INCLUDES = $(foreach path, $(SRC_PATHS) $(LOCAL_INCLUDE_PATHS), $(addprefix -I, $(path)))
|
2010-06-20 00:26:04 +04:00
|
|
|
ifeq ($(CC_VER), 2)
|
2010-06-19 13:39:04 +04:00
|
|
|
INCLUDES = $(LOC_INCLUDES)
|
|
|
|
INCLUDES += -I-
|
2010-06-20 00:26:04 +04:00
|
|
|
INCLUDES += $(foreach path, $(SYSTEM_INCLUDE_PATHS), $(addprefix -I, $(path)))
|
2014-03-26 02:35:18 +04:00
|
|
|
|
2011-10-27 00:12:09 +04:00
|
|
|
STDCPPLIBS = stdc++.r4
|
2010-06-19 13:39:04 +04:00
|
|
|
else
|
|
|
|
INCLUDES = -iquote./
|
|
|
|
INCLUDES += $(foreach path, $(SRC_PATHS) $(LOCAL_INCLUDE_PATHS), $(addprefix -iquote, $(path)))
|
2010-06-20 00:26:04 +04:00
|
|
|
INCLUDES += $(foreach path, $(SYSTEM_INCLUDE_PATHS), $(addprefix -isystem, $(path)))
|
2014-03-26 02:35:18 +04:00
|
|
|
|
2011-10-27 00:12:09 +04:00
|
|
|
STDCPPLIBS = stdc++ supc++
|
2010-06-19 13:39:04 +04:00
|
|
|
endif
|
2009-03-19 15:19:41 +03:00
|
|
|
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)))
|
2010-12-13 14:58:15 +03:00
|
|
|
|
2010-06-19 13:39:04 +04:00
|
|
|
INCLUDES = $(LOC_INCLUDES) $(SYS_INCLUDES)
|
2009-03-19 15:19:41 +03:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Add the -L prefix to all of the library paths.
|
2009-03-19 15:19:41 +03:00
|
|
|
LINK_PATHS = $(foreach path, $(SRC_PATHS) $(LIBPATHS), \
|
|
|
|
$(addprefix -L, $(path)))
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Handle the additional libraries specified. If the libraries have a .so or
|
|
|
|
# a .a prefix, or if they are _APP_ or _KERNEL_, simply add them to the list.
|
2009-03-19 15:19:41 +03:00
|
|
|
LINK_LIBS += $(filter %.so %.a _APP_ _KERNEL_, $(LIBS))
|
2015-06-22 19:18:44 +03:00
|
|
|
# If the libraries do not have suffixes and are not _APP_ or _KERNEL_,
|
|
|
|
# prepend -l to each name:(e.g. "be" becomes "-lbe").
|
2009-03-19 15:19:41 +03:00
|
|
|
LINK_LIBS += $(foreach lib, $(filter-out %.so %.a _APP_ _KERNEL_, $(LIBS)), $(addprefix -l, $(lib)))
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Add the linkpaths and linklibs to LDFLAGS.
|
2009-03-19 15:19:41 +03:00
|
|
|
LDFLAGS += $(LINK_PATHS) $(LINK_LIBS)
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Add the defines to CFLAGS.
|
2009-03-19 15:19:41 +03:00
|
|
|
CFLAGS += $(foreach define, $(DEFINES), $(addprefix -D, $(define)))
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Add the additional compiler flags to CFLAGS.
|
2009-03-19 15:19:41 +03:00
|
|
|
CFLAGS += $(COMPILER_FLAGS)
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Add the additional linkflags to LDFLAGS
|
2009-03-19 15:19:41 +03:00
|
|
|
LDFLAGS += $(LINKER_FLAGS)
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Use the archiving tools to create an an archive if we're building a static
|
|
|
|
# library, otherwise use the linker.
|
2011-10-16 20:02:34 +04:00
|
|
|
ifeq ($(strip $(TYPE)), STATIC)
|
2009-03-19 15:19:41 +03:00
|
|
|
BUILD_LINE = ar -cru "$(TARGET)" $(OBJS)
|
|
|
|
else
|
2009-10-29 22:43:57 +03:00
|
|
|
BUILD_LINE = $(LD) -o "$@" $(OBJS) $(LDFLAGS)
|
2009-03-19 15:19:41 +03:00
|
|
|
endif
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Pseudo-function for converting a list of resource definition files in RDEFS
|
|
|
|
# variable to a corresponding list of object files in $(OBJ_DIR)/xxx.rsrc.
|
2009-05-21 19:04:37 +04:00
|
|
|
# The "function" strips off the rdef file suffix (.rdef) and then strips
|
2015-06-22 19:18:44 +03:00
|
|
|
# of the directory name, leaving just the root file name. It then appends the
|
|
|
|
# the .rsrc suffix and prepends the $(OBJ_DIR)/ path.
|
2009-05-17 00:10:01 +04:00
|
|
|
define RDEFS_LIST_TO_RSRCS
|
|
|
|
$(addprefix $(OBJ_DIR)/, $(addsuffix .rsrc, $(foreach file, $(RDEFS), \
|
|
|
|
$(basename $(notdir $(file))))))
|
|
|
|
endef
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Create the resource definitions instruction in case RDEFS is not empty.
|
|
|
|
ifeq ($(RDEFS), )
|
|
|
|
RSRCS +=
|
|
|
|
else
|
|
|
|
RSRCS += $(RDEFS_LIST_TO_RSRCS)
|
|
|
|
endif
|
2009-05-17 00:10:01 +04:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Create the resource instruction.
|
|
|
|
ifeq ($(RSRCS), )
|
|
|
|
DO_RSRCS :=
|
|
|
|
else
|
|
|
|
DO_RSRCS := $(XRES) -o $(TARGET) $(RSRCS)
|
|
|
|
endif
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Set the directory for internationalization sources (catkeys) if it isn't
|
|
|
|
# already.
|
|
|
|
CATKEYS_DIR := locales
|
2011-02-28 23:38:05 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Set the directory for internationalization resource data (catalogs) if it
|
|
|
|
# isn't already.
|
|
|
|
CATALOGS_DIR := $(OBJ_DIR)/$(APP_MIME_SIG)
|
2011-02-28 23:38:05 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Pseudo-function for converting a list of language codes in CATALOGS variable
|
2011-02-28 23:38:05 +03:00
|
|
|
# to a corresponding list of catkeys files in $(CATALOGS_DIR)/xx.catalog
|
2015-06-22 19:18:44 +03:00
|
|
|
# The "function" appends the .catalog suffix and prepends the
|
|
|
|
# $(CATALOGS_DIR)/ path.
|
2011-02-28 23:38:05 +03:00
|
|
|
define LOCALES_LIST_TO_CATALOGS
|
|
|
|
$(addprefix $(CATALOGS_DIR)/, $(addsuffix .catalog, $(foreach lang, $(LOCALES), $(lang))))
|
|
|
|
endef
|
|
|
|
|
|
|
|
CATALOGS = $(LOCALES_LIST_TO_CATALOGS)
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Define the actual work to be done.
|
2009-03-19 15:19:41 +03:00
|
|
|
default: $(TARGET)
|
|
|
|
|
|
|
|
$(TARGET): $(OBJ_DIR) $(OBJS) $(RSRCS)
|
2015-06-22 19:18:44 +03:00
|
|
|
$(BUILD_LINE)
|
|
|
|
$(DO_RSRCS)
|
|
|
|
$(MIMESET) -f "$@"
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Create OBJ_DIR if it doesn't exist.
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)::
|
2015-06-22 19:18:44 +03:00
|
|
|
@[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) >/dev/null 2>&1
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Create the localization sources directory if it doesn't exist.
|
2011-02-28 23:38:05 +03:00
|
|
|
$(CATKEYS_DIR)::
|
2015-06-22 19:18:44 +03:00
|
|
|
@[ -d $(CATKEYS_DIR) ] || mkdir $(CATKEYS_DIR) >/dev/null 2>&1
|
2011-02-28 23:38:05 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Create the localization data directory if it doesn't exist.
|
2011-02-28 23:38:05 +03:00
|
|
|
$(CATALOGS_DIR):: $(OBJ_DIR)
|
2015-06-22 19:18:44 +03:00
|
|
|
@[ -d $(CATALOGS_DIR) ] || mkdir $(CATALOGS_DIR) >/dev/null 2>&1
|
2011-02-28 23:38:05 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Rules to create the dependency files.
|
2015-06-22 20:25:52 +03:00
|
|
|
$(OBJ_DIR)/%.d : %.c
|
2015-06-22 19:39:27 +03:00
|
|
|
mkdir -p $(OBJ_DIR); \
|
2009-10-29 22:43:57 +03:00
|
|
|
mkdepend $(LOC_INCLUDES) -p .c:$(OBJ_DIR)/%n.o -m -f "$@" $<
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.d : %.cpp
|
2015-06-22 19:39:27 +03:00
|
|
|
mkdir -p $(OBJ_DIR); \
|
2009-10-29 22:43:57 +03:00
|
|
|
mkdepend $(LOC_INCLUDES) -p .cpp:$(OBJ_DIR)/%n.o -m -f "$@" $<
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.d : %.cp
|
2015-06-22 19:39:27 +03:00
|
|
|
mkdir -p $(OBJ_DIR); \
|
2009-10-29 22:43:57 +03:00
|
|
|
mkdepend $(LOC_INCLUDES) -p .cp:$(OBJ_DIR)/%n.o -m -f "$@" $<
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.d : %.cc
|
2015-06-22 19:39:27 +03:00
|
|
|
mkdir -p $(OBJ_DIR); \
|
2009-10-29 22:43:57 +03:00
|
|
|
mkdepend $(LOC_INCLUDES) -p .cc:$(OBJ_DIR)/%n.o -m -f "$@" $<
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.d : %.C
|
2015-06-22 19:39:27 +03:00
|
|
|
mkdir -p $(OBJ_DIR); \
|
2009-10-29 22:43:57 +03:00
|
|
|
mkdepend $(LOC_INCLUDES) -p .C:$(OBJ_DIR)/%n.o -m -f "$@" $<
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.d : %.CC
|
2015-06-22 19:39:27 +03:00
|
|
|
mkdir -p $(OBJ_DIR); \
|
2009-10-29 22:43:57 +03:00
|
|
|
mkdepend $(LOC_INCLUDES) -p .CC:$(OBJ_DIR)/%n.o -m -f "$@" $<
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.d : %.CPP
|
2015-06-22 19:39:27 +03:00
|
|
|
mkdir -p $(OBJ_DIR); \
|
2009-10-29 22:43:57 +03:00
|
|
|
mkdepend $(LOC_INCLUDES) -p .CPP:$(OBJ_DIR)/%n.o -m -f "$@" $<
|
2009-03-19 15:19:41 +03:00
|
|
|
|
|
|
|
-include $(DEPENDS)
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Rules to make the object files.
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.o : %.c
|
2009-10-29 22:43:57 +03:00
|
|
|
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o "$@"
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.o : %.cpp
|
2009-10-29 22:43:57 +03:00
|
|
|
$(C++) -c $< $(INCLUDES) $(CFLAGS) -o "$@"
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.o : %.cp
|
2009-10-29 22:43:57 +03:00
|
|
|
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o "$@"
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.o : %.cc
|
2009-10-29 22:43:57 +03:00
|
|
|
$(C++) -c $< $(INCLUDES) $(CFLAGS) -o "$@"
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.o : %.C
|
2009-10-29 22:43:57 +03:00
|
|
|
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o "$@"
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.o : %.CC
|
2009-10-29 22:43:57 +03:00
|
|
|
$(C++) -c $< $(INCLUDES) $(CFLAGS) -o "$@"
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.o : %.CPP
|
2009-10-29 22:43:57 +03:00
|
|
|
$(C++) -c $< $(INCLUDES) $(CFLAGS) -o "$@"
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Rules to compile the resource definition files.
|
2009-05-17 00:10:01 +04:00
|
|
|
$(OBJ_DIR)/%.rsrc : %.rdef
|
2010-12-13 14:58:15 +03:00
|
|
|
cat $< | $(CC) -E $(INCLUDES) $(CFLAGS) - | grep -v '^#' | $(RESCOMP) -I $(dir $<) -o "$@" -
|
2009-05-17 00:10:01 +04:00
|
|
|
$(OBJ_DIR)/%.rsrc : %.RDEF
|
2010-12-13 14:58:15 +03:00
|
|
|
cat $< | $(CC) -E $(INCLUDES) $(CFLAGS) - | grep -v '^#' | $(RESCOMP) -I $(dir $<) -o "$@" -
|
2009-05-17 00:10:01 +04:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Rule to compile localization data catalogs.
|
2011-02-28 23:38:05 +03:00
|
|
|
$(CATALOGS_DIR)/%.catalog : $(CATKEYS_DIR)/%.catkeys
|
|
|
|
linkcatkeys -o "$@" -s $(APP_MIME_SIG) -l $(notdir $(basename $@)) $<
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Rule to preprocess program sources into file ready for collecting catkeys.
|
2011-02-28 23:38:05 +03:00
|
|
|
$(OBJ_DIR)/$(NAME).pre : $(SRCS)
|
2011-10-27 00:12:09 +04:00
|
|
|
-cat $(SRCS) | $(CC) -E -x c++ $(INCLUDES) $(CFLAGS) -DB_COLLECTING_CATKEYS - > $(OBJ_DIR)/$(NAME).pre
|
2011-02-28 23:38:05 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Rules to collect localization catkeys.
|
2011-02-28 23:38:05 +03:00
|
|
|
catkeys : $(CATKEYS_DIR)/en.catkeys
|
|
|
|
|
|
|
|
$(CATKEYS_DIR)/en.catkeys : $(CATKEYS_DIR) $(OBJ_DIR)/$(NAME).pre
|
|
|
|
collectcatkeys -s $(APP_MIME_SIG) $(OBJ_DIR)/$(NAME).pre -o $(CATKEYS_DIR)/en.catkeys
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Rule to create localization catalogs.
|
2011-02-28 23:38:05 +03:00
|
|
|
catalogs : $(CATALOGS_DIR) $(CATALOGS)
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Rules to handle lex/flex and yacc/bison files.
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.o: %.l
|
|
|
|
flex $<
|
2009-10-29 22:43:57 +03:00
|
|
|
$(CC) -c $(INCLUDES) $(CFLAGS) lex.yy.c -o "$@"
|
2009-03-19 15:19:41 +03:00
|
|
|
$(OBJ_DIR)/%.o: %.y
|
|
|
|
bison -d -y $<
|
2009-10-29 22:43:57 +03:00
|
|
|
$(CC) -c $(INCLUDES) $(CFLAGS) y.tab.c -o "$@"
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# The generic "clean" command. (Deletes everything in the object folder.)
|
2015-06-22 20:12:07 +03:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2009-08-04 20:49:06 +04:00
|
|
|
-rm -rf "$(OBJ_DIR)"
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Remove just the application from the object folder.
|
2009-03-19 15:19:41 +03:00
|
|
|
rmapp ::
|
2009-10-30 00:30:56 +03:00
|
|
|
-rm -f $(TARGET)
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Make it easy to install drivers for testing.
|
2014-08-13 10:05:13 +04:00
|
|
|
USER_BIN_PATH := $(shell finddir B_USER_NONPACKAGED_ADDONS_DIRECTORY)/kernel/drivers/bin
|
|
|
|
USER_DEV_PATH := $(shell finddir B_USER_NONPACKAGED_ADDONS_DIRECTORY)/kernel/drivers/dev
|
2009-03-19 15:19:41 +03:00
|
|
|
|
2009-08-04 20:49:06 +04:00
|
|
|
driverinstall :: default
|
2011-10-16 20:02:34 +04:00
|
|
|
ifeq ($(strip $(TYPE)), DRIVER)
|
2010-06-19 13:39:04 +04:00
|
|
|
copyattr --data $(TARGET) $(USER_BIN_PATH)/$(NAME)
|
2009-03-19 15:19:41 +03:00
|
|
|
mkdir -p $(USER_DEV_PATH)/$(DRIVER_PATH)
|
|
|
|
ln -sf $(USER_BIN_PATH)/$(NAME) $(USER_DEV_PATH)/$(DRIVER_PATH)/$(NAME)
|
|
|
|
endif
|
2009-08-04 20:49:06 +04:00
|
|
|
|
|
|
|
install :: default
|
|
|
|
ifeq ($(INSTALL_DIR), )
|
|
|
|
@echo "No install directory specified for \"$(NAME)\" (INSTALL_DIR is empty)" >&2
|
|
|
|
else
|
|
|
|
mkdir -p "$(INSTALL_DIR)"
|
2009-10-30 00:30:56 +03:00
|
|
|
cp $(TARGET) $(INSTALL_DIR)/$(NAME)
|
2009-08-04 20:49:06 +04:00
|
|
|
endif
|
2011-02-28 23:38:05 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Set the catalog installation directory if it isn't already.
|
2014-08-13 10:05:13 +04:00
|
|
|
CATALOG_INSTALL_DIR := $(shell finddir B_USER_NONPACKAGED_DATA_DIRECTORY)/locale/catalogs
|
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Rule to install localization resources catalogs.
|
2011-02-28 23:38:05 +03:00
|
|
|
catalogsinstall :: catalogs
|
2014-08-13 10:05:13 +04:00
|
|
|
mkdir -p "$(CATALOG_INSTALL_DIR)/$(APP_MIME_SIG)"
|
|
|
|
-cp $(CATALOGS_DIR)/*.catalog "$(CATALOG_INSTALL_DIR)/$(APP_MIME_SIG)"
|
2011-02-28 23:38:05 +03:00
|
|
|
|
2015-06-22 19:18:44 +03:00
|
|
|
# Alternate way of storing localization catalogs: bind them into the program
|
|
|
|
# executable's resources.
|
2011-11-06 17:15:57 +04:00
|
|
|
bindcatalogs :
|
|
|
|
for lc in $(LOCALES); do linkcatkeys -o $(TARGET) -s $(APP_MIME_SIG) -tr -l $$lc $(CATKEYS_DIR)/$$lc.catkeys; done
|