Ignore:
Timestamp:
Nov 23, 2013 7:13:40 AM (10 years ago)
Author:
bennylp
Message:

Fixed #1713: Enable building the libraries as shared libraries/DLLs for GNU targets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/build/rules.mak

    r4637 r4656  
    77 
    88# 
    9 # The full path of output lib file (e.g. ../lib/libapp.a). 
    10 # 
    11 LIB = $($(APP)_LIB) 
    12  
    13 # 
    14 # The full path of output lib file (e.g. ../lib/libapp.a). 
    15 # 
     9# The name(s) of output lib file(s) (e.g. libapp.a). 
     10# 
     11LIB := $($(APP)_LIB) 
    1612SHLIB = $($(APP)_SHLIB) 
    17  
    18 # 
    19 # The full path of output executable file (e.g. ../bin/app.exe). 
     13SONAME = $($(APP)_SONAME) 
     14 
     15ifeq ($(SHLIB_SUFFIX),so) 
     16SHLIB_OPT := -shared -Wl,-soname,$(SHLIB) 
     17else ifeq ($(SHLIB_SUFFIX),dylib) 
     18SHLIB_OPT := -dynamiclib -undefined dynamic_lookup -flat_namespace 
     19else 
     20SHLIB_OPT :=  
     21endif 
     22 
     23# 
     24# The name of output executable file (e.g. app.exe). 
    2025# 
    2126EXE = $($(APP)_EXE) 
     
    7782 
    7883print_bin: print_common 
    79         @echo EXE=$(EXE) 
     84        @echo EXE=$(subst /,$(HOST_PSEP),$(BINDIR)/$(EXE)) 
    8085        @echo BINDIR=$(BINDIR) 
    81  
     86  
    8287print_lib: print_common 
    83         @echo LIB=$(LIB) 
     88ifneq ($(LIB),) 
     89        @echo LIB=$(subst /,$(HOST_PSEP),$(LIBDIR)/$(LIB)) 
     90endif 
     91ifneq ($(SHLIB),) 
     92        @echo SHLIB=$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SHLIB)) 
     93endif 
     94ifneq ($(SONAME),) 
     95        @echo SONAME=$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SONAME)) 
     96endif 
    8497        @echo LIBDIR=$(LIBDIR) 
    8598 
    86 $(LIB): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP) 
     99ifneq ($(LIB),) 
     100$(subst /,$(HOST_PSEP),$(LIBDIR)/$(LIB)): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP) 
    87101        if test ! -d $(LIBDIR); then $(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)),$(HOST_MKDIR)); fi 
    88         $(AR) $(AR_FLAGS) $(LIB) $(OBJS) 
    89         $(RANLIB) $(LIB) 
    90  
    91 $(SHLIB): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP) 
     102        $(AR) $(AR_FLAGS) $@ $(OBJS) 
     103        $(RANLIB) $@ 
     104endif 
     105 
     106ifneq ($(SHLIB),) 
     107$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SHLIB)): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP) 
    92108        if test ! -d $(LIBDIR); then $(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)),$(HOST_MKDIR)); fi 
    93         $(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$(SHLIB)) \ 
     109        $(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$@) \ 
     110            $(subst /,$(HOST_PSEP),$(OBJS)) $($(APP)_LDFLAGS) $(SHLIB_OPT) 
     111endif 
     112  
     113ifneq ($(SONAME),) 
     114$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SONAME)): $(subst /,$(HOST_PSEP),$(LIBDIR)/$(SHLIB)) 
     115        ln -sf $(SHLIB) $@ 
     116endif 
     117 
     118ifneq ($(EXE),) 
     119$(subst /,$(HOST_PSEP),$(BINDIR)/$(EXE)): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP) 
     120        if test ! -d $(BINDIR); then $(subst @@,$(subst /,$(HOST_PSEP),$(BINDIR)),$(HOST_MKDIR)); fi 
     121        $(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$(BINDIR)/$(EXE)) \ 
    94122            $(subst /,$(HOST_PSEP),$(OBJS)) $($(APP)_LDFLAGS) 
    95  
    96 $(EXE): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP) 
    97         if test ! -d $(BINDIR); then $(subst @@,$(subst /,$(HOST_PSEP),$(BINDIR)),$(HOST_MKDIR)); fi 
    98         $(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$(EXE)) \ 
    99             $(subst /,$(HOST_PSEP),$(OBJS)) $($(APP)_LDFLAGS) 
     123endif 
    100124 
    101125$(OBJDIR)/$(app).o: $(OBJDIRS) $(OBJS) 
     
    148172 
    149173$(OBJDIRS): 
    150         $(subst @@,$(subst /,$(HOST_PSEP),$@),$(HOST_MKDIR))  
     174        $(subst @@,$(subst /,$(HOST_PSEP),$@),$(HOST_MKDIR)) 
    151175 
    152176$(LIBDIR): 
    153         $(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)),$(HOST_MKDIR)) 
     177        $(subst @@,$(subst /,$(HOST_PSEP),$@),$(HOST_MKDIR)) 
    154178 
    155179$(BINDIR): 
    156         $(subst @@,$(subst /,$(HOST_PSEP),$(BINDIR)),$(HOST_MKDIR)) 
     180        $(subst @@,$(subst /,$(HOST_PSEP),$@),$(HOST_MKDIR)) 
    157181 
    158182clean: 
     
    169193 
    170194realclean: clean 
    171         $(subst @@,$(subst /,$(HOST_PSEP),$(LIB)) $(subst /,$(HOST_PSEP),$(EXE)),$(HOST_RM)) 
     195ifneq ($(LIB),) 
     196        $(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)/$(LIB)),$(HOST_RM)) 
     197endif 
     198ifneq ($(SHLIB),) 
     199        $(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SHLIB)),$(HOST_RM)) 
     200endif 
     201ifneq ($(SONAME),) 
     202        $(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SONAME)),$(HOST_RM)) 
     203endif 
     204ifneq ($(EXE),) 
     205        $(subst @@,$(subst /,$(HOST_PSEP),$(BINDIR)/$(EXE)),$(HOST_RM)) 
     206endif 
    172207        $(subst @@,$(DEP_FILE),$(HOST_RM)) 
    173208ifeq ($(OS_NAME),linux-kernel) 
Note: See TracChangeset for help on using the changeset viewer.