# Arch independent components for creating stub libraries

STUBLIBS=$(subst .Version,,$(wildcard *.Version))
CFILES = $(addsuffix .c,$(STUBLIBS))
OFILES = $(subst .c,.o,$(CFILES))
SOFILES = $(subst .c,.so,$(CFILES))
CFLAGS=-g -Wall  -fno-builtin 
INSTALL_DIR=$(INSTALL_ROOT)/$(LIBDIR)

# For ppc64 platform add flag to generate 64-bit shared libs
ifeq ($(shell arch),ppc64)
	LD=ld -m elf64ppc
else
	LD=ld
endif

%.so : %.o
	$(LD) -shared -o $@ --version-script $(subst .o,.Version,$<) -h `grep "$(subst .o,,$<) " LibNameMap.txt | cut -f2 -d' '`  $<

libs: $(OFILES) $(SOFILES)

distclean: clean
	rm -f  *.c *.Version LibNameMap.txt

clean:
	rm -f $(OFILES) *.so


.PHONY: clean distclean libs

install:
	install -d $(INSTALL_DIR)
	install $(SOFILES) $(INSTALL_DIR)
	mv $(INSTALL_DIR)/libstdcxx.so $(INSTALL_DIR)/libstdc++.so

