Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #
  2. # $Id: Makefile,v 1.2 2002/09/07 16:01:29 peter Exp $
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1999-2000 by Michael van Canneyt
  5. #
  6. # Makefile for the Free Pascal windows.pp include files
  7. #
  8. # See the file COPYING.FPC, included in this distribution,
  9. # for details about the copyright.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. # Warning: this file contains TAB (#9) characters that are required for
  16. # make. Make sure you use an editor that does not replace TABs with
  17. # spaces, or the makefile won't work anymore after you save.
  18. #####################################################################
  19. # Defaults
  20. #####################################################################
  21. ECHO=echo
  22. # Files used by windows.pp
  23. include makefile.inc
  24. #####################################################################
  25. # windows.pp
  26. #####################################################################
  27. # default target
  28. all: ascdef.inc unidef.inc
  29. # Getting DLL names
  30. # not present in headers !!
  31. # first get the list of all exported function names
  32. # uses pedump
  33. # for system dll 's
  34. # gdi32.exp will contain all exported functions names of gdi32.dll
  35. WINDOWS_DIR:=c\:/windows
  36. %.exp : $(WINDOWS_DIR)/system/%.dll
  37. pedump $< > $*.tmp
  38. sed -n -e "s/Addr:\(.*\)Ord:\(.*\)Name: \(.*\)/@\3@/p" $*.tmp > $*.exp
  39. # -rm $*.tmp
  40. %.exd : $(WINDOWS_DIR)/system/%.drv
  41. pedump $< > $*.tmp
  42. sed -n -e "s/Addr:\(.*\)Ord:\(.*\)Name: \(.*\)/@\3@/p" $*.tmp > $*.exd
  43. # -rm $*.tmp
  44. # list of useful dll's for windows.pp
  45. dllexps : gdi32.exp kernel32.exp advapi32.exp user32.exp mapi32.exp \
  46. comdlg32.exp shell32.exp mpr.exp comctl32.exp version.exp \
  47. opengl32.exp spoolss.exp winspool.exd
  48. # get a complete listing of all system dll's
  49. allexps : $(notdir $(patsubst %.dll,%.exp,$(wildcard $(WINDOWS_DIR)/system/*.dll)) \
  50. $(patsubst %.drv,%.exd,$(wildcard $(WINDOWS_DIR)/system/*.drv)))
  51. # extract the dllnames for which the real dll file is not
  52. # known yet
  53. # func.lst will contain all functions for which we still do
  54. # not know the origin DLL
  55. %.lst : %.inc
  56. @$(ECHO) listing DLL function names of $*.inc
  57. sed -n -e "s/\(.*\)External_library name '\([^']*\)'\(.*\)/\2/p" $*.inc > $*.lst
  58. # get the DLL name from the listing in .exp files
  59. # of the current target
  60. define grepname
  61. $(filter %.dll %.drv ,$(subst .exd:,.drv ,$(subst .exp:,.dll ,$(shell grep @$*@ *.ex*))))
  62. endef
  63. # creating of a sed script that
  64. # will substitute all External_library
  65. # by the real name of the DLL if found in exports files
  66. # two stages
  67. # because you cannot set a variable inside the commands
  68. # Level 1 : set filename variable
  69. # Level 2 :
  70. %.sub : %.lst
  71. @$(ECHO) getting DLL file name for $*
  72. -rm $*.sub
  73. @$(ECHO) # Substitutions for $* >$*.sub
  74. # call make for all names in lst file
  75. # define LongList if there is an error
  76. # because the list is too long
  77. ifdef LongList
  78. $(foreach name,$(shell cat $*.lst),$(MAKE) subfile=$*.sub $(name).find ; )
  79. else
  80. $(MAKE) subfile=$*.sub $(addsuffix .find,$(shell cat $*.lst))
  81. endif
  82. # resubstitute unfound ones !!
  83. @$(ECHO) s/external \'\' name \'\([^\']*\)\'/external\
  84. External_library name \'\1\'/ >>$*.sub
  85. @$(ECHO) # End of substitutions for $* >>$*.sub
  86. # Change file according to function found in export
  87. # list remaining unfound functions in $*.mis
  88. %.npp : %.sub
  89. sed -f $*.sub $*.inc > $*.npp
  90. sed -n -e "s/\(.*\)External_library name \'\([^\']*\)\'\(.*\)/\2/p" $*.npp > $*.mis
  91. %.find :
  92. @$(ECHO) $* is in $(grepname)
  93. ifdef subfile
  94. @$(ECHO) s/external External_library name \'$*\'/external\
  95. \'$(filter %.dll %.drv ,$(subst .exd:,.drv ,$(subst .exp:,.dll ,$(shell grep @$*@ *.ex*))))\'\
  96. name \'$*\'/ >>$(subfile)
  97. else
  98. @$(ECHO) external \
  99. \'$(filter %.dll %.drv ,$(subst .exd:,.drv ,$(subst .exp:,.dll ,$(shell grep @$*@ *.ex*))))\'\
  100. name $*
  101. endif
  102. GNUWIN32LIBDIR=./
  103. %.find2 :
  104. @$(ECHO) s/In archive \(.*\)/\1/p >find.sed
  105. @$(ECHO) s/\(.*\)___imp_$*@\(.*\)/found: $*/p >>find.sed
  106. ifdef subfile
  107. sed -n -f find.sed alllibs.sym >> $(subfile)
  108. else
  109. sed -n -f find.sed alllibs.sym > $*.res
  110. endif
  111. missing : $(GNUWIN32LIBDIR)alllibs.sym $(addsuffix .lst,$(WINDOWS_FILES))
  112. -rm missing
  113. $(MAKE) subfile=missing $(addsuffix .find2,$(shell cat *.lst))
  114. substmissing : missing
  115. dtou missing
  116. @$(ECHO) N > test.sed
  117. @$(ECHO) s/lib\(.*\)\.a:\nfound: \(.*\)/\1.dll : \2/p >> test.sed
  118. @$(ECHO) D >> test.sed
  119. sed -n -f test.sed missing > missing.tmp
  120. sed -e "s#\(.*\) : \(.*\)#s/external External_library name \'\2\'/external \'\1\' name \'\2\'/#" missing.tmp > missing.sub
  121. dllnames:
  122. $(MAKE) $(addsuffix .lst,$(WINDOWS_FILES))
  123. test:
  124. @$(ECHO) namelist of $(filename) is "$(namelist)"
  125. # automatic conversion from ascfun.inc to ascdef.inc
  126. # and unifun.inc to unidef.inc
  127. ascdef.inc : ascfun.inc ascdef.sed
  128. sed -f ascdef.sed ascfun.inc > ascdef.inc
  129. unidef.inc : unifun.inc unidef.sed
  130. sed -f unidef.sed unifun.inc > unidef.inc