Author: siarzhuk Date: 2011-02-28 21:38:05 +0100 (Mon, 28 Feb 2011) New Revision: 40742 Changeset: http://dev.haiku-os.org/changeset/40742 Modified: haiku/trunk/data/develop/makefile haiku/trunk/data/develop/makefile-engine Log: Added support for localization features into makefile-engine and makefile template. Have fun! Modified: haiku/trunk/data/develop/makefile =================================================================== --- haiku/trunk/data/develop/makefile 2011-02-28 19:47:38 UTC (rev 40741) +++ haiku/trunk/data/develop/makefile 2011-02-28 20:38:05 UTC (rev 40742) @@ -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 @@ # 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 @@ # - 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 @@ # 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 Modified: haiku/trunk/data/develop/makefile-engine =================================================================== --- haiku/trunk/data/develop/makefile-engine 2011-02-28 19:47:38 UTC (rev 40741) +++ haiku/trunk/data/develop/makefile-engine 2011-02-28 20:38:05 UTC (rev 40742) @@ -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 @@ TYPE = APP endif +ifeq ($(APP_MIME_SIG), ) + APP_MIME = x.vnd-Haiku-$(NAME) +endif + ifeq ($(DRIVER_PATH), ) DRIVER_PATH = misc endif @@ -217,7 +221,21 @@ 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 @@ $(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 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 @@ 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) +