Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting CPPFLAGS and LDFLAGS #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ fi

[ x"$CXX" = x ] && CXX=g++
[ x"$CXXFLAGS" = x ] || CXXFLAGS="$CXXFLAGS "
[ x"$CPPFLAGS" = x ] || CPPFLAGS="$CPPFLAGS "
[ x"$LDFLAGS" = x ] || LDFLAGS="$LDFLAGS "

case x"$CXX" in
x*g++*|x*clang++*) CXXFLAGS="${CXXFLAGS}-Wall -Wextra";;
Expand Down Expand Up @@ -497,6 +499,8 @@ sed \
# This 'makefile' is generated from '../makefile.in'." \
-e "s,@CXX@,$CXX," \
-e "s#@CXXFLAGS@#$CXXFLAGS#" \
-e "s#@CPPFLAGS@#$CPPFLAGS#" \
-e "s#@LDFLAGS@#$LDFLAGS#" \
-e "s#@LIBS@#$libs#" \
-e "s#@CONTRIB@#$contrib#" \
-e "s#@ROOT@#$root#" \
Expand Down
8 changes: 5 additions & 3 deletions makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

CXX=@CXX@
CXXFLAGS=@CXXFLAGS@
CPPFLAGS=@CPPFLAGS@
LDFLAGS=@LDFLAGS@

LIBS=@LIBS@
ROOT=@ROOT@
Expand All @@ -30,7 +32,7 @@ OBJ_CONTRIB=$(FILT_CONTRIB:.cpp=.o)
# Include for current build directory is required for including the
# generated build header build.hpp.
DIR=../$(shell pwd|sed -e 's,.*/,,')
COMPILE=$(CXX) $(CXXFLAGS) -I$(DIR) -I$(ROOT)/src
COMPILE=$(CXX) $(CXXFLAGS) $(CPPFLAGS) -I$(DIR) -I$(ROOT)/src

#--------------------------------------------------------------------------#

Expand All @@ -54,10 +56,10 @@ contrib/%.o: $(ROOT)/contrib/%.cpp $(ROOT)/contrib/%.hpp $(ROOT)/src/*.hpp makef
# tester 'mobical') and the library are the main build targets.

cadical: src/cadical.o libcadical.a makefile
$(COMPILE) -o $@ $< -L. -lcadical $(LIBS)
$(COMPILE) -o $@ $< $(LDFLAGS) -L. -lcadical $(LIBS)

mobical: src/mobical.o libcadical.a makefile $(LIBS)
$(COMPILE) -o $@ $< -L. -lcadical
$(COMPILE) -o $@ $< $(LDFLAGS) -L. -lcadical

libcadical.a: $(OBJ_SOLVER) $(OBJ_CONTRIB) makefile
ar rc $@ $(OBJ_SOLVER) $(OBJ_CONTRIB)
Expand Down
10 changes: 7 additions & 3 deletions test/api/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ makefile=$CADICALBUILD/makefile

CXX=`grep '^CXX=' "$makefile"|sed -e 's,CXX=,,'`
CXXFLAGS=`grep '^CXXFLAGS=' "$makefile"|sed -e 's,CXXFLAGS=,,'`
CPPFLAGS=`grep '^CPPFLAGS=' "$makefile"|sed -e 's,CPPFLAGS=,,'`
LDFLAGS=`grep '^LDFLAGS=' "$makefile"|sed -e 's,LDFLAGS=,,'`

msg "using CXX=$CXX"
msg "using CXXFLAGS=$CXXFLAGS"
msg "using CPPFLAGS=$CPPFLAGS"
msg "using LDFLAGS=$LDFLAGS"

tests=../test/api

Expand All @@ -73,20 +77,20 @@ run () {
then
src=$tests/$1.c
language=" -x c"
COMPILE="$CXX `echo $CXXFLAGS|sed -e 's,-std=c++11,-std=c11,'`"
COMPILE="$CXX `echo $CXXFLAGS|sed -e 's,-std=c++11,-std=c11,'` $CPPFLAGS"
elif [ -f $tests/$1.cpp ]
then
src=$tests/$1.cpp
language=""
COMPILE="$CXX $CXXFLAGS"
COMPILE="$CXX $CXXFLAGS $CPPFLAGS"
else
die "can not find '$tests.c' nor '$tests.cpp'"
fi
name=$CADICALBUILD/test-api-$1
rm -f $name.log $name.o $name
status=0
cmd $COMPILE$language -o $name.o -c $src
cmd $COMPILE -o $name $name.o -L$CADICALBUILD -lcadical
cmd $COMPILE -o $name $name.o $LDFLAGS -L$CADICALBUILD -lcadical
cmd $name
if test $status = 0
then
Expand Down
19 changes: 16 additions & 3 deletions test/cnf/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ die "needs to be called from a top-level sub-directory of CaDiCaL"

[ x"$CADICALBUILD" = x ] && CADICALBUILD="../build"

[ -f "$CADICALBUILD/makefile" ] || \
die "can not find '$CADICALBUILD/makefile' (run 'configure' first)"

[ -x "$CADICALBUILD/cadical" ] || \
die "can not find '$CADICALBUILD/cadical' (run 'make' first)"

Expand All @@ -47,12 +50,22 @@ lratchecker=$CADICALBUILD/lrat-trim
solutionchecker=$CADICALBUILD/precochk
makefile=$CADICALBUILD/makefile

CXX=`grep '^CXX=' "$makefile"|sed -e 's,CXX=,,'`
CXXFLAGS=`grep '^CXXFLAGS=' "$makefile"|sed -e 's,CXXFLAGS=,,'`
CPPFLAGS=`grep '^CPPFLAGS=' "$makefile"|sed -e 's,CPPFLAGS=,,'`
LDFLAGS=`grep '^LDFLAGS=' "$makefile"|sed -e 's,LDFLAGS=,,'`

msg "using CXX=$CXX"
msg "using CXXFLAGS=$CXXFLAGS"
msg "using CPPFLAGS=$CPPFLAGS"
msg "using LDFLAGS=$LDFLAGS"

if [ ! -f $solutionchecker -o ! -f $dratchecker -o ! -f $lratchecker ]
then

if [ ! -f $solutionchecker -o ../test/cnf/precochk.c -nt $solutionchecker ]
then
cmd="cc -O -o $solutionchecker ../test/cnf/precochk.c -lz"
cmd="cc -O `echo $CXXFLAGS|sed -e 's,-std=c++11,-std=c11,'` $CPPFLAGS -o $solutionchecker ../test/cnf/precochk.c -lz $LDFLAGS"
cecho "$cmd"
if $cmd 2>/dev/null
then
Expand All @@ -66,7 +79,7 @@ then

if [ ! -f $dratchecker -o ../test/cnf/drat-trim.c -nt $dratchecker ]
then
cmd="cc -O -o $dratchecker ../test/cnf/drat-trim.c"
cmd="cc -O `echo $CXXFLAGS|sed -e 's,-std=c++11,-std=c11,'` $CPPFLAGS -o $dratchecker ../test/cnf/drat-trim.c $LDFLAGS"
if $cmd 2>/dev/null
then
msg "external proof checking with '$dratchecker'"
Expand All @@ -79,7 +92,7 @@ then

if [ ! -f $lratchecker -o ../test/cnf/lrat-trim.c -nt $lratchecker ]
then
cmd="cc -O -o $lratchecker ../test/cnf/lrat-trim.c"
cmd="cc -O `echo $CXXFLAGS|sed -e 's,-std=c++11,-std=c11,'` $CPPFLAGS -o $lratchecker ../test/cnf/lrat-trim.c $LDFLAGS"
if $cmd 2>/dev/null
then
msg "external proof checking with '$lratchecker'"
Expand Down