Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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. # 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. # Configuration section
  20. #####################################################################
  21. # Use smartlinking ?
  22. ifndef SMARTLINK
  23. SMARTLINK=NO
  24. endif
  25. # Name of library ?
  26. # If this is set, all units will be put in the same library.
  27. # If it is empty (default), the units will be left in separate files.
  28. ifndef LIBNAME
  29. LIBNAME=
  30. #LIBNAME=fpc
  31. endif
  32. # Should the library be shared or static (only if LIBNAME is set).
  33. # Set this to 'shared' or 'static' to create a librrary
  34. # Setting this to shared will disable smart linking.
  35. ifndef LIBTYPE
  36. LIBTYPE=
  37. #LIBTYPE=static
  38. endif
  39. #####################################################################
  40. # Defaults
  41. #####################################################################
  42. # set target and cpu which are required
  43. override OS_TARGET=win32
  44. override CPU=i386
  45. # Where are the include files
  46. RTL=..
  47. CFG=$(RTL)/cfg
  48. INC=$(RTL)/inc
  49. PROCINC=$(RTL)/$(CPU)
  50. OBJPASDIR=$(RTL)/objpas
  51. # Where are the results placed
  52. TARGETDIR=.
  53. #####################################################################
  54. # Include default makefile
  55. #####################################################################
  56. include $(CFG)/makefile.cfg
  57. #####################################################################
  58. # System dependent
  59. #####################################################################
  60. # Define Win32 Units
  61. SYSTEMPPU=syswin32$(PPUEXT)
  62. LOADERS=wprt0 wdllprt0
  63. OBJECTS=strings windows \
  64. dos objects \
  65. objpas sysutils typinfo math \
  66. cpu mmx getopts heaptrc
  67. # Files used by windows.pp
  68. WINDOWS_FILES=base errors defines \
  69. struct ascfun ascdef \
  70. unifun unidef func
  71. WINDOWS_SOURCE_FILES=$(addsuffix .pp,$(WINDOWS_FILES))
  72. #####################################################################
  73. # Include system unit dependencies
  74. #####################################################################
  75. # Get the system independent include file names.
  76. # This will set the following variables :
  77. # SYSINCNAMES
  78. include $(INC)/makefile.inc
  79. SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
  80. # Get the processor dependent include file names.
  81. # This will set the following variables :
  82. # CPUINCNAMES
  83. include $(PROCINC)/makefile.cpu
  84. SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
  85. # Put system unit dependencies together.
  86. SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
  87. #####################################################################
  88. # System independent Makefile
  89. #####################################################################
  90. # Add Prefix and Suffixes
  91. OBJLOADERS=$(addsuffix $(OEXT), $(LOADERS))
  92. PPUOBJECTS=$(addsuffix $(PPUEXT), $(OBJECTS))
  93. .PHONY : all install clean \
  94. libs libsclean \
  95. diffs diffclean \
  96. dllnames test
  97. all : $(OBJLOADERS) $(PPUOBJECTS)
  98. install : all
  99. $(MKDIR) $(UNITINSTALLDIR)
  100. $(INSTALL) *$(PPUEXT) *$(OEXT) $(UNITINSTALLDIR)
  101. clean :
  102. -$(DEL) *$(OEXT) *$(ASMEXT) *$(PPUEXT) log
  103. -$(DELTREE) *$(SMARTEXT)
  104. #####################################################################
  105. # Files
  106. #####################################################################
  107. #
  108. # Base Units (System, strings, os-dependent-base-unit)
  109. #
  110. ifneq ($(OS_SOURCE),win32)
  111. override AS=asw
  112. endif
  113. wprt0$(OEXT) : wprt0.as
  114. $(AS) -o wprt0$(OEXT) wprt0.as
  115. wdllprt0$(OEXT) : wdllprt0.as
  116. $(AS) -o wdllprt0$(OEXT) wdllprt0.as
  117. $(SYSTEMPPU) : syswin32.pp win32.inc $(SYSDEPS)
  118. $(COMPILER) -Us -Sg syswin32.pp $(REDIR)
  119. strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
  120. $(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
  121. $(SYSTEMPPU)
  122. $(COMPILER) $(INC)/strings.pp $(REDIR)
  123. #
  124. # Delphi Object Model
  125. #
  126. include $(OBJPASDIR)/makefile.op
  127. #
  128. # System Dependent Units
  129. #
  130. base$(PPUEXT) : base.pp $(SYSTEMPPU)
  131. $(COMPILER) base.pp $(REDIR)
  132. messages$(PPUEXT) : messages.pp $(SYSTEMPPU)
  133. $(COMPILER) messages.pp $(REDIR)
  134. defines$(PPUEXT) : defines.pp $(SYSTEMPPU)
  135. $(COMPILER) defines.pp $(REDIR)
  136. windows$(PPUEXT) : windows.pp $(WINDOWS_SOURCE_FILES) $(SYSTEMPPU)
  137. $(COMPILER) windows.pp $(REDIR)
  138. #
  139. # TP7 Compatible RTL Units
  140. #
  141. dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc $(SYSTEMPPU)
  142. $(COMPILER) dos.pp $(REDIR)
  143. objects$(PPUEXT) : $(INC)/objects.pp objinc.inc $(SYSTEMPPU)
  144. $(COMPILER) $(INC)/objects.pp $(REDIR)
  145. #
  146. # Other RTL Units
  147. #
  148. cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMPPU)
  149. $(COMPILER) $(PROCINC)/cpu.pp $(REDIR)
  150. mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMPPU)
  151. $(COMPILER) $(PROCINC)/mmx.pp $(REDIR)
  152. getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMPPU)
  153. $(COMPILER) $(INC)/getopts.pp $(REDIR)
  154. heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMPPU)
  155. $(COMPILER) $(INC)/heaptrc $(REDIR)
  156. #####################################################################
  157. # Libs
  158. #####################################################################
  159. staticlib:
  160. make clean
  161. make all SMARTLINK=YES LIBNAME=fpc LIBTYPE=static
  162. sharedlib:
  163. make clean
  164. make all
  165. $(PPUMOVE) -o fpc $(SHAREDLIBFILES)
  166. staticlibinstall: staticlib
  167. $(MKDIR) $(STATIC_LIBINSTALLDIR)
  168. $(MKDIR) $(STATIC_UNITINSTALLDIR)
  169. $(INSTALLEXE) libfpc$(STATICLIBEXT) $(STATIC_LIBINSTALLDIR)
  170. $(INSTALL) *$(PPUEXT) *$(OEXT) $(STATIC_UNITINSTALLDIR)
  171. sharedlibinstall: sharedlib
  172. $(MKDIR) $(SHARED_LIBINSTALLDIR)
  173. $(MKDIR) $(SHARED_UNITINSTALLDIR)
  174. $(INSTALLEXE) libfpc$(SHAREDLIBEXT) $(SHARED_LIBINSTALLDIR)
  175. $(INSTALL) *$(PPUEXT) *$(OEXT) $(SHARED_UNITINSTALLDIR)
  176. ldconfig
  177. libinstall: staticlibinstall
  178. libsclean : clean
  179. -$(DEL) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  180. #####################################################################
  181. # windows.pp
  182. #####################################################################
  183. # Getting DLL names
  184. # not present in headers !!
  185. # first get the list of all exported function names
  186. # uses pedump
  187. # for system dll 's
  188. # gdi32.exp will contain all exported functions names of gdi32.dll
  189. WINDOWS_DIR:=c\:/windows
  190. %.exp : $(WINDOWS_DIR)/system/%.dll
  191. pedump $< > $*.tmp
  192. sed -n -e "s/Addr:\(.*\)Ord:\(.*\)Name: \(.*\)/@\3@/p" $*.tmp > $*.exp
  193. # -rm $*.tmp
  194. %.exd : $(WINDOWS_DIR)/system/%.drv
  195. pedump $< > $*.tmp
  196. sed -n -e "s/Addr:\(.*\)Ord:\(.*\)Name: \(.*\)/@\3@/p" $*.tmp > $*.exd
  197. # -rm $*.tmp
  198. # list of usefull dll's for windows.pp
  199. dllexps : gdi32.exp kernel32.exp advapi32.exp user32.exp mapi32.exp \
  200. comdlg32.exp shell32.exp mpr.exp comctl32.exp version.exp \
  201. opengl32.exp spoolss.exp winspool.exd
  202. # get a complete listing of all system dll's
  203. allexps : $(notdir $(patsubst %.dll,%.exp,$(wildcard $(WINDOWS_DIR)/system/*.dll)) \
  204. $(patsubst %.drv,%.exd,$(wildcard $(WINDOWS_DIR)/system/*.drv)))
  205. # extract the dllnames for which the real dll file is not
  206. # known yet
  207. # func.lst will contain all functions for which we still do
  208. # not know the origin DLL
  209. %.lst : %.pp
  210. @echo listing DLL function names of $*.pp
  211. sed -n -e "s/\(.*\)External_library name '\([^']*\)'\(.*\)/\2/p" $*.pp > $*.lst
  212. # get the DLL name from the listing in .exp files
  213. # of the current target
  214. define grepname
  215. $(filter %.dll %.drv ,$(subst .exd:,.drv ,$(subst .exp:,.dll ,$(shell grep @$*@ *.ex*))))
  216. endef
  217. # creating of a sed script that
  218. # will substitute all External_library
  219. # by the real name of the DLL if found in exports files
  220. # two stages
  221. # because you cannot set a variable inside the commands
  222. # Level 1 : set filename variable
  223. # Level 2 :
  224. %.sub : %.lst
  225. @echo getting DLL file name for $*
  226. -rm $*.sub
  227. @echo # Substitutions for $* >$*.sub
  228. # call make for all names in lst file
  229. # define LongList if there is an error
  230. # because the list is too long
  231. ifdef LongList
  232. $(foreach name,$(shell cat $*.lst),$(MAKE) subfile=$*.sub $(name).find ; )
  233. else
  234. $(MAKE) subfile=$*.sub $(addsuffix .find,$(shell cat $*.lst))
  235. endif
  236. # resubstitute unfound ones !!
  237. @echo s/external \'\' name \'\([^\']*\)\'/external\
  238. External_library name \'\1\'/ >>$*.sub
  239. @echo # End of substitutions for $* >>$*.sub
  240. # Change file according to function found in export
  241. # list remaining unfound functions in $*.mis
  242. %.npp : %.sub
  243. sed -f $*.sub $*.pp > $*.npp
  244. sed -n -e "s/\(.*\)External_library name \'\([^\']*\)\'\(.*\)/\2/p" $*.npp > $*.mis
  245. %.find :
  246. @echo $* is in $(grepname)
  247. ifdef subfile
  248. @echo s/external External_library name \'$*\'/external\
  249. \'$(filter %.dll %.drv ,$(subst .exd:,.drv ,$(subst .exp:,.dll ,$(shell grep @$*@ *.ex*))))\'\
  250. name \'$*\'/ >>$(subfile)
  251. else
  252. @echo external \
  253. \'$(filter %.dll %.drv ,$(subst .exd:,.drv ,$(subst .exp:,.dll ,$(shell grep @$*@ *.ex*))))\'\
  254. name $*
  255. endif
  256. GNUWIN32LIBDIR=./
  257. %.find2 :
  258. @echo s/In archive \(.*\)/\1/p >find.sed
  259. @echo s/\(.*\)___imp_$*@\(.*\)/found: $*/p >>find.sed
  260. ifdef subfile
  261. sed -n -f find.sed alllibs.sym >> $(subfile)
  262. else
  263. sed -n -f find.sed alllibs.sym > $*.res
  264. endif
  265. missing : $(GNUWIN32LIBDIR)alllibs.sym $(addsuffix .lst,$(WINDOWS_FILES))
  266. -rm missing
  267. $(MAKE) subfile=missing $(addsuffix .find2,$(shell cat *.lst))
  268. substmissing : missing
  269. dtou missing
  270. @echo N > test.sed
  271. @echo s/lib\(.*\)\.a:\nfound: \(.*\)/\1.dll : \2/p >> test.sed
  272. @echo D >> test.sed
  273. sed -n -f test.sed missing > missing.tmp
  274. sed -e "s#\(.*\) : \(.*\)#s/external External_library name \'\2\'/external \'\1\' name \'\2\'/#" missing.tmp > missing.sub
  275. dllnames:
  276. $(MAKE) $(addsuffix .lst,$(WINDOWS_FILES))
  277. test:
  278. @echo namelist of $(filename) is "$(namelist)"
  279. # automatic conversion from ascfun.pp to ascdef.pp
  280. # and unifun.pp to unidef.pp
  281. # only if sed is present
  282. ifdef SED
  283. ascdef.pp : ascfun.pp ascdef.sed
  284. sed -f ascdef.sed ascfun.pp > ascdef.pp
  285. unidef.pp : unifun.pp unidef.sed
  286. sed -f unidef.sed unifun.pp > unidef.pp
  287. endif
  288. #####################################################################
  289. # Default targets
  290. #####################################################################
  291. include $(CFG)/makefile.def
  292. #
  293. # $Log$
  294. # Revision 1.19 1999-02-25 09:59:03 michael
  295. # + Fixed type in strings target
  296. #
  297. # Revision 1.18 1999/02/25 07:39:19 michael
  298. # * Joined strings and sysutils
  299. #
  300. # Revision 1.17 1999/01/15 11:47:19 peter
  301. # + added math unit to objects
  302. #
  303. # Revision 1.16 1999/01/04 11:57:45 peter
  304. # * clean doesn't clean objpasdir anymore
  305. #
  306. # Revision 1.15 1998/12/21 13:07:07 peter
  307. # * use -FE
  308. #
  309. # Revision 1.14 1998/11/30 13:13:40 pierre
  310. # * needs asw to link correctly wprt0 or wdllprt0 file
  311. #
  312. # Revision 1.13 1998/11/30 09:16:57 pierre
  313. # + added the changes from Pavel Ozerski after several modifications
  314. # to be able to create DLLs
  315. #
  316. # Revision 1.12 1998/11/24 19:52:10 jonas
  317. # + added warning about TABs
  318. #
  319. # Revision 1.11 1998/11/18 09:28:07 pierre
  320. # + added objects unit
  321. #
  322. # Revision 1.10 1998/10/14 12:49:42 peter
  323. # * fixed dos dependency
  324. #
  325. # Revision 1.9 1998/10/12 08:36:32 pierre
  326. # * wrong 'objpas' target in all removed
  327. #
  328. # Revision 1.8 1998/10/11 13:45:03 michael
  329. # + Added disk.inc to sysutils dependencies
  330. #
  331. # Revision 1.7 1998/10/11 12:21:46 michael
  332. # + Further sysutils implementations.
  333. #
  334. # Revision 1.6 1998/10/06 22:10:32 peter
  335. # + heaptrc
  336. #
  337. # Revision 1.5 1998/10/02 09:26:05 peter
  338. # * fixed rtl path
  339. #
  340. # Revision 1.4 1998/09/16 16:47:35 peter
  341. # * merged fixes
  342. #
  343. # Revision 1.1.2.2 1998/09/16 16:17:55 peter
  344. # * updates to install with go32,win32
  345. #
  346. # Revision 1.3 1998/09/15 12:09:13 peter
  347. # * merged updates
  348. #
  349. # Revision 1.2 1998/09/11 15:09:48 michael
  350. # fixed colon problem
  351. #
  352. # Revision 1.1.2.1 1998/09/15 12:02:06 peter
  353. # * updates to get objpas using its own makefile
  354. #
  355. # Revision 1.1 1998/09/10 14:15:55 peter
  356. # - renamed makefile to Makefile
  357. #
  358. # Revision 1.13 1998/09/07 18:31:54 peter
  359. # * fixed $smartlibext -> $staticlibext to fix a 'rm *' :(
  360. #
  361. # Revision 1.12 1998/09/04 17:17:36 pierre
  362. # + all unknown function ifdef with
  363. # conditionnal unknown_functions
  364. # testwin works now, but windowcreate still fails !!
  365. #
  366. # Revision 1.11 1998/09/04 12:33:12 pierre
  367. # + added SED testing for ascdef.pp and unidef.pp
  368. # * func.pp ready
  369. # still some functions missing (commented out for now)
  370. #
  371. # Revision 1.10 1998/09/03 18:17:35 pierre
  372. # * small improvements in number of found functions
  373. # all remaining are in func.pp
  374. #
  375. # Revision 1.9 1998/09/03 17:14:54 pierre
  376. # * most functions found in main DLL's
  377. # still some missing
  378. # use 'make dllnames' to get missing names
  379. #
  380. # Revision 1.7 1998/08/21 15:17:01 peter
  381. # * win32 compiles a bit better, no growheap crash
  382. #
  383. #