mirror of
https://github.com/linux-msm/qrtr.git
synced 2026-04-09 23:00:03 +02:00
makefile: split bin and lib targets macros
Build libraries with proper soname, real and linker names, using symlinks appropriately. As such, the generic macro 'add-target' can no longer be used for both binary and libaries. Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
This commit is contained in:
32
Makefile
32
Makefile
@@ -57,25 +57,45 @@ endif
|
||||
@$(CC) -MM -MF $(call src_to_dep,$<) -MP -MT "$@ $(call src_to_dep,$<)" $(CFLAGS) $(_CFLAGS) $<
|
||||
@$(CC) -o $@ -c $< $(CFLAGS) $(_CFLAGS)
|
||||
|
||||
define add-target
|
||||
define add-target-deps
|
||||
all-srcs += $($1-srcs)
|
||||
all-objs += $(call src_to_obj,$($1-srcs))
|
||||
all-deps += $(call src_to_dep,$($1-srcs))
|
||||
all-clean += $1
|
||||
$(call src_to_obj,$($1-srcs)): _CFLAGS := $($1-cflags)
|
||||
endef
|
||||
|
||||
define add-bin-target
|
||||
|
||||
$(call add-target-deps,$1)
|
||||
|
||||
$1: $(call src_to_obj,$($1-srcs))
|
||||
@echo "LD $$@"
|
||||
@$$(CC) -o $$@ $$(filter %.o,$$^) $(LDFLAGS) $2
|
||||
$$(CC) -o $$@ $$(filter %.o,$$^) $(LDFLAGS) -static
|
||||
|
||||
$3: $1
|
||||
$(PREFIX)/bin/$1: $1
|
||||
@echo "INSTALL $$<"
|
||||
@install -D -m 755 $$< $$@
|
||||
|
||||
all-install += $3
|
||||
all-install += $(PREFIX)/bin/$1
|
||||
endef
|
||||
|
||||
define add-lib-target
|
||||
|
||||
$(call add-target-deps,$1)
|
||||
|
||||
$1: $(call src_to_obj,$($1-srcs))
|
||||
@echo "LD $$@"
|
||||
$$(CC) -o $$@ $$(filter %.o,$$^) $(LDFLAGS) -shared -Wl,-soname,$1.$(proj-major)
|
||||
|
||||
$(PREFIX)/lib/$1.$(proj-version): $1
|
||||
@echo "INSTALL $$<"
|
||||
@install -D -m 755 $$< $$@
|
||||
@ln -sf $1.$(proj-version) $(PREFIX)/lib/$1.$(proj-major)
|
||||
@ln -sf $1.$(proj-major) $(PREFIX)/lib/$1
|
||||
|
||||
all-install += $(PREFIX)/lib/$1.$(proj-version)
|
||||
endef
|
||||
add-bin-target = $(call add-target,$1,-static,$(PREFIX)/bin/$1)
|
||||
add-lib-target = $(call add-target,$1,-shared,$(PREFIX)/lib/$1)
|
||||
|
||||
$(foreach v,$(filter-out %.so,$(targets)),$(eval $(call add-bin-target,$v)))
|
||||
$(foreach v,$(filter %.so,$(targets)),$(eval $(call add-lib-target,$v)))
|
||||
|
||||
Reference in New Issue
Block a user