From 9bd691f66219d717d7152199d6f3b962a13e5dd6 Mon Sep 17 00:00:00 2001 From: ketmar Date: Tue, 14 Oct 2008 07:59:54 +0300 Subject: [PATCH] "profile" rule added ; shell script to build KJam without jam added --- 0build.sh | 87 +++++++++++++++++++++++++++++++++++++++++ Jambase | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- doc/ChangeLog | 20 ++++++++++ 3 files changed, 225 insertions(+), 4 deletions(-) create mode 100755 0build.sh diff --git a/0build.sh b/0build.sh new file mode 100755 index 0000000..8d8fd7c --- /dev/null +++ b/0build.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +echo "building KJam..." + +mkdir -p bin.unix 2>/dev/null +rm bin.unix/* 2>/dev/null + +echo "Cc builtins.c" +gcc -pipe -c -o bin.unix/builtins.o -O2 builtins.c +echo "Cc command.c" +gcc -pipe -c -o bin.unix/command.o -O2 command.c +echo "Cc compile.c" +gcc -pipe -c -o bin.unix/compile.o -O2 compile.c +echo "Cc execunix.c" +gcc -pipe -c -o bin.unix/execunix.o -O2 execunix.c +echo "Cc fileunix.c" +gcc -pipe -c -o bin.unix/fileunix.o -O2 fileunix.c +echo "Cc pathunix.c" +gcc -pipe -c -o bin.unix/pathunix.o -O2 pathunix.c +echo "Yacc jamgram" +PATH="$PATH:." ./yyacc jamgram.y jamgramtab.h jamgram.yy +yacc -d jamgram.y +mv -f y.tab.c jamgram.c +mv -f y.tab.h jamgram.h +echo "Cc jamgram.c" +gcc -pipe -c -o bin.unix/jamgram.o -O2 jamgram.c +echo "Cc expand.c" +gcc -pipe -c -o bin.unix/expand.o -O2 expand.c +echo "Cc glob.c" +gcc -pipe -c -o bin.unix/glob.o -O2 glob.c +echo "Cc hash.c" +gcc -pipe -c -o bin.unix/hash.o -O2 hash.c +echo "Cc hash.c" +gcc -pipe -c -o bin.unix/headers.o -O2 headers.c +echo "Cc hash.c" +gcc -pipe -c -o bin.unix/lists.o -O2 lists.c +echo "Cc make.c" +gcc -pipe -c -o bin.unix/make.o -O2 make.c +echo "Cc make1.c" +gcc -pipe -c -o bin.unix/make1.o -O2 make1.c +echo "Cc newstr.c" +gcc -pipe -c -o bin.unix/newstr.o -fno-strict-aliasing -O2 newstr.c +echo "Cc option.c" +gcc -pipe -c -o bin.unix/option.o -O2 option.c +echo "Cc parse.c" +gcc -pipe -c -o bin.unix/parse.o -O2 parse.c +echo "Cc regexp.c" +gcc -pipe -c -o bin.unix/regexp.o -O2 regexp.c +echo "Cc rules.c" +gcc -pipe -c -o bin.unix/rules.o -fno-strict-aliasing -O2 rules.c +echo "Cc scan.c" +gcc -pipe -c -o bin.unix/scan.o -O2 scan.c +echo "Cc search.c" +gcc -pipe -c -o bin.unix/search.o -O2 search.c +echo "Cc timestamp.c" +gcc -pipe -c -o bin.unix/timestamp.o -fno-strict-aliasing -O2 timestamp.c +echo "Cc variable.c" +gcc -pipe -c -o bin.unix/variable.o -fno-strict-aliasing -O2 variable.c +echo "Cc hdrmacro.c" +gcc -pipe -c -o bin.unix/hdrmacro.o -fno-strict-aliasing -O2 hdrmacro.c +echo "Cc strings.c" +gcc -pipe -c -o bin.unix/strings.o -O2 strings.c +echo "Ar libjam.a" +ar ru bin.unix/libjam.a bin.unix/builtins.o bin.unix/command.o bin.unix/compile.o bin.unix/execunix.o bin.unix/fileunix.o bin.unix/pathunix.o bin.unix/jamgram.o bin.unix/expand.o bin.unix/glob.o bin.unix/hash.o bin.unix/headers.o bin.unix/lists.o bin.unix/make.o bin.unix/make1.o bin.unix/newstr.o bin.unix/option.o bin.unix/parse.o bin.unix/regexp.o bin.unix/rules.o bin.unix/scan.o bin.unix/search.o bin.unix/timestamp.o bin.unix/variable.o bin.unix/hdrmacro.o bin.unix/strings.o +echo "Ranlib libjam.a" +ranlib bin.unix/libjam.a +rm -f bin.unix/builtins.o bin.unix/command.o bin.unix/compile.o bin.unix/execunix.o bin.unix/fileunix.o bin.unix/pathunix.o bin.unix/jamgram.o bin.unix/expand.o bin.unix/glob.o bin.unix/hash.o bin.unix/headers.o bin.unix/lists.o bin.unix/make.o bin.unix/make1.o bin.unix/newstr.o bin.unix/option.o bin.unix/parse.o bin.unix/regexp.o bin.unix/rules.o bin.unix/scan.o bin.unix/search.o bin.unix/timestamp.o bin.unix/variable.o bin.unix/hdrmacro.o bin.unix/strings.o +echo "Cc mkjambase.c" +gcc -pipe -c -o bin.unix/mkjambase.o -O2 mkjambase.c +echo "Link mkjambase" +gcc -pipe -o bin.unix/mkjambase bin.unix/mkjambase.o +chmod 711 bin.unix/mkjambase +strip bin.unix/mkjambase +echo "Cc jam.c" +gcc -pipe -c -o bin.unix/jam.o -O2 jam.c +echo "preparing Jambase" +PATH="$PATH:." bin.unix/mkjambase jambase.c Jambase +echo "Cc jambase.c" +gcc -pipe -c -o bin.unix/jambase.o -O2 jambase.c +echo "Link jam" +gcc -pipe -o bin.unix/jam bin.unix/jam.o bin.unix/jambase.o bin.unix/libjam.a +chmod 711 bin.unix/jam +strip bin.unix/jam + +rm bin.unix/*.o bin.unix/*.a 2>/dev/null + +echo "KJam built" diff --git a/Jambase b/Jambase index d0490a7..347f660 100644 --- a/Jambase +++ b/Jambase @@ -179,15 +179,15 @@ THIS_IS_KJAM = "tan" ; # we are using kjam ############################################################################### OPTIM_SPEED = -O3 -march=pentium3 -mtune=pentium3 -mfpmath=sse -fomit-frame-pointer ; -LINKFLAGS_SPEED += -s ; +LINKFLAGS_SPEED = -s ; OPTIM_SIZE = -Os -march=i586 ; -LINKFLAGS_SIZE += -s ; +LINKFLAGS_SIZE = -s ; OPTIM_DEBUG = -O0 -g ; -LINKFLAGS_DEBUG += -s ; +LINKFLAGS_DEBUG = -g ; -CCFLAGS_NOALIAS = -fno-strict-aliasing ; +OPTIM_NOALIAS = -fno-strict-aliasing ; # @@ -335,6 +335,7 @@ else if $(UNIX) { # UNIX defaults + CC ?= gcc ; C++ ?= g++ ; CCFLAGS ?= ; C++FLAGS ?= $(CCFLAGS) ; @@ -427,6 +428,16 @@ LINKC++ ?= $(C++) ; LINKFLAGSC++ ?= $(LINKFLAGS) ; LINKLIBSC++ ?= $(LINKLIBS) ; +if $(OS) = "LINUX" { + if ( "gcc" in $(CC) ) && ! ( "-pipe" in $(CC) ) { CC += -pipe ; } + if ( "g++" in $(C++) ) && ! ( "-pipe" in $(C++) ) { C++ += -pipe ; } +} + +Echo "OS:" $(OS) ; +Echo "OSFULL:" $(OSFULL) ; +Echo "UNIX:" $(UNIX) ; + + # # Base dependencies - first for "bootstrap" kinds of rules @@ -2062,6 +2073,109 @@ rule makeSuffixed { $(<[1]) = [ FAppendSuffix $(>) : $(<[2]) ] ; } # +# Ketmar's additions +# + +# VAR = [ RemoveOpt options-to-remove : options-list ] ; +# remove options from list +rule RemoveOpt { + local oname = $(1) ; + local str = $(2) ; + local res = ; + local f ; + local oo ; + #Echo "removing " $(oname) " from " $(str) ; + for f in $(str) { + if ! $(f) in $(oname) { + res += $(f) ; + } + } + return $(res) ; +} + + +# VAR = [ RemoveOpt regexp-options-to-remove : options-list ] ; +# remove options from list with egrep-like regexps +rule RemoveOptWild { + local oname = $(1) ; + local str = $(2) ; + local res = ; + local f ; + local t ; + #Echo "removing " $(oname) " from " $(str) ; + for f in $(str) { + t = [ Match $(oname) : $(f) ] ; + #Echo $(f) ": " $(t) ; + if $(t[1]) = "" { + #Echo "include: " $(f) ; + res += $(f) ; + } + } + return $(res) ; +} + + +# profile "name" ; +# set compile flags for profile; works only for gcc/g++ +# available profiles: +# none, default: don't change +# empty: remove optimisation flags +# speed: optimise for speed and pIII +# size: optimise for size +# debug: don't optimize, add debug info +rule profile { + local orm = "(^\\-march\\=)" "(^\\-mtune\\=)" "(^\\-mfpmath\\=)" "(^\\-O.$)" ; + local ormff = "(^\\-f[^n][^o])" ; + local t ; + + if "gcc" in $(CC) { OPTIM = [ RemoveOptWild $(orm) $(ormff) : $(OPTIM) ] ; } + if "g++" in $(C++) { OPTIMC++ = [ RemoveOptWild $(orm) $(ormff) : $(OPTIMC++) ] ; } + if "gcc" in $(LINK) { LINKFLAGS = [ RemoveOpt "-g" "-s" : $(LINKFLAGS) ] ; } + if "g++" in $(C++) { LINKFLAGSC++ = [ RemoveOpt "-g" "-s" : $(LINKFLAGSC++) ] ; } + + switch $(1) { + case "none" : + Echo "MSG: default profile" ; + case "default" : + Echo "MSG: default profile" ; + case "empty" : + Echo "MSG: removing default optimization flags" ; + LINKFLAGS += -s ; + if "g++" in $(C++) { LINKFLAGSC++ += -s ; } + case "speed" : + Echo "MSG: optimizing for speed" ; + if "gcc" in $(CC) { OPTIM += $(OPTIM_SPEED) ; } + if "g++" in $(C++) { OPTIMC++ += $(OPTIM_SPEED) ; } + if "gcc" in $(CC) { LINKFLAGS += $(LINKFLAGS_SPEED) ; } + if "g++" in $(C++) { LINKFLAGSC++ += $(LINKFLAGS_SPEED) ; } + case "size" : + Echo "MSG: optimizing for speed" ; + if "gcc" in $(CC) { OPTIM += $(OPTIM_SIZE) ; } + if "g++" in $(C++) { OPTIMC++ += $(OPTIM_SIZE) ; } + if "gcc" in $(CC) { LINKFLAGS += $(LINKFLAGS_SIZE) ; } + if "g++" in $(C++) { LINKFLAGSC++ += $(LINKFLAGS_SIZE) ; } + case "debug" : + Echo "MSG: debug build" ; + if "gcc" in $(CC) { OPTIM += $(OPTIM_DEBUG) ; } + if "g++" in $(C++) { OPTIMC++ += $(OPTIM_DEBUG) ; } + if "gcc" in $(CC) { LINKFLAGS += $(LINKFLAGS_DEBUG) ; } + if "g++" in $(C++) { LINKFLAGSC++ += $(LINKFLAGS_DEBUG) ; } + case "*" : + Exit "unknown profile; possible values are: default; empty; speed; size; debug" ; + } +} + + +# ObjectNoAliasing filelist ; +# turn off aliasing optimization for specified files +# works only for gcc/g++ +rule ObjectNoAliasing { + if "gcc" in $(CC) { CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ; } + if "g++" in $(C++) { C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ; } +} + + +# # Now include the user's Jamfile. # include $(JAMFILE) ; diff --git a/doc/ChangeLog b/doc/ChangeLog index 2858d56..193add7 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -32,3 +32,23 @@ res = [ COMMAND shellcmd-list [[ : options ]] ]; new options (added to common description) [+] COMMAND/Command built-in now can parse command output + + [+] rule RemoveOpt + # VAR = [ RemoveOpt options-to-remove : options-list ] ; + # remove options from list + [+] rule RemoveOptWild + # VAR = [ RemoveOpt regexp-options-to-remove : options-list ] ; + # remove options from list with egrep-like regexps + [+] rule profile + # profile "name" ; + # set compile flags for profile; works only for gcc/g++ + # available profiles: + # none, default: don't change + # empty: remove optimisation flags + # speed: optimise for speed and pIII + # size: optimise for size + # debug: don't optimize, add debug info + [+] rule ObjectNoAliasing + # ObjectNoAliasing filelist ; + # turn off aliasing optimization for specified files + # works only for gcc/g++ -- 2.11.4.GIT