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 ;
2005-10-21 19:24:13 +00:00
use smb_build::env ;
2006-03-06 15:34:29 +00:00
use smb_build::cflags ;
2006-03-10 14:13:04 +00:00
use smb_build::summary ;
2005-07-28 11:51:37 +00:00
use config ;
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
2005-12-15 15:59:10 +00:00
my $ subsystem_output_type ;
2005-10-26 13:05:29 +00:00
if ( defined ( $ ENV { "SUBSYSTEM_OUTPUT_TYPE" } ) ) {
2005-12-15 15:59:10 +00:00
$ subsystem_output_type = $ ENV { SUBSYSTEM_OUTPUT_TYPE } ;
2005-10-26 13:05:29 +00:00
} elsif ( $ config:: config { BLDMERGED } eq "true" ) {
2005-12-15 15:59:10 +00:00
$ subsystem_output_type = "MERGEDOBJ" ;
} else {
$ subsystem_output_type = "OBJ_LIST" ;
2005-10-26 13:05:29 +00:00
}
2005-12-15 15:59:10 +00:00
my $ library_output_type ;
2005-10-26 13:05:29 +00:00
if ( defined ( $ ENV { "LIBRARY_OUTPUT_TYPE" } ) ) {
2005-12-15 15:59:10 +00:00
$ library_output_type = $ ENV { LIBRARY_OUTPUT_TYPE } ;
2005-10-26 13:05:29 +00:00
} elsif ( $ config:: config { BLDSHARED } eq "true" ) {
2006-03-07 16:27:01 +00:00
$ library_output_type = "SHARED_LIBRARY" ;
2005-10-26 13:05:29 +00:00
} elsif ( $ config:: config { BLDMERGED } eq "true" ) {
2005-12-15 15:59:10 +00:00
$ library_output_type = "MERGEDOBJ" ;
} else {
$ library_output_type = "OBJ_LIST" ;
2005-10-26 13:05:29 +00:00
}
2005-12-15 15:59:10 +00:00
my $ module_output_type ;
2005-10-28 21:13:30 +00:00
if ( defined ( $ ENV { "MODULE_OUTPUT_TYPE" } ) ) {
2005-12-15 15:59:10 +00:00
$ module_output_type = $ ENV { MODULE_OUTPUT_TYPE } ;
2005-10-28 21:13:30 +00:00
} elsif ( $ config:: config { BLDSHARED } eq "true" ) {
2006-03-07 16:27:01 +00:00
$ module_output_type = "SHARED_LIBRARY" ;
2005-10-28 21:13:30 +00:00
} elsif ( $ config:: config { BLDMERGED } eq "true" ) {
2005-12-15 15:59:10 +00:00
$ module_output_type = "MERGEDOBJ" ;
} else {
$ module_output_type = "OBJ_LIST" ;
2005-10-28 21:13:30 +00:00
}
2005-12-15 15:59:10 +00:00
my $ DEPEND = smb_build::input:: check ( $ INPUT , \ % config:: enabled ,
$ subsystem_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-12-15 15:59:10 +00:00
$ config:: config { SUBSYSTEM_OUTPUT_TYPE } = $ subsystem_output_type ;
$ config:: config { LIBRARY_OUTPUT_TYPE } = $ library_output_type ;
$ config:: config { MODULE_OUTPUT_TYPE } = $ module_output_type ;
2005-10-26 23:36:04 +00:00
my $ mkenv = new smb_build:: makefile ( \ % config:: config , $ mkfile ) ;
foreach my $ key ( values %$ OUTPUT ) {
next unless defined $ key - > { OUTPUT_TYPE } ;
$ mkenv - > MergedObj ( $ key ) if $ key - > { OUTPUT_TYPE } eq "MERGEDOBJ" ;
$ mkenv - > ObjList ( $ key ) if $ key - > { OUTPUT_TYPE } eq "OBJLIST" ;
$ mkenv - > StaticLibrary ( $ key ) if $ key - > { OUTPUT_TYPE } eq "STATIC_LIBRARY" ;
$ mkenv - > PkgConfig ( $ key ) if ( $ key - > { OUTPUT_TYPE } eq "SHARED_LIBRARY" ) and
2006-03-13 16:32:44 +00:00
defined ( $ key - > { VERSION } ) ;
2005-10-26 23:36:04 +00:00
$ mkenv - > SharedLibrary ( $ key ) if $ key - > { OUTPUT_TYPE } eq "SHARED_LIBRARY" ;
$ mkenv - > Binary ( $ key ) if $ key - > { OUTPUT_TYPE } eq "BINARY" ;
$ mkenv - > Manpage ( $ key ) if defined ( $ key - > { MANPAGE } ) ;
$ mkenv - > Header ( $ key ) if defined ( $ key - > { PUBLIC_HEADERS } ) ;
2006-03-16 16:47:18 +00:00
$ mkenv - > ProtoHeader ( $ key ) if defined ( $ key - > { PRIVATE_PROTO_HEADER } ) or
defined ( $ key - > { PUBLIC_PROTO_HEADER } ) ;
2005-10-26 23:36:04 +00:00
}
2005-10-21 21:43:39 +00:00
$ mkenv - > write ( "Makefile" ) ;
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-06 15:34:29 +00:00
cflags:: create_cflags ( $ OUTPUT , "extra_cflags.txt" ) ;
2006-03-10 14:13:04 +00:00
summary:: show ( $ OUTPUT , \ % config:: config ) ;
2005-07-28 11:51:37 +00:00
1 ;