Initial revision
[AROS-Contrib.git] / development / compilers / freepascal / demo / Makefile
blobaf8e46d6e4f3c3af68f7a739db283df64008dc0e
2 # Makefile generated by fpcmake v1.00 [2000/12/19]
5 defaultrule: all
7 #####################################################################
8 # Autodetect OS (Linux or Dos or Windows NT or OS/2)
9 # define inUnix when running under Unix (Linux,FreeBSD)
10 # define inWinNT when running under WinNT
11 # define inOS2 when running under OS/2
12 #####################################################################
14 # We need only / in the path
15 override PATH:=$(subst \,/,$(PATH))
17 # Search for PWD and determine also if we are under linux
18 PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
19 ifeq ($(PWD),)
20 PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
21 ifeq ($(PWD),)
22 nopwd:
23 @echo You need the GNU utils package to use this Makefile!
24 @echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
25 @exit
26 else
27 inUnix=1
28 PWD:=$(firstword $(PWD))
29 endif
30 else
31 PWD:=$(firstword $(PWD))
32 endif
34 # Detect NT - NT sets OS to Windows_NT
35 # Detect OS/2 - OS/2 has OS2_SHELL defined
36 ifndef inUnix
37 ifeq ($(OS),Windows_NT)
38 inWinNT=1
39 else
40 ifdef OS2_SHELL
41 inOS2=1
42 endif
43 endif
44 endif
46 # The extension of executables
47 ifdef inUnix
48 SRCEXEEXT=
49 else
50 SRCEXEEXT=.exe
51 endif
53 # The path which is searched separated by spaces
54 ifdef inUnix
55 SEARCHPATH=$(subst :, ,$(PATH))
56 else
57 SEARCHPATH=$(subst ;, ,$(PATH))
58 endif
60 # Base dir
61 ifdef PWD
62 BASEDIR:=$(shell $(PWD))
63 else
64 BASEDIR=.
65 endif
67 #####################################################################
68 # FPC version/target Detection
69 #####################################################################
71 # What compiler to use ?
72 ifndef FPC
73 # Compatibility with old makefiles
74 ifdef PP
75 FPC=$(PP)
76 else
77 FPC=ppc386
78 endif
79 endif
80 override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
81 override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
83 # Target OS
84 ifndef OS_TARGET
85 OS_TARGET:=$(shell $(FPC) -iTO)
86 endif
88 # Source OS
89 ifndef OS_SOURCE
90 OS_SOURCE:=$(shell $(FPC) -iSO)
91 endif
93 # Target CPU
94 ifndef CPU_TARGET
95 CPU_TARGET:=$(shell $(FPC) -iTP)
96 endif
98 # Source CPU
99 ifndef CPU_SOURCE
100 CPU_SOURCE:=$(shell $(FPC) -iSP)
101 endif
103 # FPC version
104 ifndef FPC_VERSION
105 FPC_VERSION:=$(shell $(FPC) -iV)
106 endif
108 export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION
110 #####################################################################
111 # FPCDIR Setting
112 #####################################################################
114 # Test FPCDIR to look if the RTL dir exists
115 ifdef FPCDIR
116 override FPCDIR:=$(subst \,/,$(FPCDIR))
117 ifeq ($(wildcard $(FPCDIR)/rtl),)
118 ifeq ($(wildcard $(FPCDIR)/units),)
119 override FPCDIR=wrong
120 endif
121 endif
122 else
123 override FPCDIR=wrong
124 endif
126 # Default FPCDIR
127 ifeq ($(FPCDIR),wrong)
128 override FPCDIR=..
129 ifeq ($(wildcard $(FPCDIR)/rtl),)
130 ifeq ($(wildcard $(FPCDIR)/units),)
131 override FPCDIR=wrong
132 endif
133 endif
134 endif
136 # Detect FPCDIR
137 ifeq ($(FPCDIR),wrong)
138 ifdef inUnix
139 override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
140 ifeq ($(wildcard $(FPCDIR)/units),)
141 override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
142 endif
143 else
144 override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
145 override FPCDIR:=$(FPCDIR)/..
146 ifeq ($(wildcard $(FPCDIR)/rtl),)
147 ifeq ($(wildcard $(FPCDIR)/units),)
148 override FPCDIR:=$(FPCDIR)/..
149 ifeq ($(wildcard $(FPCDIR)/rtl),)
150 ifeq ($(wildcard $(FPCDIR)/units),)
151 override FPCDIR=c:/pp
152 endif
153 endif
154 endif
155 endif
156 endif
157 endif
159 #####################################################################
160 # User Settings
161 #####################################################################
164 # Targets
166 override DIROBJECTS+=$(wildcard text graph)
167 ifeq ($(OS_TARGET),linux)
168 override DIROBJECTS+=$(wildcard linux)
169 endif
170 ifeq ($(OS_TARGET),go32v2)
171 override DIROBJECTS+=$(wildcard modex)
172 endif
173 ifeq ($(OS_TARGET),win32)
174 override DIROBJECTS+=$(wildcard win32)
175 endif
177 # Clean
180 # Install
182 PACKAGENAME=demo
183 ZIPTARGET=install
185 # Defaults
188 # Directories
190 ifndef TARGETDIR
191 TARGETDIR=.
192 endif
194 # Packages
197 # Libraries
200 #####################################################################
201 # Shell tools
202 #####################################################################
204 # echo
205 ifndef ECHO
206 ECHO:=$(strip $(wildcard $(addsuffix /gecho$(EXEEXT),$(SEARCHPATH))))
207 ifeq ($(ECHO),)
208 ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
209 ifeq ($(ECHO),)
210 ECHO:=echo
211 ECHOE:=echo
212 else
213 ECHO:=$(firstword $(ECHO))
214 ECHOE=$(ECHO) -E
215 endif
216 else
217 ECHO:=$(firstword $(ECHO))
218 ECHOE=$(ECHO) -E
219 endif
220 endif
222 # To copy pograms
223 ifndef COPY
224 COPY:=cp -fp
225 endif
227 # Copy a whole tree
228 ifndef COPYTREE
229 COPYTREE:=cp -rfp
230 endif
232 # To move pograms
233 ifndef MOVE
234 MOVE:=mv -f
235 endif
237 # Check delete program
238 ifndef DEL
239 DEL:=rm -f
240 endif
242 # Check deltree program
243 ifndef DELTREE
244 DELTREE:=rm -rf
245 endif
247 # To install files
248 ifndef INSTALL
249 ifdef inUnix
250 INSTALL:=install -c -m 644
251 else
252 INSTALL:=$(COPY)
253 endif
254 endif
256 # To install programs
257 ifndef INSTALLEXE
258 ifdef inUnix
259 INSTALLEXE:=install -c -m 755
260 else
261 INSTALLEXE:=$(COPY)
262 endif
263 endif
265 # To make a directory.
266 ifndef MKDIR
267 ifdef inUnix
268 MKDIR:=install -m 755 -d
269 else
270 MKDIR:=ginstall -m 755 -d
271 endif
272 endif
274 export ECHO ECHOE COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
276 #####################################################################
277 # Default Tools
278 #####################################################################
280 # assembler, redefine it if cross compiling
281 ifndef AS
282 AS=as
283 endif
285 # linker, but probably not used
286 ifndef LD
287 LD=ld
288 endif
290 # ppas.bat / ppas.sh
291 ifdef inUnix
292 PPAS=ppas.sh
293 else
294 ifdef inOS2
295 PPAS=ppas.cmd
296 else
297 PPAS=ppas.bat
298 endif
299 endif
301 # ldconfig to rebuild .so cache
302 ifdef inUnix
303 LDCONFIG=ldconfig
304 else
305 LDCONFIG=
306 endif
308 # ppumove
309 ifndef PPUMOVE
310 PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
311 ifeq ($(PPUMOVE),)
312 PPUMOVE=
313 else
314 PPUMOVE:=$(firstword $(PPUMOVE))
315 endif
316 endif
317 export PPUMOVE
319 # ppufiles
320 ifndef PPUFILES
321 PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(SRCEXEEXT),$(SEARCHPATH))))
322 ifeq ($(PPUFILES),)
323 PPUFILES=
324 else
325 PPUFILES:=$(firstword $(PPUFILES))
326 endif
327 endif
328 export PPUFILES
330 # Look if UPX is found for go32v2 and win32. We can't use $UPX becuase
331 # upx uses that one itself (PFV)
332 ifndef UPXPROG
333 ifeq ($(OS_TARGET),go32v2)
334 UPXPROG:=1
335 endif
336 ifeq ($(OS_TARGET),win32)
337 UPXPROG:=1
338 endif
339 ifdef UPXPROG
340 UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
341 ifeq ($(UPXPROG),)
342 UPXPROG=
343 else
344 UPXPROG:=$(firstword $(UPXPROG))
345 endif
346 else
347 UPXPROG=
348 endif
349 endif
350 export UPXPROG
352 # ZipProg, you can't use Zip as the var name (PFV)
353 ifndef ZIPPROG
354 ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
355 ifeq ($(ZIPPROG),)
356 ZIPPROG=
357 else
358 ZIPPROG:=$(firstword $(ZIPPROG))
359 endif
360 endif
361 export ZIPPROG
363 ZIPOPT=-9
364 ZIPEXT=.zip
366 # Tar
367 ifndef TARPROG
368 TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
369 ifeq ($(TARPROG),)
370 TARPROG=
371 else
372 TARPROG:=$(firstword $(TARPROG))
373 endif
374 endif
375 export TARPROG
377 ifeq ($(USETAR),bz2)
378 TAROPT=vI
379 TAREXT=.tar.bz2
380 else
381 TAROPT=vz
382 TAREXT=.tar.gz
383 endif
385 #####################################################################
386 # Default extensions
387 #####################################################################
389 # Default needed extensions (Go32v2,Linux)
390 LOADEREXT=.as
391 EXEEXT=.exe
392 PPLEXT=.ppl
393 PPUEXT=.ppu
394 OEXT=.o
395 ASMEXT=.s
396 SMARTEXT=.sl
397 STATICLIBEXT=.a
398 SHAREDLIBEXT=.so
399 RSTEXT=.rst
400 FPCMADE=fpcmade
402 # Go32v1
403 ifeq ($(OS_TARGET),go32v1)
404 PPUEXT=.pp1
405 OEXT=.o1
406 ASMEXT=.s1
407 SMARTEXT=.sl1
408 STATICLIBEXT=.a1
409 SHAREDLIBEXT=.so1
410 FPCMADE=fpcmade.v1
411 endif
413 # Go32v2
414 ifeq ($(OS_TARGET),go32v2)
415 FPCMADE=fpcmade.dos
416 endif
418 # Linux
419 ifeq ($(OS_TARGET),linux)
420 EXEEXT=
421 HASSHAREDLIB=1
422 FPCMADE=fpcmade.lnx
423 endif
425 # Linux
426 ifeq ($(OS_TARGET),freebsd)
427 EXEEXT=
428 HASSHAREDLIB=1
429 FPCMADE=fpcmade.freebsd
430 endif
432 # Win32
433 ifeq ($(OS_TARGET),win32)
434 PPUEXT=.ppw
435 OEXT=.ow
436 ASMEXT=.sw
437 SMARTEXT=.slw
438 STATICLIBEXT=.aw
439 SHAREDLIBEXT=.dll
440 FPCMADE=fpcmade.w32
441 endif
443 # OS/2
444 ifeq ($(OS_TARGET),os2)
445 PPUEXT=.ppo
446 ASMEXT=.so2
447 OEXT=.oo2
448 SMARTEXT=.so
449 STATICLIBEXT=.ao2
450 SHAREDLIBEXT=.dll
451 FPCMADE=fpcmade.os2
452 endif
454 # library prefix
455 LIBPREFIX=lib
456 ifeq ($(OS_TARGET),go32v2)
457 LIBPREFIX=
458 endif
459 ifeq ($(OS_TARGET),go32v1)
460 LIBPREFIX=
461 endif
463 # determine which .pas extension is used
464 ifndef PASEXT
465 ifdef EXEOBJECTS
466 override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
467 else
468 override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
469 endif
470 ifeq ($(TESTPAS),)
471 PASEXT=.pp
472 else
473 PASEXT=.pas
474 endif
475 endif
479 #####################################################################
480 # Default Directories
481 #####################################################################
483 # Linux and freebsd use unix dirs with /usr/bin, /usr/lib
484 # When zipping use the target as default, when normal install then
485 # use the source os as default
486 ifdef ZIPNAME
487 # Zipinstall
488 ifeq ($(OS_TARGET),linux)
489 UNIXINSTALLDIR=1
490 endif
491 ifeq ($(OS_TARGET),freebsd)
492 UNIXINSTALLDIR=1
493 endif
494 else
495 # Normal install
496 ifeq ($(OS_SOURCE),linux)
497 UNIXINSTALLDIR=1
498 endif
499 ifeq ($(OS_SOURCE),freebsd)
500 UNIXINSTALLDIR=1
501 endif
502 endif
504 # set the prefix directory where to install everything
505 ifndef PREFIXINSTALLDIR
506 ifdef UNIXINSTALLDIR
507 PREFIXINSTALLDIR=/usr
508 else
509 PREFIXINSTALLDIR=/pp
510 endif
511 endif
512 export PREFIXINSTALLDIR
514 # Where to place the resulting zip files
515 ifndef DESTZIPDIR
516 DESTZIPDIR:=$(BASEDIR)
517 endif
518 export DESTZIPDIR
520 #####################################################################
521 # Install Directories
522 #####################################################################
524 # set the base directory where to install everything
525 ifndef BASEINSTALLDIR
526 ifdef UNIXINSTALLDIR
527 BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION)
528 else
529 BASEINSTALLDIR=$(PREFIXINSTALLDIR)
530 endif
531 endif
533 # set the directory where to install the binaries
534 ifndef BININSTALLDIR
535 ifdef UNIXINSTALLDIR
536 BININSTALLDIR=$(PREFIXINSTALLDIR)/bin
537 else
538 BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET)
539 endif
540 endif
542 # set the directory where to install the units.
543 ifndef UNITINSTALLDIR
544 UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET)
545 ifdef UNITSUBDIR
546 UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR)
547 endif
548 endif
550 # Where to install shared libraries
551 ifndef LIBINSTALLDIR
552 ifdef UNIXINSTALLDIR
553 LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib
554 else
555 LIBINSTALLDIR=$(UNITINSTALLDIR)
556 endif
557 endif
559 # Where the source files will be stored
560 ifndef SOURCEINSTALLDIR
561 ifdef UNIXINSTALLDIR
562 SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION)
563 else
564 SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source
565 endif
566 ifdef SOURCESUBDIR
567 SOURCEINSTALLDIR:=$(SOURCEINSTALLDIR)/$(SOURCESUBDIR)
568 endif
569 endif
571 # Where the doc files will be stored
572 ifndef DOCINSTALLDIR
573 ifdef UNIXINSTALLDIR
574 DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION)
575 else
576 DOCINSTALLDIR=$(BASEINSTALLDIR)/doc
577 endif
578 endif
580 # Where to install the examples, under linux we use the doc dir
581 # because the copytree command will create a subdir itself
582 ifndef EXAMPLEINSTALLDIR
583 ifdef UNIXINSTALLDIR
584 EXAMPLEINSTALLDIR=$(DOCINSTALLDIR)/examples
585 else
586 EXAMPLEINSTALLDIR=$(BASEINSTALLDIR)/examples
587 endif
588 ifdef EXAMPLESUBDIR
589 EXAMPLEINSTALLDIR:=$(EXAMPLEINSTALLDIR)/$(EXAMPLESUBDIR)
590 endif
591 endif
593 # Where the some extra (data)files will be stored
594 ifndef DATAINSTALLDIR
595 DATAINSTALLDIR=$(BASEINSTALLDIR)
596 endif
598 #####################################################################
599 # Redirection
600 #####################################################################
602 ifndef REDIRFILE
603 REDIRFILE=log
604 endif
606 ifdef REDIR
607 ifndef inUnix
608 override FPC=redir -eo $(FPC)
609 endif
610 # set the verbosity to max
611 override FPCOPT+=-va
612 override REDIR:= >> $(REDIRFILE)
613 endif
616 #####################################################################
617 # Compiler Command Line
618 #####################################################################
620 # Load commandline OPTDEF and add FPC_CPU define
621 override FPCOPTDEF:=-d$(CPU_TARGET)
623 # Load commandline OPT and add target and unit dir to be sure
624 ifneq ($(OS_TARGET),$(OS_SOURCE))
625 override FPCOPT+=-T$(OS_TARGET)
626 endif
628 # User dirs should be first, so they are looked at first
629 ifdef UNITDIR
630 override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
631 endif
632 ifdef LIBDIR
633 override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
634 endif
635 ifdef OBJDIR
636 override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
637 endif
638 ifdef INCDIR
639 override FPCOPT+=$(addprefix -Fi,$(INCDIR))
640 endif
642 # Smartlinking
643 ifdef LINKSMART
644 override FPCOPT+=-XX
645 endif
647 # Smartlinking creation
648 ifdef CREATESMART
649 override FPCOPT+=-CX
650 endif
652 # Debug
653 ifdef DEBUG
654 override FPCOPT+=-gl -dDEBUG
655 endif
657 # Release mode (strip, optimize and don't load ppc386.cfg)
658 # 0.99.12b has a bug in the optimizer so don't use it by default
659 ifdef RELEASE
660 ifeq ($(FPC_VERSION),0.99.12)
661 override FPCOPT+=-Xs -OGp3 -n
662 else
663 override FPCOPT+=-Xs -OG2p3 -n
664 endif
665 endif
667 # Strip
668 ifdef STRIP
669 override FPCOPT+=-Xs
670 endif
672 # Optimizer
673 ifdef OPTIMIZE
674 override FPCOPT+=-OG2p3
675 endif
677 # Verbose settings (warning,note,info)
678 ifdef VERBOSE
679 override FPCOPT+=-vwni
680 endif
682 ifdef UNITSDIR
683 override FPCOPT+=-Fu$(UNITSDIR)
684 endif
686 # Target dirs and the prefix to use for clean/install
687 ifdef TARGETDIR
688 override FPCOPT+=-FE$(TARGETDIR)
689 ifeq ($(TARGETDIR),.)
690 override TARGETDIRPREFIX=
691 else
692 override TARGETDIRPREFIX=$(TARGETDIR)/
693 endif
694 endif
695 ifdef UNITTARGETDIR
696 override FPCOPT+=-FU$(UNITTARGETDIR)
697 ifeq ($(UNITTARGETDIR),.)
698 override UNITTARGETDIRPREFIX=
699 else
700 override UNITTARGETDIRPREFIX=$(TARGETDIR)/
701 endif
702 else
703 ifdef TARGETDIR
704 override UNITTARGETDIR=$(TARGETDIR)
705 override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
706 endif
707 endif
709 # Add commandline options last so they can override
710 ifdef OPT
711 override FPCOPT+=$(OPT)
712 endif
714 # Add defines from FPCOPTDEF to FPCOPT
715 ifdef FPCOPTDEF
716 override FPCOPT+=$(FPCOPTDEF)
717 endif
719 # Error file ?
720 ifdef ERRORFILE
721 override FPCOPT+=-Fr$(ERRORFILE)
722 endif
724 # Was a config file specified ?
725 ifdef CFGFILE
726 override FPCOPT+=@$(CFGFILE)
727 endif
729 # For win32 the options are passed using the environment FPCEXTCMD
730 ifeq ($(OS_SOURCE),win32)
731 override FPCEXTCMD:=$(FPCOPT)
732 override FPCOPT:=!FPCEXTCMD
733 export FPCEXTCMD
734 endif
736 # Compiler commandline
737 override COMPILER:=$(FPC) $(FPCOPT)
739 # also call ppas if with command option -s
740 # but only if the OS_SOURCE and OS_TARGE are equal
741 ifeq (,$(findstring -s ,$(COMPILER)))
742 EXECPPAS=
743 else
744 ifeq ($(OS_SOURCE),$(OS_TARGET))
745 EXECPPAS:=@$(PPAS)
746 endif
747 endif
749 #####################################################################
750 # Standard rules
751 #####################################################################
753 all: fpc_all $(addsuffix _all,$(DIROBJECTS))
755 debug: fpc_debug $(addsuffix _debug,$(DIROBJECTS))
757 smart: fpc_smart $(addsuffix _smart,$(DIROBJECTS))
759 shared: fpc_shared $(addsuffix _shared,$(DIROBJECTS))
761 showinstall: fpc_showinstall $(addsuffix _showinstall,$(DIROBJECTS))
763 install: fpc_install $(addsuffix _install,$(DIROBJECTS))
765 sourceinstall: fpc_sourceinstall
767 exampleinstall: fpc_exampleinstall
769 zipinstall: fpc_zipinstall
771 zipsourceinstall: fpc_zipsourceinstall
773 zipexampleinstall: fpc_zipexampleinstall
775 clean: fpc_clean $(addsuffix _clean,$(DIROBJECTS))
777 distclean: fpc_distclean $(addsuffix _distclean,$(DIROBJECTS))
779 cleanall: fpc_cleanall $(addsuffix _cleanall,$(DIROBJECTS))
781 require: $(addsuffix _require,$(DIROBJECTS))
783 .PHONY: all debug smart shared showinstall install sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall clean distclean cleanall require
785 #####################################################################
786 # General compile rules
787 #####################################################################
789 .PHONY: fpc_packages fpc_all fpc_debug
791 $(FPCMADE): $(ALLTARGET)
792 @$(ECHO) Compiled > $(FPCMADE)
794 fpc_packages: $(COMPILEPACKAGES)
796 fpc_all: fpc_packages $(FPCMADE)
798 fpc_debug:
799 $(MAKE) all DEBUG=1
801 # Search paths for .ppu if targetdir is set
802 ifdef UNITTARGETDIR
803 vpath %$(PPUEXT) $(UNITTARGETDIR)
804 endif
806 # General compile rules, available for both possible PASEXT
808 .SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp
810 %$(PPUEXT): %.pp
811 $(COMPILER) $< $(REDIR)
812 $(EXECPPAS)
814 %$(PPUEXT): %.pas
815 $(COMPILER) $< $(REDIR)
816 $(EXECPPAS)
818 %$(EXEEXT): %.pp
819 $(COMPILER) $< $(REDIR)
820 $(EXECPPAS)
822 %$(EXEEXT): %.pas
823 $(COMPILER) $< $(REDIR)
824 $(EXECPPAS)
826 #####################################################################
827 # Library
828 #####################################################################
830 .PHONY: fpc_smart fpc_shared
832 ifdef LIBVERSION
833 LIBFULLNAME=$(LIBNAME).$(LIBVERSION)
834 else
835 LIBFULLNAME=$(LIBNAME)
836 endif
838 # Default sharedlib units are all unit objects
839 ifndef SHAREDLIBUNITOBJECTS
840 SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS)
841 endif
843 fpc_smart:
844 $(MAKE) all LINKSMART=1 CREATESMART=1
846 fpc_shared: all
847 ifdef HASSHAREDLIB
848 ifndef LIBNAME
849 @$(ECHO) "LIBNAME not set"
850 else
851 $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBFULLNAME)
852 endif
853 else
854 @$(ECHO) "Shared Libraries not supported"
855 endif
857 #####################################################################
858 # Install rules
859 #####################################################################
861 .PHONY: fpc_showinstall fpc_install
863 ifdef EXTRAINSTALLUNITS
864 override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))
865 endif
867 ifdef INSTALLPPUFILES
868 override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
869 ifdef PPUFILES
870 INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES))
871 else
872 INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))))
873 endif
874 override INSTALLPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES))
875 endif
877 ifdef INSTALLEXEFILES
878 override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
879 endif
881 fpc_showinstall: $(SHOWINSTALLTARGET)
882 ifdef INSTALLEXEFILES
883 @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES))
884 endif
885 ifdef INSTALLPPUFILES
886 @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES))
887 ifneq ($(INSTALLPPULINKFILES),)
888 @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES))
889 endif
890 ifneq ($(wildcard $(LIBFULLNAME)),)
891 @$(ECHO) $(LIBINSTALLDIR)/$(LIBFULLNAME)
892 ifdef HASSHAREDLIB
893 @$(ECHO) $(LIBINSTALLDIR)/$(LIBNAME)
894 endif
895 endif
896 endif
897 ifdef EXTRAINSTALLFILES
898 @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES))
899 endif
901 fpc_install: $(INSTALLTARGET)
902 # Create UnitInstallFiles
903 ifdef INSTALLEXEFILES
904 $(MKDIR) $(BININSTALLDIR)
905 # Compress the exes if upx is defined
906 ifdef UPXPROG
907 -$(UPXPROG) $(INSTALLEXEFILES)
908 endif
909 $(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR)
910 endif
911 ifdef INSTALLPPUFILES
912 $(MKDIR) $(UNITINSTALLDIR)
913 $(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR)
914 ifneq ($(INSTALLPPULINKFILES),)
915 $(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR)
916 endif
917 ifneq ($(wildcard $(LIBFULLNAME)),)
918 $(MKDIR) $(LIBINSTALLDIR)
919 $(INSTALL) $(LIBFULLNAME) $(LIBINSTALLDIR)
920 ifdef inUnix
921 ln -sf $(LIBFULLNAME) $(LIBINSTALLDIR)/$(LIBNAME)
922 endif
923 endif
924 endif
925 ifdef EXTRAINSTALLFILES
926 $(MKDIR) $(DATAINSTALLDIR)
927 $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR)
928 endif
930 #####################################################################
931 # SourceInstall rules
932 #####################################################################
934 .PHONY: fpc_sourceinstall
936 ifndef SOURCETOPDIR
937 SOURCETOPDIR=$(BASEDIR)
938 endif
940 fpc_sourceinstall: clean
941 $(MKDIR) $(SOURCEINSTALLDIR)
942 $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR)
944 #####################################################################
945 # exampleinstall rules
946 #####################################################################
948 .PHONY: fpc_exampleinstall
950 fpc_exampleinstall: $(addsuffix _clean,$(EXAMPLEDIROBJECTS))
951 ifdef EXAMPLESOURCEFILES
952 $(MKDIR) $(EXAMPLEINSTALLDIR)
953 $(COPY) $(EXAMPLESOURCEFILES) $(EXAMPLEINSTALLDIR)
954 endif
955 ifdef EXAMPLEDIROBJECTS
956 ifndef EXAMPLESOURCEFILES
957 $(MKDIR) $(EXAMPLEINSTALLDIR)
958 endif
959 $(COPYTREE) $(addsuffix /*,$(EXAMPLEDIROBJECTS)) $(EXAMPLEINSTALLDIR)
960 endif
962 #####################################################################
963 # Zip
964 #####################################################################
966 .PHONY: fpc_zipinstall
968 # Create suffix to add
969 ifndef PACKAGESUFFIX
970 PACKAGESUFFIX=$(OS_TARGET)
971 ifeq ($(OS_TARGET),go32v2)
972 PACKAGESUFFIX=go32
973 endif
974 ifeq ($(OS_TARGET),win32)
975 PACKAGESUFFIX=w32
976 endif
977 ifeq ($(OS_TARGET),os2)
978 PACKAGESUFFIX=emx
979 endif
980 endif
982 # Temporary path to pack a file
983 ifndef PACKDIR
984 ifndef inUnix
985 PACKDIR=$(BASEDIR)/pack_tmp
986 else
987 PACKDIR=/tmp/fpc-pack
988 endif
989 endif
991 # Maybe create default zipname from packagename
992 ifndef ZIPNAME
993 ifdef PACKAGENAME
994 ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX)
995 endif
996 endif
998 # Use tar by default under linux
999 ifndef USEZIP
1000 ifdef inUnix
1001 USETAR=1
1002 endif
1003 endif
1005 fpc_zipinstall:
1006 ifndef ZIPNAME
1007 @$(ECHO) "Please specify ZIPNAME!"
1008 @exit 1
1009 else
1010 $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
1011 ifdef USETAR
1012 $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT)
1013 cd $(PACKDIR) ; $(TARPROG) cf$(TAROPT) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) * ; cd $(BASEDIR)
1014 else
1015 $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT)
1016 cd $(PACKDIR) ; $(ZIPPROG) -Dr $(ZIPOPT) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) * ; cd $(BASEDIR)
1017 endif
1018 $(DELTREE) $(PACKDIR)
1019 endif
1021 .PHONY: fpc_zipsourceinstall
1023 fpc_zipsourceinstall:
1024 $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src
1026 .PHONY: fpc_zipexampleinstall
1028 fpc_zipexampleinstall:
1029 $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall PACKAGESUFFIX=exm
1031 #####################################################################
1032 # Clean rules
1033 #####################################################################
1035 .PHONY: fpc_clean fpc_cleanall fpc_distclean
1037 ifdef EXEFILES
1038 override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
1039 endif
1041 ifdef EXTRACLEANUNITS
1042 override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS))
1043 endif
1045 ifdef CLEANPPUFILES
1046 override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
1047 # Get the .o and .a files created for the units
1048 ifdef PPUFILES
1049 CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES))
1050 else
1051 CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))))
1052 endif
1053 override CLEANPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES))
1054 endif
1056 fpc_clean: $(CLEANTARGET)
1057 ifdef CLEANEXEFILES
1058 -$(DEL) $(CLEANEXEFILES)
1059 endif
1060 ifdef CLEANPPUFILES
1061 -$(DEL) $(CLEANPPUFILES)
1062 endif
1063 ifneq ($(CLEANPPULINKFILES),)
1064 -$(DEL) $(CLEANPPULINKFILES)
1065 endif
1066 ifdef CLEANRSTFILES
1067 -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
1068 endif
1069 ifdef EXTRACLEANFILES
1070 -$(DEL) $(EXTRACLEANFILES)
1071 endif
1072 ifdef LIBNAME
1073 -$(DEL) $(LIBNAME) $(LIBFULLNAME)
1074 endif
1075 -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE)
1077 fpc_distclean: fpc_clean
1079 # Also run clean first if targetdir is set. Unittargetdir is always
1080 # set if targetdir or unittargetdir is specified
1081 ifdef UNITTARGETDIR
1082 TARGETDIRCLEAN=fpc_clean
1083 endif
1085 fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
1086 ifdef CLEANEXEFILES
1087 -$(DEL) $(CLEANEXEFILES)
1088 endif
1089 -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
1090 -$(DELTREE) *$(SMARTEXT)
1091 -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE)
1093 #####################################################################
1094 # Directories
1095 #####################################################################
1097 OBJECTDIRTEXT=1
1098 OBJECTDIRGRAPH=1
1099 ifeq ($(OS_TARGET),linux)
1100 OBJECTDIRLINUX=1
1101 endif
1102 ifeq ($(OS_TARGET),go32v2)
1103 OBJECTDIRMODEX=1
1104 endif
1105 ifeq ($(OS_TARGET),win32)
1106 OBJECTDIRWIN32=1
1107 endif
1109 # Dir text
1111 ifdef OBJECTDIRTEXT
1112 .PHONY: text_all text_debug text_examples text_test text_smart text_shared text_showinstall text_install text_sourceinstall text_exampleinstall text_zipinstall text_zipsourceinstall text_zipexampleinstall text_clean text_distclean text_cleanall text_require text_info
1114 text_all:
1115 $(MAKE) -C text all
1117 text_debug:
1118 $(MAKE) -C text debug
1120 text_examples:
1121 $(MAKE) -C text examples
1123 text_test:
1124 $(MAKE) -C text test
1126 text_smart:
1127 $(MAKE) -C text smart
1129 text_shared:
1130 $(MAKE) -C text shared
1132 text_showinstall:
1133 $(MAKE) -C text showinstall
1135 text_install:
1136 $(MAKE) -C text install
1138 text_sourceinstall:
1139 $(MAKE) -C text sourceinstall
1141 text_exampleinstall:
1142 $(MAKE) -C text exampleinstall
1144 text_zipinstall:
1145 $(MAKE) -C text zipinstall
1147 text_zipsourceinstall:
1148 $(MAKE) -C text zipsourceinstall
1150 text_zipexampleinstall:
1151 $(MAKE) -C text zipexampleinstall
1153 text_clean:
1154 $(MAKE) -C text clean
1156 text_distclean:
1157 $(MAKE) -C text distclean
1159 text_cleanall:
1160 $(MAKE) -C text cleanall
1162 text_require:
1163 $(MAKE) -C text require
1165 text_info:
1166 $(MAKE) -C text info
1167 endif
1169 # Dir graph
1171 ifdef OBJECTDIRGRAPH
1172 .PHONY: graph_all graph_debug graph_examples graph_test graph_smart graph_shared graph_showinstall graph_install graph_sourceinstall graph_exampleinstall graph_zipinstall graph_zipsourceinstall graph_zipexampleinstall graph_clean graph_distclean graph_cleanall graph_require graph_info
1174 graph_all:
1175 $(MAKE) -C graph all
1177 graph_debug:
1178 $(MAKE) -C graph debug
1180 graph_examples:
1181 $(MAKE) -C graph examples
1183 graph_test:
1184 $(MAKE) -C graph test
1186 graph_smart:
1187 $(MAKE) -C graph smart
1189 graph_shared:
1190 $(MAKE) -C graph shared
1192 graph_showinstall:
1193 $(MAKE) -C graph showinstall
1195 graph_install:
1196 $(MAKE) -C graph install
1198 graph_sourceinstall:
1199 $(MAKE) -C graph sourceinstall
1201 graph_exampleinstall:
1202 $(MAKE) -C graph exampleinstall
1204 graph_zipinstall:
1205 $(MAKE) -C graph zipinstall
1207 graph_zipsourceinstall:
1208 $(MAKE) -C graph zipsourceinstall
1210 graph_zipexampleinstall:
1211 $(MAKE) -C graph zipexampleinstall
1213 graph_clean:
1214 $(MAKE) -C graph clean
1216 graph_distclean:
1217 $(MAKE) -C graph distclean
1219 graph_cleanall:
1220 $(MAKE) -C graph cleanall
1222 graph_require:
1223 $(MAKE) -C graph require
1225 graph_info:
1226 $(MAKE) -C graph info
1227 endif
1229 # Dir linux
1231 ifdef OBJECTDIRLINUX
1232 .PHONY: linux_all linux_debug linux_examples linux_test linux_smart linux_shared linux_showinstall linux_install linux_sourceinstall linux_exampleinstall linux_zipinstall linux_zipsourceinstall linux_zipexampleinstall linux_clean linux_distclean linux_cleanall linux_require linux_info
1234 linux_all:
1235 $(MAKE) -C linux all
1237 linux_debug:
1238 $(MAKE) -C linux debug
1240 linux_examples:
1241 $(MAKE) -C linux examples
1243 linux_test:
1244 $(MAKE) -C linux test
1246 linux_smart:
1247 $(MAKE) -C linux smart
1249 linux_shared:
1250 $(MAKE) -C linux shared
1252 linux_showinstall:
1253 $(MAKE) -C linux showinstall
1255 linux_install:
1256 $(MAKE) -C linux install
1258 linux_sourceinstall:
1259 $(MAKE) -C linux sourceinstall
1261 linux_exampleinstall:
1262 $(MAKE) -C linux exampleinstall
1264 linux_zipinstall:
1265 $(MAKE) -C linux zipinstall
1267 linux_zipsourceinstall:
1268 $(MAKE) -C linux zipsourceinstall
1270 linux_zipexampleinstall:
1271 $(MAKE) -C linux zipexampleinstall
1273 linux_clean:
1274 $(MAKE) -C linux clean
1276 linux_distclean:
1277 $(MAKE) -C linux distclean
1279 linux_cleanall:
1280 $(MAKE) -C linux cleanall
1282 linux_require:
1283 $(MAKE) -C linux require
1285 linux_info:
1286 $(MAKE) -C linux info
1287 endif
1289 # Dir modex
1291 ifdef OBJECTDIRMODEX
1292 .PHONY: modex_all modex_debug modex_examples modex_test modex_smart modex_shared modex_showinstall modex_install modex_sourceinstall modex_exampleinstall modex_zipinstall modex_zipsourceinstall modex_zipexampleinstall modex_clean modex_distclean modex_cleanall modex_require modex_info
1294 modex_all:
1295 $(MAKE) -C modex all
1297 modex_debug:
1298 $(MAKE) -C modex debug
1300 modex_examples:
1301 $(MAKE) -C modex examples
1303 modex_test:
1304 $(MAKE) -C modex test
1306 modex_smart:
1307 $(MAKE) -C modex smart
1309 modex_shared:
1310 $(MAKE) -C modex shared
1312 modex_showinstall:
1313 $(MAKE) -C modex showinstall
1315 modex_install:
1316 $(MAKE) -C modex install
1318 modex_sourceinstall:
1319 $(MAKE) -C modex sourceinstall
1321 modex_exampleinstall:
1322 $(MAKE) -C modex exampleinstall
1324 modex_zipinstall:
1325 $(MAKE) -C modex zipinstall
1327 modex_zipsourceinstall:
1328 $(MAKE) -C modex zipsourceinstall
1330 modex_zipexampleinstall:
1331 $(MAKE) -C modex zipexampleinstall
1333 modex_clean:
1334 $(MAKE) -C modex clean
1336 modex_distclean:
1337 $(MAKE) -C modex distclean
1339 modex_cleanall:
1340 $(MAKE) -C modex cleanall
1342 modex_require:
1343 $(MAKE) -C modex require
1345 modex_info:
1346 $(MAKE) -C modex info
1347 endif
1349 # Dir win32
1351 ifdef OBJECTDIRWIN32
1352 .PHONY: win32_all win32_debug win32_examples win32_test win32_smart win32_shared win32_showinstall win32_install win32_sourceinstall win32_exampleinstall win32_zipinstall win32_zipsourceinstall win32_zipexampleinstall win32_clean win32_distclean win32_cleanall win32_require win32_info
1354 win32_all:
1355 $(MAKE) -C win32 all
1357 win32_debug:
1358 $(MAKE) -C win32 debug
1360 win32_examples:
1361 $(MAKE) -C win32 examples
1363 win32_test:
1364 $(MAKE) -C win32 test
1366 win32_smart:
1367 $(MAKE) -C win32 smart
1369 win32_shared:
1370 $(MAKE) -C win32 shared
1372 win32_showinstall:
1373 $(MAKE) -C win32 showinstall
1375 win32_install:
1376 $(MAKE) -C win32 install
1378 win32_sourceinstall:
1379 $(MAKE) -C win32 sourceinstall
1381 win32_exampleinstall:
1382 $(MAKE) -C win32 exampleinstall
1384 win32_zipinstall:
1385 $(MAKE) -C win32 zipinstall
1387 win32_zipsourceinstall:
1388 $(MAKE) -C win32 zipsourceinstall
1390 win32_zipexampleinstall:
1391 $(MAKE) -C win32 zipexampleinstall
1393 win32_clean:
1394 $(MAKE) -C win32 clean
1396 win32_distclean:
1397 $(MAKE) -C win32 distclean
1399 win32_cleanall:
1400 $(MAKE) -C win32 cleanall
1402 win32_require:
1403 $(MAKE) -C win32 require
1405 win32_info:
1406 $(MAKE) -C win32 info
1407 endif
1409 #####################################################################
1410 # Local Makefile
1411 #####################################################################
1413 ifneq ($(wildcard fpcmake.loc),)
1414 include fpcmake.loc
1415 endif
1417 #####################################################################
1418 # Users rules
1419 #####################################################################
1421 .PHONY: info
1423 info:
1424 @echo Makefile targets are
1425 @echo - all
1426 @echo - text
1427 @echo - graph
1428 @echo - modex
1429 @echo - win32
1430 @echo
1431 @echo - installexamples
1433 #################################
1434 # Demo installation for linux
1437 .PHONY: installexamples
1439 installexamples:
1440 $(MAKE) sourceinstall SOURCEINSTALLDIR=$(EXAMPLEINSTALLDIR)