theos的makefile写法与其他linux/unix环境下的makefile写法大同小异,但是对于makefile不熟悉的在导入一些dylib或者framework的时候就会变得很蛋疼。
对于framework可以直接通过Frameworks和private frameworks来导入,但是dylib文件却不能那么简单的写进去,如果要引用zlib,那么如果写成xxx_LDFLAGS = -zlib,虽然在编译的时候不会提示找不到对应的lib库但是却会提示找不到相关的符号。
这个东西的写法比较蛋疼,例如要调用libz.1.2.5.dylib ,那么写法是去掉前面的lib和最后的.dylib,然后将剩余部分拼到-l后面也就是上图中看到的那个样子:
xxx_LDFLAGS = -lz.1.2.5 |
详细信息可以参考这个页面:https://github.com/DHowett/theos/issues/15
一个makefile模板:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# # Use this makefile to compile service project. # When change SDK or add new files ,re-edit values below. # zhj # 2012-07-17 # txtw # export THEOS=/opt/theos/ export SDKVERSION=5.1 export THEOS_DEVICE_IP=10.0.2.3 #192.168.1.157 #10.0.2.2 export CURRENT_VERSION = 1104 include theos/makefiles/common.mk TWEAK_NAME = service RESOURCE_DIR = Resources DEBUG = 1 #SUBPROJECTS=servicePreferences #编译单元 # # #编译 ----------------------------ASIHTTPRequest-------------------- service_FILES += ASIHTTPRequest/ASIAuthenticationDialog.m service_FILES += ASIHTTPRequest/ASIDownloadCache.m service_FILES += ASIHTTPRequest/ASIFormDataRequest.m service_FILES += ASIHTTPRequest/ASIHTTPRequest.m service_FILES += ASIHTTPRequest/ASIInputStream.m service_FILES += ASIHTTPRequest/ASINetworkQueue.m service_FILES += ASIHTTPRequest/Reachability.m #编译 ----------------------------Encoder--------------------------- service_FILES += Encoder/CrypHelper.m service_FILES += Encoder/GTMBase64.m service_FILES += Encoder/NSData+Base64.m service_FILES += Encoder/NSString+MD5Addition.m service_FILES += Encoder/UIDevice+IdentifierAddition.m #编译 ----------------------------TBXML----------------------------- service_FILES += TBXML/NSDataAdditions.m service_FILES += TBXML/TBXML.m #编译 ----------------------------Regex----------------------------- service_FILES += Regex/RegexKitLite.m #编译 ----------------------------Constant-------------------------- service_FILES += Constant/Constant.m service_FILES += Constant/UserDefaults.m #编译 ----------------------------SOAP----------------------------- service_FILES += SOAP/Head.m service_FILES += SOAP/Body.m #编译 ----------------------------MsgService----------------------------- service_FILES += MsgService/MsgService.m service_FILES += MsgService/MessageInfo.m service_FILES += MsgService/Msgs/NetBrain.m service_FILES += MsgService/Msgs/KeepAliveReturnMsg.m service_FILES += MsgService/Msgs/DevBindReturnMsg.m service_FILES += MsgService/Msgs/FamilyPhoneMsg.m service_FILES += MsgService/Msgs/LocationMsg.m #编译 ----------------------------ParseXML----------------------------- service_FILES += ParseXML/ParseXML.m #编译 ----------------------------Command--------------------------------- service_FILES += Command/TxtwCommand.m #编译 ----------------------------BaiduMap--------------------------------- service_FILES += BaiduMap/MapPointAnnotion.m #编译 ----------------------------service----------------------------- service_FILES += service/service.mm service_FILES += Tweak.xm #连接单元 # #连接 ----------------------------framework-------------------------- service_FRAMEWORKS = Foundation UIKit QuartzCore Foundation CoreFoundation CoreGraphics MobileCoreServices service_FRAMEWORKS += SystemConfiguration CFNetwork CoreTelephony CoreLocation MapKit #连接 ----------------------------dylib------------------------------ service_LDFLAGS = -lxml2 -lz -licucore -lgcc -lgcc_eh -lstdc++ service_LDFLAGS += -L./BaiduMap/inc -R./BaiduMap/inc/ -lbaidumapapi #编译器 ---------------------------------------------------------- #service_CFLAGS += -std=c99 #service_CFLAGS += -all_load #资源文件 ---------------------------------------------------------- internal-package:: ifneq ($(wildcard $(RESOURCE_DIR)/*.png), ) mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME) cp $(RESOURCE_DIR)/*.png $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME)/ endif ifneq ($(wildcard $(RESOURCE_DIR)/*.lproj), ) mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME) rsync -avC $(RESOURCE_DIR)/*.lproj $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME) endif ifneq ($(wildcard $(RESOURCE_DIR)/$(TWEAK_NAME).plist), ) mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME) cp $(RESOURCE_DIR)/$(TWEAK_NAME).plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME) endif include $(THEOS_MAKE_PATH)/tweak.mk |
注释:
1 2 3 4 5 6 7 8 9 10 11 |
9~14行属于系统配置部分:其中11行是调试设备的IP地址 16行是引入常用的一般模板 18行工程名称 20行存放资源文件的本地目录名称:可以自定义 主要是在生成包拷贝时使用 22行是否是调试状态:常用的一个宏设置是否显示NSLog 区分是debug还是release 也可以自己尝试设置其他宏变量 26~83行是编译所需要的的源文件 88~90行是sdk中的framework 93~95行是需要的一些系统静态库和第三方静态库 97~99行是编译器参数设置 101~114行是拷贝资源文件 116行是引入tweak模板 |
参考链接:
https://github.com/DHowett/theos/issues/15
http://www.cnblogs.com/qiezi/archive/2012/09/29/2708726.html
https://github.com/DHowett/theos