Added support for localization features into makefile-engine

and makefile template. Have fun!



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40742 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Siarzhuk Zharski
2011-02-28 20:38:05 +00:00
parent 1c53a6ee5d
commit 4f36bcc2d7
2 changed files with 67 additions and 3 deletions
+16 -1
View File
@@ -1,4 +1,4 @@
## BeOS Generic Makefile v2.3 ##
## BeOS Generic Makefile v2.4 ##
## 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
@@ -16,6 +16,10 @@ NAME=
# DRIVER: Kernel Driver
TYPE=
# if you plan to use localization features
# specify the application MIME siganture
APP_MIME_SIG=
# add support for new Pe and Eddie features
# to fill in generic makefile
@@ -51,6 +55,9 @@ RSRCS=
# - if your library follows the naming pattern of:
# libXXX.so or libXXX.a you can simply specify XXX
# library: libbe.so entry: be
#
# - for localization support add following libs:
# locale localestub
#
# - if your library does not follow the standard library
# naming scheme you need to specify the path to the library
@@ -80,6 +87,14 @@ LOCAL_INCLUDE_PATHS =
# NONE, SOME, FULL
OPTIMIZE=
# specify here the codes for languages you are going
# to support in this application. The default "en"
# one must be provided too. "make catkeys" will recreate only
# locales/en.catkeys file. Use it as template for creating other
# languages catkeys. All localization files must be placed
# in "locales" sub-directory.
LOCALES=
# 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
+51 -2
View File
@@ -1,8 +1,8 @@
## BeOS and Haiku Generic Makefile Engine v2.2.0
## BeOS and Haiku Generic Makefile Engine v2.4.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, 2.3
## Supports Generic Makefile v2.0, 2.01, 2.1, 2.2, 2.3, 2.4
# determine wheather running on x86 or ppc
MACHINE=$(shell uname -m)
@@ -21,6 +21,10 @@ ifeq ($(TYPE), )
TYPE = APP
endif
ifeq ($(APP_MIME_SIG), )
APP_MIME = x.vnd-Haiku-$(NAME)
endif
ifeq ($(DRIVER_PATH), )
DRIVER_PATH = misc
endif
@@ -217,6 +221,20 @@ endef
DO_RSRCS := $(XRES) -o $(TARGET) $(RSRCS)
endif
# the directory for internationalization sources (catkeys)
CATKEYS_DIR := locales
# the directory for internationalization resource data (catalogs)
CATALOGS_DIR := $(OBJ_DIR)/$(APP_MIME_SIG)
# pseudo-function for converting a list of language codes in CATALOGS variable
# to a corresponding list of catkeys files in $(CATALOGS_DIR)/xx.catalog
# The "function" appends the .catalog suffix and prepends the $(CATALOGS_DIR)/ path
define LOCALES_LIST_TO_CATALOGS
$(addprefix $(CATALOGS_DIR)/, $(addsuffix .catalog, $(foreach lang, $(LOCALES), $(lang))))
endef
CATALOGS = $(LOCALES_LIST_TO_CATALOGS)
# define the actual work to be done
default: $(TARGET)
@@ -231,6 +249,14 @@ $(TARGET): $(OBJ_DIR) $(OBJS) $(RSRCS)
$(OBJ_DIR)::
@[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1
# rule to create the localization sources directory if needed
$(CATKEYS_DIR)::
@[ -d $(CATKEYS_DIR) ] || mkdir $(CATKEYS_DIR) > /dev/null 2>&1
# rule to create the localization data directory if needed
$(CATALOGS_DIR):: $(OBJ_DIR)
@[ -d $(CATALOGS_DIR) ] || mkdir $(CATALOGS_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; \
@@ -278,6 +304,23 @@ $(OBJ_DIR)/%.rsrc : %.rdef
$(OBJ_DIR)/%.rsrc : %.RDEF
cat $< | $(CC) -E $(INCLUDES) $(CFLAGS) - | grep -v '^#' | $(RESCOMP) -I $(dir $<) -o "$@" -
# rule to compile localization data catalogs
$(CATALOGS_DIR)/%.catalog : $(CATKEYS_DIR)/%.catkeys
linkcatkeys -o "$@" -s $(APP_MIME_SIG) -l $(notdir $(basename $@)) $<
# rule to preprocess program sources into file ready for collecting catkeys
$(OBJ_DIR)/$(NAME).pre : $(SRCS)
-cat $(SRCS) | $(CC) -E $(INCLUDES) $(CFLAGS) -DB_COLLECTING_CATKEYS - > $(OBJ_DIR)/$(NAME).pre
# rules to collect localization catkeys
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
# rule to create localization catalogs
catalogs : $(CATALOGS_DIR) $(CATALOGS)
# rules to handle lex/flex and yacc/bison files
$(OBJ_DIR)/%.o: %.l
@@ -316,3 +359,9 @@ else
mkdir -p "$(INSTALL_DIR)"
cp $(TARGET) $(INSTALL_DIR)/$(NAME)
endif
# rule to install localization resources catalogs
catalogsinstall :: catalogs
mkdir -p "/boot/home/config/data/locale/catalogs/$(APP_MIME_SIG)"
-cp $(CATALOGS_DIR)/*.catalog /boot/home/config/data/locale/catalogs/$(APP_MIME_SIG)