Makefile 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ifeq ($(OS), Windows_NT)
  2. PIC_FLAG =
  3. STATIC_EXT = lib
  4. DYNAMIC_EXT = dll
  5. else
  6. PIC_FLAG = -fPIC
  7. STATIC_EXT = a
  8. DYNAMIC_EXT = so
  9. endif
  10. STATIC_LIBS = libxrcu.$(STATIC_EXT)
  11. SHARED_LIBS = libxrcu.$(DYNAMIC_EXT)
  12. HEADERS = xrcu.hpp stack.hpp hash_table.hpp skip_list.hpp \
  13. xatomic.hpp lwlock.hpp optional.hpp queue.hpp
  14. OBJS = xrcu.o hash_table.o stack.o lwlock.o skip_list.o queue.o utils.o
  15. LOBJS = $(OBJS:.o=.lo)
  16. TEST_OBJS = $(LOBJS)
  17. -include config.mak
  18. ALL_LIBS = $(STATIC_LIBS) $(SHARED_LIBS)
  19. AR = $(CROSS_COMPILE)ar
  20. RANLIB = $(CROSS_COMPILE)ranlib
  21. CXXFLAGS += $(CXXFLAGS_AUTO)
  22. all: $(ALL_LIBS)
  23. check: $(TEST_OBJS)
  24. $(CXX) $(CXXFLAGS) tests/test.cpp $(TEST_OBJS) -o tst
  25. ./tst
  26. %.o: %.cpp $(HEADERS)
  27. $(CXX) $(CXXFLAGS) -c $< -o $@
  28. %.lo: %.cpp $(HEADERS)
  29. $(CXX) $(CXXFLAGS) $(PIC_FLAG) -c $< -o $@
  30. libxrcu.$(STATIC_EXT): $(OBJS)
  31. rm -f $@
  32. $(AR) rc $@ $(OBJS)
  33. $(RANLIB) $@
  34. libxrcu.$(DYNAMIC_EXT): $(LOBJS)
  35. $(CXX) -fPIC -shared $(CXXFLAGS) -o $@ $(LOBJS)
  36. install: $(ALL_LIBS)
  37. mkdir -p $(includedir)/xrcu
  38. cp libxrcu* $(libdir)/
  39. cp $(HEADERS) $(includedir)/xrcu
  40. clean:
  41. rm -rf *.o *.lo libxrcu.* tst