iphone JB开发小记(五)theos的makefile

 theos 是初期ios插件开发者经常使用的工具,现在被集成在iosOpenDev的logos所实现,不需要再自己写makefile来实现
程序的自动编译。不过这里还是要简单的介绍一下如何写一个插件的makefile,这样更有利于理解编译机制.

 以下是一个我自己工程中用到的makefile:

  1 #
  2 # Use this makefile to compile service project.
  3 # When change SDK or add new files ,re-edit values below.
  4 # zhj
  5 # 2012-07-17
  6 # txtw
  7 #
  8 
  9 export THEOS=/opt/theos/
 10 export SDKVERSION=5.1
 11 export THEOS_DEVICE_IP=10.0.2.3
 12 #192.168.1.157
 13 #10.0.2.2
 14 export CURRENT_VERSION = 1104
 15 
 16 include theos/makefiles/common.mk
 17 
 18 TWEAK_NAME = service
 19 
 20 RESOURCE_DIR = Resources
 21 
 22 DEBUG = 1
 23 
 24 #SUBPROJECTS=servicePreferences
 25 
 26 #编译单元
 27 #
 28 #
 29 
 30 
 31 #编译 ----------------------------ASIHTTPRequest--------------------
 32 service_FILES += ASIHTTPRequest/ASIAuthenticationDialog.m
 33 service_FILES += ASIHTTPRequest/ASIDownloadCache.m
 34 service_FILES += ASIHTTPRequest/ASIFormDataRequest.m
 35 service_FILES += ASIHTTPRequest/ASIHTTPRequest.m
 36 service_FILES += ASIHTTPRequest/ASIInputStream.m
 37 service_FILES += ASIHTTPRequest/ASINetworkQueue.m
 38 service_FILES += ASIHTTPRequest/Reachability.m
 39 
 40 #编译 ----------------------------Encoder---------------------------
 41 service_FILES += Encoder/CrypHelper.m
 42 service_FILES += Encoder/GTMBase64.m
 43 service_FILES += Encoder/NSData+Base64.m
 44 service_FILES += Encoder/NSString+MD5Addition.m
 45 service_FILES += Encoder/UIDevice+IdentifierAddition.m
 46 
 47 #编译 ----------------------------TBXML-----------------------------
 48 service_FILES += TBXML/NSDataAdditions.m
 49 service_FILES += TBXML/TBXML.m
 50 
 51 #编译 ----------------------------Regex-----------------------------
 52 service_FILES += Regex/RegexKitLite.m
 53 
 54 #编译 ----------------------------Constant--------------------------
 55 service_FILES += Constant/Constant.m
 56 service_FILES += Constant/UserDefaults.m
 57 
 58 #编译 ----------------------------SOAP-----------------------------
 59 service_FILES += SOAP/Head.m
 60 service_FILES += SOAP/Body.m
 61 
 62 #编译 ----------------------------MsgService-----------------------------
 63 service_FILES += MsgService/MsgService.m
 64 service_FILES += MsgService/MessageInfo.m
 65 service_FILES += MsgService/Msgs/NetBrain.m
 66 service_FILES += MsgService/Msgs/KeepAliveReturnMsg.m
 67 service_FILES += MsgService/Msgs/DevBindReturnMsg.m
 68 service_FILES += MsgService/Msgs/FamilyPhoneMsg.m
 69 service_FILES += MsgService/Msgs/LocationMsg.m
 70 
 71 #编译 ----------------------------ParseXML-----------------------------
 72 service_FILES += ParseXML/ParseXML.m
 73 
 74 
 75 #编译 ----------------------------Command---------------------------------
 76 service_FILES += Command/TxtwCommand.m
 77 
 78 #编译 ----------------------------BaiduMap---------------------------------
 79 service_FILES += BaiduMap/MapPointAnnotion.m
 80 
 81 #编译 ----------------------------service-----------------------------
 82 service_FILES += service/service.mm
 83 service_FILES += Tweak.xm
 84 
 85 
 86 #连接单元
 87 #
 88 #连接 ----------------------------framework--------------------------
 89 service_FRAMEWORKS = Foundation UIKit QuartzCore Foundation CoreFoundation CoreGraphics  MobileCoreServices
 90 service_FRAMEWORKS += SystemConfiguration  CFNetwork CoreTelephony CoreLocation MapKit
 91 
 92 
 93 #连接 ----------------------------dylib------------------------------
 94 service_LDFLAGS = -lxml2 -lz -licucore -lgcc -lgcc_eh -lstdc++ 
 95 service_LDFLAGS += -L./BaiduMap/inc -R./BaiduMap/inc/ -lbaidumapapi
 96 
 97 #编译器 ----------------------------------------------------------
 98 #service_CFLAGS += -std=c99 
 99 #service_CFLAGS += -all_load
100 
101 #资源文件 ----------------------------------------------------------
102 internal-package::
103    ifneq ($(wildcard $(RESOURCE_DIR)/*.png), )
104     mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME)
105     cp $(RESOURCE_DIR)/*.png $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME)/
106    endif
107    ifneq ($(wildcard $(RESOURCE_DIR)/*.lproj), )
108     mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME)
109     rsync -avC $(RESOURCE_DIR)/*.lproj $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME)
110    endif
111    ifneq ($(wildcard $(RESOURCE_DIR)/$(TWEAK_NAME).plist), )
112     mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME)
113     cp $(RESOURCE_DIR)/$(TWEAK_NAME).plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME)
114    endif
115 
116 include $(THEOS_MAKE_PATH)/tweak.mk

 对这个makefile做一个简单的解读:

 1  9~14行属于系统配置部分:其中11行是调试设备的IP地址
 2  16行是引入常用的一般模板
 3  18行工程名称
 4  20行存放资源文件的本地目录名称:可以自定义 主要是在生成包拷贝时使用
 5  22行是否是调试状态:常用的一个宏设置是否显示NSLog 区分是debug还是release 也可以自己尝试设置其他宏变量
 6  26~83行是编译所需要的的源文件
 7  88~90行是sdk中的framework
 8  93~95行是需要的一些系统静态库和第三方静态库
 9  97~99行是编译器参数设置
10  101~114行是拷贝资源文件
11  116行是引入tweak模板

 

 通过上面的文件我们可以看到,theos的makefile写法与其他linux/unix环境下的makefile写法大同小异,多参考一些github上的tweak的makefile写法,很快就可以掌握技巧。

posted @ 2012-09-29 16:44  有只茄子  阅读(4795)  评论(0编辑  收藏  举报