Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed

# -------------------------------------------------------------------------
# This is the Makefile.def I currently use on my own Debian systems.  It
# provides cross build for Linux 32 bit, Windows, optional Valgrind testing
# and PPC/M68K cross compiling/emulation to test on a big endian host:
# any additionally needed flags

CFLAGS_COMMON = -g -O3 -fomit-frame-pointer -Wall -Wundef -Wextra -Werror -pedantic -Wshift-count-overflow
CFLAGS_C = -Wstrict-prototypes
CFLAGS_GCC_EXTRA = -Wshift-overflow=2
CFLAGS_CLANG_EXTRA = -Wshift-overflow
CFLAGS_CLANGPP_EXTRA = -Wshift-overflow -Wno-deprecated -Wno-keyword-macro
CFLAGS_TCC_EXTRA = -Wshift-overflow=2
# leave this out by default, because it prohibits use of long long and long double data types:
#CFLAGS_CVER = -ansi -std=c89
#CFLAGS_CPPVER = -ansi -std=c++98
CFLAGS_GCC = $(CFLAGS_COMMON) $(CFLAGS_C) $(CFLAGS_GCC_EXTRA) $(CFLAGS_CVER)
CFLAGS_CLANG = $(CFLAGS_COMMON) $(CFLAGS_C) $(CFLAGS_CLANG_EXTRA) $(CFLAGS_CVER)
CFLAGS_GPP = $(CFLAGS_COMMON) $(CFLAGS_GCC_EXTRA) $(CFLAGS_CPPVER)
CFLAGS_CLANGPP = $(CFLAGS_COMMON) $(CFLAGS_CLANGPP_EXTRA) $(CFLAGS_CPPVER)
CFLAGS_TCC = $(CFLAGS_COMMON) $(CFLAGS_C) $(CFLAGS_TCC_EXTRA) $(CFLAGS_CVER)

CFLAGS_ASAN = -fsanitize=address -static-libasan
LDFLAGS_ASAN = $(CFLAGS_ASAN)

# ...for host-side build tools:

OBJDIR =
CC = gcc
CFLAGS = $(CFLAGS_GCC)
HOST_OBJEXTENSION = .o
LDFLAGS =
LD = $(CC)
HOST_EXEXTENSION =

# Here I select the target.  Object directories have to exist *before* build:

TARG_OBJDIR ?= i686-linux/
#TARG_OBJDIR ?= ppc-linux/
#TARG_OBJDIR ?= m68k-linux/
#TARG_OBJDIR ?= i686-w32/

# ...for the actual build targets.  This is the simple case for no cross-build:

ifeq ($(TARG_OBJDIR),i686-linux/)
 TARG_CC = gcc
 TARG_CFLAGS = $(CFLAGS_GCC)
 #TARG_CC = clang
 #TARG_CFLAGS = $(CFLAGS_CLANG)
 #TARG_CC = g++
 #TARG_CFLAGS = $(CFLAGS_GPP)
 #TARG_CC = clang++
 #TARG_CFLAGS = $(CFLAGS_CLANGPP)
 #TARG_CC = tcc
 #TARG_CFLAGS = $(CFLAGS_TCC)
 TARG_OBJEXTENSION = $(HOST_OBJEXTENSION)
 TARG_LD = $(TARG_CC)
 TARG_LDFLAGS = $(LDFLAGS)
 TARG_EXEXTENSION = $(HOST_EXEXTENSION)
 ifeq ($(VALGRIND),1)
  TARG_RUNCMD = "valgrind --leak-check=full"
 endif
endif

# ASAN requires compilation & linking with different flags:

ifeq ($(TARG_OBJDIR),i686-linux-asan/)
 TARG_CC = gcc
 TARG_CFLAGS = $(CFLAGS_ASAN) $(CFLAGS_GCC)
 TARG_OBJEXTENSION = .o
 TARG_LD = $(TARG_CC)
 TARG_LDFLAGS = $(LDFLAGS_ASAN) $(LDFLAGS)
 TARG_EXEXTENSION =
endif

# PPC build to test big endian
# install qemu-system-ppc, qemu-user-static, gcc-powerpc(64)-linux-gnu, libc6-dev-ppc64-powerpc-cross

ifeq ($(TARG_OBJDIR),ppc-linux/)
 TARG_CC = powerpc-linux-gnu-gcc
 TARG_CFLAGS = $(CFLAGS_GCC)
 TARG_OBJEXTENSION = .o
 TARG_LD = $(TARG_CC)
 TARG_LDFLAGS = $(LDFLAGS) -static
 TARG_EXEXTENSION =
 TARG_RUNCMD = qemu-ppc-static
endif

# Similar for M68K

ifeq ($(TARG_OBJDIR),m68k-linux/)
 TARG_CC = m68k-linux-gnu-gcc
 TARG_CFLAGS = $(CFLAGS_GCC)
 TARG_OBJEXTENSION = .o
 TARG_LD = $(TARG_CC)
 TARG_LDFLAGS = $(LDFLAGS) -static
 TARG_EXEXTENSION =
 TARG_RUNCMD = qemu-m68k-static
endif

# cross Build with MinGW32

ifeq ($(TARG_OBJDIR),i686-w32/)
 TARG_CC = i686-w64-mingw32-gcc
 TARG_CFLAGS = $(CFLAGS_GCC)
 TARG_OBJEXTENSION = .o
 TARG_LD = $(TARG_CC)
 TARG_LDFLAGS = $(LDFLAGS)
 TARG_EXEXTENSION = .exe
 TARG_RUNCMD = wine
 TEX2DOC_FLAGS=-codepage 1252
endif

# -------------------------------------------------------------------------
# directories where binaries, includes, and manpages should go during
# installation

BINDIR = /usr/local/bin
INCDIR = /usr/local/include/asl
MANDIR = /usr/local/man
LIBDIR =
DOCDIR = /usr/local/doc/asl