Skip to content

Commit

Permalink
build system: Split checks common to CC and CXX
Browse files Browse the repository at this point in the history
  • Loading branch information
tihirvon committed Jul 3, 2006
1 parent c197e8e commit 8ebcb2e
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 33 deletions.
83 changes: 55 additions & 28 deletions scripts/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@
#
# This file is licensed under the GPLv2.

# C compiler
# ----------
# CC default gcc
# LD default $CC
# LDFLAGS common linker flags for CC
#
# C++ Compiler
# ------------
# CXX default g++
# CXXLD default $CXX
# CXXLDFLAGS common linker flags for CXX
#
# Common for C and C++
# --------------------
# SOFLAGS flags for compiling position independent code (-fPIC)
# LDSOFLAGS flags for linking shared libraries
# LDDLFLAGS flags for linking dynamically loadable modules

msg_checking()
{
printf "checking $@... "
Expand Down Expand Up @@ -93,39 +111,36 @@ check_cxx_flag()
fi
}

# adds CC, LD, CFLAGS, LDFLAGS and SOFLAGS to config.mk
check_cc()
cc_cxx_common()
{
var_default CC ${CROSS}gcc
var_default LD $CC
var_default CFLAGS "-g -O2 -Wall"
var_default LDFLAGS ""
test "$cc_cxx_common_done" && return 0
cc_cxx_common_done=yes

var_default SOFLAGS "-fPIC"
# libs (.so)
var_default LDSOFLAGS "-shared"
# plugins (.so)
var_default LDDLFLAGS "-shared"

check_program $CC || return 1

common_cf=
common_lf=
COMPAT_LIBS=

case $(uname -s) in
*BSD)
CFLAGS="$CFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
common_cf="$common_cf -I/usr/local/include"
common_lf="$common_lf -L/usr/local/lib"
;;
Darwin)
# fink
if test -d /sw/lib
then
CFLAGS="$CFLAGS -I/sw/include"
LDFLAGS="$LDFLAGS -L/sw/lib"
common_cf="$common_cf -I/sw/include"
common_lf="$common_lf -L/sw/lib"
fi
# darwinports
if test -d /opt/local/lib
then
CFLAGS="$CFLAGS -I/opt/local/include"
LDFLAGS="$LDFLAGS -L/opt/local/lib"
common_cf="$common_cf -I/opt/local/include"
common_lf="$common_lf -L/opt/local/lib"
fi
LDSOFLAGS="-dynamic"
case ${MACOSX_DEPLOYMENT_TARGET} in
Expand All @@ -141,8 +156,8 @@ check_cc()
esac
;;
SunOS)
CFLAGS="$CFLAGS -D__EXTENSIONS__ -I/usr/local/include"
LDFLAGS="$LDFLAGS -R/usr/local/lib -L/usr/local/lib"
common_cf="$common_cf -D__EXTENSIONS__ -I/usr/local/include"
common_lf="$common_lf -R/usr/local/lib -L/usr/local/lib"

# this is ugly but can be removed after Solaris is either
# dead or fixed
Expand All @@ -163,28 +178,40 @@ check_cc()
fi
;;
esac
makefile_vars CC LD CFLAGS LDFLAGS SOFLAGS LDSOFLAGS LDDLFLAGS COMPAT_LIBS
makefile_vars SOFLAGS LDSOFLAGS LDDLFLAGS COMPAT_LIBS
}

# CC, LD, CFLAGS, LDFLAGS, SOFLAGS, LDSOFLAGS, LDDLFLAGS
check_cc()
{
var_default CC ${CROSS}gcc
var_default LD $CC
var_default CFLAGS "-g -O2 -Wall"
var_default LDFLAGS ""
check_program $CC || return 1

cc_cxx_common
CFLAGS="$CFLAGS $common_cf"
LDFLAGS="$LDFLAGS $common_lf"

makefile_vars CC LD CFLAGS LDFLAGS
return 0
}

# adds CXX, CXXLD, CXXFLAGS and CXXLDFLAGS to config.mk
# CXX, CXXLD, CXXFLAGS, CXXLDFLAGS, SOFLAGS, LDSOFLAGS, LDDLFLAGS
check_cxx()
{
var_default CXX ${CROSS}g++
var_default CXXLD $CXX
var_default CXXFLAGS "-g -O2 -Wall"
var_default CXXLDFLAGS ""

check_program $CXX || return 1

case $(uname -s) in
*BSD)
CXXFLAGS="$CXXFLAGS -I/usr/local/include"
CXXLDFLAGS="$CXXLDFLAGS -L/usr/local/lib"
;;
esac
cc_cxx_common
CXXFLAGS="$CXXFLAGS $common_cf"
CXXLDFLAGS="$CXXLDFLAGS $common_lf"

makefile_vars CXX CXXLD CXXFLAGS CXXLDFLAGS
check_shared_flags
return 0
}

Expand Down
18 changes: 13 additions & 5 deletions scripts/lib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ uninstall:
%.lo: %.cpp
$(call cmd,cxx_lo)

# CC for programs and shared libraries
# CC for program object files (.o)
quiet_cmd_cc = CC $@
quiet_cmd_cc_lo = CC $@
cmd_cc = $(CC) -c $(CFLAGS) -o $@ $<

# CC for shared library and dynamically loadable module objects (.lo)
quiet_cmd_cc_lo = CC $@
cmd_cc_lo = $(CC) -c $(CFLAGS) $(SOFLAGS) -o $@ $<

# LD for programs, optional parameter: libraries
Expand All @@ -112,10 +114,12 @@ quiet_cmd_ld_so = LD $@
quiet_cmd_ld_dl = LD $@
cmd_ld_dl = $(LD) $(LDDLFLAGS) $(LDFLAGS) -o $@ $^ $(1)

# CXX for programs and shared libraries
# CXX for program object files (.o)
quiet_cmd_cxx = CXX $@
quiet_cmd_cxx_lo = CXX $@
cmd_cxx = $(CXX) -c $(CXXFLAGS) -o $@ $<

# CXX for shared library and dynamically loadable module objects (.lo)
quiet_cmd_cxx_lo = CXX $@
cmd_cxx_lo = $(CXX) -c $(CXXFLAGS) $(SOFLAGS) -o $@ $<

# CXXLD for programs, optional parameter: libraries
Expand All @@ -124,7 +128,11 @@ quiet_cmd_cxxld = CXXLD $@

# CXXLD for shared libraries, optional parameter: libraries
quiet_cmd_cxxld_so = CXXLD $@
cmd_cxxld_so = $(CXXLD) -shared $(LDFLAGS) -o $@ $^ $(1)
cmd_cxxld_so = $(CXXLD) $(LDSOFLAGS) $(CXXLDFLAGS) -o $@ $^ $(1)

# CXXLD for dynamically loadable modules, optional parameter: libraries
quiet_cmd_cxxld_dl = CXXLD $@
cmd_cxxld_dl = $(CXXLD) $(LDDLFLAGS) $(CXXLDFLAGS) -o $@ $^ $(1)

# create archive
quiet_cmd_ar = AR $@
Expand Down

0 comments on commit 8ebcb2e

Please sign in to comment.