Don't know how I missed SciCalc.h compilation errors.

Sanitizing Library and Program rules. No needs to pass compiler/linker
options throught the build rules since ObjectXXFlags are designed for that.
Also reduces parameter numbers for rules iteself.

Added LinkAgainst rule; jam's LinkLibraries will build library that we
want to link against which is no too good for system libraries. 
LinkAgainst will directly pass libraries to the linker.

Also fixed few bugs like GLOBALFLAGS inclusion since it was skipped 
throught the compilation (that brought a lot of warnings due appended 
-Wall -pedantic options :P).
This commit is contained in:
Sanel Zukan 2007-07-20 15:48:49 +00:00
parent f65296f795
commit 8b405a9165
3 changed files with 76 additions and 82 deletions

View File

@ -10,30 +10,12 @@
SUFSHAREDLIB = ".so" ;
# StaticLibrary [lib-name] : [source-files] : [flags] ;
# StaticLibrary [lib-name] : [source-files] ;
rule StaticLibrary
{
local objects = [ FGristFiles $(>:S=$(SUFOBJ)) ] ;
C++FLAGS on $(objects) = [ on $(objects) return $(C++FLAGS) ] $(3) ;
CCFLAGS on $(objects) = [ on $(objects) return $(CCFLAGS) ] $(3) ;
Library $(<) : $(>) ;
}
# Not used (althought it do the job) since MainFromObjects defines
# 'exe' target ('jam exe') which will build the library; I want 'lib' target :-P
#rule SharedLibraryFromObjects
#{
# local shlib = $(1) ;
# # In case path be part of $(shlib), gcc will set bad soname
# # so it must be removed
# local shlib_only = $(1:D=) ;
#
# MainFromObjects $(shlib) : $(2) ;
# LINKFLAGS on $(shlib) = [ on $(shlib) return $(LINKFLAGS) ]
# -shared -Wl,-soname,\"$(shlib_only)\" $(3) ;
#}
rule SharedLibraryFromObjects
{
if ! $(UNIX) {
@ -46,9 +28,9 @@ rule SharedLibraryFromObjects
t = $(1) ;
s = [ FGristFiles $(2) ] ;
# Rip directory part from target because this will
# Rip directory and grist parts from target because this will
# be passed to compiler as soname
t_only = $(t:D=) ;
t_only = $(t:D=:G=) ;
# if given suffix, skip it; otherwise add SUFSHAREDLIB
if ! $(t:S) {
@ -62,9 +44,7 @@ rule SharedLibraryFromObjects
MakeLocate $(t) $(t)($(s:BS)) : $(LOCATE_TARGET) ;
}
# FIXME: option 'on $(t) return $(LINKLIBS)' can be re-used
# instead $(3) parameter so [opt-linklibs] are not needed. Check this.
LINKLIBS on $(t) = [ on $(t) return $(LINKLIBS) ] -shared -Wl,-soname,\"$(t_only)\" $(3) ;
LINKLIBS on $(t) = -shared -Wl,-soname,\"$(t_only)\" [ on $(t) return $(LINKLIBS) ] ;
# Let target is dependant on source
Depends $(t) : $(s) ;
@ -73,10 +53,8 @@ rule SharedLibraryFromObjects
Clean clean : $(t) ;
}
# SharedLibrary [libname] : [sources] : [opt-linklibs] ;
# Creates shared library [libname] from [sources]. If [opt-linklibs] are provided,
# library will be linked with them (they _must_ be in form -lfoo which will be directly
# passed to compiler).
# SharedLibrary [libname] : [sources] ;
# Creates shared library [libname] from [sources].
#
# Note: ftjam in later versions provide rule with the same name, althought it calls
# libtool in the background. The way jam works, selecting latest redefined rules, ftjam's
@ -85,24 +63,27 @@ rule SharedLibrary
{
local shlib = $(1) ;
local src = $(2) ;
local objects = $(src:S=$(SUFOBJ)) ;
local objects = [ FGristFiles $(src:S=$(SUFOBJ)) ] ;
SharedLibraryFromObjects $(shlib) : $(objects) : $(3) ;
CCFLAGS on $(objects) += -fPIC ;
C++FLAGS on $(objects) += -fPIC ;
SharedLibraryFromObjects $(shlib) : $(objects) ;
Objects $(src) ;
}
# SharedLibraryVersioned [libname] : [sources] : [opt-linklibs] : [opt-version] : ["nolink"] ;
# SharedLibraryVersioned [libname] : [sources] : [opt-version] : ["nolink"] ;
# Creates versioned shared library (foo.so.[version]) which is often library naming
# on unix platforms. If [opt-version] is not given, it is like calling SharedLibrary only.
# By default it will create, besides [libname], ".so" symlink to it too. If "nolink" is given
# as 5 parameter, it will skip symlink creation.
# as 4 parameter, it will skip symlink creation.
rule SharedLibraryVersioned
{
if $(4) {
if $(3) {
local target target_dir symlink versioned ;
# Set .so.version extension
versioned = "$(SUFSHAREDLIB).$(4)" ;
versioned = "$(SUFSHAREDLIB).$(3)" ;
# Jam is not smart about ripping suffixes so cases 'foo.so.2.0'
# will produce 'foo.so.2'. We must hope that provided [libname] does _not_
@ -110,10 +91,10 @@ rule SharedLibraryVersioned
# With good hopes, we set first full target name and it's link abbreviation.
target = $(1:S=$(versioned)) ;
symlink = $(1:S=$(SUFSHAREDLIB)) ;
SharedLibrary $(target) : $(2) : $(3) ;
SharedLibrary $(target) : $(2) ;
# Create symlink
if $(5) != "nolink" {
if $(4) != "nolink" {
# copy target directory or symlink will be created
# from place where jam is called
LOCATE on $(symlink) = [ on $(target) return $(LOCATE) ] ;
@ -124,6 +105,6 @@ rule SharedLibraryVersioned
Clean clean : $(symlink) ;
}
} else {
SharedLibrary $(1) : $(2) : $(3) ;
SharedLibrary $(1) : $(2) ;
}
}

View File

@ -13,10 +13,12 @@ rule MakeProgramPrivate
{
local target objects ;
# This will make happy original jam and ftjam since constructing it's
# grist from source file will make it unique and prevent colision with the
# same directory name
target = $(1:G=$(SOURCE_GRIST)) ;
# If this is gristed, targets of LinkAgainst, SharedLibrary and SharedLibraryVersioned
# _must_ be too. As I could see, in Jambase target is not gristed.
# I'm not sure what for cases foo/foo, but for now, things looking very good.
# target = $(1:G=$(SOURCE_GRIST)) ;
target = $(1) ;
# so 'jam foo' works when 'foo' is final executable
if $(target) != $(<) {
@ -27,8 +29,8 @@ rule MakeProgramPrivate
objects = [ FGristFiles $(2:S=$(SUFOBJ)) ] ;
# Pick up values if someone set flags outside (via ObjectCcFlags and etc.)
CFLAGS on $(objects) = [ on $(objects) return $(CFLAGS) ] $(4) ;
C++FLAGS on $(objects) = [ on $(objects) return $(C++FLAGS) ] $(4) ;
CFLAGS on $(objects) += $(4) ;
C++FLAGS on $(objects) += $(4) ;
LINKLIBS on $(target) = $(3) [ on $(target) return $(LINKLIBS) ] ;
@ -36,19 +38,30 @@ rule MakeProgramPrivate
Objects $(>) ;
}
# Program [target] : [sources] : [libraries] : [flags] ;
# LinkAgainst [taraget] : [libraries] ;
# Add [libraries] to list of libraries for linking with [taraget]. This
# rule is similar to jam's LinkLibraries, but it will not built those libraries
# nor marked them for building. Also requires [libraries] are in the form '-lfoo'.
rule LinkAgainst
{
# Here is not used grist on target (LinkLibraries does not use it too).
# If gristing is added, make shure is added to SharedLibrary and SharedLibraryVersioned
# or it will not pick libraries and symlink will not be created.
LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] $(2) ;
}
# Program [target] : [sources] ;
# Compiles and links [target] from [sources]. No external flags or
# libraries are used since this should be generic rule for compiling
# any program.
rule Program
{
MakeProgramPrivate $(1) : $(2) : $(3) : $(4) ;
Main $(1) : $(2) ;
}
# EdeProgram [target] : [sources] : [optinal-libraries] : [optinal-flags] : [noinstall] ;
# EdeProgram [target] : [sources] : [noinstall] ;
# Creates EDE specific programs. They will be linked with EDELIBLIB
# and FLTKLIB. If [optinal-libraries] or [optinal-flags] are given, they will be
# used too.
# and FLTKLIB. If [noinstall] is given, [target] will not be installed wit 'jam install'.
rule EdeProgram
{
if ! $(EDELIBINCLUDE) || ! $(EDELIBLIB) {
@ -57,17 +70,17 @@ rule EdeProgram
}
MakeProgramPrivate $(1) : $(2)
: $(3) $(EDELIBLIB) $(FLTKLIB) $(STDLIB)
: $(4) $(EDELIBINCLUDE) $(FLTKINCLUDE) ;
: $(EDELIBLIB) $(FLTKLIB) $(STDLIB)
: $(GLOBALFLAGS) $(EDELIBINCLUDE) $(FLTKINCLUDE) ;
if $(5) != "noinstall" {
if $(3) != "noinstall" {
InstallEdeProgram $(1) ;
}
}
# EfltkProgram [target] : [sources] : [optinal-libraries] : [optinal-flags] : [noinstall] ;
# Creates programs that will be linked with efltk. If [optinal-libraries] or
# [optinal-flags] are given, they will be used too.
# EfltkProgram [target] : [sources] : [noinstall] ;
# Creates programs that will be linked with efltk. If [noinstall] is given,
# [target] will not be installed wit 'jam install'.
rule EfltkProgram
{
if ! $(EFLTKINCLUDE) || ! $(EFLTKLIB) {
@ -76,16 +89,16 @@ rule EfltkProgram
}
MakeProgramPrivate $(1) : $(2)
: $(3) $(EFLTKLIB) $(STDLIB)
: $(4) $(EFLTKINCLUDE) ;
: $(EFLTKLIB) $(STDLIB)
: $(GLOBALFLAGS) $(EFLTKINCLUDE) ;
# install it where ede binaries resides
if $(5) != "noinstall" {
if $(3) != "noinstall" {
InstallEdeProgram $(1) ;
}
}
# FltkProgram [target] : [sources] : [optinal-libraries] : [optinal-flags] : [noinstall] ;
# FltkProgram [target] : [sources] : [noinstall] ;
# Creates programs that will be linked with fltk only. It will use full fltk
# dependencies (images).
rule FltkProgram
@ -96,16 +109,16 @@ rule FltkProgram
}
MakeProgramPrivate $(1) : $(2)
: $(3) $(FLTKLIB) $(STDLIB)
: $(4) $(FLTKINCLUDE) ;
: $(FLTKLIB) $(STDLIB)
: $(GLOBALFLAGS) $(FLTKINCLUDE) ;
# install it where ede binaries resides
if $(5) != "noinstall" {
if $(3) != "noinstall" {
InstallEdeProgram $(1) ;
}
}
# FltkProgramBare [target] : [sources] : [optinal-libraries] : [optinal-flags] : [noinstall] ;
# FltkProgramBare [target] : [sources] : [noinstall] ;
# Creates programs that will be linked with fltk only. No images will be linked in it.
rule FltkProgramBare
{
@ -115,11 +128,11 @@ rule FltkProgramBare
}
MakeProgramPrivate $(1) : $(2)
: $(3) $(FLTKLIB_NOIMAGES) $(STDLIB)
: $(4) $(FLTKINCLUDE) ;
: $(FLTKLIB_NOIMAGES) $(STDLIB)
: $(GLOBALFLAGS) $(FLTKINCLUDE) ;
# install it where ede binaries resides
if $(5) != "noinstall" {
if $(3) != "noinstall" {
InstallEdeProgram $(1) ;
}
}

View File

@ -12,25 +12,25 @@ class SciCalc {
enum {MaxNumBrkts=10};
enum Operator {PLUS,MINUS,MULT,DIV,POW,INVPOW,EVAL};
enum mode {NONE=0,DOT=-1,NORM=-2,EXP=-3};
double value[4*(MaxNumBrkts+1)]; /* The values on the stack */;
int priority[6]; /* the priorities of each operator */;
int oper[3*(MaxNumBrkts+1)]; /* the operators between them */;
int top; /* the top of the stack */;
int startbrkt[(MaxNumBrkts+1)]; /* the positions of the left brackets */;
int currentbrkt; /* bracketing we are in */;
double mem; /* The memory value */;
double value[4*(MaxNumBrkts+1)]; /* The values on the stack */
int priority[6]; /* the priorities of each operator */
int oper[3*(MaxNumBrkts+1)]; /* the operators between them */
int top; /* the top of the stack */
int startbrkt[(MaxNumBrkts+1)]; /* the positions of the left brackets */
int currentbrkt; /* bracketing we are in */
double mem; /* The memory value */
int ready; /* Whether last number is ready.
if "ready" is set, then typing another number
overwrites the current number. */;
int dot; /* Whether the dot has been typed */;
double diver; /* The divider when behind the dot */;
int behind; /* Number of digits behind dot */;
int inv; /* Whether inverse key is depressed */;
int emode; /* Whether we are entering the exponent */;
int exponent; /* the exponent value whilst entering exponent */;
double mantissa; /* the mantissa value whilst entering exponent */;
int base; /* the base we are working in (2,8,10 or 16) */;
int drgmode; /* whether we are in deg, rad or grad mode */;
overwrites the current number. */
int dot; /* Whether the dot has been typed */
double diver; /* The divider when behind the dot */
int behind; /* Number of digits behind dot */
int inv; /* Whether inverse key is depressed */
int emode; /* Whether we are entering the exponent */
int exponent; /* the exponent value whilst entering exponent */
double mantissa; /* the mantissa value whilst entering exponent */
int base; /* the base we are working in (2,8,10 or 16) */
int drgmode; /* whether we are in deg, rad or grad mode */
public:
SciCalc();
private: