Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. CC = gcc
  2. CFLAGS = -O2 -Wall
  3. # MAC_BUILD - set this to "universal" to build a 2-way fat library
  4. MAC_BUILD = universal
  5. # if ARCH set, disable universal build on the mac
  6. ifdef ARCH
  7. MAC_BUILD =
  8. else
  9. ARCH = $(shell uname -m)
  10. endif
  11. UNAME = $(shell uname -s)
  12. ifeq ($(UNAME), Linux)
  13. RANLIB=ranlib
  14. CFLAGS+=-D_GNU_SOURCE -fPIC
  15. endif
  16. ifeq ($(UNAME), SunOS)
  17. RANLIB=/bin/true
  18. PATH +=:/usr/perl5/5.10.0/bin:/usr/perl5/5.12/bin
  19. CFLAGS += -fPIC
  20. ifeq ($(ARCH), i86pc)
  21. ARCH = $(shell isainfo -k)
  22. ifeq ($(ARCH), amd64)
  23. ARCH = x86_64
  24. else
  25. ARCH = i386
  26. endif
  27. endif
  28. ifeq ($(ARCH), x86_64)
  29. CFLAGS += -m64
  30. else
  31. CFLAGS += -m32
  32. endif
  33. endif
  34. ifeq ($(UNAME), FreeBSD)
  35. RANLIB=ranlib
  36. CFLAGS += -Wno-error=unknown-pragmas -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common
  37. CFLAGS += -fPIC
  38. ifeq ($(ARCH), i386)
  39. CFLAGS += -m32
  40. endif
  41. ifeq ($(ARCH), amd64)
  42. ARCH = x86_64
  43. endif
  44. endif
  45. ifeq ($(UNAME), Darwin)
  46. RANLIB=ranlib
  47. ifeq ($(MAC_BUILD), universal)
  48. CFLAGS += -arch i386 -arch x86_64
  49. else
  50. CFLAGS += -arch $(ARCH)
  51. endif
  52. endif
  53. # main library build
  54. objects = usdt.o usdt_dof_file.o usdt_tracepoints.o usdt_probe.o usdt_dof.o usdt_dof_sections.o
  55. headers = usdt.h usdt_internal.h
  56. .c.o: $(headers)
  57. all: libusdt.a
  58. libusdt.a: $(objects) $(headers)
  59. rm -f libusdt.a
  60. $(AR) cru libusdt.a $(objects)
  61. $(RANLIB) libusdt.a
  62. # Tracepoints build.
  63. #
  64. # If on Darwin and building a universal library, manually assemble a
  65. # two-way fat object file from both the 32 and 64 bit tracepoint asm
  66. # files.
  67. #
  68. # Otherwise, just choose the appropriate asm file based on the build
  69. # architecture.
  70. ifeq ($(UNAME), Darwin)
  71. ifeq ($(MAC_BUILD), universal)
  72. usdt_tracepoints_i386.o: usdt_tracepoints_i386.s
  73. $(CC) -arch i386 -o usdt_tracepoints_i386.o -c usdt_tracepoints_i386.s
  74. usdt_tracepoints_x86_64.o: usdt_tracepoints_x86_64.s
  75. $(CC) -arch x86_64 -o usdt_tracepoints_x86_64.o -c usdt_tracepoints_x86_64.s
  76. usdt_tracepoints.o: usdt_tracepoints_i386.o usdt_tracepoints_x86_64.o
  77. lipo -create -output usdt_tracepoints.o usdt_tracepoints_i386.o \
  78. usdt_tracepoints_x86_64.o
  79. else # Darwin, not universal
  80. usdt_tracepoints.o: usdt_tracepoints_$(ARCH).s
  81. $(CC) -arch $(ARCH) -o usdt_tracepoints.o -c usdt_tracepoints_$(ARCH).s
  82. endif
  83. else # not Darwin; FreeBSD and Illumos
  84. ifeq ($(ARCH), x86_64)
  85. usdt_tracepoints.o: usdt_tracepoints_x86_64.s
  86. $(CC) $(CFLAGS) -o usdt_tracepoints.o -c usdt_tracepoints_x86_64.s
  87. endif
  88. ifeq ($(ARCH), i386)
  89. usdt_tracepoints.o: usdt_tracepoints_i386.s
  90. $(CC) $(CFLAGS) -o usdt_tracepoints.o -c usdt_tracepoints_i386.s
  91. endif
  92. endif
  93. clean:
  94. rm -f *.gch
  95. rm -f *.o
  96. rm -f libusdt.a
  97. rm -f test_usdt
  98. rm -f test_usdt32
  99. rm -f test_usdt64
  100. rm -f test_mem_usage
  101. .PHONY: clean test
  102. # testing
  103. test_mem_usage: libusdt.a test_mem_usage.o
  104. $(CC) $(CFLAGS) -o test_mem_usage test_mem_usage.o libusdt.a
  105. ifeq ($(UNAME), Darwin)
  106. ifeq ($(MAC_BUILD), universal)
  107. test_usdt64: libusdt.a test_usdt.o
  108. $(CC) -arch x86_64 -o test_usdt64 test_usdt.o libusdt.a
  109. test_usdt32: libusdt.a test_usdt.o
  110. $(CC) -arch i386 -o test_usdt32 test_usdt.o libusdt.a
  111. else
  112. test_usdt: libusdt.a test_usdt.o
  113. $(CC) $(CFLAGS) -o test_usdt test_usdt.o libusdt.a
  114. endif
  115. else
  116. test_usdt: libusdt.a test_usdt.o
  117. $(CC) $(CFLAGS) -o test_usdt test_usdt.o libusdt.a
  118. endif
  119. ifeq ($(UNAME), Darwin)
  120. ifeq ($(MAC_BUILD), universal)
  121. test: test_usdt32 test_usdt64
  122. sudo prove test.pl :: 64
  123. sudo prove test.pl :: 32
  124. else
  125. test: test_usdt
  126. sudo prove test.pl
  127. endif
  128. else
  129. test: test_usdt
  130. sudo prove test.pl
  131. endif