文件
Paze-C-CPP-Compiler/Makefile
T
Paze AI 251ee470bf feat: Paze C Compiler - 完整改造自 tcc 0.9.28rc
- 所有 tcc 文件/内容/宏改名为 pcc (tcc.c->pcc.c, tccelf.c->pccelf.c, libtcc.c->libpcc.c 等)
- 支持架构: i386, x86_64, ARM, ARM64, RISC-V, C67
- 支持格式: PE, ELF, Mach-O, COFF
- 完整预处理、代码生成、链接器、调试信息
- 构建成功: pcc.exe (x86_64 Windows)
- 功能测试通过: 递归/结构体/浮点/switch/循环
- 自编译测试通过: pcc 可以编译自身
2026-08-16 13:30:01 +08:00

538 行
18 KiB
Makefile

# --------------------------------------------------------------------------
#
# Paze C Compiler Makefile
#
ifndef TOP
TOP = .
INCLUDED = no
endif
ifeq ($(findstring $(MAKECMDGOALS),clean distclean),)
include $(TOP)/config.mak
endif
ifeq (-$(GCC_MAJOR)-$(findstring $(GCC_MINOR),56789)-,-4--)
CFLAGS += -D_FORTIFY_SOURCE=0
endif
LIBPCC = libpcc.a
LIBPCC1 = libpcc1.a
LINK_LIBPCC =
LIBS =
CFLAGS += $(CPPFLAGS)
VPATH = $(TOPSRC)
-LTCC = $(TOP)/$(LIBPCC)
ifdef CONFIG_WIN32
CFG = -win
ifneq ($(CONFIG_static),yes)
LIBPCC = libpcc$(DLLSUF)
LIBPCCDEF = libpcc.def
endif
ifneq ($(CONFIG_debug),yes)
ifneq ($(CC_NAME),clang)
LDFLAGS += -s
endif
endif
NATIVE_TARGET = $(if $(findstring arm64,$(ARCH)),arm64-win32,$(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32))
else
CFG = -unx
LIBS+=-lm
ifneq ($(CONFIG_ldl),no)
LIBS+=-ldl
endif
ifneq ($(CONFIG_pthread),no)
LIBS+=-lpthread
endif
# make libpcc as static or dynamic library?
ifeq ($(CONFIG_static),no)
LIBPCC=libpcc$(DLLSUF)
export LD_LIBRARY_PATH := $(CURDIR)/$(TOP)
ifneq ($(CONFIG_rpath),no)
ifndef CONFIG_OSX
LINK_LIBPCC += -Wl,-rpath,"$(libdir)"
else
# macOS doesn't support env-vars libdir out of the box - which we need for
# `make test' when libpcc.dylib is used (configure --disable-static), so
# we bake a relative path into the binary. $libdir is used after install.
LINK_LIBPCC += -Wl,-rpath,"@executable_path/$(TOP)" -Wl,-rpath,"$(libdir)"
# -current/compatibility_version must not contain letters.
MACOS_DYLIB_VERSION := $(firstword $(subst rc, ,$(VERSION)))
DYLIBVER += -current_version $(MACOS_DYLIB_VERSION)
DYLIBVER += -compatibility_version $(MACOS_DYLIB_VERSION)
endif
endif
endif
NATIVE_TARGET = $(ARCH)
ifdef CONFIG_OSX
NATIVE_TARGET = $(ARCH)-osx
ifneq ($(CC_NAME),pcc)
LDFLAGS += -flat_namespace
ifneq (1,$(shell expr $(GCC_MAJOR) ">=" 15))
LDFLAGS += -undefined warning # depreciated in clang >= 15.0
endif
endif
export MACOSX_DEPLOYMENT_TARGET := 10.6
endif
endif
# run local version of pcc with local libraries and includes
TCCFLAGS-unx = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP)
TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)
TCCFLAGS = $(TCCFLAGS$(CFG))
PCC_LOCAL = $(TOP)/pcc$(EXESUF)
PCC = $(PCC_LOCAL) $(TCCFLAGS)
# run tests with the installed pcc instead
ifdef TESTINSTALL
PCC_LOCAL = $(bindir)/pcc
TCCFLAGS-unx = -I$(TOP)
TCCFLAGS-win = -B$(bindir) -I$(TOP)
-LTCC = $(libdir)/$(LIBPCC) $(LINK_LIBPCC)
endif
CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_PCC_STATIC -DPCC_PROFILE
LIBS_P = $(LIBS)
LDFLAGS_P = $(LDFLAGS)
DEF-i386 = -DPCC_TARGET_I386
DEF-i386-win32 = -DPCC_TARGET_I386 -DPCC_TARGET_PE
DEF-i386-OpenBSD = $(DEF-i386) -DTARGETOS_OpenBSD
DEF-x86_64 = -DPCC_TARGET_X86_64
DEF-x86_64-win32 = -DPCC_TARGET_X86_64 -DPCC_TARGET_PE
DEF-x86_64-osx = -DPCC_TARGET_X86_64 -DPCC_TARGET_MACHO
DEF-arm-fpa = -DPCC_TARGET_ARM
DEF-arm-fpa-ld = -DPCC_TARGET_ARM -DLDOUBLE_SIZE=12
DEF-arm-vfp = -DPCC_TARGET_ARM -DTCC_ARM_VFP
DEF-arm-eabi = -DPCC_TARGET_ARM -DTCC_ARM_VFP -DTCC_ARM_EABI
DEF-arm-eabihf = $(DEF-arm-eabi) -DTCC_ARM_HARDFLOAT
DEF-arm = $(DEF-arm-eabihf)
DEF-arm-NetBSD = $(DEF-arm-eabihf) -DTARGETOS_NetBSD
DEF-arm-wince = $(DEF-arm-eabihf) -DPCC_TARGET_PE
DEF-arm64 = -DPCC_TARGET_ARM64
DEF-arm64-osx = $(DEF-arm64) -DPCC_TARGET_MACHO
DEF-arm64-FreeBSD = $(DEF-arm64) -DTARGETOS_FreeBSD
DEF-arm64-NetBSD = $(DEF-arm64) -DTARGETOS_NetBSD
DEF-arm64-OpenBSD = $(DEF-arm64) -DTARGETOS_OpenBSD
DEF-arm64-win32 = $(DEF-arm64) -DPCC_TARGET_PE
DEF-riscv64 = -DPCC_TARGET_RISCV64
DEF-c67 = -DPCC_TARGET_C67 -w # disable warnigs
DEF-x86_64-FreeBSD = $(DEF-x86_64) -DTARGETOS_FreeBSD
DEF-x86_64-NetBSD = $(DEF-x86_64) -DTARGETOS_NetBSD
DEF-x86_64-OpenBSD = $(DEF-x86_64) -DTARGETOS_OpenBSD
ifeq ($(INCLUDED),no)
# --------------------------------------------------------------------------
# running top Makefile
PROGS = pcc$(EXESUF)
TCCLIBS = $(LIBPCCDEF) $(LIBPCC) $(LIBPCC1)
TCCDOCS = pcc.1 pcc-doc.html pcc-doc.info
all: $(PROGS) $(TCCLIBS) $(TCCDOCS)
# cross compiler targets to build
PCC_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm64-win32 arm-wince c67
PCC_X += riscv64 arm64-osx
# PCC_X += arm-fpa arm-fpa-ld arm-vfp arm-eabi
# cross libpcc1.a targets to build
LIBPCC1_X = $(filter-out c67,$(PCC_X))
PROGS_CROSS = $(foreach X,$(PCC_X),$X-pcc$(EXESUF))
LIBPCC1_CROSS = $(foreach X,$(LIBPCC1_X),$X-libpcc1.a)
# build cross compilers & libs
cross: $(LIBPCC1_CROSS) $(PROGS_CROSS)
# build specific cross compiler & lib
cross-%: %-pcc$(EXESUF) %-libpcc1.a ;
install: ; @$(MAKE) --no-print-directory install$(CFG)
install-strip: ; @$(MAKE) --no-print-directory install$(CFG) CONFIG_strip=yes
uninstall: ; @$(MAKE) --no-print-directory uninstall$(CFG)
ifdef CONFIG_cross
all : cross
endif
# --------------------------------------------
T = $(or $(CROSS_TARGET),$(NATIVE_TARGET))
X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
ifneq ($(T),$(NATIVE_TARGET))
$(if $(DEF-$T),,$(error error: unknown target: '$T'))
ifneq ($(CONFIG_WIN32),yes)
DEF-win = -DCONFIG_PCCDIR="\"$(tccdir)/win32\""
endif
# some default config for cross compilers
TRIPLET-i386 = i686-linux-gnu
TRIPLET-x86_64 = x86_64-linux-gnu
TRIPLET-arm = arm-linux-gnueabihf
TRIPLET-arm64 = aarch64-linux-gnu
TRIPLET-riscv64 = riscv64-linux-gnu
ifneq ($(TRIPLET-$T),)
# assume support files in "/usr/<triplet>"
ROOT-$T = /usr/$(TRIPLET-$T)
INC-$T = {B}/include:{R}/include
LIB-$T = {R}/lib:{B}
CRT-$T = {R}/lib
endif
DEFINES += $(DEF-$T)
DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"")
DEFINES += $(if $(CRT-$T),-DCONFIG_PCC_CRTPREFIX="\"$(CRT-$T)\"")
DEFINES += $(if $(LIB-$T),-DCONFIG_PCC_LIBPATHS="\"$(LIB-$T)\"")
DEFINES += $(if $(INC-$T),-DCONFIG_PCC_SYSINCLUDEPATHS="\"$(INC-$T)\"")
DEFINES += $(if $(ELF-$T),-DCONFIG_PCC_ELFINTERP="\"$(ELF-$T)\"")
DEFINES += $(DEF-$(or $(findstring win,$T),unx))
DEFINES += -DCONFIG_PCC_CROSSPREFIX="\"$X\""
endif
# include custom configuration (see make help)
-include config-extra.mak
# so one can use: make EXTRA-DEFS=...
DEFINES += $(EXTRA-DEFS)
# find config.h with 'out of tree' builds
DEFINES += -I$(TOP)
CORE_FILES = pcc.c pcctools.c libpcc.c pccpp.c pccgen.c pccdbg.c pccelf.c pccasm.c pccrun.c
CORE_FILES += pcc.h config.h libpcc.h pcctok.h
i386_FILES = $(CORE_FILES) i386-gen.c i386-link.c i386-asm.c i386-asm.h i386-tok.h
i386-win32_FILES = $(i386_FILES) pccpe.c
x86_64_FILES = $(CORE_FILES) x86_64-gen.c x86_64-link.c i386-asm.c x86_64-asm.h
x86_64-win32_FILES = $(x86_64_FILES) pccpe.c
x86_64-osx_FILES = $(x86_64_FILES) pccmacho.c
arm_FILES = $(CORE_FILES) arm-gen.c arm-link.c arm-asm.c arm-tok.h
arm-wince_FILES = $(arm_FILES) pccpe.c
arm-fpa_FILES = $(arm_FILES)
arm-fpa-ld_FILES = $(arm_FILES)
arm-vfp_FILES = $(arm_FILES)
arm-eabi_FILES = $(arm_FILES)
arm-eabihf_FILES = $(arm_FILES)
arm64_FILES = $(CORE_FILES) arm64-gen.c arm64-link.c arm64-asm.c arm64-tok.h
arm64-osx_FILES = $(arm64_FILES) pccmacho.c
arm64-win32_FILES = $(arm64_FILES) pccpe.c
c67_FILES = $(CORE_FILES) c67-gen.c c67-link.c pcccoff.c
riscv64_FILES = $(CORE_FILES) riscv64-gen.c riscv64-link.c riscv64-asm.c
TCCDEFS_H$(subst yes,,$(CONFIG_predefs)) = tccdefs_.h
# libpcc sources
LIBPCC_SRC = $(filter-out pcc.c pcctools.c,$(filter %.c,$($T_FILES)))
ifeq ($(ONE_SOURCE),yes)
LIBPCC_OBJ = $(X)libpcc.o
LIBPCC_INC = $($T_FILES)
PCC_FILES = $(X)pcc.o
$(X)pcc.o $(X)libpcc.o : $(TCCDEFS_H)
else
LIBPCC_OBJ = $(patsubst %.c,$(X)%.o,$(LIBPCC_SRC))
LIBPCC_INC = $(filter %.h %-gen.c %-link.c,$($T_FILES))
PCC_FILES = $(X)pcc.o $(LIBPCC_OBJ)
$(X)tccpp.o : $(TCCDEFS_H)
$(X)libpcc.o : DEFINES += -DONE_SOURCE=0
$(CROSS_TARGET)-pcc.o : DEFINES += -DONE_SOURCE=0
endif
# native pcc always made from pcc.o and libpcc.[so|a]
pcc.o : DEFINES += -DONE_SOURCE=0
GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)
ifneq ($(GITHASH),no)
GITHASH:=$(shell git log -1 --date=short --pretty='format:%cd $(GITHASH)@%h')
GITMODF:=$(shell git diff --quiet || echo '*')
DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)$(GITMODF)\""
endif
ifeq ($(CONFIG_debug),yes)
CFLAGS += -g
LDFLAGS += -g
endif
# convert "include/pccdefs.h" to "tccdefs_.h"
%_.h : include/%.h c2str.exe
$S./c2str.exe $< $@
c2str.exe : conftest.c
$S$(CC) -DC2STR $< -o $@
# target specific object rule
$(X)%.o : %.c $(LIBPCC_INC)
$S$(CC) -o $@ -c $< $(addsuffix ,$(DEFINES) $(CFLAGS))
# additional dependencies
$(X)pcc.o : pcctools.c
$(X)pcc.o : DEFINES += $(DEF_GITHASH)
# Host Paze C Compiler
pcc$(EXESUF): pcc.o $(LIBPCC)
$S$(CC) -o $@ $^ $(addsuffix ,$(LIBS) $(LDFLAGS) $(LINK_LIBPCC))
# Cross Paze C Compilers
# (the TCCDEFS_H dependency is only necessary for parallel makes,
# ala 'make -j x86_64-pcc i386-pcc pcc', which would create multiple
# c2str.exe and tccdefs_.h files in parallel, leading to access errors.
# This forces it to be made only once. Make normally tracks multiple paths
# to the same goals and only remakes it once, but that doesn't work over
# sub-makes like in this target)
%-pcc$(EXESUF): $(TCCDEFS_H) FORCE
@$(MAKE) --no-print-directory $@ CROSS_TARGET=$* ONE_SOURCE=$(or $(ONE_SOURCE),yes)
$(CROSS_TARGET)-pcc$(EXESUF): $(PCC_FILES)
$S$(CC) -o $@ $^ $(LIBS) $(LDFLAGS)
# profiling version
pcc_p$(EXESUF): $($T_FILES)
$S$(CC) -o $@ $< $(DEFINES) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
# static libpcc library
libpcc.a: $(LIBPCC_OBJ)
$S$(AR) rcs $@ $^
ifeq ($(CC_NAME)-$(ARCH),clang-x86_64)
# avoid 32-bit relocations in libpcc.a for its usage with pcc -run
libpcc.a: override CFLAGS += -fPIC
endif
# dynamic libpcc library
libpcc.so: $(LIBPCC_OBJ)
$S$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LIBS) $(LDFLAGS)
libpcc.so: override CFLAGS += -fPIC
libpcc.so: override LDFLAGS += -fPIC
# OSX dynamic libpcc library
libpcc.dylib: $(LIBPCC_OBJ)
$S$(CC) -dynamiclib $(DYLIBVER) -install_name @rpath/$@ -o $@ $^ $(LDFLAGS)
# OSX libpcc.dylib (without rpath/ prefix)
libpcc.osx: $(LIBPCC_OBJ)
$S$(CC) -shared -install_name libpcc.dylib -o libpcc.dylib $^ $(LDFLAGS)
# windows dynamic libpcc library
libpcc.dll : $(LIBPCC_OBJ)
$S$(CC) -shared -o $@ $^ $(LDFLAGS)
libpcc.dll : DEFINES += -DLIBPCC_AS_DLL
# import file for windows libpcc.dll
libpcc.def : libpcc.dll pcc$(EXESUF)
$S$(XTCC) -impdef $< -o $@
XTCC ?= ./pcc$(EXESUF)
# PazeCC runtime libraries
libpcc1.a : pcc$(EXESUF) FORCE
@$(MAKE) -C lib
# Cross libpcc1.a
%-libpcc1.a : %-pcc$(EXESUF) FORCE
@$(MAKE) -C lib CROSS_TARGET=$*
.PRECIOUS: %-libpcc1.a
FORCE:
# WHICH = which $1 2>/dev/null
# some versions of gnu-make do not recognize 'command' as a shell builtin
WHICH = sh -c 'command -v $1'
run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2,@echo "(skipping $@ - no $1)")
S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
# --------------------------------------------------------------------------
# documentation and man page
pcc-doc.html: pcc-doc.texi
$(call run-if,makeinfo,--no-split --html --number-sections -o $@ $<)
pcc-doc.info: pcc-doc.texi
$(call run-if,makeinfo,$< || true)
pcc.1 : pcc-doc.pod
$(call run-if,pod2man,--section=1 --center="Paze C Compiler" \
--release="$(VERSION)" $< >$@)
%.pod : %.texi
$(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@)
doc : $(TCCDOCS)
# --------------------------------------------------------------------------
# install
INSTALL = install -m 644
INSTALLBIN = install -m 755 $(STRIP_$(CONFIG_strip))
STRIP_yes = -s
LIBPCC1_W = $(filter %-win32-libpcc1.a %-wince-libpcc1.a,$(LIBPCC1_CROSS))
LIBPCC1_U = $(filter-out $(LIBPCC1_W),$(wildcard *-libpcc1.a))
IB = $(if $1,$(IM) mkdir -p $2 && $(INSTALLBIN) $1 $2)
IBw = $(call IB,$(wildcard $1),$2)
IF = $(if $1,$(IM) mkdir -p $2 && $(INSTALL) $1 $2)
IFw = $(call IF,$(wildcard $1),$2)
IR = $(IM) mkdir -p $2 && cp -r $1/. $2
IM = @echo "-> $2 : $1" ;
BINCHECK = $(if $(wildcard $(PROGS) *-pcc$(EXESUF)),,@echo "Makefile: nothing found to install" && exit 1)
EXTRA_O = runmain.o bt-exe.o bt-dll.o bt-log.o bcheck.o
# install progs & libs
install-unx:
$(call BINCHECK)
$(call IBw,$(PROGS) *-pcc,"$(bindir)")
$(call IFw,$(LIBPCC1) $(EXTRA_O) $(LIBPCC1_U),"$(tccdir)")
$(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/pcclib.h,"$(tccdir)/include")
$(call $(if $(findstring .so,$(LIBPCC)),IBw,IFw),$(LIBPCC),"$(libdir)")
$(call IF,$(TOPSRC)/libpcc.h,"$(includedir)")
$(call IFw,pcc.1,"$(mandir)/man1")
$(call IFw,pcc-doc.info,"$(infodir)")
$(call IFw,pcc-doc.html,"$(docdir)")
ifneq "$(wildcard $(LIBPCC1_W))" ""
$(call IFw,$(TOPSRC)/win32/lib/*.def $(LIBPCC1_W),"$(tccdir)/win32/lib")
$(call IR,$(TOPSRC)/win32/include,"$(tccdir)/win32/include")
$(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/pcclib.h,"$(tccdir)/win32/include")
endif
# uninstall
uninstall-unx:
@rm -fv $(addprefix "$(bindir)/",$(PROGS) $(PROGS_CROSS))
@rm -fv $(addprefix "$(libdir)/", libpcc*.a libpcc*.so libpcc.dylib)
@rm -fv $(addprefix "$(includedir)/", libpcc.h)
@rm -fv "$(mandir)/man1/pcc.1" "$(infodir)/pcc-doc.info"
@rm -fv "$(docdir)/pcc-doc.html"
@rm -frv "$(tccdir)"
# install progs & libs on windows
install-win:
$(call BINCHECK)
$(call IBw,$(PROGS) *-pcc.exe libpcc.dll,"$(bindir)")
$(call IF,$(TOPSRC)/win32/lib/*.def,"$(tccdir)/lib")
$(call IFw,libpcc1.a $(EXTRA_O) $(LIBPCC1_W),"$(tccdir)/lib")
$(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/pcclib.h,"$(tccdir)/include")
$(call IR,$(TOPSRC)/win32/include,"$(tccdir)/include")
$(call IR,$(TOPSRC)/win32/examples,"$(tccdir)/examples")
$(call IF,$(TOPSRC)/tests/libpcc_test.c,"$(tccdir)/examples")
$(call IFw,$(TOPSRC)/libpcc.h libpcc.def libpcc.a,"$(libdir)")
$(call IFw,$(TOPSRC)/win32/pcc-win32.txt pcc-doc.html,"$(docdir)")
ifneq "$(wildcard $(LIBPCC1_U))" ""
$(call IFw,$(LIBPCC1_U),"$(tccdir)/lib")
$(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/pcclib.h,"$(tccdir)/lib/include")
endif
# uninstall on windows
uninstall-win:
@rm -fv $(foreach P,libpcc*.dll $(PROGS) *-pcc.exe,"$(bindir)"/$P)
@rm -fr $(foreach P,doc examples include lib libpcc,"$(tccdir)"/$P/*)
@rm -frv $(foreach P,doc examples include lib libpcc,"$(tccdir)"/$P)
# the msys-git shell works to configure && make except it does not have install
ifeq ($(OS),Windows_NT)
ifeq ($(shell $(call WHICH,install) || echo no),no)
INSTALL = cp
INSTALLBIN = cp
endif
endif
# --------------------------------------------------------------------------
# other stuff
TAGFILES = *.[ch] include/*.h lib/*.[chS]
tags : ; ctags $(TAGFILES)
# cannot have both tags and TAGS on windows
ETAGS : ; etags $(TAGFILES)
# create release tarball from *current* git branch (including pcc-doc.html
# and converting two files to CRLF)
PCC-VERSION = pcc-$(VERSION)
PCC-VERSION = tinycc-mob-$(shell git rev-parse --short=7 HEAD)
tar: pcc-doc.html
mkdir -p $(PCC-VERSION)
( cd $(PCC-VERSION) && git --git-dir ../.git checkout -f )
cp pcc-doc.html $(PCC-VERSION)
for f in pcc-win32.txt build-pcc.bat ; do \
cat win32/$$f | sed 's,\(.*\),\1\r,g' > $(PCC-VERSION)/win32/$$f ; \
done
tar cjf $(PCC-VERSION).tar.bz2 $(PCC-VERSION)
rm -rf $(PCC-VERSION)
git reset
config.mak:
$(if $(wildcard $@),,@echo "Please run ./configure." && exit 1)
# run all tests
test:
@$(MAKE) -C tests
# run test(s) from tests2 subdir (see make help)
tests2.%:
@$(MAKE) -C tests/tests2 $@
# run test(s) from testspp subdir (see make help)
testspp.%:
@$(MAKE) -C tests/pp $@
# run tests with code coverage
tcov-tes% : pcc_c$(EXESUF)
@rm -f $<.tcov
@$(MAKE) --no-print-directory PCC_LOCAL=$(CURDIR)/$< tes$*
pcc_c$(EXESUF): $($T_FILES)
$S$(PCC) pcc.c -o $@ -ftest-coverage $(DEFINES) $(LIBS)
# run tests with sanitize option
sani-tes% : pcc_s$(EXESUF)
@$(MAKE) --no-print-directory PCC_LOCAL=$(CURDIR)/$< tes$*
pcc_s$(EXESUF): $($T_FILES)
$S$(CC) pcc.c -o $@ -fsanitize=address,undefined $(DEFINES) $(CFLAGS) $(LDFLAGS) $(LIBS)
# test the installed pcc instead
test-install: $(TCCDEFS_H)
@$(MAKE) -C tests TESTINSTALL=yes #_all
clean:
@rm -f pcc *-pcc pcc_p pcc_c pcc_s
@rm -f tags ETAGS *.o *.a *.so* *.out *.log lib*.def *.exe *.dll
@rm -f a.out *.dylib *_.h *.pod *.tcov
@$(MAKE) -s -C lib $@
@$(MAKE) -s -C tests $@
distclean: clean
@rm -vf config.h config.mak config.texi
@rm -vf $(TCCDOCS)
.PHONY: all clean test tar tags ETAGS doc distclean install uninstall FORCE
help:
@echo "make"
@echo " build native compiler (from separate objects)"
@echo "make ONE_SOURCE=no/yes SILENT=no/yes"
@echo " force building from separate/one object(s), less/more silently"
@echo "make cross-TARGET"
@echo " build one specific cross compiler for 'TARGET'. Currently supported:"
@echo " $(wordlist 1,8,$(PCC_X))"
@echo " $(wordlist 9,99,$(PCC_X))"
@echo "make cross"
@echo " build all cross compilers"
@echo "make test"
@echo " run all tests"
@echo "make tests2.all / make tests2.37 / make tests2.37+"
@echo " run all/single test(s) from tests2, optionally update .expect"
@echo "make testspp.all / make testspp.17"
@echo " run all/single test(s) from tests/pp"
@echo "make tcov-test / tcov-tests2.37 / tcov-testspp.17"
@echo " run tests as above with code coverage. After test(s) see pcc_c$(EXESUF).tcov"
@echo "make sani-test / sani-tests2.37 / sani-testspp.17"
@echo " run tests as above with sanitize option."
@echo "make test-install"
@echo " run tests with the installed pcc"
@echo "Other supported make targets:"
@echo " install install-strip uninstall doc [dist]clean tags ETAGS tar help"
@echo "Custom configuration:"
@echo " The makefile includes a file 'config-extra.mak' if it is present."
@echo " This file may contain some custom configuration. For example to"
@echo " configure the search paths for a cross-compiler, assuming the"
@echo " support files in /usr/i686-linux-gnu:"
@echo " ROOT-i386 = /usr/i686-linux-gnu"
@echo " CRT-i386 = {R}/lib"
@echo " LIB-i386 = {B}:{R}/lib"
@echo " INC-i386 = {B}/include:{R}/include (*)"
@echo " DEF-i386 += -D__linux__"
@echo " Or also, for the cross platform files in /usr/<triplet>"
@echo " TRIPLET-i386 = i686-linux-gnu"
@echo " (*) pcc replaces {B} by 'tccdir' and {R} by 'CONFIG_SYSROOT'"
# --------------------------------------------------------------------------
endif # ($(INCLUDED),no)