#
# Copyright (C) 2006 Ludovic Jacomme (ludovic.jacomme@gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
TARGET = pspssh
PSPSDK = $(shell psp-config --pspsdk-path)
PSPBIN = $(shell psp-config --psp-prefix)/bin
SDL_CONFIG = $(PSPBIN)/sdl-config
OBJS = \
./libtomcrypt/src/ciphers/aes/aes_enc.o \
./libtomcrypt/src/ciphers/aes/aes.o \
./libtomcrypt/src/ciphers/safer/safer.o \
./libtomcrypt/src/ciphers/safer/safer_tab.o \
./libtomcrypt/src/ciphers/safer/saferp.o \
./libtomcrypt/src/ciphers/twofish/twofish.o \
./libtomcrypt/src/ciphers/anubis.o \
./libtomcrypt/src/ciphers/blowfish.o \
./libtomcrypt/src/ciphers/cast5.o \
./libtomcrypt/src/ciphers/des.o \
./libtomcrypt/src/ciphers/khazad.o \
./libtomcrypt/src/ciphers/noekeon.o \
./libtomcrypt/src/ciphers/rc2.o \
./libtomcrypt/src/ciphers/rc5.o \
./libtomcrypt/src/ciphers/rc6.o \
./libtomcrypt/src/ciphers/skipjack.o \
./libtomcrypt/src/ciphers/xtea.o \
./libtomcrypt/src/encauth/ccm/ccm_memory.o \
./libtomcrypt/src/encauth/ccm/ccm_test.o \
./libtomcrypt/src/encauth/eax/eax_addheader.o \
./libtomcrypt/src/encauth/eax/eax_decrypt.o \
./libtomcrypt/src/encauth/eax/eax_decrypt_verify_memory.o \
./libtomcrypt/src/encauth/eax/eax_done.o \
./libtomcrypt/src/encauth/eax/eax_encrypt.o \
./libtomcrypt/src/encauth/eax/eax_encrypt_authenticate_memory.o \
./libtomcrypt/src/encauth/eax/eax_init.o \
./libtomcrypt/src/encauth/eax/eax_test.o \
./libtomcrypt/src/encauth/gcm/gcm_add_aad.o \
./libtomcrypt/src/encauth/gcm/gcm_add_iv.o \
./libtomcrypt/src/encauth/gcm/gcm_done.o \
./libtomcrypt/src/encauth/gcm/gcm_gf_mult.o \
./libtomcrypt/src/encauth/gcm/gcm_init.o \
./libtomcrypt/src/encauth/gcm/gcm_memory.o \
./libtomcrypt/src/encauth/gcm/gcm_process.o \
./libtomcrypt/src/encauth/gcm/gcm_reset.o \
./libtomcrypt/src/encauth/gcm/gcm_test.o \
./libtomcrypt/src/encauth/ocb/ocb_decrypt.o \
./libtomcrypt/src/encauth/ocb/ocb_decrypt_verify_memory.o \
./libtomcrypt/src/encauth/ocb/ocb_done_decrypt.o \
./libtomcrypt/src/encauth/ocb/ocb_done_encrypt.o \
./libtomcrypt/src/encauth/ocb/ocb_encrypt.o \
./libtomcrypt/src/encauth/ocb/ocb_encrypt_authenticate_memory.o \
./libtomcrypt/src/encauth/ocb/ocb_init.o \
./libtomcrypt/src/encauth/ocb/ocb_ntz.o \
./libtomcrypt/src/encauth/ocb/ocb_shift_xor.o \
./libtomcrypt/src/encauth/ocb/ocb_test.o \
./libtomcrypt/src/encauth/ocb/s_ocb_done.o \
./libtomcrypt/src/hashes/chc/chc.o \
./libtomcrypt/src/hashes/helper/hash_file.o \
./libtomcrypt/src/hashes/helper/hash_filehandle.o \
./libtomcrypt/src/hashes/helper/hash_memory.o \
./libtomcrypt/src/hashes/helper/hash_memory_multi.o \
./libtomcrypt/src/hashes/sha2/sha256.o \
./libtomcrypt/src/hashes/sha2/sha512.o \
./libtomcrypt/src/hashes/whirl/whirl.o \
./libtomcrypt/src/hashes/md2.o \
./libtomcrypt/src/hashes/md4.o \
./libtomcrypt/src/hashes/md5.o \
./libtomcrypt/src/hashes/rmd128.o \
./libtomcrypt/src/hashes/rmd160.o \
./libtomcrypt/src/hashes/sha1.o \
./libtomcrypt/src/hashes/tiger.o \
./libtomcrypt/src/mac/hmac/hmac_done.o \
./libtomcrypt/src/mac/hmac/hmac_file.o \
./libtomcrypt/src/mac/hmac/hmac_init.o \
./libtomcrypt/src/mac/hmac/hmac_memory.o \
./libtomcrypt/src/mac/hmac/hmac_memory_multi.o \
./libtomcrypt/src/mac/hmac/hmac_process.o \
./libtomcrypt/src/mac/hmac/hmac_test.o \
./libtomcrypt/src/mac/omac/omac_done.o \
./libtomcrypt/src/mac/omac/omac_file.o \
./libtomcrypt/src/mac/omac/omac_init.o \
./libtomcrypt/src/mac/omac/omac_memory.o \
./libtomcrypt/src/mac/omac/omac_memory_multi.o \
./libtomcrypt/src/mac/omac/omac_process.o \
./libtomcrypt/src/mac/omac/omac_test.o \
./libtomcrypt/src/mac/pelican/pelican.o \
./libtomcrypt/src/mac/pelican/pelican_memory.o \
./libtomcrypt/src/mac/pelican/pelican_test.o \
./libtomcrypt/src/mac/pmac/pmac_done.o \
./libtomcrypt/src/mac/pmac/pmac_file.o \
./libtomcrypt/src/mac/pmac/pmac_init.o \
./libtomcrypt/src/mac/pmac/pmac_memory.o \
./libtomcrypt/src/mac/pmac/pmac_memory_multi.o \
./libtomcrypt/src/mac/pmac/pmac_ntz.o \
./libtomcrypt/src/mac/pmac/pmac_process.o \
./libtomcrypt/src/mac/pmac/pmac_shift_xor.o \
./libtomcrypt/src/mac/pmac/pmac_test.o \
./libtomcrypt/src/misc/base64/base64_decode.o \
./libtomcrypt/src/misc/base64/base64_encode.o \
./libtomcrypt/src/misc/crypt/crypt.o \
./libtomcrypt/src/misc/crypt/crypt_argchk.o \
./libtomcrypt/src/misc/crypt/crypt_cipher_descriptor.o \
./libtomcrypt/src/misc/crypt/crypt_cipher_is_valid.o \
./libtomcrypt/src/misc/crypt/crypt_find_cipher.o \
./libtomcrypt/src/misc/crypt/crypt_find_cipher_any.o \
./libtomcrypt/src/misc/crypt/crypt_find_cipher_id.o \
./libtomcrypt/src/misc/crypt/crypt_find_hash.o \
./libtomcrypt/src/misc/crypt/crypt_find_hash_any.o \
./libtomcrypt/src/misc/crypt/crypt_find_hash_id.o \
./libtomcrypt/src/misc/crypt/crypt_find_prng.o \
./libtomcrypt/src/misc/crypt/crypt_hash_descriptor.o \
./libtomcrypt/src/misc/crypt/crypt_hash_is_valid.o \
./libtomcrypt/src/misc/crypt/crypt_prng_descriptor.o \
./libtomcrypt/src/misc/crypt/crypt_prng_is_valid.o \
./libtomcrypt/src/misc/crypt/crypt_register_cipher.o \
./libtomcrypt/src/misc/crypt/crypt_register_hash.o \
./libtomcrypt/src/misc/crypt/crypt_register_prng.o \
./libtomcrypt/src/misc/crypt/crypt_unregister_cipher.o \
./libtomcrypt/src/misc/crypt/crypt_unregister_hash.o \
./libtomcrypt/src/misc/crypt/crypt_unregister_prng.o \
./libtomcrypt/src/misc/mpi/is_prime.o \
./libtomcrypt/src/misc/mpi/mpi_to_ltc_error.o \
./libtomcrypt/src/misc/mpi/rand_prime.o \
./libtomcrypt/src/misc/pkcs5/pkcs_5_1.o \
./libtomcrypt/src/misc/pkcs5/pkcs_5_2.o \
./libtomcrypt/src/misc/burn_stack.o \
./libtomcrypt/src/misc/error_to_string.o \
./libtomcrypt/src/misc/zeromem.o \
./libtomcrypt/src/modes/cbc/cbc_decrypt.o \
./libtomcrypt/src/modes/cbc/cbc_done.o \
./libtomcrypt/src/modes/cbc/cbc_encrypt.o \
./libtomcrypt/src/modes/cbc/cbc_getiv.o \
./libtomcrypt/src/modes/cbc/cbc_setiv.o \
./libtomcrypt/src/modes/cbc/cbc_start.o \
./libtomcrypt/src/modes/cfb/cfb_decrypt.o \
./libtomcrypt/src/modes/cfb/cfb_done.o \
./libtomcrypt/src/modes/cfb/cfb_encrypt.o \
./libtomcrypt/src/modes/cfb/cfb_getiv.o \
./libtomcrypt/src/modes/cfb/cfb_setiv.o \
./libtomcrypt/src/modes/cfb/cfb_start.o \
./libtomcrypt/src/modes/ctr/ctr_decrypt.o \
./libtomcrypt/src/modes/ctr/ctr_done.o \
./libtomcrypt/src/modes/ctr/ctr_encrypt.o \
./libtomcrypt/src/modes/ctr/ctr_getiv.o \
./libtomcrypt/src/modes/ctr/ctr_setiv.o \
./libtomcrypt/src/modes/ctr/ctr_start.o \
./libtomcrypt/src/modes/ecb/ecb_decrypt.o \
./libtomcrypt/src/modes/ecb/ecb_done.o \
./libtomcrypt/src/modes/ecb/ecb_encrypt.o \
./libtomcrypt/src/modes/ecb/ecb_start.o \
./libtomcrypt/src/modes/ofb/ofb_decrypt.o \
./libtomcrypt/src/modes/ofb/ofb_done.o \
./libtomcrypt/src/modes/ofb/ofb_encrypt.o \
./libtomcrypt/src/modes/ofb/ofb_getiv.o \
./libtomcrypt/src/modes/ofb/ofb_setiv.o \
./libtomcrypt/src/modes/ofb/ofb_start.o \
./libtommath/bncore.o \
./libtommath/bn_mp_init.o \
./libtommath/bn_mp_clear.o \
./libtommath/bn_mp_exch.o \
./libtommath/bn_mp_grow.o \
./libtommath/bn_mp_shrink.o \
./libtommath/bn_mp_clamp.o \
./libtommath/bn_mp_zero.o \
./libtommath/bn_mp_set.o \
./libtommath/bn_mp_set_int.o \
./libtommath/bn_mp_init_size.o \
./libtommath/bn_mp_copy.o \
./libtommath/bn_mp_init_copy.o \
./libtommath/bn_mp_abs.o \
./libtommath/bn_mp_neg.o \
./libtommath/bn_mp_cmp_mag.o \
./libtommath/bn_mp_cmp.o \
./libtommath/bn_mp_cmp_d.o \
./libtommath/bn_mp_rshd.o \
./libtommath/bn_mp_lshd.o \
./libtommath/bn_mp_mod_2d.o \
./libtommath/bn_mp_div_2d.o \
./libtommath/bn_mp_mul_2d.o \
./libtommath/bn_mp_div_2.o \
./libtommath/bn_mp_mul_2.o \
./libtommath/bn_s_mp_add.o \
./libtommath/bn_s_mp_sub.o \
./libtommath/bn_fast_s_mp_mul_digs.o \
./libtommath/bn_s_mp_mul_digs.o \
./libtommath/bn_fast_s_mp_mul_high_digs.o \
./libtommath/bn_s_mp_mul_high_digs.o \
./libtommath/bn_fast_s_mp_sqr.o \
./libtommath/bn_s_mp_sqr.o \
./libtommath/bn_mp_add.o \
./libtommath/bn_mp_sub.o \
./libtommath/bn_mp_karatsuba_mul.o \
./libtommath/bn_mp_mul.o \
./libtommath/bn_mp_karatsuba_sqr.o \
./libtommath/bn_mp_sqr.o \
./libtommath/bn_mp_div.o \
./libtommath/bn_mp_mod.o \
./libtommath/bn_mp_add_d.o \
./libtommath/bn_mp_sub_d.o \
./libtommath/bn_mp_mul_d.o \
./libtommath/bn_mp_div_d.o \
./libtommath/bn_mp_mod_d.o \
./libtommath/bn_mp_expt_d.o \
./libtommath/bn_mp_addmod.o \
./libtommath/bn_mp_submod.o \
./libtommath/bn_mp_mulmod.o \
./libtommath/bn_mp_sqrmod.o \
./libtommath/bn_mp_gcd.o \
./libtommath/bn_mp_lcm.o \
./libtommath/bn_fast_mp_invmod.o \
./libtommath/bn_mp_invmod.o \
./libtommath/bn_mp_reduce.o \
./libtommath/bn_mp_montgomery_setup.o \
./libtommath/bn_fast_mp_montgomery_reduce.o \
./libtommath/bn_mp_montgomery_reduce.o \
./libtommath/bn_mp_exptmod_fast.o \
./libtommath/bn_mp_exptmod.o \
./libtommath/bn_mp_2expt.o \
./libtommath/bn_mp_n_root.o \
./libtommath/bn_mp_jacobi.o \
./libtommath/bn_reverse.o \
./libtommath/bn_mp_count_bits.o \
./libtommath/bn_mp_read_unsigned_bin.o \
./libtommath/bn_mp_read_signed_bin.o \
./libtommath/bn_mp_to_unsigned_bin.o \
./libtommath/bn_mp_to_signed_bin.o \
./libtommath/bn_mp_unsigned_bin_size.o \
./libtommath/bn_mp_signed_bin_size.o \
./libtommath/bn_mp_xor.o \
./libtommath/bn_mp_and.o \
./libtommath/bn_mp_or.o \
./libtommath/bn_mp_rand.o \
./libtommath/bn_mp_montgomery_calc_normalization.o \
./libtommath/bn_mp_prime_is_divisible.o \
./libtommath/bn_prime_tab.o \
./libtommath/bn_mp_prime_fermat.o \
./libtommath/bn_mp_prime_miller_rabin.o \
./libtommath/bn_mp_prime_is_prime.o \
./libtommath/bn_mp_prime_next_prime.o \
./libtommath/bn_mp_dr_reduce.o \
./libtommath/bn_mp_dr_is_modulus.o \
./libtommath/bn_mp_dr_setup.o \
./libtommath/bn_mp_reduce_setup.o \
./libtommath/bn_mp_toom_mul.o \
./libtommath/bn_mp_toom_sqr.o \
./libtommath/bn_mp_div_3.o \
./libtommath/bn_s_mp_exptmod.o \
./libtommath/bn_mp_reduce_2k.o \
./libtommath/bn_mp_reduce_is_2k.o \
./libtommath/bn_mp_reduce_2k_setup.o \
./libtommath/bn_mp_reduce_2k_l.o \
./libtommath/bn_mp_reduce_is_2k_l.o \
./libtommath/bn_mp_reduce_2k_setup_l.o \
./libtommath/bn_mp_radix_smap.o \
./libtommath/bn_mp_read_radix.o \
./libtommath/bn_mp_toradix.o \
./libtommath/bn_mp_radix_size.o \
./libtommath/bn_mp_fread.o \
./libtommath/bn_mp_fwrite.o \
./libtommath/bn_mp_cnt_lsb.o \
./libtommath/bn_error.o \
./libtommath/bn_mp_init_multi.o \
./libtommath/bn_mp_clear_multi.o \
./libtommath/bn_mp_exteuclid.o \
./libtommath/bn_mp_toradix_n.o \
./libtommath/bn_mp_prime_random_ex.o \
./libtommath/bn_mp_get_int.o \
./libtommath/bn_mp_sqrt.o \
./libtommath/bn_mp_is_square.o \
./libtommath/bn_mp_init_set.o \
./libtommath/bn_mp_init_set_int.o \
./libtommath/bn_mp_invmod_slow.o \
./libtommath/bn_mp_prime_rabin_miller_trials.o \
./libtommath/bn_mp_to_signed_bin_n.o \
./libtommath/bn_mp_to_unsigned_bin_n.o \
./buffer.o \
./dss.o \
./bignum.o \
./signkey.o \
./rsa.o \
./random.o \
./queue.o \
./atomicio.o \
./compat.o \
./fake-rfc2553.o \
./dbutil.o \
./psp_missing.o \
./common-session.o \
./packet.o \
./common-algo.o \
./common-kex.o \
./common-channel.o \
./common-chansession.o \
./termcodes.o \
./loginrec.o \
./tcp-accept.o \
./listener.o \
./process-packet.o \
./common-runopts.o \
./circbuffer.o \
./cli-algo.o \
./cli-main.o \
./cli-auth.o \
./cli-authpasswd.o \
./cli-kex.o \
./cli-session.o \
./cli-service.o \
./cli-runopts.o \
./cli-tcpfwd.o \
./cli-chansession.o \
./cli-authpubkey.o \
./cli-channel.o \
./cli-authinteract.o \
\
psp_global.o \
psp_main.o \
psp_font.o \
psp_sdl.o \
psp_danzeff.o \
psp_battery.o \
psp_fmgr.o \
psp_wifi.o \
psp_login.o \
psp_menu.o \
psp_help.o \
psp_battery.o \
psp_ssh.o \
psp_loadutil.o \
psp_random.o \
psp_vt100.o \
psp_irkeyb.o


DEFAULT_CFLAGS = $(shell $(SDL_CONFIG) --cflags) 
PSP_FW_VERSION=15
PSPSSH_VERSION=1.1.1

MORE_CFLAGS = -O2 -G0 -DPSP \
-I/usr/local/pspdev/psp/sdk/include -DDROPBEAR_SERVER -DDROPBEAR_CLIENT \
-I./src/headers/ \
-I./libtomcrypt/src/headers/ \
-I./libtommath  \
-DUSE_PSP_IRKEYB \
-DPSPSSH_VERSION=\"$(PSPSSH_VERSION)\"

# -DNO_STDIO_REDIRECT

CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
CXXFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -fno-exceptions -fno-rtti

LIBS += -lpspirkeyb  -lpspwlan -lpsppower -lSDL_image -lSDL -lpng -ljpeg -lpspaudio -lpspgu -lpsphprm -lz -lm

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = PSPSSH-v$(PSPSSH_VERSION)
PSP_EBOOT_ICON= pspssh.png
PSP_EBOOT_PIC1 = pspssh-pic.png

include $(PSPSDK)/lib/build.mak

all: SCEkxploit

libtomcrypt/src/ciphers/aes/aes_enc.o: libtomcrypt/src/ciphers/aes/aes.c libtomcrypt/src/ciphers/aes/aes_tab.c
	$(CC) $(CFLAGS) -DENCRYPT_ONLY -c libtomcrypt/src/ciphers/aes/aes.c -o libtomcrypt/src/ciphers/aes/aes_enc.o

install: all
	@mkdir -p /media/usbdisk/psp/game150/__SCE__pspssh/
	@mkdir -p /media/usbdisk/psp/game150/%__SCE__pspssh/
	cp __SCE__pspssh/EBOOT.PBP /media/usbdisk/psp/game150/__SCE__pspssh/
	cp %__SCE__pspssh/EBOOT.PBP /media/usbdisk/psp/game150/%__SCE__pspssh/

realclean: clean
	/bin/rm -f $(OBJS) EBOOT.PBP PARAM.SFO
	/bin/rm -rf __SCE__pspssh %__SCE__pspssh

ctags:
	ctags *[ch] 
