# Target versions
TARGET_VERSIONS = 1_0_X 1_1_1 1_1_2 1_1_3
# Directories
SRC_DIR = main
VPATH = $(SRC_DIR) pygen pygen/src phraseGen phraseGen/src wbgen wbgen/generator util ZTA4_iPhone/Shanghai
# Compiler settings
TOOLCHAIN = /opt/iphone-toolchain
CC = $(TOOLCHAIN)/bin/arm-apple-darwin-gcc
STRIP = $(TOOLCHAIN)/bin/arm-apple-darwin-strip
STRIPFLAGS=-X -x -S
INC += -I$(SRC_DIR) -Ipygen -IphraseGen -Iwbgen -Iutil -IZTA4_iPhone/Shanghai
ifneq ($(INTERNAL_BUILD),)
DEFINES += -DINTERNAL_BUILD
endif
ifneq ($(PLATFORM_BUILD),)
BUILD_DIR_ROOT = build_platform
DEFINES += -D__ICOSTA_PLATFORM__
TARGETS := iCostaA4.dylib
else
BUILD_DIR_ROOT = build
TARGETS := iCostaPy.dylib \
iCostaWb.dylib \
iCostaWb98.dylib \
iCostaCj.dylib
endif
CFLAGS += -c -fPIC -Wall $(INC) $(DEFINES)
ifneq ($(INTERNAL_BUILD),)
CFLAGS += -g
endif
CFLAGS_1_0_X = $(CFLAGS) -I$(TOOLCHAIN)/arm-apple-darwin/include -D__FIRMWARE_1_0_X__
CFLAGS_1_1_1 = $(CFLAGS) -I$(TOOLCHAIN)/arm-apple-darwin/include-1.1.1 -D__FIRMWARE_1_1_X__
CFLAGS_1_1_2 = $(CFLAGS) -I$(TOOLCHAIN)/arm-apple-darwin/include-1.1.2 -D__FIRMWARE_1_1_X__
CFLAGS_1_1_3 = $(CFLAGS) -I$(TOOLCHAIN)/arm-apple-darwin/include-1.1.3 -D__FIRMWARE_1_1_X__ -D__FIRMWARE_1_1_3__
CFLAGS_1_1_3 = $(CFLAGS) -I$(TOOLCHAIN)/arm-apple-darwin/include-1.1.3 -D__FIRMWARE_1_1_X__ -D__FIRMWARE_1_1_3__
LDFLAGS += -dynamiclib -lobjc -liconv -framework Foundation -framework CoreFoundation -framework GraphicsServices -framework CoreGraphics -framework UIKit -framework Celestial \
-dead-strip -image_base 0x10400000
LDFLAGS_1_0_X = -isysroot $(TOOLCHAIN)/arm-apple-darwin/system-1.0.1 $(LDFLAGS)
LDFLAGS_1_1_1 = -isysroot $(TOOLCHAIN)/arm-apple-darwin/system-1.1.1 $(LDFLAGS)
LDFLAGS_1_1_2 = -isysroot $(TOOLCHAIN)/arm-apple-darwin/system-1.1.2 $(LDFLAGS)
LDFLAGS_1_1_3 = -isysroot $(TOOLCHAIN)/arm-apple-darwin/system-1.1.3 $(LDFLAGS)
# object files
OBJS := main.o \
interceptions.o \
interceptManager.o \
info.o
OBJS_ICOSTA_IM := iCostaCandidateView.o iCostaPopupView.o candidatePager.o assnInput.o dynaArray.o phraseComposition.o
OBJS_1_0_X := $(OBJS)
OBJS_1_1_1 := $(OBJS) UIKeyboardLayoutiCosta.o UIKeyboardLayoutiCosta_Landscape.o KeyboardLayoutiCostaImpl.o UIKeyboardImpl-Expose_Layouts.o
OBJS_1_1_2 := $(OBJS_1_1_1)
OBJS_1_1_3 := $(OBJS_1_1_1)
OBJS_EXTRA_PY = $(OBJS_ICOSTA_IM) UIKeyboardSublayoutiCosta.o pyinput.o phraseInput.o pyPhraseTable.o pyPhraseTable_userDefined.o assnTable.o encoding.o
OBJS_EXTRA_WB98 = $(OBJS_ICOSTA_IM) UIKeyboardSublayoutiCosta.o pyinput_wb98.o assnTable.o
OBJS_EXTRA_WB = $(OBJS_ICOSTA_IM) UIKeyboardSublayoutiCosta_wb.o wbinput.o dd.o di.o dsearch.o assnTable.o
OBJS_EXTRA_CJ = $(OBJS_ICOSTA_IM) UIKeyboardSublayoutiCosta.o pyinput_cj.o assnTable_big5.o
OBJS_EXTRA_A4 = UIKeyboardSublayoutBridge.o
EXTRA_LIBS_A4 = ZTA4_iPhone/Shanghai/UIKeyboardEx.dylib
# BUILD_DIR_xx
define build_dir_template
BUILD_DIR_$(1) := $$(BUILD_DIR_ROOT)/$(1)
endef
$(foreach v,$(TARGET_VERSIONS),$(eval $(call build_dir_template,$(v))))
# TARGETS_xx
define target_template
TARGETS_$(1) := $(addprefix $(BUILD_DIR_$(1))/,$(TARGETS))
OBJS_$(1) := $(addprefix $(BUILD_DIR_$(1))/,$(OBJS_$(1)))
endef
$(foreach v,$(TARGET_VERSIONS),$(eval $(call target_template,$(v))))
# Rules
.PHONY: usage clean $(foreach v,$(TARGET_VERSIONS),init_$(v)) apt install_helpers
usage:
@echo "Available targets:"
@echo
@echo "all build all three targets and make apt repository files"
@echo "build_1_0_X build for firmware 1.0.x"
@echo "build_1_1_1 build for firmware 1.1.1"
@echo "build_1_1_2 build for firmware 1.1.2"
@echo "build_1_1_3 build for firmware 1.1.3/1.1.4"
@echo "apt make apt repository files"
all: apt
apt: $(foreach v,$(TARGET_VERSIONS),build_$(v)) install-helpers
# init_
define init_template
init_$(1):
@if [ ! -d $$(BUILD_DIR_$(1)) ]; then mkdir -p $$(BUILD_DIR_$(1)); fi
endef
#define obfuscate_template
#obfuscate_$(1): init_$(1) $$(BUILD_DIR_$(1))/Obfuscator.class
# cd main && java -cp ../$$(BUILD_DIR_$(1)) Obfuscator && cd ..
#endef
$(foreach v,$(TARGET_VERSIONS),$(eval $(call init_template,$(v))))
#$(foreach v,$(TARGET_VERSIONS),$(eval $(call obfuscate_template,$(v))))
# build_
define build_template
build_$(1): init_$(1) $$(TARGETS_$(1))
endef
# extra cflags
$(foreach v,$(TARGET_VERSIONS),$(eval $(call build_template,$(v))))
# BUILD_DIR_xx/iCostaXX.dylib - $(call dylib_template,version,target)
define dylib_template
EXTRA_OBJS = $(if $(findstring Py,$(2)),$(addprefix $(BUILD_DIR_$(1))/,$(OBJS_EXTRA_PY)), \
$(if $(findstring Wb98,$(2)),$(addprefix $(BUILD_DIR_$(1))/,$(OBJS_EXTRA_WB98)), \
$(if $(findstring Wb,$(2)),$(addprefix $(BUILD_DIR_$(1))/,$(OBJS_EXTRA_WB)), \
$(if $(findstring Cj,$(2)),$(addprefix $(BUILD_DIR_$(1))/,$(OBJS_EXTRA_CJ)), \
$(if $(findstring A4,$(2)),$(addprefix $(BUILD_DIR_$(1))/,$(OBJS_EXTRA_A4))) \
) \
) \
) \
)
EXTRA_LIBS = $(if $(findstring A4,$(2)),$(EXTRA_LIBS_A4),)
$(2): $$(OBJS_$(1)) $$(EXTRA_OBJS)
$$(CC) $$(LDFLAGS_$(1)) $$(EXTRA_LIBS) -o $$@ $$^
ifeq ($(INTERNAL_BUILD),)
mv $$@ $$@.before_strip
$$(STRIP) $$(STRIPFLAGS) -o $$@ $$@.before_strip
endif
endef
$(foreach v,$(TARGET_VERSIONS),$(foreach t,$(TARGETS_$(v)),$(eval $(call dylib_template,$(v),$(t)))))
# Compile rules
define compile_template
$$(BUILD_DIR_$(1))/%.o: %.m
$$(CC) $$(CFLAGS_$(1)) -o $$@ $$<
$$(BUILD_DIR_$(1))/%.o: %.c
$$(CC) $$(CFLAGS_$(1)) -o $$@ $$<
$$(BUILD_DIR_$(1))/pyinput.o: pyinput.c pygen/pytable.inc
$$(CC) $$(CFLAGS_$(1)) -o $$@ $$<
$$(BUILD_DIR_$(1))/pyinput_cj.o: pyinput.c pygen/cjtable.inc
$$(CC) $$(CFLAGS_$(1)) -DCJ_TABLE -o $$@ $$<
$$(BUILD_DIR_$(1))/pyinput_wb98.o: pyinput.c pygen/wb98table.inc
$$(CC) $$(CFLAGS_$(1)) -DWB98_TABLE -o $$@ $$<
$$(BUILD_DIR_$(1))/UIKeyboardSublayoutiCosta_wb.o: UIKeyboardSublayoutiCosta.m
$$(CC) $$(CFLAGS_$(1)) -DWB_INPUT_METHOD -o $$@ $$<
endef
$(foreach v,$(TARGET_VERSIONS),$(eval $(call compile_template,$(v))))
$(BUILD_DIR_ROOT)/%.class: %.java
javac -d $(BUILD_DIR_ROOT) -sourcepath $(dir $<) $<
pygen/pytable.inc: pygen/data/pinyin.txt $(BUILD_DIR_ROOT)/PyGenerator.class
java -cp $(BUILD_DIR_ROOT) PyGenerator pygen/data/pinyin.txt $@
pygen/wb98table.inc: pygen/data/wb98chars.txt $(BUILD_DIR_ROOT)/PyGenerator.class
java -cp $(BUILD_DIR_ROOT) PyGenerator pygen/data/wb98chars.txt $@
#pygen/cjtable.inc: pygen/data/cjchars.txt $(BUILD_DIR_ROOT)/PyGenerator.class
# java -cp $(BUILD_DIR_ROOT) PyGenerator pygen/data/cjchars.txt $@
pygen/cjtable.inc: pygen/data/FTCJ_B5.TXT $(BUILD_DIR_ROOT)/PyGenerator.class
java -cp $(BUILD_DIR_ROOT) PyGenerator --cj $< $@
wbgen/dd.c wbgen/di.c: wbgen/data/Sun86.TXT $(BUILD_DIR_ROOT)/DictHandler.class
java -cp $(BUILD_DIR_ROOT) DictHandler wbgen/data/Sun86.TXT wbgen/dd.c wbgen/di.c
phraseGen/assnTable.c: phraseGen/data/okcuphrase.txt $(BUILD_DIR_ROOT)/AssociationGenerator.class
java -cp $(BUILD_DIR_ROOT) AssociationGenerator -gb $< $@
phraseGen/assnTable_big5.c: phraseGen/data/okcuphrase-b5.txt $(BUILD_DIR_ROOT)/AssociationGenerator.class
java -cp $(BUILD_DIR_ROOT) AssociationGenerator -big5 $< $@
clean:
ifneq ($(PLATFORM_BUILD),)
-rm -rf build_platform/1*
else
-rm -rf build/1*
endif
若你在年轻时上过水木, 它会一生跟随着你, 如一场浮动的盛宴
禁色和禁果仍被保存吗?
这世界有否给潜移默化?
离过家回了家仍住中环吗?
-----信有带到新居里烧吗?
一切美好的都会消失
人要是没有理想, 跟咸鱼有什么两样?
“把人们引向艺术和科学的最强烈动机之一,是要逃避日常生活中令人厌恶的粗俗和使人绝望的沉闷,是要摆脱人们自己反复无常的欲望的桎梏。一个修养有素的人总是渴望逃避个人生活而进入客观直觉和思维的世界。”
不要忘了,这个世界穿透一切高墙的东西,它就在我们的内心深处,他们无法达到,也接触不到,那就是希望。(FROM《肖申克的救赎》)