0

我有一个 Makefile,我想修改它,以选择某个目录中的所有 c 文件,而不是单独指定所有 c 文件。

谢谢,这是代码:(我将只粘贴与主题相关的切片)

#MQTT PATH
MQTT_DIR = $(SAMPLE_DIR)/mqtt_lib

#TRSMIO PATH
TRSMIO_DIR = $(SAMPLE_DIR)/trsmio_lib

#UTIL PATH
UTIL_DIR = $(SAMPLE_DIR)/util_lib

# Location of the SDK "startup.c" file used to launch custom (sample) code.
SDK_CS = $(SDK_DIR)/startup.c


#DEPENDECIES OF MAINS TASK
MQTT_CS = $(MQTT_DIR)/libmqtt_util.c
MQTT_LIB = $(MQTT_DIR)/libmqtt.c
MQTT_CGI = $(MQTT_DIR)/libmqtt_cgi.c
MQTT_MGR = $(MQTT_DIR)/libmqtt_config_mgr.c
LIB_TIMER = $(UTIL_DIR)/lib_timer.c
TRSMIO_HOSTLINK = $(TRSMIO_DIR)/trsmio_hostlink.c
TRSMIO_HOSTLINK_CONFIG = $(TRSMIO_DIR)/trsmio_hostlink_config_mgr.c
LIB_NET_DEBUG = $(UTIL_DIR)/lib_netdebug.c
TASK_MGR = $(UTIL_DIR)/task_mgr.c

#MAIN TASKS
TRSMIO_TEST = $(SAMPLE_DIR)/trsmio_test.c
#MQTT_TEST = $(SAMPLE_DIR)/libmqtt_test.c


# Location and name of the sample source code file:
SAMPLE_CS = $(SAMPLE_DIR)/$(MAKECMDGOALS).c

# Location of the Evolution OS object module library, statically linked with 
# the sample code.
EVOS_LIB = $(SDK_DIR)/$(PLATFORM_DIR)/evolution.lib

EVOS_WEB_LIB = $(SDK_DIR)/$(PLATFORM_DIR)/evolution_with_web.lib
#EVOS_WEB_LIB = $(SDK_DIR)/$(PLATFORM_DIR)/evolution_no_web.lib

# All C source code files to be built and included in the image.
ALL_C_COMPILE_SOURCES =         \
    $(SDK_CS)                   \
    $(TASK_MGR)                 \
    $(LIB_NET_DEBUG)        \
    $(MQTT_CS)                  \
    $(MQTT_CGI)         \
    $(MQTT_LIB)                 \
    $(MQTT_MGR)                 \
    $(TRSMIO_HOSTLINK)          \
    $(TRSMIO_HOSTLINK_CONFIG)   \
    $(LIB_TIMER)            \
    $(TRSMIO_TEST)          \
    $(SAMPLE_CS)

   work/$(notdir $(SAMPLE_CS:.c=.o)): $(SAMPLE_CS)
@echo $<
@$(CC) $(CFLAGS) -c $< -o $@

work/$(notdir $(LIB_TIMER:.c=.o)): $(LIB_TIMER)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@

work/$(notdir $(TASK_MGR:.c=.o)): $(TASK_MGR)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@

work/$(notdir $(LIB_NET_DEBUG:.c=.o)): $(LIB_NET_DEBUG)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@

work/$(notdir $(MQTT_MGR:.c=.o)): $(MQTT_MGR)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@

work/$(notdir $(TRSMIO_HOSTLINK_CONFIG:.c=.o)): $(TRSMIO_HOSTLINK_CONFIG)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@    

work/$(notdir $(TRSMIO_HOSTLINK:.c=.o)): $(TRSMIO_HOSTLINK)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@

work/$(notdir $(TRSMIO_TEST:.c=.o)): $(TRSMIO_TEST)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@    

work/$(notdir $(MQTT_CGI:.c=.o)): $(MQTT_CGI)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@

work/$(notdir $(MQTT_CS:.c=.o)): $(MQTT_CS)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@    

work/$(notdir $(MQTT_LIB:.c=.o)): $(MQTT_LIB)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@        

work/$(notdir $(SDK_CS:.c=.o)): $(SDK_CS)
    @echo $<
    @$(CC) $(CFLAGS) -c $< -o $@
4

1 回答 1

4

我不确定您尝试的方法是否明智,但方法如下:

ALL_C_FILES = $(wildcard $(SOME_DIR)/*.c)
于 2013-08-02T12:10:16.200 回答