r12216: Couple of small fixes: reduce include/includes.h a bit, simplify headers
[bbaumbach/samba-autobuild/.git] / source4 / build / smb_build / main.pl
1 # Samba Build System                                    
2 # - the main program                                    
3 #                                                       
4 #  Copyright (C) Stefan (metze) Metzmacher 2004 
5 #  Copyright (C) Jelmer Vernooij 2005
6 #  Released under the GNU GPL                           
7
8 use smb_build::makefile;
9 use smb_build::smb_build_h;
10 use smb_build::input;
11 use smb_build::config_mk;
12 use smb_build::output;
13 use smb_build::env;
14 use config;
15 use strict;
16
17 my $INPUT = {};
18
19 my $mkfile = smb_build::config_mk::run_config_mk($INPUT, "main.mk");
20
21 if (defined($ENV{"SUBSYSTEM_OUTPUT_TYPE"})) {
22         $smb_build::input::subsystem_output_type = $ENV{SUBSYSTEM_OUTPUT_TYPE};
23 } elsif ($config::config{BLDMERGED} eq "true") {
24         $smb_build::input::subsystem_output_type = "MERGEDOBJ";
25 }
26
27 if (defined($ENV{"LIBRARY_OUTPUT_TYPE"})) {
28         $smb_build::input::library_output_type = $ENV{LIBRARY_OUTPUT_TYPE};
29 } elsif ($config::config{BLDSHARED} eq "true") {
30         #FIXME: This should eventually become SHARED_LIBRARY 
31         # rather then MERGEDOBJ once I'm certain it works ok -- jelmer
32         $smb_build::input::library_output_type = "MERGEDOBJ";
33 } elsif ($config::config{BLDMERGED} eq "true") {
34         $smb_build::input::library_output_type = "MERGEDOBJ";
35 }
36
37 if (defined($ENV{"MODULE_OUTPUT_TYPE"})) {
38         $smb_build::input::module_output_type = $ENV{MODULE_OUTPUT_TYPE};
39 } elsif ($config::config{BLDSHARED} eq "true") {
40         #FIXME: This should eventually become SHARED_LIBRARY 
41         # rather then MERGEDOBJ once I'm certain it works ok -- jelmer
42         $smb_build::input::module_output_type = "MERGEDOBJ";
43 } elsif ($config::config{BLDMERGED} eq "true") {
44         $smb_build::input::module_output_type = "MERGEDOBJ";
45 }
46
47 my $DEPEND = smb_build::input::check($INPUT, \%config::enabled);
48 my $OUTPUT = output::create_output($DEPEND);
49 my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
50
51 foreach my $key (values %$OUTPUT) {
52         next unless defined $key->{OUTPUT_TYPE};
53
54         $mkenv->MergedObj($key) if $key->{OUTPUT_TYPE} eq "MERGEDOBJ";
55         $mkenv->ObjList($key) if $key->{OUTPUT_TYPE} eq "OBJLIST";
56         $mkenv->StaticLibrary($key) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY";
57         $mkenv->PkgConfig($key) if ($key->{OUTPUT_TYPE} eq "SHARED_LIBRARY") and
58                                                 defined($key->{MAJOR_VERSION});
59         $mkenv->SharedLibrary($key) if $key->{OUTPUT_TYPE} eq "SHARED_LIBRARY";
60         $mkenv->Binary($key) if $key->{OUTPUT_TYPE} eq "BINARY";
61         $mkenv->Manpage($key) if defined($key->{MANPAGE});
62         $mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
63 }
64
65 # FIXME: These two lines are a hack
66 $mkenv->ProtoHeader($OUTPUT->{PROTO});
67 $mkenv->ProtoHeader($OUTPUT->{ALL_OBJS});
68
69 $mkenv->write("Makefile");
70 smb_build_h::create_smb_build_h($OUTPUT, "include/smb_build.h");
71
72 1;