# Example of a typical Makefile template for autosetup

# Tools. CC is standard. The rest are via cc-check-tools
CC = @CC@
RANLIB = @RANLIB@
AR = @AR@
STRIP = @STRIP@

# FLAGS/LIBS
CFLAGS += @CFLAGS@
LDFLAGS += @LDFLAGS@
LDLIBS += @LIBS@
#LDLIBS += -lsqlite3 -lz
LDFLAGS_MODULE_LOADER += @LDFLAGS_MODULE_LOADER@

# Install destination
prefix = @prefix@
exec_prefix = @exec_prefix@
DESTDIR = $(prefix)

CONFIG.MAKE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
#TOP_SRCDIR_ABS := $(dir $(realpath $(CONFIG.MAKE)))
TOP_SRCDIR_REL := $(patsubst %/,%,$(dir $(CONFIG.MAKE)))
TOP_SRCDIR_ABS := $(realpath $(TOP_SRCDIR_REL))
#$(error TOP_SRCDIR_REL=$(TOP_SRCDIR_REL))

SRC.DIR := $(TOP_SRCDIR_REL)/src

# Project-specific CFLAGS
TOP_INCDIR := $(TOP_SRCDIR_REL)/include
COMPAT_DIR := $(TOP_SRCDIR_REL)/compat
#CPPFLAGS += -D_GNU_SOURCE -Wall -Werror -I. -I$(TOP_INCDIR)
CPPFLAGS += -I. -I$(TOP_INCDIR) -I$(COMPAT_DIR)/javavm/export -I$(COMPAT_DIR)/tcl-8.6/generic -I$(SRC.DIR)
ifneq (,$(wildcard $(HOME)/include/*))
  # This is admittedly primarily for my own sake!
  CPPFLAGS += -I$(HOME)/include
endif

ifeq (,$(filter tcc,$(CC)))
  # Assume gcc-compatible compilation flags...
  CFLAGS += -Wall -Werror -Wsign-compare -pedantic
#??? -fno-strict-aliasing
  ifeq (1,@HAVE_C99_INT@)
    CFLAGS += -std=c99
  else
    CFLAGS += -std=c89
  #  ifeq (1,@HAVE_LONG_LONG@)
     # Avoid a -Werror/-Wall/-pedantic failure in sqlite3.h:
      CFLAGS += -Wno-long-long
  #  endif
  endif
endif
# /tcc

CLEAN_FILES += *.o lib*.a *.so

ShakeNMake.QUIET ?= @BUILD_QUIETLY@
