Skip to content

Commit

Permalink
Updated library building to allow for appending object files and libr…
Browse files Browse the repository at this point in the history
…aries

This is useful for cases where you want to build a static library that is
a superset of several smaller libraries. Or if you have a c++ library that
wraps a c library this allows you to include the c library in the c++
library so that you do not have to supply both to the linker.
  • Loading branch information
davidchappelle committed Jun 5, 2014
1 parent d4a1f5d commit e2e5fef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mk/library.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ endif
-include $(TOP_DIRECTORY)/mk/configuration.mk

OBJECTS=$(addprefix $(BUILD_OUTPUT_DIRECTORY)/,$(addsuffix .o,$(basename $(SOURCES))))
LIBRARIES=$(addprefix $(LIBRARY_DIRECTORY)/lib,$(addsuffix .a,$(LIBRARY_APPEND)))
DEPENDENCIES=$(addprefix $(BUILD_OUTPUT_DIRECTORY)/,$(addsuffix .d,$(basename $(SOURCES))))
LIBRARY_DIRECTORY=$(TOP_DIRECTORY)/lib
LIBRARY_TARGET=$(LIBRARY_DIRECTORY)/lib$(LIBRARY).a
BUILD_OUTPUT_FILES=$(OBJECTS) $(DEPENDENCIES) $(LIBRARY_TARGET)

all: build-directories $(OBJECTS) $(LIBRARY_TARGET)
all: build-directories $(OBJECTS) $(LIBRARIES) $(LIBRARY_TARGET)

$(LIBRARY_TARGET): $(OBJECTS)
@$(AR) -r $(LIBRARY_TARGET) $(OBJECTS)
$(LIBRARY_TARGET): $(ARCHIVE_OBJECTS)
@$(AR) -rcT $(LIBRARY_TARGET) $(OBJECTS) $(LIBRARIES)

-include $(TOP_DIRECTORY)/mk/target.mk
-include $(TOP_DIRECTORY)/mk/build.mk
Expand Down

0 comments on commit e2e5fef

Please sign in to comment.