2005-12-13 19:38:12 +00:00
# Samba Build System
# - create output for Makefile
#
# Copyright (C) Stefan (metze) Metzmacher 2004
# Copyright (C) Jelmer Vernooij 2005
# Released under the GNU GPL
2004-05-13 10:20:53 +00:00
2005-10-21 21:43:39 +00:00
package smb_build::makefile ;
use smb_build::env ;
2004-11-12 02:00:58 +00:00
use strict ;
2005-10-21 21:43:39 +00:00
use base 'smb_build::env' ;
2005-10-26 23:36:04 +00:00
sub new ($$$)
2005-10-21 21:43:39 +00:00
{
2005-10-26 23:36:04 +00:00
my ( $ myname , $ config , $ mkfile ) = @ _ ;
2005-10-21 21:43:39 +00:00
my $ self = new smb_build:: env ( $ config ) ;
bless ( $ self , $ myname ) ;
2005-10-26 19:07:01 +00:00
$ self - > { manpages } = [] ;
$ self - > { sbin_progs } = [] ;
$ self - > { bin_progs } = [] ;
$ self - > { static_libs } = [] ;
$ self - > { shared_libs } = [] ;
$ self - > { headers } = [] ;
2005-10-26 20:06:26 +00:00
$ self - > { pc_files } = [] ;
2005-10-21 22:49:23 +00:00
$ self - > { output } = "" ;
2005-10-26 19:07:01 +00:00
$ self - > { mkfile } = $ mkfile ;
2005-10-21 22:49:23 +00:00
$ self - > output ( "################################################\n" ) ;
$ self - > output ( "# Autogenerated by build/smb_build/makefile.pm #\n" ) ;
$ self - > output ( "################################################\n" ) ;
$ self - > output ( "\n" ) ;
$ self - > output ( "default: all\n\n" ) ;
$ self - > _prepare_path_vars ( ) ;
$ self - > _prepare_compiler_linker ( ) ;
2005-12-18 22:28:41 +00:00
$ self - > output ( ".SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .so .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .ho\n" ) ;
2005-10-21 22:49:23 +00:00
$ self - > _prepare_hostcc_rule ( ) ;
$ self - > _prepare_std_CC_rule ( "c" , "o" , '$(PICFLAG)' , "Compiling" , "Rule for std objectfiles" ) ;
$ self - > _prepare_std_CC_rule ( "h" , "h.gch" , '$(PICFLAG)' , "Precompiling" , "Rule for precompiled headerfiles" ) ;
2005-10-21 21:43:39 +00:00
return $ self ;
}
2005-10-21 22:49:23 +00:00
sub output ($$)
{
my ( $ self , $ text ) = @ _ ;
$ self - > { output } . = $ text ;
}
2005-10-21 19:24:13 +00:00
sub _prepare_path_vars ($)
2004-05-13 10:20:53 +00:00
{
2005-10-21 21:43:39 +00:00
my ( $ self ) = @ _ ;
2004-05-13 10:20:53 +00:00
2005-10-21 22:49:23 +00:00
$ self - > output ( << "__EOD__"
2005-10-21 21:43:39 +00:00
prefix = $ self - > { config } - > { prefix }
exec_prefix = $ self - > { config } - > { exec_prefix }
selftest_prefix = $ self - > { config } - > { selftest_prefix }
VPATH = $ self - > { config } - > { srcdir }
srcdir = $ self - > { config } - > { srcdir }
builddir = $ self - > { config } - > { builddir }
BASEDIR = $ self - > { config } - > { prefix }
BINDIR = $ self - > { config } - > { bindir }
SBINDIR = $ self - > { config } - > { sbindir }
datadir = $ self - > { config } - > { datadir }
LIBDIR = $ self - > { config } - > { libdir }
2005-10-26 14:18:27 +00:00
INCLUDEDIR = $ self - > { config } - > { includedir }
2005-10-21 21:43:39 +00:00
CONFIGDIR = $ self - > { config } - > { configdir }
localstatedir = $ self - > { config } - > { localstatedir }
SWATDIR = $ self - > { config } - > { swatdir }
VARDIR = $ self - > { config } - > { localstatedir }
LOGFILEBASE = $ self - > { config } - > { logfilebase }
NCALRPCDIR = $ self - > { config } - > { localstatedir } / ncalrpc
LOCKDIR = $ self - > { config } - > { lockdir }
PIDDIR = $ self - > { config } - > { piddir }
MANDIR = $ self - > { config } - > { mandir }
PRIVATEDIR = $ self - > { config } - > { privatedir }
2005-09-17 13:08:49 +00:00
2005-04-02 01:43:54 +00:00
__EOD__
2005-10-21 22:49:23 +00:00
) ;
2004-05-13 10:20:53 +00:00
}
2005-10-21 19:24:13 +00:00
sub _prepare_compiler_linker ($)
2004-05-13 10:20:53 +00:00
{
2005-10-21 21:43:39 +00:00
my ( $ self ) = @ _ ;
2005-10-21 19:24:13 +00:00
2005-12-15 15:59:10 +00:00
my $ devld_local = "" ;
my $ devld_install = "" ;
$ self - > { duplicate_build } = 0 ;
if ( $ self - > { config } - > { LIBRARY_OUTPUT_TYPE } eq "SHARED_LIBRARY" ) {
if ( $ self - > { developer } ) {
$ self - > { duplicate_build } = 1 ;
$ devld_local = " -Wl,-rpath,\$(builddir)/bin" ;
}
$ devld_install = " -Wl,-rpath-link,\$(builddir)/bin" ;
2005-10-28 18:26:26 +00:00
}
2005-10-21 22:49:23 +00:00
$ self - > output ( << "__EOD__"
2005-10-21 21:43:39 +00:00
SHELL = $ self - > { config } - > { SHELL }
2005-09-10 08:41:57 +00:00
2005-10-21 21:43:39 +00:00
PERL = $ self - > { config } - > { PERL }
2005-09-10 08:41:57 +00:00
2005-12-13 21:42:03 +00:00
CPP = $ self - > { config } - > { CPP }
CPPFLAGS = $ self - > { config } - > { CPPFLAGS }
2005-10-21 21:43:39 +00:00
CC = $ self - > { config } - > { CC }
2005-12-13 21:42:03 +00:00
CFLAGS = - I \ $ ( srcdir ) /include -I\$(srcdir) -I\$(srcdir)/ lib - D_SAMBA_BUILD_ - DHAVE_CONFIG_H $ self - > { config } - > { CFLAGS } \ $ ( CPPFLAGS )
2005-10-21 21:43:39 +00:00
PICFLAG = $ self - > { config } - > { PICFLAG }
HOSTCC = $ self - > { config } - > { HOSTCC }
2005-09-10 08:41:57 +00:00
2005-10-28 18:26:26 +00:00
LD = $ self - > { config } - > { LD }
2005-12-15 15:59:10 +00:00
LDFLAGS = $ self - > { config } - > { LDFLAGS } - L \ $ ( builddir ) / bin
LOCAL_LINK_FLAGS = $ devld_local
INSTALL_LINK_FLAGS = $ devld_install
2004-05-13 10:20:53 +00:00
2005-10-21 21:43:39 +00:00
STLD = $ self - > { config } - > { AR }
2005-12-15 15:59:10 +00:00
STLD_FLAGS = - rc - L \ $ ( builddir ) / bin
2004-05-13 10:20:53 +00:00
2005-10-21 21:43:39 +00:00
SHLD = $ self - > { config } - > { CC }
2005-12-15 15:59:10 +00:00
SHLD_FLAGS = $ self - > { config } - > { LDSHFLAGS } - L \ $ ( builddir ) / bin
2005-10-21 21:43:39 +00:00
SONAMEFLAG = $ self - > { config } - > { SONAMEFLAG }
SHLIBEXT = $ self - > { config } - > { SHLIBEXT }
2005-04-02 01:43:54 +00:00
2005-10-21 21:43:39 +00:00
XSLTPROC = $ self - > { config } - > { XSLTPROC }
2005-06-27 12:09:52 +00:00
2005-10-21 21:43:39 +00:00
LEX = $ self - > { config } - > { LEX }
YACC = $ self - > { config } - > { YACC }
YAPP = $ self - > { config } - > { YAPP }
PIDL_ARGS = $ self - > { config } - > { PIDL_ARGS }
2005-08-02 23:15:56 +00:00
2005-10-21 21:43:39 +00:00
GCOV = $ self - > { config } - > { GCOV }
2005-08-03 07:17:14 +00:00
2005-10-21 21:43:39 +00:00
DEFAULT_TEST_TARGET = $ self - > { config } - > { DEFAULT_TEST_TARGET }
2005-08-03 04:15:16 +00:00
2005-04-02 01:43:54 +00:00
__EOD__
2005-10-21 22:49:23 +00:00
) ;
2004-05-13 10:20:53 +00:00
}
2005-10-26 19:07:01 +00:00
sub _prepare_mk_files ($)
2004-05-13 10:20:53 +00:00
{
2005-10-21 22:49:23 +00:00
my $ self = shift ;
2005-10-26 19:07:01 +00:00
my @ tmp = ( ) ;
2005-10-26 14:18:27 +00:00
2005-10-26 19:07:01 +00:00
foreach ( @ smb_build:: config_mk:: parsed_files ) {
s/ .*$//g ;
push ( @ tmp , $ _ ) ;
2005-10-26 14:18:27 +00:00
}
2005-10-26 19:07:01 +00:00
$ self - > output ( "MK_FILES = " . array2oneperline ( \ @ tmp ) . "\n" ) ;
2005-06-27 12:09:52 +00:00
}
2005-10-26 23:36:04 +00:00
sub _prepare_dummy_MAKEDIR ($)
2004-05-13 10:20:53 +00:00
{
2005-10-26 23:36:04 +00:00
my ( $ self ) = @ _ ;
2004-05-13 10:20:53 +00:00
2005-10-21 22:49:23 +00:00
$ self - > output ( << '__EOD__'
2005-06-25 03:10:57 +00:00
dynconfig . o: dynconfig . c Makefile
@ echo Compiling $* . c
2005-09-17 00:42:05 +00:00
@$ ( CC ) $ ( CFLAGS ) $ ( PICFLAG ) $ ( PATH_FLAGS ) - c $< - o $@
2005-04-02 01:43:54 +00:00
__EOD__
2005-10-21 22:49:23 +00:00
) ;
2005-10-21 21:43:39 +00:00
if ( $ self - > { config } - > { BROKEN_CC } eq "yes" ) {
2005-10-21 22:49:23 +00:00
$ self - > output ( ' - mv `echo $@ | sed \'s%^.*/%%g\'` $@
' ) ;
2005-09-17 00:42:05 +00:00
}
2005-10-21 22:49:23 +00:00
$ self - > output ( "\n" ) ;
2004-05-13 10:20:53 +00:00
}
2005-10-21 19:24:13 +00:00
sub _prepare_std_CC_rule ($$$$$$)
2004-05-13 10:20:53 +00:00
{
2005-10-21 21:43:39 +00:00
my ( $ self , $ src , $ dst , $ flags , $ message , $ comment ) = @ _ ;
2004-05-13 10:20:53 +00:00
2005-10-21 22:49:23 +00:00
$ self - > output ( << "__EOD__"
2005-06-05 16:37:27 +00:00
# $comment
2004-05-13 10:20:53 +00:00
. $ src . $ dst:
2005-04-02 01:43:54 +00:00
\ @ echo $ message \ $\ * . $ src
2005-07-13 09:44:55 +00:00
\ @ \ $ ( CC ) `script/cflags.sh \$\@` \ $ ( CFLAGS ) $ flags - c \ $< - o \ $\ @
2005-09-17 00:42:05 +00:00
__EOD__
2005-10-21 22:49:23 +00:00
) ;
2005-10-21 21:43:39 +00:00
if ( $ self - > { config } - > { BROKEN_CC } eq "yes" ) {
2005-10-21 22:49:23 +00:00
$ self - > output ( ' - mv `echo $@ | sed \'s%^.*/%%g\'` $@
' ) ;
2005-09-17 00:42:05 +00:00
}
2005-10-21 22:49:23 +00:00
$ self - > output ( "\n" ) ;
2005-09-17 00:42:05 +00:00
}
2005-04-02 01:43:54 +00:00
2005-10-21 19:24:13 +00:00
sub _prepare_hostcc_rule ($)
2005-09-17 00:42:05 +00:00
{
2005-10-21 21:43:39 +00:00
my ( $ self ) = @ _ ;
2005-10-21 19:24:13 +00:00
2005-10-21 22:49:23 +00:00
$ self - > output ( << "__EOD__"
2005-09-17 00:42:05 +00:00
. c . ho:
\ @ echo Compiling \ $\ * . c with host compiler
\ @ \ $ ( HOSTCC ) `script/cflags.sh \$\@` \ $ ( CFLAGS ) - c \ $< - o \ $\ @
2005-04-02 01:43:54 +00:00
__EOD__
2005-10-21 22:49:23 +00:00
) ;
2005-10-21 21:43:39 +00:00
if ( $ self - > { config } - > { BROKEN_CC } eq "yes" ) {
2005-10-21 22:49:23 +00:00
$ self - > output ( ' - mv `echo $@ | sed \'s%^.*/%%g\' -e \'s%\.ho$$%.o%\'` $@
' ) ;
2005-09-17 00:42:05 +00:00
}
2005-10-21 22:49:23 +00:00
$ self - > output ( "\n" ) ;
2004-05-13 10:20:53 +00:00
}
sub array2oneperline ($)
{
my $ array = shift ;
my $ output = "" ;
2005-07-21 21:27:39 +00:00
foreach ( @$ array ) {
next unless defined ( $ _ ) ;
2004-05-13 10:20:53 +00:00
2005-07-21 21:27:39 +00:00
$ output . = " \\\n\t\t$_" ;
2004-05-13 10:20:53 +00:00
}
return $ output ;
}
2005-12-13 21:00:52 +00:00
sub _prepare_list ($$$)
2004-05-13 10:20:53 +00:00
{
2005-12-13 21:00:52 +00:00
my ( $ self , $ ctx , $ var ) = @ _ ;
2004-05-13 10:20:53 +00:00
2005-12-13 21:00:52 +00:00
my $ tmplist = array2oneperline ( $ ctx - > { $ var } ) ;
2005-10-26 19:07:01 +00:00
return if ( $ tmplist eq "" ) ;
2004-05-13 10:20:53 +00:00
2005-12-13 21:00:52 +00:00
$ self - > output ( "$ctx->{TYPE}\_$ctx->{NAME}_$var =$tmplist\n" ) ;
2004-05-13 10:20:53 +00:00
}
2005-10-26 19:07:01 +00:00
sub SharedLibrary ($$)
2004-05-13 10:20:53 +00:00
{
2005-10-21 22:49:23 +00:00
my ( $ self , $ ctx ) = @ _ ;
2004-05-13 10:20:53 +00:00
2005-12-15 16:32:08 +00:00
push ( @ { $ self - > { shared_libs } } , "bin/$ctx->{LIBRARY_REALNAME}" ) ;
2005-10-26 19:07:01 +00:00
2005-12-13 21:42:03 +00:00
$ self - > _prepare_list ( $ ctx , "OBJ_LIST" ) ;
2005-12-13 21:00:52 +00:00
$ self - > _prepare_list ( $ ctx , "CFLAGS" ) ;
$ self - > _prepare_list ( $ ctx , "DEPEND_LIST" ) ;
$ self - > _prepare_list ( $ ctx , "LINK_LIST" ) ;
$ self - > _prepare_list ( $ ctx , "LINK_FLAGS" ) ;
2004-05-13 10:20:53 +00:00
2005-10-21 22:49:23 +00:00
$ self - > output ( << "__EOD__"
2004-11-14 13:52:16 +00:00
#
2005-12-15 15:59:10 +00:00
bin /$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) bin/ . dummy
2004-05-13 10:20:53 +00:00
\ @ echo Linking \ $\ @
\ @ \ $ ( SHLD ) \ $ ( SHLD_FLAGS ) - o \ $\ @ \ \
2005-12-13 21:42:03 +00:00
\ $( $ ctx - > { TYPE } _ $ ctx - > { NAME } _LINK_FLAGS ) \ \
\ $( $ ctx - > { TYPE } _ $ ctx - > { NAME } _LINK_LIST )
2005-04-02 01:43:54 +00:00
__EOD__
2005-10-21 22:49:23 +00:00
) ;
2004-11-14 16:22:01 +00:00
if ( defined ( $ ctx - > { LIBRARY_SONAME } ) ) {
2005-10-21 22:49:23 +00:00
$ self - > output ( << "__EOD__"
2004-11-14 13:52:16 +00:00
# Symlink $ctx->{LIBRARY_SONAME}
bin /$ctx->{LIBRARY_SONAME}: bin/ $ ctx - > { LIBRARY_REALNAME } bin / . dummy
\ @ echo Symlink \ $\ @
\ @ ln - sf $ ctx - > { LIBRARY_REALNAME } \ $\ @
2004-11-14 16:22:01 +00:00
# Symlink $ctx->{LIBRARY_NAME}
2004-11-14 13:52:16 +00:00
bin /$ctx->{LIBRARY_NAME}: bin/ $ ctx - > { LIBRARY_SONAME } bin / . dummy
\ @ echo Symlink \ $\ @
\ @ ln - sf $ ctx - > { LIBRARY_SONAME } \ $\ @
2005-04-02 01:43:54 +00:00
__EOD__
2005-10-21 22:49:23 +00:00
) ;
2004-11-15 20:25:40 +00:00
}
2004-05-13 10:20:53 +00:00
}
2005-10-26 19:07:01 +00:00
sub MergedObj ($$)
2005-08-02 19:38:30 +00:00
{
2005-10-21 22:49:23 +00:00
my ( $ self , $ ctx ) = @ _ ;
2005-08-02 19:38:30 +00:00
2005-10-26 19:07:01 +00:00
return unless $ ctx - > { TARGET } ;
2005-08-02 19:38:30 +00:00
2005-12-13 21:42:03 +00:00
$ self - > _prepare_list ( $ ctx , "OBJ_LIST" ) ;
2005-12-13 21:00:52 +00:00
$ self - > _prepare_list ( $ ctx , "CFLAGS" ) ;
$ self - > _prepare_list ( $ ctx , "DEPEND_LIST" ) ;
2005-08-02 19:38:30 +00:00
2005-12-13 21:42:03 +00:00
$ self - > output ( "$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n" ) ;
2005-08-02 19:38:30 +00:00
2005-10-21 22:49:23 +00:00
$ self - > output ( "\t\@echo \"Pre-Linking $ctx->{TYPE} $ctx->{NAME}\"\n" ) ;
2005-12-13 21:42:03 +00:00
$ self - > output ( "\t@\$(LD) -r \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) -o $ctx->{TARGET}\n" ) ;
2005-10-21 22:49:23 +00:00
$ self - > output ( "\n" ) ;
2005-08-02 19:38:30 +00:00
}
2005-10-26 19:07:01 +00:00
sub ObjList ($$)
2005-06-05 13:52:11 +00:00
{
2005-10-21 22:49:23 +00:00
my ( $ self , $ ctx ) = @ _ ;
2005-06-05 22:30:20 +00:00
2005-10-26 19:07:01 +00:00
return unless $ ctx - > { TARGET } ;
2005-06-25 03:40:34 +00:00
2005-12-13 21:42:03 +00:00
$ self - > _prepare_list ( $ ctx , "OBJ_LIST" ) ;
2005-12-13 21:00:52 +00:00
$ self - > _prepare_list ( $ ctx , "CFLAGS" ) ;
$ self - > _prepare_list ( $ ctx , "DEPEND_LIST" ) ;
2005-10-21 22:49:23 +00:00
$ self - > output ( "$ctx->{TARGET}: " ) ;
2005-12-13 21:42:03 +00:00
$ self - > output ( "\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n" ) ;
2005-10-21 22:49:23 +00:00
$ self - > output ( "\t\@touch $ctx->{TARGET}\n" ) ;
2005-06-05 13:52:11 +00:00
}
2005-10-26 19:07:01 +00:00
sub StaticLibrary ($$)
2004-05-13 10:20:53 +00:00
{
2005-10-21 22:49:23 +00:00
my ( $ self , $ ctx ) = @ _ ;
2004-05-13 10:20:53 +00:00
2005-10-26 19:07:01 +00:00
push ( @ { $ self - > { static_libs } } , $ ctx - > { OUTPUT } ) ;
2005-12-13 21:42:03 +00:00
$ self - > _prepare_list ( $ ctx , "OBJ_LIST" ) ;
2005-12-13 21:00:52 +00:00
$ self - > _prepare_list ( $ ctx , "CFLAGS" ) ;
2005-10-26 23:36:04 +00:00
2005-12-13 21:00:52 +00:00
$ self - > _prepare_list ( $ ctx , "DEPEND_LIST" ) ;
$ self - > _prepare_list ( $ ctx , "LINK_LIST" ) ;
$ self - > _prepare_list ( $ ctx , "LINK_FLAGS" ) ;
2004-05-13 10:20:53 +00:00
2005-10-21 22:49:23 +00:00
$ self - > output ( << "__EOD__"
2004-05-13 10:20:53 +00:00
#
2005-12-13 21:42:03 +00:00
$ ctx - > { TARGET } : \ $( $ ctx - > { TYPE } _ $ ctx - > { NAME } _DEPEND_LIST ) \ $( $ ctx - > { TYPE } _ $ ctx - > { NAME } _OBJ_LIST ) bin / . dummy
2005-05-18 01:11:33 +00:00
\ @ echo Linking \ $@
\ @ \ $ ( STLD ) \ $ ( STLD_FLAGS ) \ $@ \ \
2005-12-13 21:42:03 +00:00
\ $( $ ctx - > { TYPE } _ $ ctx - > { NAME } _LINK_LIST )
2004-05-13 16:15:46 +00:00
2005-04-02 01:43:54 +00:00
__EOD__
2005-10-21 22:49:23 +00:00
) ;
2004-05-13 10:20:53 +00:00
}
2005-10-26 19:07:01 +00:00
sub Header ($$)
{
my ( $ self , $ ctx ) = @ _ ;
foreach ( @ { $ ctx - > { PUBLIC_HEADERS } } ) {
push ( @ { $ self - > { headers } } , "$ctx->{BASEDIR}/$_" ) ;
}
}
sub Binary ($$)
2004-05-13 10:20:53 +00:00
{
2005-10-21 22:49:23 +00:00
my ( $ self , $ ctx ) = @ _ ;
2004-05-13 10:20:53 +00:00
2005-12-15 15:59:10 +00:00
my $ installdir ;
if ( $ self - > { duplicate_build } ) {
$ installdir = "bin/install" ;
} else {
$ installdir = "bin" ;
}
2005-10-26 19:07:01 +00:00
unless ( defined ( $ ctx - > { INSTALLDIR } ) ) {
} elsif ( $ ctx - > { INSTALLDIR } eq "SBINDIR" ) {
2005-12-15 15:59:10 +00:00
push ( @ { $ self - > { sbin_progs } } , "$installdir/$ctx->{BINARY}" ) ;
2005-10-26 19:07:01 +00:00
} elsif ( $ ctx - > { INSTALLDIR } eq "BINDIR" ) {
2005-12-15 15:59:10 +00:00
push ( @ { $ self - > { bin_progs } } , "$installdir/$ctx->{BINARY}" ) ;
2005-10-26 19:07:01 +00:00
}
2005-12-15 15:59:10 +00:00
push ( @ { $ self - > { binaries } } , "bin/$ctx->{BINARY}" ) ;
2005-12-13 21:42:03 +00:00
$ self - > _prepare_list ( $ ctx , "OBJ_LIST" ) ;
2005-12-13 21:00:52 +00:00
$ self - > _prepare_list ( $ ctx , "CFLAGS" ) ;
$ self - > _prepare_list ( $ ctx , "DEPEND_LIST" ) ;
$ self - > _prepare_list ( $ ctx , "LINK_LIST" ) ;
$ self - > _prepare_list ( $ ctx , "LINK_FLAGS" ) ;
2004-05-13 10:20:53 +00:00
2005-12-15 15:59:10 +00:00
if ( $ self - > { duplicate_build } ) {
2005-10-21 22:49:23 +00:00
$ self - > output ( << "__EOD__"
2004-05-13 10:20:53 +00:00
#
2005-12-13 21:42:03 +00:00
bin /$ctx->{BINARY}: bin/ . dummy \ $( $ ctx - > { TYPE } _ $ ctx - > { NAME } _DEPEND_LIST ) \ $( $ ctx - > { TYPE } _ $ ctx - > { NAME } _OBJ_LIST )
2004-05-13 10:20:53 +00:00
\ @ echo Linking \ $\ @
2005-12-15 15:59:10 +00:00
\ @ \ $ ( CC ) \ $ ( LDFLAGS ) - o \ $\ @ \ $ ( LOCAL_LINK_FLAGS ) \ \
2005-12-13 21:42:03 +00:00
\ $\ ( $ ctx - > { TYPE } _ $ ctx - > { NAME } _LINK_LIST ) \ \
\ $\ ( $ ctx - > { TYPE } _ $ ctx - > { NAME } _LINK_FLAGS )
2005-12-15 15:59:10 +00:00
__EOD__
) ;
}
$ self - > output ( << "__EOD__"
$ installdir / $ ctx - > { BINARY } : \ $( $ ctx - > { TYPE } _ $ ctx - > { NAME } _DEPEND_LIST ) \ $( $ ctx - > { TYPE } _ $ ctx - > { NAME } _OBJ_LIST )
\ @ echo Linking \ $\ @
\ @ \ $ ( CC ) \ $ ( LDFLAGS ) - o \ $\ @ \ $ ( INSTALL_LINK_FLAGS ) \ \
\ $\ ( $ ctx - > { TYPE } _ $ ctx - > { NAME } _LINK_LIST ) \ \
\ $\ ( $ ctx - > { TYPE } _ $ ctx - > { NAME } _LINK_FLAGS )
2005-04-02 01:43:54 +00:00
__EOD__
2005-10-21 22:49:23 +00:00
) ;
2004-05-13 10:20:53 +00:00
}
2005-10-26 19:07:01 +00:00
sub Manpage ($$)
2004-05-13 10:20:53 +00:00
{
2005-10-26 19:07:01 +00:00
my ( $ self , $ ctx ) = @ _ ;
2004-05-13 10:20:53 +00:00
2005-10-26 19:07:01 +00:00
my $ dir = $ ctx - > { BASEDIR } ;
2004-05-13 10:20:53 +00:00
2005-10-26 19:07:01 +00:00
$ dir =~ s/^\.\///g ;
2004-05-13 10:20:53 +00:00
2005-10-26 19:07:01 +00:00
push ( @ { $ self - > { manpages } } , "$dir/$ctx->{MANPAGE}" ) ;
2004-05-13 10:20:53 +00:00
}
2005-10-26 20:06:26 +00:00
sub PkgConfig ($$)
{
my ( $ self , $ ctx ) = @ _ ;
2005-10-28 18:26:26 +00:00
my $ link_name = $ ctx - > { NAME } ;
$ link_name =~ s/^LIB//g ;
$ link_name = lc ( $ link_name ) ;
2005-12-15 16:32:08 +00:00
if ( not defined ( $ ctx - > { DESCRIPTION } ) ) {
warn ( "$ctx->{NAME} has not DESCRIPTION set, not generating .pc file" ) ;
return ;
}
2005-10-28 18:26:26 +00:00
my $ path = "$ctx->{BASEDIR}/$link_name.pc" ;
2005-10-26 20:06:26 +00:00
push ( @ { $ self - > { pc_files } } , $ path ) ;
2005-10-28 18:26:26 +00:00
smb_build::env:: PkgConfig ( $ self ,
$ path ,
$ link_name ,
$ ctx - > { OUTPUT } ,
join ( ' ' , @ { $ ctx - > { CFLAGS } } ) ,
"$ctx->{MAJOR_VERSION}.$ctx->{MINOR_VERSION}.$ctx->{RELEASE_VERSION}" ,
$ ctx - > { DESCRIPTION }
) ;
2005-10-26 20:06:26 +00:00
}
2005-10-26 23:36:04 +00:00
sub ProtoHeader ($$)
{
my ( $ self , $ ctx ) = @ _ ;
2005-12-13 21:42:03 +00:00
$ self - > _prepare_list ( $ ctx , "OBJ_LIST" ) ;
2005-10-26 23:36:04 +00:00
}
2005-10-26 19:07:01 +00:00
sub write ($$)
2004-05-13 10:20:53 +00:00
{
2005-10-26 19:07:01 +00:00
my ( $ self , $ file ) = @ _ ;
2004-05-13 10:20:53 +00:00
2005-10-26 19:07:01 +00:00
$ self - > output ( "MANPAGES = " . array2oneperline ( $ self - > { manpages } ) . "\n" ) ;
$ self - > output ( "BIN_PROGS = " . array2oneperline ( $ self - > { bin_progs } ) . "\n" ) ;
$ self - > output ( "SBIN_PROGS = " . array2oneperline ( $ self - > { sbin_progs } ) . "\n" ) ;
2005-12-15 15:59:10 +00:00
$ self - > output ( "BINARIES = " . array2oneperline ( $ self - > { binaries } ) . "\n" ) ;
2005-10-26 19:07:01 +00:00
$ self - > output ( "STATIC_LIBS = " . array2oneperline ( $ self - > { static_libs } ) . "\n" ) ;
$ self - > output ( "SHARED_LIBS = " . array2oneperline ( $ self - > { shared_libs } ) . "\n" ) ;
$ self - > output ( "PUBLIC_HEADERS = " . array2oneperline ( $ self - > { headers } ) . "\n" ) ;
2005-10-26 20:06:26 +00:00
$ self - > output ( "PC_FILES = " . array2oneperline ( $ self - > { pc_files } ) . "\n" ) ;
2005-06-06 01:22:57 +00:00
2005-10-26 23:36:04 +00:00
$ self - > _prepare_mk_files ( ) ;
2005-10-26 19:07:01 +00:00
if ( $ self - > { developer } ) {
$ self - > output ( << __EOD__
2005-12-13 21:42:03 +00:00
#-include \$(_ALL_OBJS_OBJ_LIST:.o=.d)
2005-10-26 19:07:01 +00:00
IDL_FILES = \ $ ( wildcard librpc /idl/ * . idl )
\ $ ( patsubst librpc /idl/ % . idl , librpc /gen_ndr/ ndr_ % . c , \ $ ( IDL_FILES ) ) \ \
\ $ ( patsubst librpc /idl/ % . idl , librpc /gen_ndr/ ndr_ \ % _c . c , \ $ ( IDL_FILES ) ) \ \
\ $ ( patsubst librpc /idl/ % . idl , librpc /gen_ndr/ ndr_ % . h , \ $ ( IDL_FILES ) ) : idl
__EOD__
) ;
2004-05-13 10:20:53 +00:00
}
2005-10-26 23:36:04 +00:00
$ self - > _prepare_dummy_MAKEDIR ( ) ;
2005-10-26 19:07:01 +00:00
$ self - > output ( $ self - > { mkfile } ) ;
2004-05-13 10:20:53 +00:00
2005-09-17 13:08:49 +00:00
open ( MAKEFILE , ">$file" ) || die ( "Can't open $file\n" ) ;
2005-10-21 21:43:39 +00:00
print MAKEFILE $ self - > { output } ;
2005-09-17 13:08:49 +00:00
close ( MAKEFILE ) ;
2004-05-13 10:20:53 +00:00
2005-10-26 20:06:26 +00:00
print __FILE__ . ": creating $file\n" ;
2004-05-13 10:20:53 +00:00
}
2004-11-12 01:40:02 +00:00
1 ;