2005-12-13 19:38:12 +00:00
# Samba Build System
# - the main program
#
# Copyright (C) Stefan (metze) Metzmacher 2004
# Copyright (C) Jelmer Vernooij 2005
# Released under the GNU GPL
2005-07-28 11:51:37 +00:00
use smb_build::makefile ;
2006-02-23 12:44:21 +00:00
use smb_build::header ;
2005-07-28 11:51:37 +00:00
use smb_build::input ;
use smb_build::config_mk ;
use smb_build::output ;
2006-03-10 14:13:04 +00:00
use smb_build::summary ;
2006-05-12 22:21:44 +00:00
use smb_build::config ;
2005-07-28 11:51:37 +00:00
use strict ;
my $ INPUT = { } ;
2006-04-11 11:37:52 +00:00
my $ mkfile = smb_build::config_mk:: run_config_mk ( $ INPUT , $ config:: config { srcdir } , $ config:: config { builddir } , "main.mk" ) ;
2005-10-26 13:05:29 +00:00
2008-02-18 18:55:37 +01:00
my $ subsys_output_type = [ "MERGED_OBJ" ] ;
2007-01-16 09:48:39 +00:00
2005-12-15 15:59:10 +00:00
my $ library_output_type ;
2006-11-06 14:03:51 +00:00
if ( $ config:: config { USESHARED } eq "true" ) {
2006-11-06 20:17:25 +00:00
$ library_output_type = [ "SHARED_LIBRARY" , "STATIC_LIBRARY" ] ;
2005-12-15 15:59:10 +00:00
} else {
2006-11-06 20:17:25 +00:00
$ library_output_type = [ "STATIC_LIBRARY" ] ;
push ( @$ library_output_type , "SHARED_LIBRARY" ) if
( $ config:: config { BLDSHARED } eq "true" )
2005-10-26 13:05:29 +00:00
}
2005-12-15 15:59:10 +00:00
my $ module_output_type ;
2006-11-06 14:03:51 +00:00
if ( $ config:: config { USESHARED } eq "true" ) {
2006-11-06 20:17:25 +00:00
$ module_output_type = [ "SHARED_LIBRARY" ] ;
2005-12-15 15:59:10 +00:00
} else {
2008-02-18 18:55:37 +01:00
$ module_output_type = [ "MERGED_OBJ" ] ;
2005-10-28 21:13:30 +00:00
}
2007-01-16 09:48:39 +00:00
my $ DEPEND = smb_build::input:: check ( $ INPUT , \ % config:: enabled ,
$ subsys_output_type ,
$ library_output_type ,
$ module_output_type ) ;
2006-03-06 21:14:41 +00:00
my $ OUTPUT = output:: create_output ( $ DEPEND , \ % config:: config ) ;
2005-10-26 23:36:04 +00:00
my $ mkenv = new smb_build:: makefile ( \ % config:: config , $ mkfile ) ;
2008-02-18 17:08:54 +01:00
my $ shared_libs_used = 0 ;
2006-04-27 19:50:13 +00:00
foreach my $ key ( values %$ OUTPUT ) {
2008-02-18 17:08:54 +01:00
$ mkenv - > _prepare_list ( $ key , "OBJ_LIST" ) ;
2008-02-18 17:28:24 +01:00
push ( @ { $ mkenv - > { all_objs } } , "\$($key->{NAME}_OBJ_LIST)" ) ;
2006-04-27 19:50:13 +00:00
}
2005-10-26 23:36:04 +00:00
foreach my $ key ( values %$ OUTPUT ) {
next unless defined $ key - > { OUTPUT_TYPE } ;
2008-02-16 20:38:21 +01:00
$ mkenv - > MergedObj ( $ key ) if grep ( /MERGED_OBJ/ , @ { $ key - > { OUTPUT_TYPE } } ) ;
2008-04-14 17:54:19 +02:00
$ mkenv - > StaticLibraryPrimitives ( $ key ) if grep ( /STATIC_LIBRARY/ , @ { $ key - > { OUTPUT_TYPE } } ) ;
2008-01-22 18:21:48 +01:00
if ( defined ( $ key - > { PC_FILE } ) ) {
2008-02-16 17:12:01 +01:00
$ mkenv - > output ( "PC_FILES += $key->{BASEDIR}/$key->{PC_FILE}\n" ) ;
2008-01-22 18:21:48 +01:00
}
2008-02-13 21:03:01 +01:00
$ mkenv - > SharedLibraryPrimitives ( $ key ) if ( $ key - > { TYPE } eq "LIBRARY" ) and
2007-11-15 15:44:17 +01:00
grep ( /SHARED_LIBRARY/ , @ { $ key - > { OUTPUT_TYPE } } ) ;
2007-11-16 21:50:31 +01:00
if ( $ key - > { TYPE } eq "LIBRARY" and
$ { $ key - > { OUTPUT_TYPE } } [ 0 ] eq "SHARED_LIBRARY" ) {
$ shared_libs_used = 1 ;
}
2008-02-13 21:03:01 +01:00
$ mkenv - > SharedModulePrimitives ( $ key ) if ( $ key - > { TYPE } eq "MODULE" or
2007-11-21 14:49:35 +01:00
$ key - > { TYPE } eq "PYTHON" ) and
2007-11-15 15:44:17 +01:00
grep ( /SHARED_LIBRARY/ , @ { $ key - > { OUTPUT_TYPE } } ) ;
2007-11-21 11:10:45 +01:00
$ mkenv - > PythonFiles ( $ key ) if defined ( $ key - > { PYTHON_FILES } ) ;
2008-02-25 18:29:04 +01:00
$ mkenv - > CFlags ( $ key ) ;
2005-10-26 23:36:04 +00:00
}
2008-02-13 21:03:01 +01:00
foreach my $ key ( values %$ OUTPUT ) {
next unless defined $ key - > { OUTPUT_TYPE } ;
2008-04-14 17:54:19 +02:00
$ mkenv - > Integrated ( $ key ) if grep ( /INTEGRATED/ , @ { $ key - > { OUTPUT_TYPE } } ) ;
}
foreach my $ key ( values %$ OUTPUT ) {
next unless defined $ key - > { OUTPUT_TYPE } ;
$ mkenv - > StaticLibrary ( $ key ) if grep ( /STATIC_LIBRARY/ , @ { $ key - > { OUTPUT_TYPE } } ) ;
2008-02-13 21:03:01 +01:00
$ mkenv - > SharedLibrary ( $ key ) if ( $ key - > { TYPE } eq "LIBRARY" ) and
grep ( /SHARED_LIBRARY/ , @ { $ key - > { OUTPUT_TYPE } } ) ;
$ mkenv - > SharedModule ( $ key ) if ( $ key - > { TYPE } eq "MODULE" or
$ key - > { TYPE } eq "PYTHON" ) and
grep ( /SHARED_LIBRARY/ , @ { $ key - > { OUTPUT_TYPE } } ) ;
$ mkenv - > Binary ( $ key ) if grep ( /BINARY/ , @ { $ key - > { OUTPUT_TYPE } } ) ;
2008-04-14 17:54:19 +02:00
$ mkenv - > ProtoHeader ( $ key ) if defined ( $ key - > { PRIVATE_PROTO_HEADER } ) ;
2008-02-13 21:03:01 +01:00
}
2008-02-11 01:42:29 +01:00
$ mkenv - > write ( "data.mk" ) ;
2006-02-23 12:44:21 +00:00
header:: create_smb_build_h ( $ OUTPUT , "include/build.h" ) ;
2005-07-28 11:51:37 +00:00
2006-03-10 14:13:04 +00:00
summary:: show ( $ OUTPUT , \ % config:: config ) ;
2005-07-28 11:51:37 +00:00
1 ;