Changeset 1937

Show
Ignore:
Timestamp:
11/21/08 11:35:19 (2 months ago)
Author:
batt
Message:

Add rules for creating static libraries.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bertos/config.mk

    r1694 r1937  
    2929CC      = gcc 
    3030CXX     = g++ 
     31AR      = ar 
    3132AS      = $(CC) -x assembler-with-cpp 
    3233LD      = $(CC) 
     
    113114# additional libs 
    114115LIB = -lm 
     116 
     117# Archiver flags 
     118ARFLAGS = rcs 
  • trunk/bertos/rules.mk

    r1936 r1937  
    4040# e.g. Embedded target = hex, s19, bin 
    4141#      Hosted = exe 
     42#      Library = lib.a 
    4243TRG_TGT = $(TRG:%=$(OUTDIR)/%.tgt) 
    4344 
     
    7475        $$(OUTDIR)/$(1).tgt : $$(OUTDIR)/$(1).s19 $$(OUTDIR)/$(1).hex $$(OUTDIR)/$(1).bin 
    7576else 
    76         #On Darwin architecture the assembly doesn't link correctly if this flag is set. 
     77        #On Darwin architecture the assembly doesn't link correctly if these flags are set. 
    7778        ifeq ($(shell uname | grep -c "Darwin"),1) 
    7879                LIST_FLAGS := "" 
     
    8283        #use hosted specific map flags 
    8384        $(1)_MAP_FLAGS = $$(MAP_FLAGS_HOST) 
    84         #in hosted application we need only executable file. 
    85         $$(OUTDIR)/$(1).tgt : $$(OUTDIR)/$(1) 
     85 
     86        #Handle library creation 
     87        ifeq ($$($(1)_MAKELIB),1) 
     88                $$(OUTDIR)/$(1).tgt : $$(OUTDIR)/$(1).a 
     89        else 
     90                #Otherwise in  hosted application we need only executable file. 
     91                $$(OUTDIR)/$(1).tgt : $$(OUTDIR)/$(1) 
     92        endif 
    8693endif 
    8794 
     
    137144$(1)_CXX     = $$($(1)_CROSS)$$(CXX) 
    138145$(1)_AS      = $$($(1)_CROSS)$$(AS) 
     146$(1)_AR      = $$($(1)_CROSS)$$(AR) 
    139147$(1)_OBJCOPY = $$($(1)_CROSS)$$(OBJCOPY) 
    140148$(1)_STRIP   = $$($(1)_CROSS)$$(STRIP) 
     
    205213        @$$(MKDIR_P) $$(dir $$@) 
    206214        $Q $$($(1)_LD) $$($(1)_OBJ) $$(LIB) $$(LDFLAGS) $$($(1)_LDFLAGS) -o $$@ 
     215 
     216 
     217# Instructions to create a static library from object files 
     218$$(OUTDIR)/$(1).a: bumprev $$($(1)_OBJ) 
     219        $L "$(1): Creating static library $$@" 
     220        @$$(MKDIR_P) $$(dir $$@) 
     221        $Q $$($(1)_AR) $$(ARFLAGS) $$($(1)_ARFLAGS) $$@ $$($(1)_OBJ) 
    207222 
    208223# Strip debug info