Skip to content

Commit

Permalink
Adds support for compiling ASM files in an application library. (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsracz authored Dec 23, 2020
1 parent f07e093 commit 9a29192
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions etc/applib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ exist := $(wildcard sources)
ifneq ($(strip $(exist)),)
include sources
else
FULLPATHASMSRCS := $(wildcard $(VPATH)/*.S)
FULLPATHCSRCS = $(wildcard $(VPATH)/*.c)
FULLPATHCXXSRCS = $(wildcard $(VPATH)/*.cxx)
FULLPATHCPPSRCS = $(wildcard $(VPATH)/*.cpp)
ASMSRCS = $(notdir $(FULLPATHASMSRCS)) $(wildcard *.S)
CSRCS = $(notdir $(FULLPATHCSRCS))
CXXSRCS = $(notdir $(FULLPATHCXXSRCS))
CPPSRCS = $(notdir $(FULLPATHCPPSRCS))
Expand All @@ -33,7 +35,7 @@ ifdef APP_PATH
INCLUDES += -I$(APP_PATH)
endif

OBJS = $(CXXSRCS:.cxx=.o) $(CPPSRCS:.cpp=.o) $(CSRCS:.c=.o)
OBJS = $(CXXSRCS:.cxx=.o) $(CPPSRCS:.cpp=.o) $(CSRCS:.c=.o) $(ASMSRCS:.S=.o)
LIBNAME = lib$(BASENAME).a

ifdef BOARD
Expand All @@ -56,7 +58,7 @@ all: $(LIBNAME)
-include $(OBJS:.o=.d)

.SUFFIXES:
.SUFFIXES: .o .c .cxx .cpp
.SUFFIXES: .o .c .cxx .cpp .S

.cpp.o:
$(CXX) $(CXXFLAGS) $< -o $@
Expand All @@ -70,6 +72,9 @@ all: $(LIBNAME)
$(CC) $(CFLAGS) $< -o $@
$(CC) -MM $(CFLAGS) $< > $*.d

.S.o:
$(AS) $(ASFLAGS) -MD -MF $*.d $(abspath $<) -o $@

$(LIBNAME): $(OBJS)
$(AR) cr $(LIBNAME) $(OBJS)
mkdir -p ../lib
Expand Down

0 comments on commit 9a29192

Please sign in to comment.