# 
# Default target
#

default:: libs

# Get the variables definition
include $(ZK_ROOT)/makefiles/Makefile.vars

# Override and define new variables
ZK_PUBLIBS := libcrypto.a

TARGET=gcc
ifneq (,$(findstring linux,$(ZK_ARCH)))
  TARGET := linux-elf
endif

# Debug and Profile configuration
CONFIG :=
ifeq ($(ZK_CONFIG),Debug)
  CONFIG := debug
endif

ifeq ($(ZK_CONFIG),Profile)
  CONFIG := profile
endif

ifeq ($(ZK_CONFIG),Insure)
  CONFIG := insure
endif

# Get the target rules
include $(ZK_ROOT)/makefiles/Makefile.targs

# Add new targets or complement default target using :: rules
$(ZK_FULLLIBS): makefile.$(ZK_ARCH)$(ZK_CONFIG) builddirs
	make -f makefile.$(ZK_ARCH)$(ZK_CONFIG) headers
	make -f makefile.$(ZK_ARCH)$(ZK_CONFIG) $(addprefix $(ZK_BUILDDIR_PUBLIB)/,$(ZK_PUBLIBS))

clean:: makefile.$(ZK_ARCH)$(ZK_CONFIG)
	-make -f makefile.$(ZK_ARCH)$(ZK_CONFIG) clean
	-rm -f makefile.$(ZK_ARCH)$(ZK_CONFIG)
	-rm -rf $(ZK_CWDDIR)/include/openssl

makefile.$(ZK_ARCH)$(ZK_CONFIG): makefile
	@if [ ! -d "$(ZK_CWDDIR)/include/openssl" ]; then mkdir -p "$(ZK_CWDDIR)/include/openssl"; fi
	-rm -f Makefile.ssl crypto/opensslconf.h
	sh config no-symlinks
	make -f Makefile.ssl files
	perl util/mk1mf.pl INC=$(ZK_CWDDIR)/include TMP=$(ZK_BUILDDIR_PROJ) OUT=$(ZK_BUILDDIR_PUBLIB) no-idea no-rc5 $(CONFIG) $(TARGET) > $@

depend:: makefile.$(ZK_ARCH)$(ZK_CONFIG) builddirs
	make -f makefile.$(ZK_ARCH)$(ZK_CONFIG) headers

# Specify dependencies

