Makefile.fpc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #
  2. # Makefile.fpc for Free Pascal GDB Interface
  3. #
  4. [package]
  5. name=gdbint
  6. version=2.5.1
  7. [target]
  8. units=gdbint gdbcon
  9. examples=examples/testgdb examples/symify
  10. [compiler]
  11. objectdir=$(GDBLIBDIR)
  12. librarydir=$(GDBLIBDIR)
  13. includedir=$(GDBLIBDIR) src
  14. sourcedir=src tests
  15. [require]
  16. libc=y
  17. [install]
  18. fpcpackage=y
  19. [default]
  20. fpcdir=../..
  21. [prerules]
  22. # For unix be sure to use the locally created gdbver
  23. ifdef inUnix
  24. CURRDIR=./
  25. else
  26. CURRDIR=
  27. endif
  28. # Look for a valid GDBLIBDIR environment variable
  29. ifdef GDBLIBDIR
  30. override LIBGDBFILE:=$(firstword $(wildcard $(addsuffix /libgdb.a,$(GDBLIBDIR))))
  31. endif
  32. # Use default dirs if not available
  33. ifeq ($(LIBGDBFILE),)
  34. # Default locations <target>/<cpu> (linux) or <target> (win32,go32v2) only
  35. override GDBLIBDIR=$(wildcard $(FPCDIR)/libgdb/$(OS_TARGET)/$(CPU_TARGET))
  36. ifeq ($(GDBLIBDIR),)
  37. override GDBLIBDIR=$(FPCDIR)/libgdb/$(OS_TARGET)
  38. endif
  39. # Detect if libgdb.a is available
  40. override LIBGDBFILE:=$(firstword $(wildcard $(addsuffix /libgdb.a,$(GDBLIBDIR))))
  41. endif
  42. # Set GDBFOUND variable
  43. ifeq ($(LIBGDBFILE),)
  44. GDBFOUND=0
  45. else
  46. GDBFOUND=1
  47. # Detect if gdblib.inc is available
  48. override LIBGDBINC:=$(firstword $(wildcard $(addsuffix /gdblib.inc,$(GDBLIBDIR))))
  49. ifeq ($(LIBGDBINC),)
  50. GDBLIBINCFOUND=0
  51. GDBLIBINCCOND=
  52. else
  53. GDBLIBINCFOUND=1
  54. GDBLIBINCCOND=-dUSE_GDBLIBINC
  55. endif
  56. endif
  57. [rules]
  58. ifeq ($(FULL_SOURCE),$(FULL_TARGET))
  59. CAN_RUN_GDBVER=1
  60. endif
  61. ifeq ($(FULL_SOURCE),i386-win32)
  62. ifeq ($(FULL_TARGET),i386-go32v2)
  63. CAN_RUN_GDBVER=1
  64. endif
  65. endif
  66. ifdef CAN_RUN_GDBVER
  67. ifeq ($(GDBFOUND),1)
  68. # libgdb.a found
  69. $(CURRDIR)getver$(EXEEXT) : gdbver.pp
  70. $(COMPILER) -o$(CURRDIR)getver$(EXEEXT) gdbver.pp
  71. ifndef GOTGDBVER
  72. # gdbver doesn't exists, build it first
  73. gdbint$(PPUEXT): $(CURRDIR)gdbver$(EXEEXT) gdbint.pp
  74. $(MAKE) gdbint$(PPUEXT) GOTGDBVER=1
  75. else
  76. # gdbver exists
  77. GDBVER:=GDB_V$(strip $(shell $(CURRDIR)gdbver$(EXEEXT) -n))
  78. gdbver.inc: gdbver$(EXEEXT)
  79. ./gdbver$(EXEEXT) -o gdbver.inc
  80. gdbint$(PPUEXT): gdbint.pp gdbver.inc
  81. # MingW?
  82. ifeq ($(wildcard $(GDBLIBDIR)/libmingw32.a),)
  83. @$(ECHO) Using GDB $(GDBVER)
  84. $(COMPILER) -d$(GDBVER) $(GDBLIBINCCOND) -Fisrc -Fusrc src/gdbint.pp
  85. else
  86. @$(ECHO) Using GDB $(GDBVER) (MingW)
  87. $(COMPILER) -d$(GDBVER) $(GDBLIBINCCOND) -dUSE_MINGW_GDB -Fisrc -Fusrc src/gdbint.pp
  88. endif
  89. $(DEL) gdbver$(EXEEXT) gdbver$(OEXT)
  90. endif
  91. else
  92. # libgdb.a not found, default to libgdb v6
  93. GDBVER=GDB_V606
  94. gdbver.inc:
  95. $(CPPROG) src/gdbver_nogdb.inc src/gdbver.inc
  96. gdbint$(PPUEXT): gdbint.pp gdbver.inc
  97. @$(ECHO) libgdb.a not found, using default GDB $(GDBVER)
  98. $(COMPILER) -d$(GDBVER) $(GDBLIBINCCOND) -Fisrc -Fusrc src/gdbint.pp
  99. endif
  100. else
  101. # Different OS_TARGET, default to libgdb v6
  102. GDBVER=GDB_V606
  103. gdbver.inc:
  104. $(CPPROG) src/gdbver_nogdb.inc src/gdbver.inc
  105. gdbint$(PPUEXT): gdbint.pp gdbver.inc
  106. @$(ECHO) Different target os or cpu, using default GDB $(GDBVER)
  107. $(COMPILER) -d$(GDBVER) $(GDBLIBINCCOND) -Fisrc -Fusrc src/gdbint.pp
  108. endif
  109. gdbcon$(PPUEXT): gdbcon.pp gdbint$(PPUEXT)
  110. ifeq ($(wildcard $(GDBLIBDIR)/libmingw32.a),)
  111. $(COMPILER) src/gdbcon.pp
  112. else
  113. $(COMPILER) -dUSE_MINGW_GDB src/gdbcon.pp
  114. endif
  115. $(EXECPPAS)
  116. ifeq ($(OS_TARGET),go32v2)
  117. DBGCOM=dbgcom$(OEXT)
  118. else
  119. DBGCOM=
  120. endif
  121. ifdef $(COMPILEDBGCOM)
  122. # FPC conditionnal remove the file watching mecanism introduced
  123. # in v2.02 of dbgcom.c because it relies
  124. # on the fact that all files are opened via C lib calls
  125. # which is wrong for FPC !!
  126. $(DBGCOM): ../v4.16/dbgcom.c
  127. gcc -c -DFPC -Dother_sel -gstabs -o dbgcom.o -I../v4.16 ../v4.16/dbgcom.c
  128. else
  129. $(DBGCOM):
  130. endif
  131. simple: $(DBGCOM)
  132. -rm gdbint.ppu
  133. ppc386 -dUSE_LIBGDB -fisrc -fusrc gdbint
  134. ppc386 testgdb
  135. examples/testgdb$(EXEEXT): examples/testgdb.pp gdbint$(PPUEXT) gdbcon$(PPUEXT) $(DBGCOM)
  136. ifeq ($(wildcard $(GDBLIBDIR)/libmingw32.a),)
  137. $(COMPILER) -FEexamples examples/testgdb.pp
  138. else
  139. $(COMPILER) -FEexamples -dUSE_MINGW_GDB examples/testgdb.pp
  140. endif
  141. $(EXECPPAS)
  142. examples/symify$(EXEEXT): examples/symify.pp gdbint$(PPUEXT) gdbcon$(PPUEXT) $(DBGCOM)
  143. ifeq ($(wildcard $(GDBLIBDIR)/libmingw32.a),)
  144. $(COMPILER) -FEexamples examples/symify.pp
  145. else
  146. $(COMPILER) -FEexamples -dUSE_MINGW_GDB examples/symify.pp
  147. endif
  148. $(EXECPPAS)
  149. # Allow test for example
  150. .PHONY: test
  151. test: examples
  152. clean: fpc_clean
  153. $(DEL) src/gdbver$(EXEEXT) src/gdbver$(OEXT)
  154. distclean: fpc_distclean
  155. $(DEL) src/gdbver.inc
  156. .NOTPARALLEL: