# Copyright (C) 2001-2008, The Perl Foundation.

TARGET_NAME = sqlite3s

C_FILES = sqlite3s.c
O_FILES = sqlite3s.o

BUILDPREFIX     =
PARROT_ROOT     = @build_dir@
PREFIX          = @prefix@
EXEC_PREFIX     = @exec_prefix@
DESTDIR         =
BIN_DIR         = @bin_dir@
LIB_DIR         = @lib_dir@
INCLUDE_DIR     = @include_dir@
DOC_DIR         = @doc_dir@
INC_DIR         = @inc@
RM_F             = @rm_f@
RM_RF            = @rm_rf@
AR_CR            = @ar@ @ar_flags@
RANLIB           = @ranlib@
PERL             = @perl@
CP               = @cp@
CHMOD            = @chmod@
TOUCH            = @touch@
YACC             = @yacc@
LEX              = @lex@
MKPATH           = @mkpath@
AS               = @as@
CC               = @cc@
CC_INC           = @cc_inc@
C_LIBS           = @libs@
CC_SHARED        = @cc_shared@
CFLAGS           = $(CC_INC) @ccflags@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@ $(CC_SHARED)
LINK_DYNAMIC     = @link_dynamic@
LINK             = @link@
LINKFLAGS        = @linkflags@ @link_debug@ @ld_debug@
LD               = @ld@
LDFLAGS          = @ldflags@ @ld_debug@
#IF(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@
O                = @o@
EXE              = @exe@
SHARE_EXT        = @share_ext@
LOAD_EXT         = @load_ext@
A                = @a@
LD_SHARE_FLAGS   = @ld_share_flags@
LD_LOAD_FLAGS    = @ld_load_flags@
DYNEXT_DIR          = runtime/parrot/dynext

@make_set_make@
MAKE = @make_c@
SHARED_LIB = $(TARGET_NAME)$(SHARE_EXT)

.SUFFIXES : .c .h .pmc .dump $(O) .str .pir .pbc

# Passing an empty argument in @ARGV to cc_flags.pl to indicate where extra -Is
# (etc) should go. Otherwise it will insert them after the first space, which
# makes life go horribly wrong if $(CC) contains spaces but can't have -I
# arguments (etc) injected in the middle.
# There is probably a better way to do this, but I can't work it out right now.
.c$(O) :
	@$(CC) "" $(CFLAGS) -I$(@D) @cc_o_out@$@ -c $<

#PERL6=../../perl6
PERL6=../../parrot ../../languages/perl6/perl6.pbc

all :
	cd ../..; make perl6
	cd ../../compilers/ncigen; $(PERL6) ../../ext/SQLite3/gen_sqlite3.pl /usr/include/sqlite3.h > ../../ext/SQLite3/genSQLite3.pir

test:
	$(RM_F) test.db t/test.db
	PERL6LIB=../../languages/perl6 $(PERL6) t/test.p6

$(SHARED_LIB) : $(C_FILES)
	$(MKPATH) @blib_dir@
	$(CC) $(CC_INC) $(LD_SHARE_FLAGS) $(LDFLAGS) @ld_out@$@ \
#IF(cygwin):		-Wl,--out-implib=lib$(TARGET_NAME).dll.a \
#IF(win32 and cc==gcc):		-Wl,--out-implib=lib$(TARGET_NAME).lib \
		$(C_FILES) $(C_LIBS) $(ICU_SHARED)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2


clean : 
	$(RM_F) $(SHARED_LIB) @blib_dir@ $(O_FILES) Makefile
#IF(cygwin):	$(RM_F) lib$(TARGET_NAME).dll.a
#IF(win32 and cc==gcc):	$(RM_F) lib$(TARGET_NAME).lib
