2
我對編寫makefile和Objective-C語言都很陌生。我試圖編譯這個Makefile一個小的測試應用程序:在Mac OS的終端上編譯Objective-C
Q = @
INCLUDE_PREF = -I
CC := gcc
#Here the source files are specified
list_src_files = $(shell find . -type f -name "*.m")
SRCS := $(subst ./,,$(call list_src_files))
#Here is our include files
list_include_dirs = $(shell find . -type d -name "include")
INCLUDE_LS := $(call list_include_dirs)
INCLUDE_DIRS := $(INCLUDE_PREF).
INCLUDE_DIRS += $(addprefix $(INCLUDE_PREF), $(subst ./,,$(INCLUDE_LS)))
#Flags used with gcc
CFLAGS = -Wall -fobjc-arc -framework Foundation -g -O0 $(INCLUDE_DIRS)
#Here all object files are specified
OBJS := $(SRCS:%.m=%.o)
#Here is the name of target specified
TARGET := Convertor
#Here is our target
$(TARGET): $(OBJS)
@echo "Building target"
$(Q)$(CC) $(CFLAGS) $^ -o [email protected]
%.o: %.m
@echo "Building objects"
$(Q)$(CC) $(CFLAGS) -c $< -o [email protected]
.PHONY: clean
clean:
$(Q)-rm $(OBJS) $(TARGET) 2>/dev/null || true
我試圖編譯的代碼是:
#import <Foundation/Foundation.h>
#define DEBUG
#define VALID_PARMS_NBR 3
#ifdef DEBUG
# define dbg(fmt, ...) NSLog((@"%s " fmt), __PRETTY_FUNCTION__, ##__VA_ARGS__)
#else
# define dbg(...)
#endif
int main (int argc, char *argv[])
{
if (argc < VALID_PARMS_NBR) {
NSLog(@"Usage of this program is: prog_name arg1 arg2");
} else {
dbg(@"Parameters: %s, %s, %s\n", argv[0], argv[1], argv[2]);
}
return 0;
}
警告編譯器扔我每次:
clang: warning: -framework Foundation: 'linker' input unused
請問,請指出我在哪裏弄錯了Makefile?爲什麼會出現此警告?
我正在查看類似的問題,但沒有任何工作。