diff options
Diffstat (limited to 'cros_ec/Makefile')
-rw-r--r-- | cros_ec/Makefile | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/cros_ec/Makefile b/cros_ec/Makefile index dce7c20dbf..8653fa5fb8 100644 --- a/cros_ec/Makefile +++ b/cros_ec/Makefile @@ -2,26 +2,50 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -LIB_SRCS=\ - lib/ec_console.c +CROS_EC_TOP := $(shell pwd) +LIBDIR = $(CROS_EC_TOP)/lib +STUBDIR = $(CROS_EC_TOP)/chip_stub +TESTDIR = $(CROS_EC_TOP)/test +BUILD_ROOT := ${BUILD}/$(shell basename ${CROS_EC_TOP}) +LIBS = $(CROS_EC_LIB) # Firmware library must be self-contained -STUB_SRCS=\ - chip_stub/ec_os.c \ - chip_stub/ec_uart.c +INCLUDES = \ + -I$(CROS_EC_TOP)/include \ + -I$(LIBDIR)/include -TESTPROGS=fakemain ec_os_test +ifeq ($(FIRMWARE_ARCH),) +INCLUDES += -I$(STUBDIR)/include +else +INCLUDES += -I$(FWDIR)/arch/$(FIRMWARE_ARCH)/include +endif -CFLAGS=-Wall -I include -I chip_stub -pthread +# find ./lib -iname '*.c' | sort +LIB_SRCS = \ + ./lib/ec_console.c \ + ./lib/ec_host_command.c -all: $(TESTPROGS) +LIB_OBJS = $(LIB_SRCS:%.c=${BUILD_ROOT}/%.o) -clean: - rm -f $(TESTPROGS) +STUB_SRCS = \ + ./chip_stub/ec_os.c \ + ./chip_stub/ec_uart.c -ec_os_test: test/ec_os_test.c chip_stub/ec_os.c chip_stub/ec_uart.c - gcc $(CFLAGS) -o ec_os_test \ - test/ec_os_test.c chip_stub/ec_os.c chip_stub/ec_uart.c +STUB_OBJS = $(STUB_SRCS:%.c=${BUILD_ROOT}/%.o) -fakemain: test/fakemain.c $(LIB_SRCS) $(STUB_SRCS) - gcc $(CFLAGS) -o fakemain test/fakemain.c \ - $(LIB_SRCS) $(STUB_SRCS) +ALL_SRCS = ${LIB_SRCS} ${STUB_SRCS} + +ifeq ($(FIRMWARE_ARCH),) +all : $(CROS_EC_LIB) $(CHIP_STUB_LIB) +else +all : $(CROS_EC_LIB) +endif + +include ../common.mk + +$(CROS_EC_LIB) : $(LIB_OBJS) + rm -f $@ + ar qc $@ $^ + +$(CHIP_STUB_LIB) : $(STUB_OBJS) + rm -f $@ + ar qc $@ $^ |