GNUmakefile 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. # DUMA configuration:
  2. #
  3. # add "-DDUMA_NO_GLOBAL_MALLOC_FREE" (without quotes)
  4. # for not defining malloc/free in global namespace
  5. #
  6. # add "-DDUMA_EXPLICIT_INIT" (without quotes)
  7. # to do all the "risky" stuff getenv(), sem_init(), write() .. explicitly
  8. # from main().
  9. # you have to call duma_init() explicitly from main() this option also
  10. # avoids leak error messages for allocations before duma_init() got called.
  11. # this helps for leaky standard environments.
  12. #
  13. # add "-DDUMA_NO_THREAD_SAFETY" (without quotes)
  14. # for not supporting multi-threading
  15. #
  16. # add "-DDUMA_SO_NO_CPP_SUPPORT" or "-DDUMA_LIB_NO_CPP_SUPPORT" (without quotes)
  17. # for not directing new/delete to malloc/free
  18. #
  19. # add "-DDUMA_SO_NO_LEAKDETECTION" or "-DDUMA_LIB_NO_LEAKDETECTION" (without quotes)
  20. # if you don't want support for leak detection
  21. #
  22. # add "-DDUMA_SO_PREFER_ATEXIT" or "-DDUMA_LIB_PREFER_ATEXIT" (without quotes)
  23. # if you prefer atexit() over GNU Compiler's function attribute "destructor"
  24. #
  25. # add "-DDUMA_SO_PREFER_GETENV" or "-DDUMA_LIB_PREFER_GETENV" (without quotes)
  26. # if you prefer standard C library getenv() over global char **environ
  27. #
  28. # add "-DDUMA_OLD_NEW_MACRO" (without quotes)
  29. # if you want to use DUMA's old style NEW_ELEM() / NEW_ARRAY() macros.
  30. # when not defining this option, a standard conform new syntax can get used.
  31. # unfortunately you have to use DEL_ELEM/DEL_ARRAY further to utilize
  32. # filename and linenumber of deallocation calls
  33. #
  34. # add "-DDUMA_SO_NO_HANG_MSG" or "-DDUMA_LIB_NO_HANG_MSG" (without quotes)
  35. # set this if you want to suppress the extra messages around atexit().
  36. #
  37. # add "-DDUMA_NO_STRERROR" (without quotes)
  38. # set this if you want to suppress calls to strerror() to avoid recursion
  39. # on specific platforms.
  40. #
  41. ########################################
  42. #
  43. # preprocessor flags for building the shared library (DUMA_SO_LIBRARY):
  44. # - DUMA_SO_NO_CPP_SUPPORT
  45. # - DUMA_SO_NO_LEAKDETECTION
  46. # - DUMA_SO_PREFER_ATEXIT
  47. # - DUMA_SO_PREFER_GETENV
  48. # - DUMA_SO_NO_HANG_MSG
  49. #
  50. # preprocessor flags for building the static library:
  51. # - DUMA_LIB_NO_CPP_SUPPORT
  52. # - DUMA_LIB_NO_LEAKDETECTION
  53. # - DUMA_LIB_PREFER_ATEXIT
  54. # - DUMA_LIB_PREFER_GETENV
  55. # - DUMA_LIB_NO_HANG_MSG
  56. # - DUMA_NO_GLOBAL_MALLOC_FREE
  57. # - DUMA_EXPLICIT_INIT
  58. # - DUMA_NO_THREAD_SAFETY
  59. # - DUMA_OLD_NEW_MACRO
  60. # - DUMA_OLD_DEL_MACRO
  61. # - DUMA_NO_STRERROR
  62. #
  63. ########################################
  64. # edit following line
  65. DUMA_OPTIONS=
  66. # no leak detection on any platform:
  67. # use static library for finding leaks - with information memory was allocated
  68. # i think leak-checking without further information is quite useless!
  69. # additionaly too many platforms/environments are broken.
  70. DUMA_OPTIONS += -DDUMA_SO_NO_LEAKDETECTION
  71. # some test cases:
  72. #DUMA_OPTIONS += -DDUMA_LIB_NO_LEAKDETECTION
  73. #DUMA_OPTIONS += -DDUMA_NO_THREAD_SAFETY
  74. #DUMA_OPTIONS += -DDUMA_NO_CPP_SUPPORT
  75. PIC=-fPIC -DPIC
  76. DUMA_SO_OPTIONS=$(PIC) -DDUMA_SO_LIBRARY
  77. # for FreeBSD 5.4
  78. # DUMA_OPTIONS += -DPAGE_PROTECTION_VIOLATED_SIGNAL=SIGBUS
  79. #
  80. # for FreeBSD 5.4 if DUMA_EXPLICIT_INIT is not set
  81. # DUMA_OPTIONS += -DDUMA_NO_LEAKDETECTION
  82. #
  83. # for cygwin environment on Windows
  84. # DUMA_OPTIONS += -DDUMA_EXPLICIT_INIT
  85. # also define 'WIN32'
  86. # some defaults:
  87. INSTALL=install
  88. RM=rm
  89. RMFORCE=rm -f
  90. ECHO=echo
  91. ECHOLF=echo .
  92. CC=cc
  93. CXX=c++
  94. LD=ld
  95. AR=ar
  96. RANLIB=ranlib
  97. INSTALL=install
  98. ifndef $(OS)
  99. OS=$(shell uname -s 2>/dev/null | tr '[:upper:]' '[:lower:]' 2>/dev/null || true)
  100. endif
  101. # dynamic dependencies
  102. DUMA_DYN_DEPS=$(DUMASO) tstheap_so$(EXEPOSTFIX) dumatestpp_so$(EXEPOSTFIX)
  103. # some OS specifics:
  104. ifeq ($(OS), windows_nt)
  105. ifeq ($(OSTYPE), msys)
  106. $(info using settings for OS=Windows_NT, OSTYPE=msys)
  107. # call mingw32-make OSTYPE=msys
  108. # from Windows command prompt
  109. # having added the PATH for MINGW/bin
  110. # using explicit initialization to avoid leak report
  111. # from __w32_sharedptr_initialize() function
  112. BSWITCH=101
  113. DUMA_OPTIONS += -DDUMA_EXPLICIT_INIT
  114. RM=del
  115. RMFORCE=del /F 2>nul
  116. ECHO=echo
  117. ECHOLF=echo .
  118. CURPATH=
  119. DUMA_DYN_DEPS=
  120. DUMASO=
  121. CFLAGS=-g -O0
  122. CPPFLAGS=-g -O0
  123. LIBS=
  124. EXEPOSTFIX=.exe
  125. endif
  126. ifeq ($(OSTYPE), msys-sh)
  127. $(info using settings for OS=Windows_NT, OSTYPE=msys-sh)
  128. # call mingw32-make OSTYPE=msyssh
  129. # from MSYS shell
  130. # having added the PATH for MINGW/bin
  131. # using explicit initialization to avoid leak report
  132. # from __w32_sharedptr_initialize() function
  133. BSWITCH=102
  134. DUMA_OPTIONS += -DDUMA_EXPLICIT_INIT
  135. CC=mingw32-gcc
  136. CXX=mingw32-g++
  137. RM=rm
  138. RMFORCE=rm -f
  139. ECHO=echo
  140. ECHOLF=echo
  141. CURPATH=./
  142. DUMA_DYN_DEPS=
  143. DUMASO=
  144. CFLAGS=-g -O0
  145. CPPFLAGS=-g -O0
  146. LIBS=
  147. EXEPOSTFIX=.exe
  148. endif
  149. ifeq ($(OSTYPE), cygwin)
  150. $(info using settings for OS=Windows_NT, OSTYPE=cygwin)
  151. # call make OSTYPE=cygwin
  152. BSWITCH=103
  153. DUMA_OPTIONS += -DDUMA_EXPLICIT_INIT
  154. CURPATH=./
  155. DUMA_DYN_DEPS=
  156. DUMASO=
  157. CFLAGS=-g -O0 -DWIN32 -Wall -Wextra
  158. CPPFLAGS=-g -O0 -DWIN32 -Wall -Wextra
  159. LIBS=
  160. EXEPOSTFIX=.exe
  161. endif
  162. ifndef BSWITCH
  163. $(info using settings for OS=Windows_NT)
  164. BSWITCH=100
  165. DUMA_OPTIONS += -DDUMA_EXPLICIT_INIT
  166. CURPATH=./
  167. DUMA_DYN_DEPS=
  168. DUMASO=
  169. CFLAGS=-g -O0 -DWIN32
  170. CPPFLAGS=-g -O0 -DWIN32
  171. LIBS=
  172. EXEPOSTFIX=.exe
  173. endif
  174. endif
  175. ifeq ($(OS), darwin)
  176. $(info using settings for OS=darwin)
  177. # call: make OS=darwin
  178. BSWITCH=210
  179. DUMA_OPTIONS += -DPAGE_PROTECTION_VIOLATED_SIGNAL=SIGBUS
  180. DUMA_OPTIONS += -DDUMA_SO_PREFER_GETENV
  181. # DUMA_OPTIONS += -DDUMA_LIB_NO_LEAKDETECTION
  182. CURPATH=./
  183. # DUMA_DYN_DEPS=
  184. DUMASO=libduma.dylib
  185. DUMASO_LINK1=libduma.dylib
  186. CFLAGS=-g -O0
  187. CPPFLAGS=-g -O0
  188. LIBS=-lpthread
  189. EXEPOSTFIX=
  190. endif
  191. ifeq ($(OS), freebsd)
  192. $(info using settings for OS=freebsd)
  193. BSWITCH=310
  194. DUMA_OPTIONS += -DDUMA_NO_THREAD_SAFETY
  195. DUMA_OPTIONS += -DDUMA_EXPLICIT_INIT
  196. CURPATH=./
  197. DUMA_DYN_DEPS=
  198. DUMASO=
  199. DUMASO_LINK1=
  200. CFLAGS=-g -O0
  201. CPPFLAGS=-g -O0
  202. LIBS=-lpthread
  203. EXEPOSTFIX=
  204. endif
  205. ifeq ($(OS), netbsd)
  206. $(info using settings for OS=netbsd)
  207. BSWITCH=320
  208. CURPATH=./
  209. DUMASO=libduma.so.0.0.0
  210. DUMASO_LINK1=libduma.so.0
  211. DUMASO_LINK2=libduma.so
  212. CFLAGS=-g -O0
  213. CPPFLAGS=-g -O0
  214. LIBS=-lpthread
  215. EXEPOSTFIX=
  216. endif
  217. ifeq ($(OS), solaris)
  218. $(info using settings for OS=solaris)
  219. BSWITCH=410
  220. DUMA_OPTIONS += -DDUMA_NO_STRERROR
  221. CURPATH=./
  222. DUMA_DYN_DEPS=
  223. DUMASO=libduma.so.0.0.0
  224. DUMASO_LINK1=libduma.so.0
  225. DUMASO_LINK2=libduma.so
  226. CFLAGS=-g -O0
  227. CPPFLAGS=-g -O0
  228. LDFLAGS += -lgcc_s
  229. LDOPTIONS += -lgcc_s
  230. LIBS=-Wl,-R/opt/sfw/lib -lpthread
  231. EXEPOSTFIX=
  232. endif
  233. ifeq ($(OS), linux)
  234. ifeq ($(shell $(CXX) -v 2>&1 | grep -c "clang version"), 1)
  235. COMPILERX := clang++
  236. else
  237. COMPILERX := g++
  238. endif
  239. export COMPILERX
  240. ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
  241. COMPILER := clang
  242. else
  243. COMPILER := gcc
  244. endif
  245. export COMPILER
  246. CC=${COMPILER}
  247. CXX=${COMPILERX}
  248. $(info using CC=${COMPILER})
  249. $(info using CXX=${COMPILERX})
  250. ifeq ($(OSTYPE), pie)
  251. $(info using settings for OS=linux, OSTYPE=pie)
  252. # Linux PIE-mode with GNU compiler and GNU tools.
  253. CC=${COMPILER} -fpie -fPIE
  254. CXX=${COMPILERX} -fpie -fPIE
  255. BSWITCH=510
  256. else
  257. $(info using settings for OS=linux)
  258. CC=${COMPILER}
  259. CXX=${COMPILERX}
  260. BSWITCH=610
  261. endif
  262. CURPATH=./
  263. DUMASO=libduma.so.0.0.0
  264. DUMASO_LINK1=libduma.so.0
  265. DUMASO_LINK2=libduma.so
  266. CFLAGS=-g -O0 -Wall -Wextra
  267. CPPFLAGS=-g -O0 -Wall -Wextra
  268. LIBS=-lpthread
  269. EXEPOSTFIX=
  270. RM=rm
  271. RMFORCE=rm -f
  272. ECHO=echo
  273. ECHOLF=printf '\n'
  274. endif
  275. ifndef BSWITCH
  276. # default is generic full "UNIX"
  277. BSWITCH=810
  278. $(warning using default options. OS/OSTYPE not set or contain unknown values!)
  279. CURPATH=./
  280. DUMASO=libduma.so.0.0.0
  281. DUMASO_LINK1=libduma.so.0
  282. DUMASO_LINK2=libduma.so
  283. CFLAGS=-g -O0 -Wall -Wextra
  284. CPPFLAGS=-g -O0 -Wall -Wextra
  285. LIBS=-lpthread
  286. EXEPOSTFIX=
  287. endif
  288. ifndef HOST_CFLAGS
  289. HOST_CFLAGS=$(CFLAGS)
  290. endif
  291. ifndef CC_FOR_BUILD
  292. CC_FOR_BUILD=$(CC)
  293. endif
  294. ############################################################
  295. ifndef prefix
  296. prefix=/usr
  297. $(info using default prefix [$(prefix)])
  298. endif
  299. MAN_INSTALL_DIR=$(prefix)/share/man/man3
  300. DOC_INSTALL_DIR=$(prefix)/share/doc/duma
  301. ifndef srcdir
  302. srcdir=.
  303. $(info using default srcdir [$(srcdir)])
  304. endif
  305. ifndef exec_prefix
  306. exec_prefix=$(prefix)
  307. $(info using default exec_prefix [$(exec_prefix)])
  308. endif
  309. # The directory for installing executable programs that users can run.
  310. ifndef bindir
  311. bindir=$(exec_prefix)/bin
  312. endif
  313. # The directory for installing read-only architecture independent data files.
  314. ifndef datadir
  315. datadir=$(prefix)/share
  316. endif
  317. # The directory for installing read-only data files that pertain to a single machine--that is to say, files for configuring a host.
  318. ifndef sysconfdir
  319. sysconfdir=$(prefix)/etc
  320. endif
  321. # The directory for object files and libraries of object code.
  322. ifndef libdir
  323. libdir=$(exec_prefix)/lib
  324. endif
  325. # The directory for installing header files to be included by user programs with the C `#include' preprocessor directive.
  326. ifndef includedir
  327. includedir=$(prefix)/include
  328. endif
  329. PACKAGE_SOURCE=README.txt CHANGELOG LICENSE COPYING-GPL COPYING-LGPL duma.3 GNUmakefile gdbinit.rc \
  330. duma.h dumapp.h duma_sem.h paging.h print.h duma_hlp.h noduma.h \
  331. duma.c dumapp.cpp sem_inc.c print.c \
  332. tests/dumatest.c tests/tstheap.c tests/thread-test.c tests/testmt.c tests/dumatestpp.cpp tests/testoperators.cpp \
  333. createconf.c make_git_source_version.sh
  334. OBJECTS=dumapp.o duma.o sem_inc.o print.o
  335. SO_OBJECTS=dumapp_so.o duma_so.o sem_inc_so.o print_so.o
  336. # Make all the top-level targets the makefile knows about.
  337. all: verinfo.h libduma.a $(DUMA_DYN_DEPS)
  338. @ $(ECHO) "Build complete - you can now run make test."
  339. # Perform self tests on the program this makefile builds.
  340. check test: tstheap$(EXEPOSTFIX) dumatest$(EXEPOSTFIX) thread-test$(EXEPOSTFIX) testmt$(EXEPOSTFIX) dumatestpp$(EXEPOSTFIX) testoperators$(EXEPOSTFIX) $(DUMA_DYN_DEPS)
  341. @ $(ECHOLF)
  342. @ $(ECHO) "Testing DUMA (static library):"
  343. $(CURPATH)dumatest$(EXEPOSTFIX)
  344. @ $(ECHOLF)
  345. $(CURPATH)tstheap$(EXEPOSTFIX) 3072
  346. @ $(ECHOLF)
  347. $(CURPATH)testoperators$(EXEPOSTFIX)
  348. @ $(ECHOLF)
  349. @ $(ECHO) "DUMA static confidence test PASSED."
  350. ifdef DUMASO
  351. @ $(ECHOLF)
  352. @ $(ECHO) "Testing DUMA (dynamic library)."
  353. ifeq ($(OS), solaris)
  354. LD_PRELOAD=./$(DUMASO) DYLD_INSERT_LIBRARIES=./$(DUMASO) DYLD_FORCE_FLAT_NAMESPACE=1 exec $(CURPATH)tstheap_so 3072
  355. else
  356. (export LD_PRELOAD=./$(DUMASO); export DYLD_INSERT_LIBRARIES=./$(DUMASO); export DYLD_FORCE_FLAT_NAMESPACE=1 ; exec $(CURPATH)tstheap_so 3072)
  357. endif
  358. @ $(ECHOLF)
  359. @ $(ECHO) "DUMA dynamic confidence test PASSED."
  360. @ $(ECHOLF)
  361. @ $(ECHO) "You may now run make install and then installcheck"
  362. @ $(ECHOLF)
  363. endif
  364. # Perform installation tests (if any).
  365. # The user must build and install the program before running the tests.
  366. installcheck:
  367. ifdef DUMASO
  368. @ $(ECHOLF)
  369. @ $(ECHO) "Testing installed DUMA (dynamic library)."
  370. @ $(bindir)/duma $(CURPATH)tstheap_so 3072
  371. @ $(ECHOLF)
  372. @ $(ECHO) "DUMA installcheck test PASSED."
  373. @ $(ECHOLF)
  374. endif
  375. # Print variables of GNUmakefile
  376. printvars:
  377. @echo OS [$(OS)]
  378. @echo OSTYPE [$(OSTYPE)]
  379. @echo bswitch [$(BSWITCH)]
  380. @echo srcdir [$(srcdir)]
  381. @echo prefix [$(prefix)]
  382. @echo exec_prefix [$(exec_prefix)]
  383. @echo bindir [$(bindir)]
  384. @echo datadir [$(datadir)]
  385. @echo sysconfdir [$(sysconfdir)]
  386. @echo libdir [$(libdir)]
  387. @echo includedir [$(includedir)]
  388. ifneq ($(oldincludedir),)
  389. @echo oldincludedir [$(oldincludedir)]
  390. else
  391. @echo oldincludedir empty
  392. endif
  393. @echo MAN_INSTALL_DIR [$(MAN_INSTALL_DIR)]
  394. @echo DOC_INSTALL_DIR [$(DOC_INSTALL_DIR)]
  395. @echo MAKE [$(MAKE)]
  396. @echo CC [$(CC)]
  397. @echo CFLAGS [$(CFLAGS)]
  398. @echo CXX [$(CXX)]
  399. @echo CPPFLAGS [$(CPPFLAGS)]
  400. @echo LD [$(LD)]
  401. @echo AR [$(AR)]
  402. @echo LIBS [$(LIBS)]
  403. @echo RANLIB [$(RANLIB)]
  404. @echo INSTALL [$(INSTALL)]
  405. @echo RM [$(RM)]
  406. @echo RMFORCE [$(RMFORCE)]
  407. @echo ECHO [$(ECHO)]
  408. @echo ECHOLF [$(ECHOLF)]
  409. @echo PIC [$(PIC)]
  410. @echo EXEPOSTFIX [$(EXEPOSTFIX)]
  411. @echo CURPATH [$(CURPATH)]
  412. @echo DUMA_OPTIONS [$(DUMA_OPTIONS)]
  413. @echo DUMA_SO_OPTIONS [$(DUMA_SO_OPTIONS)]
  414. @echo OBJECTS [$(OBJECTS)]
  415. @echo SO_OBJECTS [$(SO_OBJECTS)]
  416. @echo DUMASO [$(DUMASO)]
  417. @echo DUMASO_LINK1 [$(DUMASO_LINK1)]
  418. @echo DUMASO_LINK2 [$(DUMASO_LINK2)]
  419. @echo DUMA_DYN_DEPS [$(DUMA_DYN_DEPS)]
  420. @echo PACKAGE_SOURCE [$(PACKAGE_SOURCE)]
  421. # Print filenames unknown to git
  422. printuk:
  423. - git status -s --untracked-files=all 2>/dev/null | grep '^? '
  424. # Print filenames known to git but not "up-to-date" (modified)
  425. printmod:
  426. - git status -s 2>/dev/null |grep '^\ \?M '
  427. # Copy the executable file into a directory that users typically search for
  428. # commands; copy any auxiliary files that the executable uses into the
  429. # directories where it will look for them.
  430. install: libduma.a duma.3 $(DUMASO)
  431. - mkdir -p $(DESTDIR)$(DOC_INSTALL_DIR)
  432. $(INSTALL) -m 644 README.txt $(DESTDIR)$(DOC_INSTALL_DIR)
  433. - mkdir -p $(DESTDIR)$(includedir)
  434. $(INSTALL) -m 644 noduma.h duma.h dumapp.h duma_sem.h duma_config.h $(DESTDIR)$(includedir)
  435. - mkdir -p $(DESTDIR)$(bindir)
  436. $(INSTALL) -m 755 duma.sh $(DESTDIR)$(bindir)/duma
  437. - mkdir -p $(DESTDIR)$(libdir)
  438. $(INSTALL) -m 644 libduma.a $(DESTDIR)$(libdir)
  439. ifdef DUMASO
  440. $(INSTALL) -m 755 $(DUMASO) $(DESTDIR)$(libdir)
  441. endif
  442. ifdef DUMASO_LINK1
  443. - $(RMFORCE) $(DESTDIR)$(libdir)/$(DUMASO_LINK1)
  444. ln -s $(DUMASO) $(DESTDIR)$(libdir)/$(DUMASO_LINK1)
  445. endif
  446. ifdef DUMASO_LINK2
  447. - $(RMFORCE) $(DESTDIR)$(libdir)/$(DUMASO_LINK2)
  448. ln -s $(DUMASO) $(DESTDIR)$(libdir)/$(DUMASO_LINK2)
  449. endif
  450. - mkdir -p $(DESTDIR)$(MAN_INSTALL_DIR)
  451. $(INSTALL) -m 644 duma.3 $(DESTDIR)/$(MAN_INSTALL_DIR)/duma.3
  452. # Delete all the installed files that the `install' target would create
  453. uninstall:
  454. - $(RMFORCE) $(DESTDIR)$(DOC_INSTALL_DIR)/README.txt
  455. - $(RMFORCE) $(DESTDIR)$(includedir)/noduma.h
  456. - $(RMFORCE) $(DESTDIR)$(includedir)/duma.h
  457. - $(RMFORCE) $(DESTDIR)$(includedir)/dumapp.h
  458. - $(RMFORCE) $(DESTDIR)$(includedir)/duma_sem.h
  459. - $(RMFORCE) $(DESTDIR)$(includedir)/duma_config.h
  460. - $(RMFORCE) $(DESTDIR)$(bindir)/duma
  461. - $(RMFORCE) $(DESTDIR)$(libdir)/libduma.a
  462. ifdef DUMASO
  463. - $(RMFORCE) $(DESTDIR)$(libdir)/$(DUMASO)
  464. endif
  465. ifdef DUMASO_LINK1
  466. - $(RMFORCE) $(DESTDIR)$(libdir)/$(DUMASO_LINK1)
  467. endif
  468. ifdef DUMASO_LINK2
  469. - $(RMFORCE) $(DESTDIR)$(libdir)/$(DUMASO_LINK2)
  470. endif
  471. - $(RMFORCE) $(DESTDIR)$(MAN_INSTALL_DIR)/duma.3
  472. # Delete all files that are normally created by running make.
  473. clean:
  474. - $(RMFORCE) $(OBJECTS) $(SO_OBJECTS) tstheap.o dumatest.o thread-test.o testmt.o dumatestpp.o \
  475. tstheap_so.o dumatestpp_so.o testoperators.o \
  476. tstheap$(EXEPOSTFIX) tstheap_so$(EXEPOSTFIX) dumatest$(EXEPOSTFIX) dumatestpp$(EXEPOSTFIX) dumatestpp_so$(EXEPOSTFIX) testoperators$(EXEPOSTFIX) \
  477. thread-test$(EXEPOSTFIX) testmt$(EXEPOSTFIX) \
  478. libduma.a $(DUMASO) libduma.cat DUMA.shar
  479. # Any of these targets might be defined to delete more files than `clean' does.
  480. # For example, this would delete configuration files or links that you would
  481. # normally create as preparation for compilation, even if the makefile itself
  482. # cannot create these files.
  483. distclean realclean clobber: clean
  484. - $(RMFORCE) duma_config.h verinfo.h createconf.o createconf$(EXEPOSTFIX)
  485. roff:
  486. nroff -man < duma.3 > duma.cat
  487. DUMA.shar: $(PACKAGE_SOURCE)
  488. shar $(PACKAGE_SOURCE) > DUMA.shar
  489. shar: DUMA.shar
  490. libduma.a: duma_config.h verinfo.h $(OBJECTS)
  491. - $(RMFORCE) libduma.a
  492. $(AR) crv libduma.a $(OBJECTS)
  493. $(RANLIB) libduma.a
  494. verinfo.h: FORCE
  495. - $(CURPATH)make_git_source_version.sh > $(CURPATH)verinfo.h
  496. $(shell touch verinfo.h || true)
  497. duma_config.h:
  498. $(MAKE) reconfig
  499. reconfig: createconf$(EXEPOSTFIX) createconf.o createconf.c
  500. - $(CURPATH)createconf$(EXEPOSTFIX)
  501. dos2unix:
  502. @ dos2unix --d2u $(PACKAGE_SOURCE)
  503. createconf$(EXEPOSTFIX): createconf.o
  504. - $(RMFORCE) createconf$(EXEPOSTFIX)
  505. $(CC_FOR_BUILD) $(HOST_CFLAGS) $(DUMA_OPTIONS) createconf.o -o createconf$(EXEPOSTFIX)
  506. tstheap$(EXEPOSTFIX): libduma.a tstheap.o
  507. - $(RMFORCE) tstheap$(EXEPOSTFIX)
  508. $(CC) $(CFLAGS) tstheap.o libduma.a -o tstheap$(EXEPOSTFIX) $(LIBS)
  509. dumatest$(EXEPOSTFIX): libduma.a dumatest.o
  510. - $(RMFORCE) dumatest$(EXEPOSTFIX)
  511. $(CC) $(CFLAGS) dumatest.o libduma.a -o dumatest$(EXEPOSTFIX) $(LIBS)
  512. dumatestpp$(EXEPOSTFIX): libduma.a dumatestpp.o duma_sem.h dumapp.h
  513. - $(RMFORCE) dumatestpp$(EXEPOSTFIX)
  514. $(CXX) $(CPPFLAGS) dumatestpp.o libduma.a -o dumatestpp$(EXEPOSTFIX) $(LIBS)
  515. thread-test$(EXEPOSTFIX): libduma.a thread-test.o
  516. - $(RMFORCE) thread-test$(EXEPOSTFIX)
  517. $(CC) $(CFLAGS) thread-test.o libduma.a -o thread-test$(EXEPOSTFIX) $(LIBS)
  518. testmt$(EXEPOSTFIX): libduma.a testmt.o
  519. - $(RMFORCE) testmt$(EXEPOSTFIX)
  520. $(CC) $(CFLAGS) testmt.o libduma.a -o testmt$(EXEPOSTFIX) $(LIBS)
  521. testoperators$(EXEPOSTFIX): libduma.a testoperators.o duma_sem.h dumapp.h
  522. - $(RMFORCE) testoperators$(EXEPOSTFIX)
  523. $(CXX) $(CPPFLAGS) testoperators.o libduma.a -o testoperators$(EXEPOSTFIX) $(LIBS)
  524. testmemlimit$(EXEPOSTFIX): libduma.a testmemlimit.o
  525. - $(RMFORCE) testmemlimit$(EXEPOSTFIX)
  526. $(CC) $(CFLAGS) testmemlimit.o libduma.a -o testmemlimit$(EXEPOSTFIX) $(LIBS)
  527. tstheap_so$(EXEPOSTFIX): tstheap_so.o
  528. - $(RMFORCE) tstheap_so$(EXEPOSTFIX)
  529. $(CC) $(CFLAGS) tstheap_so.o -o tstheap_so$(EXEPOSTFIX) $(LIBS)
  530. dumatestpp_so$(EXEPOSTFIX): dumatestpp_so.o
  531. - $(RMFORCE) dumatestpp_so$(EXEPOSTFIX)
  532. $(CXX) $(CPPFLAGS) dumatestpp_so.o -o dumatestpp_so$(EXEPOSTFIX) $(LIBS)
  533. testmemlimit_so$(EXEPOSTFIX): testmemlimit_so.o
  534. - $(RMFORCE) testmemlimit_so$(EXEPOSTFIX)
  535. $(CC) $(CFLAGS) testmemlimit_so.o -o testmemlimit_so$(EXEPOSTFIX) $(LIBS)
  536. $(OBJECTS) tstheap.o dumatest.o thread-test.o testmt.o dumatestpp.o: duma.h
  537. ifeq ($(OS), windows_nt)
  538. # do nothing
  539. else
  540. ifeq ($(OS), darwin)
  541. $(DUMASO): duma_config.h verinfo.h $(SO_OBJECTS)
  542. $(CXX) -g -dynamiclib -Wl -o $(DUMASO) $(SO_OBJECTS) -lpthread -lc
  543. $(CXX) -g -dynamiclib -o $(DUMASO) $(SO_OBJECTS) -lpthread -lc
  544. else
  545. $(DUMASO): duma_config.h verinfo.h $(SO_OBJECTS)
  546. $(CXX) -g -shared -Wl,-soname,$(DUMASO) -o $(DUMASO) $(SO_OBJECTS) -lpthread -lc
  547. # $(CXX) -g -shared -o $(DUMASO) $(SO_OBJECTS) -lpthread -lc
  548. endif
  549. endif
  550. #
  551. # define rules how to build objects for createconf
  552. #
  553. createconf.o:
  554. $(CC_FOR_BUILD) $(HOST_CFLAGS) $(DUMA_OPTIONS) -c createconf.c -o $@
  555. #
  556. # define rules how to build objects for shared library
  557. #
  558. dumapp_so.o: dumapp.cpp duma.h duma_sem.h dumapp.h
  559. $(CXX) $(CPPFLAGS) $(DUMA_SO_OPTIONS) -c dumapp.cpp -o $@
  560. duma_so.o: duma.c duma.h duma_config.h verinfo.h
  561. $(CC) $(CFLAGS) $(DUMA_SO_OPTIONS) -c duma.c -o $@
  562. sem_inc_so.o: sem_inc.c duma_sem.h
  563. $(CC) $(CFLAGS) $(DUMA_SO_OPTIONS) -c sem_inc.c -o $@
  564. print_so.o: print.c print.h
  565. $(CC) $(CFLAGS) $(DUMA_SO_OPTIONS) -c print.c -o $@
  566. # DUMA_SO_OPTIONS needed cause duma.h is included explicitly
  567. tstheap_so.o:
  568. $(CC) $(CFLAGS) $(DUMA_SO_OPTIONS) -c tests/tstheap.c -o $@
  569. dumatestpp_so.o:
  570. $(CXX) $(CPPFLAGS) $(DUMA_SO_OPTIONS) -c tests/dumatestpp.cpp -o $@
  571. testmemlimit_so.o:
  572. $(CC) $(CFLAGS) $(DUMA_SO_OPTIONS) -c tests/testmemlimit.c -o $@
  573. #
  574. # define rules how to build objects for static library
  575. #
  576. dumapp.o: dumapp.cpp duma.h duma_sem.h dumapp.h
  577. $(CXX) $(CPPFLAGS) -c dumapp.cpp -o $@
  578. duma.o: duma.c duma.h duma_config.h verinfo.h
  579. $(CC) $(CFLAGS) -c duma.c -o $@
  580. sem_inc.o: sem_inc.c duma_sem.h
  581. $(CC) $(CFLAGS) -c sem_inc.c -o $@
  582. print.o: print.c print.h
  583. $(CC) $(CFLAGS) -c print.c -o $@
  584. #
  585. # define rules how to build the test objects
  586. #
  587. dumatest.o: tests/dumatest.c duma.h duma_config.h verinfo.h
  588. $(CC) $(CFLAGS) -c tests/dumatest.c -o $@
  589. dumatestpp.o: tests/dumatestpp.cpp duma.h duma_sem.h dumapp.h duma_config.h verinfo.h
  590. $(CXX) $(CPPFLAGS) -c tests/dumatestpp.cpp -o $@
  591. tstheap.o: tests/tstheap.c duma.h duma_config.h verinfo.h
  592. $(CC) $(CFLAGS) -c tests/tstheap.c -o $@
  593. testoperators.o: tests/testoperators.cpp duma.h duma_sem.h dumapp.h duma_config.h verinfo.h
  594. $(CXX) $(CPPFLAGS) -c tests/testoperators.cpp -o $@
  595. thread-test.o: tests/thread-test.c duma.h duma_config.h verinfo.h
  596. $(CC) $(CFLAGS) -c tests/thread-test.c -o $@
  597. testmt.o: tests/testmt.c duma.h duma_config.h verinfo.h
  598. $(CC) $(CFLAGS) -c tests/testmt.c -o $@
  599. #
  600. # default rules
  601. #
  602. #.c.o:
  603. # $(CC) $(CFLAGS) -c $< -o $@
  604. #
  605. #.cpp.o:
  606. # $(CXX) $(CPPFLAGS) -c $< -o $@
  607. #
  608. .PHONY: check test installcheck install uninstall clean distclean realclean clobber dos2unix printvars printuk printmod FORCE
  609. FORCE: