1 ## Haiku Generic Jamfile Engine v1.0.2
2 ## Does all the hard work for the Generic Jamfile
3 ## which simply defines the project parameters.
4 ## Most of the real work is done in the Jambase
5 ## embedded into the jam executable.
7 ## Inspired by the Be Makefile Engine
9 ## Supports Generic Jamfile v1.0.1
11 ## Copyright (c) 2002-2010 Ryan Leavengood
12 ## Copyright (c) 2011 Peter Poláčik
13 ## Released under the Terms of the MIT License, see
14 ## http://www.opensource.org/licenses/mit-license.html
16 ##-------------------------------------------------------------------
17 ## Define some utility rules
18 ##-------------------------------------------------------------------
20 # AddResources <Application Name> : <Resource Files> ;
21 # Adds the given resources to the given application.
29 $(XRES) -o "$(<)" $(>)
32 # MimeSet <Application Name> ;
33 # Sets the mime type of the given application to be an application.
39 # ProcessLibs <List of Library Names> ;
40 # Prepends -l to any library names that aren't _APP_ or _KERNEL_ or
41 # that don't have .a or .so file extensions. The result will be given
42 # to the linker so that it links to the right libraries.
48 if ( ( $(i) in _APP_ _KERNEL_ ) || ( $(i:S) in .so .a ) )
60 # MkObjectDirs <List of Source Files> ;
61 # Makes the necessary sub-directories in the object target directory based
62 # on the sub-directories used for the source files.
68 dir = [ FDirName $(LOCATE_TARGET) $(i:D) ] ;
69 Depends $(i:S=$(SUFOBJ)) : $(dir) ;
74 # CollectCatKeys <Pseudotarget Name> : <Source Files> ;
75 # Collects catalog keys for localization from sources into per-locale files
79 Depends $(<) : $(LOCATE_TARGET) ;
80 #Depends $(<) : $(SRCS) ;
81 Depends $(CATKEYS_DIR)/en.catkeys : $(<) ;
84 actions CollectCatKeys
86 cat $(SRCS) | gcc -E -x c++ $(HDRS) $(CCFLAGS) \
87 -DB_COLLECTING_CATKEYS - > $(LOCATE_TARGET)/$(NAME).pre
88 mkdir -p "$(CATKEYS_DIR)"
89 collectcatkeys -s $(APP_MIME_SIG) $(LOCATE_TARGET)/$(NAME).pre \
90 -o $(CATKEYS_DIR)/en.catkeys
93 # Catalogs <Pseudotarget Name> : <CollectCatKeys Target> ;
94 # Compiles .catkeys files into .catalog files, one per locale
98 Depends $(<) : $(SRCS) ;
101 Depends $(<) : $(CATKEYS_DIR)/$(lng:S=.catkeys) ;
102 Depends $(CATKEYS_DIR)/$(lng:S=.catkeys) : $(>) ;
103 #Clean clean : $(CATKEYS_DIR)/$(lng:S=.catkeys) ;
105 $(LOCATE_TARGET)/$(APP_MIME_SIG)/$(lng:S=.catalog) ;
107 Clean clean : $(LOCATE_TARGET)/$(NAME).pre ;
112 mkdir -p $(LOCATE_TARGET)/$(APP_MIME_SIG)
113 TMP=`echo "$(LOCALES)" | tr ';' ' '`
115 for lang in $TMP ; do
116 if [ ! -f $(CATKEYS_DIR)/$lang.catkeys ]; then
117 cp $(CATKEYS_DIR)/en.catkeys \
118 $(CATKEYS_DIR)/$lang.catkeys; fi
120 -o $(LOCATE_TARGET)/$(APP_MIME_SIG)/$lang.catalog \
122 -l `basename $(LOCATE_TARGET)/$(APP_MIME_SIG)/$lang.catalog` \
123 $(CATKEYS_DIR)/$lang.catkeys
127 # CatalogsInstall <Pseudotarget Name> : <Catalog Files> ;
128 # Copies .catalog files into system locale directory
131 Depends $(<) : $(>) ;
132 Depends $(>) : catalogs ;
135 actions CatalogsInstall
137 mkdir -p "/boot/home/config/data/locale/catalogs/$(APP_MIME_SIG)" ;
138 cp $(LOCATE_TARGET)/$(APP_MIME_SIG)/*.catalog \
139 /boot/home/config/data/locale/catalogs/$(APP_MIME_SIG)
142 # BindCatalogs <Pseudotarget Name> : <Catalog Files> ;
143 # Binds .catalog files into program executable
146 Depends $(<) : $(>) ;
147 Depends $(<) : $(NAME) ;
148 Depends $(<) : $(LOCATE_TARGET)/$(NAME) ;
149 Depends $(LOCATE_TARGET)/$(NAME) : $(NAME) ;
155 TMP=`echo $(LOCALES) | tr ';' ' '`
157 linkcatkeys -o $(LOCATE_TARGET)/$(NAME) \
158 -s $(APP_MIME_SIG) -tr \
159 -l $lc $(CATKEYS_DIR)/$lc.catkeys
163 # RmApp <Pseudotarget Name> : <Application Name> ;
164 # Removes the given application file when the given pseudotarget
168 Depends $(<) : $(>) ;
176 # RunApp <Pseudotarget Name> : <Application Name> ;
177 # Runs the given application in the background when the given pseudotarget
181 Depends $(<) : $(>) ;
189 # InstallDriver1 <Pseudotarget Name> : <Driver File> ;
190 # Installs the given driver in the correct location when the given pseudotarget
194 Depends $(<) : $(>) ;
195 USER_BIN_PATH = /boot/home/config/add-ons/kernel/drivers/bin ;
196 USER_DEV_PATH = /boot/home/config/add-ons/kernel/drivers/dev ;
199 actions InstallDriver1
201 copyattr --data "$(>)" "$(USER_BIN_PATH)/$(>:B)"
202 mkdir -p $(USER_DEV_PATH)/$(DRIVER_PATH)
203 ln -sf "$(USER_BIN_PATH)/$(>:B)" "$(USER_DEV_PATH)/$(DRIVER_PATH)/$(>:B)"
206 # InstallDriver <Pseudotarget Name> : <Driver File> ;
207 # Installs the given driver in the correct location when the given pseudotarget
208 # is specified, after making sure that this is actually a driver.
211 if ( $(TYPE) = DRIVER )
213 InstallDriver1 $(<) : $(>) ;
217 # Link <Application Name> : <List of Object Files> ;
218 # Replaces the actions for the default Jam Link rule with one that handles spaces
219 # in application names.
220 actions Link bind NEEDLIBS
222 $(LINK) $(LINKFLAGS) -o "$(<)" $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
225 # BeMain <Application Name> : <List of Source Files> ;
226 # This is the main rule that builds the project.
231 if ( $(TYPE) = STATIC )
233 Library $(<) : $(>) ;
242 AddResources $(<) : $(RSRCS) ;
253 ##-------------------------------------------------------------------
254 ## Now all the needed variables are defined
255 ##-------------------------------------------------------------------
257 # Set the directory where object files and binaries will be created.
258 # The pre-defined Jam variable OSPLAT will indicate what platform we
259 # are on (X86 vs PPC, etc.)
260 LOCATE_TARGET = obj.$(OSPLAT) ;
265 ECHO "No NAME defined!" ;
271 ECHO "No TYPE defined...defaulting to APP" ;
277 ECHO "NO SRCS defined...defaulting to *.cpp in current directory" ;
278 SRCS = [ GLOB . : *.cpp ] ;
281 if ( ! $(DRIVER_PATH) )
286 # Now handle platform-specific settings
287 if ( $(OSPLAT) = X86 )
289 if ( $(TYPE) = DRIVER )
291 CCFLAGS += -D_KERNEL_MODE=1 -no-fpic ;
292 C++FLAGS += -D_KERNEL_MODE=1 -no-fpic ;
297 case FULL : OPTIMIZER = -O3 ;
298 case SOME : OPTIMIZER = -O1 ;
299 case NONE : OPTIMIZER = -O0 ;
301 case * : OPTIMIZER = -O3 ;
306 if ( $(DEBUGGER) = TRUE )
312 CCFLAGS += $(OPTIMIZER) $(DEBUG) ;
313 C++FLAGS += $(OPTIMIZER) $(DEBUG) ;
315 if ( $(WARNINGS) = ALL )
317 CCFLAGS += -Wall -Wno-multichar -Wno-ctor-dtor-privacy ;
318 C++FLAGS += -Wall -Wno-multichar -Wno-ctor-dtor-privacy ;
320 else if ( $(WARNINGS) = NONE )
326 LINKFLAGS += $(DEBUG) ;
331 case APP : LINKFLAGS += -Xlinker -soname=_APP_ ;
332 case SHARED : LINKFLAGS += -shared -Xlinker -soname=$(NAME) ;
333 case DRIVER : LINKFLAGS += -nostdlib /boot/develop/lib/x86/_KERNEL_ ;
336 else if ( $(OSPLAT) = PPC )
340 case FULL : OPTIMIZER = -O7 ;
341 case SOME : OPTIMIZER = -O3 ;
342 case NONE : OPTIMIZER = -O0 ;
344 case * : OPTIMIZER = -O7 ;
349 if ( $(DEBUGGER) = TRUE )
354 CCFLAGS += $(OPTIMIZER) $(DEBUG) ;
355 C++FLAGS += $(OPTIMIZER) $(DEBUG) ;
357 if ( $(WARNINGS) = ALL )
359 CCFLAGS += -w on -requireprotos ;
360 C++FLAGS += -w on -requireprotos ;
362 else if ( $(WARNINGS) = NONE )
368 # Clear the standard environment variable
369 # Now there are no standard libraries to link against
373 if ( $(TYPE) = SHARED )
378 if ( $(TYPE) = DRIVER )
380 LINKFLAGS += -nodefaults -export all -G
381 /boot/develop/lib/ppc/glue-noinit.a
382 /boot/develop/lib/ppc/_KERNEL_ ;
386 LINKFLAGS += -export pragma -init _init_routine_
387 -term _term_routine_ -lroot
388 /boot/develop/lib/ppc/glue-noinit.a
389 /boot/develop/lib/ppc/init_term_dyn.o
390 /boot/develop/lib/ppc/start_dyn.o ;
393 if ( $(SYMBOLS) = TRUE )
395 LINKFLAGS += -map $(NAME).xMAP ;
398 if ( $(DEBUGGER) = TRUE )
400 LINKFLAGS += -g -osym $(NAME).SYM ;
405 EXIT "Your platform is unsupported" ;
408 # Handle the other settings
409 LINKLIBS += [ ProcessLibs $(LIBS) ] ;
412 LINKFLAGS += -L$(i) ;
414 HDRS += $(SYSTEM_INCLUDE_PATHS) ;
415 HDRS += $(LOCAL_INCLUDE_PATHS) ;
416 CCFLAGS += $(COMPILER_FLAGS) ;
417 C++FLAGS += $(COMPILER_FLAGS) ;
418 LINKFLAGS += $(LINKER_FLAGS) ;
420 # Localization specific variables
422 if ( ! $(APP_MIME_SIG) )
424 ECHO "No mime signature defined! Defaulting to x.vnd-Haiku-$(NAME)" ;
425 APP_MIME_SIG = x.vnd-Haiku-$(NAME) ;
428 CATKEYS_DIR = locales ;
429 if ( $(APP_MIME_SIG) )
431 CATALOGS_DIR = $(LOCATE_TARGET)/$(APP_MIME_SIG) ;
432 CATALOGS = $(LOCALES:D=$(CATALOGS_DIR):S=.catalog) ;
439 # Defining this variable keeps objects from being deleted by the Library
440 # rule. By default the objects are deleted after being archived into
441 # the library. I prefer they not be.
444 # Set up the driverinstall target...this makes it easy to install drivers
446 Always driverinstall ;
447 NotFile driverinstall ;
448 InstallDriver driverinstall : $(NAME) ;
450 # Set up the rmapp target...this removes only the application
453 RmApp rmapp : $(NAME) ;
455 # Set up the test target...this runs the application in the background
458 RunApp test : $(NAME) ;
462 CollectCatKeys catkeys : $(SRCS) ;
466 Catalogs catalogs : catkeys ;
468 #Always catalogsinstall ;
469 NotFile catalogsinstall ;
470 CatalogsInstall catalogsinstall : $(CATALOGS_DIR)/$(LOCALES:S=.catalog) ;
472 #Always bindcatalogs ;
473 NotFile bindcatalogs ;
474 BindCatalogs bindcatalogs : $(CATALOGS_DIR)/$(LOCALES:S=.catalog) ;
476 ##-------------------------------------------------------------------
478 ##-------------------------------------------------------------------
480 BeMain $(NAME) : $(SRCS) ;