Skip to content

Commit

Permalink
Allow overriding CC on macos & freebsd.
Browse files Browse the repository at this point in the history
Other platforms allow overriding CC in the bootstrap build by setting CC
in the environment, but macos & freebsd were setting it back to clang.
Similarly, if CONFIG_CC is set in the tup.config, the actual tup build
for macos & freebsd would ignore that value and just use clang.

Now the CC environment variable for bootstrapping and CONFIG_CC for the
tup build should work for setting the compiler in all cases.

Fixes #497.
  • Loading branch information
gittup committed Apr 1, 2024
1 parent 84aa23e commit 628988f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
24 changes: 13 additions & 11 deletions Tuprules.tup
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@ else
TARGET = @(TUP_PLATFORM)
endif

ifdef CC
CC = @(CC)
else
ifeq ($(TARGET),win32)
CC = x86_64-w64-mingw32-gcc
CC32 = i686-w64-mingw32-gcc
else
CC = gcc
endif
endif

ifeq (@(TUP_DEBUG),y)
CFLAGS += -Og
else
Expand Down Expand Up @@ -88,11 +77,24 @@ endif
!dot = |> ^ DOT %f^ dot -Efontname="Vernada, serif" -Nfontname="Vernada, serif" -Efontsize=10 -Nfontsize=10 -Tpng %f > %o |>
!cp = |> ^ CP %f -> %o^ cp %f %o |>

# Default to using gcc to compile. This is overridden on some OSes in the
# included $(TARGET).tup file, and can be overridden by the user in the
# tup.config file by setting CONFIG_CC (and/or CONFIG_CC32 on Windows).
CC = gcc

TUP_MONITOR = null
TUP_SUID_GROUP = root
TUP_USE_SYSTEM_PCRE = y
include $(TARGET).tup

ifdef CC
CC = @(CC)
endif

ifdef CC32
CC32 = @(CC32)
endif

ifdef TUP_USE_SYSTEM_PCRE
use_system_pcre = @(TUP_USE_SYSTEM_PCRE)
else
Expand Down
7 changes: 4 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ else
exit 1
fi
LDFLAGS="$LDFLAGS -lm"
: ${CC:=gcc}
default_cc=gcc
case "$os" in
Linux)
plat_files="$plat_files ../src/compat/dummy.c"
Expand All @@ -47,20 +47,21 @@ case "$os" in
plat_files="$plat_files ../src/compat/dummy.c"
plat_files="$plat_files ../src/compat/clearenv.c "
plat_cflags="$plat_cflags -include ../src/compat/macosx.h"
CC=clang
default_cc=clang
;;
FreeBSD)
plat_files="$plat_files ../src/compat/dummy.c"
plat_files="$plat_files ../src/compat/utimensat_linux.c"
plat_files="$plat_files ../src/compat/clearenv.c"
CC=clang
default_cc=clang
;;
NetBSD)
plat_files="$plat_files ../src/compat/dummy.c"
plat_files="$plat_files ../src/compat/clearenv.c"
plat_cflags="$plat_cflags -include ../src/compat/netbsd.h"
;;
esac
: ${CC:=$default_cc}

rm -rf build
echo " mkdir build"
Expand Down
5 changes: 2 additions & 3 deletions win32.tup
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
ifdef CC32
CC32 = @(CC32)
endif
CC = x86_64-w64-mingw32-gcc
CC32 = i686-w64-mingw32-gcc

# Compatibility function prototypes and include path for wrapper functions
CFLAGS += -include $(TUP_CWD)/src/compat/win32/mingw.h
Expand Down

0 comments on commit 628988f

Please sign in to comment.