.gitignore

ifdef TARGET
TARGET = @(TARGET)
else
TARGET = @(TUP_PLATFORM)
endif

ifdef CC
CC = @(CC)
else
CC = gcc
endif

ifeq (@(TUP_DEBUG),y)
CFLAGS += -g
else
CFLAGS += -Os
endif

ifeq (@(TUP_SANITIZE),y)
CFLAGS += -fsanitize=address
LDFLAGS += -lasan

CFLAGS += -fsanitize=undefined
LDFLAGS += -lubsan
endif

ifdef AR
AR = @(AR)
else
AR = ar
endif

CFLAGS += -W
CFLAGS += -Wall
ifeq (@(TUP_WERROR),y)
CFLAGS += -Werror
endif
CFLAGS += -Wbad-function-cast
CFLAGS += -Wcast-align
CFLAGS += -Wcast-qual
CFLAGS += -Wchar-subscripts
CFLAGS += -Wmissing-prototypes
CFLAGS += -Wnested-externs
CFLAGS += -Wpointer-arith
CFLAGS += -Wredundant-decls
CFLAGS += -Wshadow
CFLAGS += -Wstrict-prototypes
CFLAGS += -Wwrite-strings
CFLAGS += -Wswitch-enum
CFLAGS += -fno-common
CFLAGS += -I$(TUP_CWD)/src

ifeq (@(TUP_32_BIT),y)
CFLAGS += -m32
LDFLAGS += -m32
endif

!cc = |> ^ CC %f^ $(CC) -c %f -o %o $(CFLAGS) $(CFLAGS_%f) |> %B.o
!ld = |> ^ LINK %o^ $(CC) %f -o %o $(LDFLAGS) $(LDFLAGS_%o) |>
!ar = |> ^ AR %o^ $(AR) crs %o %f |>
!dot = |> ^ DOT %f^ dot -Efontname="Vernada, serif" -Nfontname="Vernada, serif" -Efontsize=10 -Nfontsize=10 -Tpng %f > %o |>
!cp = |> ^ CP %f -> %o^ cp %f %o |>

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

ifeq ($(TUP_SERVER),fuse)
CFLAGS += -D_FILE_OFFSET_BITS=64
export PKG_CONFIG_PATH
endif

ifeq ($(TUP_SERVER),ldpreload)
FPIC = -fpic
SHARED = -shared

LDFLAGS_tup-ldpreload.so += $(FPIC)
LDFLAGS_tup-ldpreload.so += $(SHARED)
LDFLAGS_tup-ldpreload.so += -ldl
endif
