##
## Copyright (C) JAEHYUK CHO
## All rights reserved.
## Code by JaeHyuk Cho <mailto:minzkn@minzkn.com>
##
UNIVERSAL_ARCH:=i386 x86_64#
# iOS SDK가 설치된 경우
UNIVERSAL_ARCH+=ppc#
.PHONY: all clean
all: test
clean:
rm -f *.o test $(foreach s_this_arch,$(UNIVERSAL_ARCH),*.o.$(s_this_arch) test.$(s_this_arch))
test: test.o libtest.a libtest.so libpthread.so
ifneq ($(UNIVERSAL_ARCH),)
$(foreach s_this_arch,$(UNIVERSAL_ARCH),\
gcc -o $(@).$(s_this_arch) $(^:%.o=%.o.$(s_this_arch));\
)
lipo -create $(UNIVERSAL_ARCH:%=$(@).%) -output $(@)
else
gcc -o $(@) $(^)
endif
libtest.so: test_shared_api.o
ifneq ($(UNIVERSAL_ARCH),)
$(foreach s_this_arch,$(UNIVERSAL_ARCH),\
gcc -shared -dynamiclib -dylinker_install_name $(notdir $(@)) -o $(@).$(s_this_arch) $(^:%=%.$(s_this_arch));\
)
lipo -create $(UNIVERSAL_ARCH:%=$(@).%) -output $(@)
else
gcc -shared -dynamiclib -dylinker_install_name $(notdir $(@)) -o $(@) $(^)
endif
libtest.a: test_static_api.o
ifneq ($(UNIVERSAL_ARCH),)
$(foreach s_this_arch,$(UNIVERSAL_ARCH),\
ar rc $(@).$(s_this_arch) $(^:%=%.$(s_this_arch));\
)
lipo -create $(UNIVERSAL_ARCH:%=$(@).%) -output $(@)
else
ar rc $(@) $(^)
endif
%.o: %.c
ifneq ($(UNIVERSAL_ARCH),)
$(foreach s_this_arch,$(UNIVERSAL_ARCH),\
gcc -c -o $(@).$(s_this_arch) $(<);\
)
lipo -create $(UNIVERSAL_ARCH:%=$(@).%) -output $(@)
else
gcc -c -o $(@) $(<)
endif