makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. #
  2. # $Id$
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1996-98 by Michael van Canneyt
  5. #
  6. # Makefile for the Free Pascal Win32 Runtime Library
  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. #####################################################################
  16. # Start of configurable section.
  17. # Please note that all these must be set in the main makefile, and
  18. # should be set there.
  19. # Don't remove the indef statements. They serve to avoid conflicts
  20. # with the main makefile.
  21. #####################################################################
  22. # What is the Operating System ?
  23. ifndef OS_SOURCE
  24. OS_SOURCE=win32
  25. endif
  26. # What is the target operating system ?
  27. ifndef OS_TARGET
  28. OS_TARGET=win32
  29. endif
  30. # What is the target processor :
  31. ifndef CPU
  32. CPU=i386
  33. #CPU=m68k
  34. endif
  35. # What compiler to use ?
  36. ifndef PP
  37. PP=ppc386
  38. endif
  39. # What options to pass to the compiler ?
  40. # You may want to specify a config file or error definitions file here.
  41. ifndef OPT
  42. OPT=
  43. endif
  44. # Where is the PPUMOVE program ?
  45. ifndef PPUMOVE
  46. PPUMOVE=ppumove
  47. endif
  48. # Use smartlinking ?
  49. ifndef SMARTLINK
  50. SMARTLINK=NO
  51. endif
  52. # Name of library ?
  53. # If this is set, all units will be put in the same library.
  54. # If it is empty (default), the units will be left in separate files.
  55. ifndef LIBNAME
  56. LIBNAME=
  57. #LIBNAME=fpc
  58. endif
  59. # Should the library be shared or static (only if LIBNAME is set).
  60. # Set this to 'shared' or 'static' to create a librrary
  61. # Setting this to shared will disable smart linking.
  62. ifndef LIBTYPE
  63. LIBTYPE=
  64. #LIBTYPE=static
  65. endif
  66. #####################################################################
  67. # End of configurable section.
  68. # Do not edit after this line.
  69. #####################################################################
  70. #####################################################################
  71. # System independent
  72. #####################################################################
  73. # Where are the include files ?
  74. INC=../inc
  75. PROCINC=../$(CPU)
  76. CFG=../cfg
  77. OBJPASDIR=../objpas
  78. # Get some defaults for Programs and OSes.
  79. # This will set the following variables :
  80. # inlinux indos COPY REPLACE DEL INSTALL INSTALLEXE MKDIR
  81. # It will also set OPT for cross-compilation, and add required options.
  82. # also checks for config file.
  83. # it expects INC PROCINC to be set !!
  84. include $(CFG)/makefile.cfg
  85. # Get the system independent include file names.
  86. # This will set the following variables :
  87. # SYSINCNAMES
  88. include $(INC)/makefile.inc
  89. SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
  90. # Get the processor dependent include file names.
  91. # This will set the following variables :
  92. # CPUINCNAMES
  93. include $(PROCINC)/makefile.cpu
  94. SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
  95. # Put system unit dependencies together.
  96. SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
  97. #####################################################################
  98. # System dependent
  99. #####################################################################
  100. # Override extensions
  101. PPUEXT=.ppw
  102. SHAREDLIBEXT=.dll
  103. # Define Linux Units
  104. SYSTEMPPU=syswin32$(PPUEXT)
  105. OBJECTS=strings objpas \
  106. dos \
  107. windows
  108. # base messages defines
  109. # Files used by windows.pp
  110. WINDOWS_FILES=base errors defines \
  111. struct ascfun ascdef \
  112. unifun unidef func
  113. # Add Prefix and Suffixes
  114. PPUOBJECTS=$(addsuffix $(PPUEXT), $(OBJECTS))
  115. WINDOWS_SOURCE_FILES=$(addsuffix .pp,$(WINDOWS_FILES))
  116. .PHONY : all install clean \
  117. libs libsclean \
  118. diffs diffclean \
  119. dllnames test
  120. all : $(OBJLOADERS) $(PPUOBJECTS)
  121. install : all
  122. $(MKDIR) $(UNITINSTALLDIR)
  123. $(INSTALL) *$(PPUEXT) *$(OEXT) $(UNITINSTALLDIR)
  124. clean :
  125. -$(DEL) *$(OEXT) *$(ASMEXT) *$(PPUEXT) log
  126. -$(DELTREE) *$(SMARTEXT)
  127. #####################################################################
  128. # Files
  129. #####################################################################
  130. #
  131. # Base Units (System, strings, os-dependent-base-unit)
  132. #
  133. $(SYSTEMPPU) : syswin32.pp win32.inc $(SYSDEPS)
  134. $(PP) $(OPT) -Us -Sg syswin32.pp $(REDIR)
  135. strings$(PPUEXT) : $(PROCINC)/strings.pp $(SYSTEMPPU)
  136. $(COPY) $(PROCINC)/strings.pp .
  137. $(PP) $(OPT) strings $(REDIR)
  138. $(DEL) strings.pp
  139. #
  140. # Delphi Object Model
  141. #
  142. objpas$(PPUEXT) : $(OBJPASDIR)/objpas.pp $(SYSTEMPPU)
  143. $(COPY) $(OBJPASDIR)/objpas.pp .
  144. $(PP) $(OPT) objpas $(REDIR)
  145. $(DEL) objpas.pp
  146. #
  147. # System Dependent Units
  148. #
  149. base$(PPUEXT) : base.pp $(SYSTEMPPU)
  150. $(PP) $(OPT) base.pp $(REDIR)
  151. messages$(PPUEXT) : messages.pp $(SYSTEMPPU)
  152. $(PP) $(OPT) messages.pp $(REDIR)
  153. defines$(PPUEXT) : defines.pp $(SYSTEMPPU)
  154. $(PP) $(OPT) defines.pp $(REDIR)
  155. windows$(PPUEXT) : windows.pp $(WINDOWS_SOURCE_FILES) $(SYSTEMPPU)
  156. $(PP) $(OPT) windows.pp $(REDIR)
  157. #
  158. # TP7 Compatible RTL Units
  159. #
  160. dos$(PPUEXT) : $(DOSDEPS) $(INC)/filerec.inc $(INC)/textrec.inc $(SYSTEMPPU)
  161. $(PP) $(OPT) dos $(REDIR)
  162. #objects$(PPUEXT) : $(INC)/objects.pp objinc.inc $(SYSTEMPPU)
  163. # $(COPY) $(INC)/objects.pp .
  164. # $(PP) $(OPT) objects $(REDIR)
  165. # $(DEL) objects.pp
  166. #
  167. # Other RTL Units
  168. #
  169. #####################################################################
  170. # Libs
  171. #####################################################################
  172. staticlib:
  173. make clean
  174. make all SMARTLINK=YES LIBNAME=fpc LIBTYPE=static
  175. sharedlib:
  176. make clean
  177. make all
  178. $(PPUMOVE) -o fpc $(SHAREDLIBFILES)
  179. staticlibinstall: staticlib
  180. $(MKDIR) $(STATIC_LIBINSTALLDIR)
  181. $(MKDIR) $(STATIC_UNITINSTALLDIR)
  182. $(INSTALLEXE) libfpc$(STATICLIBEXT) $(STATIC_LIBINSTALLDIR)
  183. $(INSTALL) *$(PPUEXT) *$(OEXT) $(STATIC_UNITINSTALLDIR)
  184. sharedlibinstall: sharedlib
  185. $(MKDIR) $(SHARED_LIBINSTALLDIR)
  186. $(MKDIR) $(SHARED_UNITINSTALLDIR)
  187. $(INSTALLEXE) libfpc$(SHAREDLIBEXT) $(SHARED_LIBINSTALLDIR)
  188. $(INSTALL) *$(PPUEXT) *$(OEXT) $(SHARED_UNITINSTALLDIR)
  189. ldconfig
  190. libinstall: staticlibinstall
  191. libsclean : clean
  192. -$(DEL) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  193. # Getting DLL names
  194. # not present in headers !!
  195. # first get the list of all exported function names
  196. # uses pedump
  197. # for system dll 's
  198. # gdi32.exp will contain all exported functions names of gdi32.dll
  199. WINDOWS_DIR:=c:/windows
  200. %.exp : $(WINDOWS_DIR)/system/%.dll
  201. pedump $< > $*.tmp
  202. sed -n -e "s/Addr:\(.*\)Ord:\(.*\)Name: \(.*\)/@\3@/p" $*.tmp > $*.exp
  203. # -rm $*.tmp
  204. %.exd : $(WINDOWS_DIR)/system/%.drv
  205. pedump $< > $*.tmp
  206. sed -n -e "s/Addr:\(.*\)Ord:\(.*\)Name: \(.*\)/@\3@/p" $*.tmp > $*.exd
  207. # -rm $*.tmp
  208. # list of usefull dll's for windows.pp
  209. dllexps : gdi32.exp kernel32.exp advapi32.exp user32.exp mapi32.exp \
  210. comdlg32.exp shell32.exp mpr.exp comctl32.exp version.exp \
  211. opengl32.exp spoolss.exp winspool.exd
  212. # get a complete listing of all system dll's
  213. allexps : $(notdir $(patsubst %.dll,%.exp,$(wildcard $(WINDOWS_DIR)/system/*.dll)) \
  214. $(patsubst %.drv,%.exd,$(wildcard $(WINDOWS_DIR)/system/*.drv)))
  215. # extract the dllnames for which the real dll file is not
  216. # known yet
  217. # func.lst will contain all functions for which we still do
  218. # not know the origin DLL
  219. %.lst : %.pp
  220. @echo listing DLL function names of $*.pp
  221. sed -n -e "s/\(.*\)External_library name '\([^']*\)'\(.*\)/\2/p" $*.pp > $*.lst
  222. # get the DLL name from the listing in .exp files
  223. # of the current target
  224. define grepname
  225. $(filter %.dll %.drv ,$(subst .exd:,.drv ,$(subst .exp:,.dll ,$(shell grep @$*@ *.ex*))))
  226. endef
  227. # creating of a sed script that
  228. # will substitute all External_library
  229. # by the real name of the DLL if found in exports files
  230. # two stages
  231. # because you cannot set a variable inside the commands
  232. # Level 1 : set filename variable
  233. # Level 2 :
  234. %.sub : %.lst
  235. @echo getting DLL file name for $*
  236. -rm $*.sub
  237. @echo # Substitutions for $* >$*.sub
  238. # call make for all names in lst file
  239. # define LongList if there is an error
  240. # because the list is too long
  241. ifdef LongList
  242. $(foreach name,$(shell cat $*.lst),$(MAKE) subfile=$*.sub $(name).find ; )
  243. else
  244. $(MAKE) subfile=$*.sub $(addsuffix .find,$(shell cat $*.lst))
  245. endif
  246. # resubstitute unfound ones !!
  247. @echo s/external \'\' name \'\([^\']*\)\'/external\
  248. External_library name \'\1\'/ >>$*.sub
  249. @echo # End of substitutions for $* >>$*.sub
  250. # Change file according to function found in export
  251. # list remaining unfound functions in $*.mis
  252. %.npp : %.sub
  253. sed -f $*.sub $*.pp > $*.npp
  254. sed -n -e "s/\(.*\)External_library name \'\([^\']*\)\'\(.*\)/\2/p" $*.npp > $*.mis
  255. %.find :
  256. @echo $* is in $(grepname)
  257. ifdef subfile
  258. @echo s/external External_library name \'$*\'/external\
  259. \'$(filter %.dll %.drv ,$(subst .exd:,.drv ,$(subst .exp:,.dll ,$(shell grep @$*@ *.ex*))))\'\
  260. name \'$*\'/ >>$(subfile)
  261. else
  262. @echo external \
  263. \'$(filter %.dll %.drv ,$(subst .exd:,.drv ,$(subst .exp:,.dll ,$(shell grep @$*@ *.ex*))))\'\
  264. name $*
  265. endif
  266. GNUWIN32LIBDIR=./
  267. %.find2 :
  268. @echo s/In archive \(.*\)/\1/p >find.sed
  269. @echo s/\(.*\)___imp_$*@\(.*\)/found: $*/p >>find.sed
  270. ifdef subfile
  271. sed -n -f find.sed alllibs.sym >> $(subfile)
  272. else
  273. sed -n -f find.sed alllibs.sym > $*.res
  274. endif
  275. missing : $(GNUWIN32LIBDIR)alllibs.sym $(addsuffix .lst,$(WINDOWS_FILES))
  276. -rm missing
  277. $(MAKE) subfile=missing $(addsuffix .find2,$(shell cat *.lst))
  278. substmissing : missing
  279. dtou missing
  280. @echo N > test.sed
  281. @echo s/lib\(.*\)\.a:\nfound: \(.*\)/\1.dll : \2/p >> test.sed
  282. @echo D >> test.sed
  283. sed -n -f test.sed missing > missing.tmp
  284. sed -e "s#\(.*\) : \(.*\)#s/external External_library name \'\2\'/external \'\1\' name \'\2\'/#" missing.tmp > missing.sub
  285. dllnames:
  286. $(MAKE) $(addsuffix .lst,$(WINDOWS_FILES))
  287. test:
  288. @echo namelist of $(filename) is "$(namelist)"
  289. # automatic conversion from ascfun.pp to ascdef.pp
  290. # and unifun.pp to unidef.pp
  291. # only if sed is present
  292. ifdef SED
  293. ascdef.pp : ascfun.pp ascdef.sed
  294. sed -f ascdef.sed ascfun.pp > ascdef.pp
  295. unidef.pp : unifun.pp unidef.sed
  296. sed -f unidef.sed unifun.pp > unidef.pp
  297. endif
  298. #####################################################################
  299. # Default targets
  300. #####################################################################
  301. include $(CFG)/makefile.def
  302. #
  303. # $Log$
  304. # Revision 1.13 1998-09-07 18:31:54 peter
  305. # * fixed $smartlibext -> $staticlibext to fix a 'rm *' :(
  306. #
  307. # Revision 1.12 1998/09/04 17:17:36 pierre
  308. # + all unknown function ifdef with
  309. # conditionnal unknown_functions
  310. # testwin works now, but windowcreate still fails !!
  311. #
  312. # Revision 1.11 1998/09/04 12:33:12 pierre
  313. # + added SED testing for ascdef.pp and unidef.pp
  314. # * func.pp ready
  315. # still some functions missing (commented out for now)
  316. #
  317. # Revision 1.10 1998/09/03 18:17:35 pierre
  318. # * small improvements in number of found functions
  319. # all remaining are in func.pp
  320. #
  321. # Revision 1.9 1998/09/03 17:14:54 pierre
  322. # * most functions found in main DLL's
  323. # still some missing
  324. # use 'make dllnames' to get missing names
  325. #
  326. # Revision 1.7 1998/08/21 15:17:01 peter
  327. # * win32 compiles a bit better, no growheap crash
  328. #
  329. #