Makefile 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. #
  2. # Library: libcrc
  3. # File: Makefile
  4. # Author: Lammert Bies
  5. #
  6. # This file is licensed under the MIT License as stated below
  7. #
  8. # Copyright (c) 1999-2019 Lammert Bies
  9. #
  10. # Permission is hereby granted, free of charge, to any person obtaining a copy
  11. # of this software and associated documentation files (the "Software"), to deal
  12. # in the Software without restriction, including without limitation the rights
  13. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14. # copies of the Software, and to permit persons to whom the Software is
  15. # furnished to do so, subject to the following conditions:
  16. #
  17. # The above copyright notice and this permission notice shall be included in all
  18. # copies or substantial portions of the Software.
  19. #
  20. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  23. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  26. # SOFTWARE.
  27. #
  28. # Description
  29. # -----------
  30. # This Makefile is used to build the libcrc library. The only action you should
  31. # normally have to do is to run the make program from the command line,
  32. # independent on the Operating System you are working on.
  33. #
  34. # This Makefile is manually maintained. No autoconf or automake involved. This
  35. # was a deliberate decision due to the absense of these tools on some systems,
  36. # in particular in Windows environments.
  37. #
  38. # Dependencies
  39. # ------------
  40. # This Makefile is known to be functional with GNU Make. Other make utilities
  41. # may work or may have problems. GNU Make is available both in source code
  42. # and precompiled binaries for a large number of environments and therefore
  43. # you are recommended to install a version of GNU Make if you encounter
  44. # problems with the default make utility in your development chain.
  45. #
  46. # Aside from GNU Make and the standard C compiler headers and libraries which
  47. # should have been installed already together with your compiler there are no
  48. # other known dependencies.
  49. #
  50. # Library Type
  51. # ------------
  52. # The generated library is a library useable for static linking in this
  53. # source directory structure. The decision for a static linkable library
  54. # was deliberate because of the relatively small size of the library and the
  55. # routines and to avoid version and dependency issues when distributing the
  56. # end application to different environments.
  57. #
  58. ifeq ($(OS),Windows_NT)
  59. BINDIR = bin\\
  60. GENDIR = precalc\\
  61. INCDIR = include\\
  62. LIBDIR = lib\\
  63. OBJDIR = obj\\
  64. SRCDIR = src\\
  65. TABDIR = tab\\
  66. TSTDIR = test\\
  67. EXADIR = examples\\
  68. CC = cl
  69. LINK = link
  70. RM = del /q
  71. STRIP = dir
  72. OBJEXT = .obj
  73. LIBEXT = .lib
  74. EXEEXT = .exe
  75. OFLAG = -Fo
  76. XFLAG = /NOLOGO /OUT:
  77. AR = lib
  78. ARQC = /NOLOGO /OUT:
  79. ARQ = /NOLOGO
  80. RANLIB = dir
  81. CFLAGS = -Ox -Ot -MT -GT -volatile:iso -I${INCDIR} -nologo -J -sdl -Wall -WX \
  82. -wd4464 -wd4668 -wd4710 -wd4711 -wd4201 -wd4820
  83. else
  84. BINDIR = bin/
  85. GENDIR = precalc/
  86. INCDIR = include/
  87. LIBDIR = lib/
  88. OBJDIR = obj/
  89. SRCDIR = src/
  90. TABDIR = tab/
  91. TSTDIR = test/
  92. EXADIR = examples/
  93. CC ?= cc
  94. LINK ?= $(CC)
  95. RM = /bin/rm -f
  96. STRIP = strip
  97. OBJEXT = .o
  98. LIBEXT = .a
  99. EXEEXT =
  100. OFLAG = -o
  101. XFLAG = -o
  102. AR = ar
  103. ARQC = qc
  104. ARQ = q
  105. RANLIB = ranlib
  106. CFLAGS = -Wall -Wextra -Wstrict-prototypes -Wshadow -Wpointer-arith \
  107. -Wcast-qual -Wcast-align -Wwrite-strings -Wredundant-decls \
  108. -Wnested-externs -Werror -O3 \
  109. -funsigned-char -I${INCDIR}
  110. endif
  111. #
  112. # Default compile commands for the source files
  113. #
  114. ${OBJDIR}%${OBJEXT} : ${SRCDIR}%.c
  115. ${CC} -c ${CFLAGS} ${OFLAG}$@ $<
  116. ${TSTDIR}${OBJDIR}%${OBJEXT} : ${TSTDIR}%.c
  117. ${CC} -c ${CFLAGS} ${OFLAG}$@ $<
  118. ${GENDIR}${OBJDIR}%${OBJEXT} : ${GENDIR}%.c
  119. ${CC} -c ${CFLAGS} ${OFLAG}$@ $<
  120. ${EXADIR}${OBJDIR}%${OBJEXT} : ${EXADIR}%.c
  121. ${CC} -c ${CFLAGS} ${OFLAG}$@ $<
  122. #
  123. # The make file is used to compile the library, a test program to verify the
  124. # functionality of the checksum algorithms after compilation and example
  125. # programs.
  126. #
  127. all: \
  128. ${LIBDIR}libcrc${LIBEXT} \
  129. testall${EXEEXT} \
  130. tstcrc${EXEEXT}
  131. #
  132. # This target cleans up all files created in the compilation phase.
  133. #
  134. clean:
  135. ${RM} ${OBJDIR}*${OBJEXT}
  136. ${RM} ${TABDIR}*.inc
  137. ${RM} ${EXADIR}${OBJDIR}*${OBJEXT}
  138. ${RM} ${TSTDIR}${OBJDIR}*${OBJEXT}
  139. ${RM} ${GENDIR}${OBJDIR}*${OBJEXT}
  140. ${RM} ${LIBDIR}libcrc${LIBEXT}
  141. ${RM} ${BINDIR}prc${EXEEXT}
  142. ${RM} testall${EXEEXT}
  143. ${RM} tstcrc${EXEEXT}
  144. #
  145. # The testall program can be run after compilation to verify the checksum
  146. # routines. The extension of the program depends on the operating system used.
  147. #
  148. testall${EXEEXT} : \
  149. ${TSTDIR}${OBJDIR}testall${OBJEXT} \
  150. ${TSTDIR}${OBJDIR}testcrc${OBJEXT} \
  151. ${TSTDIR}${OBJDIR}testnmea${OBJEXT} \
  152. ${LIBDIR}libcrc${LIBEXT} \
  153. Makefile
  154. ${LINK} ${XFLAG}testall${EXEEXT} \
  155. ${TSTDIR}${OBJDIR}testall${OBJEXT} \
  156. ${TSTDIR}${OBJDIR}testcrc${OBJEXT} \
  157. ${TSTDIR}${OBJDIR}testnmea${OBJEXT} \
  158. ${LIBDIR}libcrc${LIBEXT}
  159. ${STRIP} testall${EXEEXT}
  160. #
  161. # The prc program is used during compilation to generate the lookup tables
  162. # for the CRC calculation routines.
  163. #
  164. ${BINDIR}prc${EXEEXT} : \
  165. ${GENDIR}${OBJDIR}precalc${OBJEXT} \
  166. ${GENDIR}${OBJDIR}crc32_table${OBJEXT} \
  167. ${GENDIR}${OBJDIR}crc64_table${OBJEXT} \
  168. Makefile
  169. ${LINK} ${XFLAG}${BINDIR}prc${EXEEXT} \
  170. ${GENDIR}${OBJDIR}precalc${OBJEXT} \
  171. ${GENDIR}${OBJDIR}crc32_table${OBJEXT} \
  172. ${GENDIR}${OBJDIR}crc64_table${OBJEXT}
  173. ${STRIP} ${BINDIR}prc${EXEEXT}
  174. #
  175. # The tstcrc program can be run to calculate the CRC values of manual input or
  176. # of the contents of one or more files.
  177. #
  178. tstcrc${EXEEXT} : \
  179. ${EXADIR}${OBJDIR}tstcrc${OBJEXT} \
  180. ${LIBDIR}libcrc${LIBEXT} \
  181. Makefile
  182. ${LINK} ${XFLAG}tstcrc${EXEEXT} \
  183. ${EXADIR}${OBJDIR}tstcrc${OBJEXT} \
  184. ${LIBDIR}libcrc${LIBEXT}
  185. ${STRIP} tstcrc${EXEEXT}
  186. #
  187. # libcrc is the library which can be linked with other applications. The
  188. # extension of the library depends on the operating system used.
  189. #
  190. ${LIBDIR}libcrc${LIBEXT} : \
  191. ${OBJDIR}crc8${OBJEXT} \
  192. ${OBJDIR}crc16${OBJEXT} \
  193. ${OBJDIR}crc32${OBJEXT} \
  194. ${OBJDIR}crc64${OBJEXT} \
  195. ${OBJDIR}crcccitt${OBJEXT} \
  196. ${OBJDIR}crcdnp${OBJEXT} \
  197. ${OBJDIR}crckrmit${OBJEXT} \
  198. ${OBJDIR}crcsick${OBJEXT} \
  199. ${OBJDIR}nmea-chk${OBJEXT} \
  200. Makefile
  201. ${RM} ${LIBDIR}libcrc${LIBEXT}
  202. ${AR} ${ARQC}${LIBDIR}libcrc${LIBEXT} ${OBJDIR}crc16${OBJEXT}
  203. ${AR} ${ARQ} ${LIBDIR}libcrc${LIBEXT} ${OBJDIR}crc32${OBJEXT}
  204. ${AR} ${ARQ} ${LIBDIR}libcrc${LIBEXT} ${OBJDIR}crc64${OBJEXT}
  205. ${AR} ${ARQ} ${LIBDIR}libcrc${LIBEXT} ${OBJDIR}crc8${OBJEXT}
  206. ${AR} ${ARQ} ${LIBDIR}libcrc${LIBEXT} ${OBJDIR}crcccitt${OBJEXT}
  207. ${AR} ${ARQ} ${LIBDIR}libcrc${LIBEXT} ${OBJDIR}crcdnp${OBJEXT}
  208. ${AR} ${ARQ} ${LIBDIR}libcrc${LIBEXT} ${OBJDIR}crckrmit${OBJEXT}
  209. ${AR} ${ARQ} ${LIBDIR}libcrc${LIBEXT} ${OBJDIR}crcsick${OBJEXT}
  210. ${AR} ${ARQ} ${LIBDIR}libcrc${LIBEXT} ${OBJDIR}nmea-chk${OBJEXT}
  211. ${RANLIB} ${LIBDIR}libcrc${LIBEXT}
  212. #
  213. # Lookup table include file dependencies
  214. #
  215. ${TABDIR}gentab32.inc : ${BINDIR}prc${EXEEXT}
  216. ${BINDIR}prc --crc32 ${TABDIR}gentab32.inc
  217. ${TABDIR}gentab64.inc : ${BINDIR}prc${EXEEXT}
  218. ${BINDIR}prc --crc64 ${TABDIR}gentab64.inc
  219. #
  220. # Individual source files with their header file dependencies
  221. #
  222. ${OBJDIR}crc8${OBJEXT} : ${SRCDIR}crc8.c ${INCDIR}checksum.h
  223. ${OBJDIR}crc16${OBJEXT} : ${SRCDIR}crc16.c ${INCDIR}checksum.h
  224. ${OBJDIR}crc32${OBJEXT} : ${SRCDIR}crc32.c ${INCDIR}checksum.h ${TABDIR}gentab32.inc
  225. ${OBJDIR}crc64${OBJEXT} : ${SRCDIR}crc64.c ${INCDIR}checksum.h ${TABDIR}gentab64.inc
  226. ${OBJDIR}crcccitt${OBJEXT} : ${SRCDIR}crcccitt.c ${INCDIR}checksum.h
  227. ${OBJDIR}crcdnp${OBJEXT} : ${SRCDIR}crcdnp.c ${INCDIR}checksum.h
  228. ${OBJDIR}crckrmit${OBJEXT} : ${SRCDIR}crckrmit.c ${INCDIR}checksum.h
  229. ${OBJDIR}crcsick${OBJEXT} : ${SRCDIR}crcsick.c ${INCDIR}checksum.h
  230. ${OBJDIR}nmea-chk${OBJEXT} : ${SRCDIR}nmea-chk.c ${INCDIR}checksum.h
  231. ${EXADIR}${OBJDIR}tstcrc${OBJEXT} : ${EXADIR}tstcrc.c ${INCDIR}checksum.h
  232. ${TSTDIR}${OBJDIR}testall${OBJEXT} : ${TSTDIR}testall.c ${TSTDIR}testall.h
  233. ${TSTDIR}${OBJDIR}testcrc${OBJEXT} : ${TSTDIR}testcrc.c ${TSTDIR}testall.h ${INCDIR}checksum.h
  234. ${TSTDIR}${OBJDIR}testnmea${OBJEXT} : ${TSTDIR}testnmea.c ${TSTDIR}testall.h ${INCDIR}checksum.h
  235. ${GENDIR}${OBJDIR}crc32_table${OBJEXT} : ${GENDIR}crc32_table.c ${GENDIR}precalc.h ${INCDIR}checksum.h
  236. ${GENDIR}${OBJDIR}crc64_table${OBJEXT} : ${GENDIR}crc64_table.c ${GENDIR}precalc.h ${INCDIR}checksum.h
  237. ${GENDIR}${OBJDIR}precalc${OBJEXT} : ${GENDIR}precalc.c ${GENDIR}precalc.h