aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes/UConfig.pas
blob: 51e9348ef999588da92680b9957879447b65ec64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
unit UConfig;

// -------------------------------------------------------------------
// Note on version comparison (for developers only):
// -------------------------------------------------------------------
// Delphi (in contrast to FPC) DOESN'T support MACROS. So we
// can't define a macro like VERSION_MAJOR(version) to extract
// parts of the version-number or to create version numbers for
// comparison purposes as with a MAKE_VERSION(maj, min, rev) macro.
// So we have to define constants for every part of the version here.
//
// In addition FPC (in contrast to delphi) DOES NOT support floating-
// point numbers in $IF compiler-directives (e.g. {$IF VERSION > 1.23})
// It also DOESN'T support arithmetic operations so we aren't able to
// compare versions this way (brackets aren't supported too):
//   {$IF VERSION > ((VER_MAJ*2)+(VER_MIN*23)+(VER_REL*1))}
//
// Hence we have to use fixed numbers in the directives. At least
// Pascal allows leading 0s so 0005 equals 5 (octals are
// preceded by & and not by 0 in FPC).
// We also fix the count of digits for each part of the version number
// to 3 (aaaiiirrr with aaa=major, iii=minor, rrr=release version)
//
// A check for a library with at least a version of 2.5.11 would look
// like this:
//   {$IF LIB_VERSION >= 002005011}
//
// If you just need to check the major version do this:
//   {$IF LIB_VERSION_MAJOR >= 23}
//
// IMPORTANT:
//   Because this unit must be included in a uses-section it is
//   not possible to use the version-numbers in this uses-clause.
//   Example:
//     interface
//     uses 
//       versions, // include this file
//       {$IF USE_UNIT_XYZ}xyz;{$IFEND}      // Error: USE_UNIT_XYZ not defined
//     const
//       {$IF USE_UNIT_XYZ}test = 2;{$IFEND} // OK
//     uses
//       {$IF USE_UNIT_XYZ}xyz;{$IFEND}      // OK
//
//   Even if this file was an include-file no constants could be declared
//   before the interface's uses clause.
//   In FPC macros {$DEFINE VER:= 3} could be used to declare the version-numbers 
//   but this is incompatible to Delphi. In addition macros do not allow expand
//   arithmetic expressions. Although you can define 
//     {$DEFINE FPC_VER:= FPC_VERSION*1000000+FPC_RELEASE*1000+FPC_PATCH}
//   the following check would fail:
//     {$IF FPC_VERSION_INT >= 002002000}
//   would fail because FPC_VERSION_INT is interpreted as a string. 
//
// PLEASE consider this if you use version numbers in $IF compiler-
// directives. Otherwise you might break portability.
// -------------------------------------------------------------------

interface

{$IFDEF FPC}
  {$MODE Delphi}
{$ENDIF}

{$I switches.inc}
   
uses
  Sysutils;

const
  // include config-file
  {$DEFINE IncludeConstants}
  {$IF Defined(MSWindows)}
    {$I ../config-win.inc}
  {$ELSEIF Defined(Linux)}
    {$I ../config-linux.inc}
  {$ELSEIF Defined(Darwin)}
    {$I ../config-macosx.inc}
  {$ELSE}
    {$MESSAGE Fatal 'Unknown OS'}
  {$IFEND}

{* Libraries *}

  VERSION_MAJOR   = 1000000;
  VERSION_MINOR   = 1000;
  VERSION_RELEASE = 1;

  (* 
   * FPC_VERSION is already defined as a macro by FPC itself.
   * You should use the built-in macros
   *   FPC_VERSION (=PPC_MAJOR)
   *   FPC_RELEASE (=PPC_MINOR)
   *   FPC_PATCH   (=PPC_RELEASE)
   * instead of the PPC_* ones defined here.
   * This way Windows users do not need to set this.
   *
   * Note: It might be necessary to enable macros ({$MACRO ON} or -Sm) 
   *   first if you want to use the FPC_* macros. 
   *   In FPC 2.2.0 they work even without macros being enabled but 
   *   this might be different in other versions.
   *
   * Example (Check for version >= 2.0.1):
   *   {$IF (FPC_VERSION > 2) or ((FPC_VERSION = 2) and 
   *      ( (FPC_RELEASE > 0) or ((FPC_RELEASE = 0) and 
   *        (FPC_PATCH  >= 1)) ))}
   *     {$DEFINE FPC_VER_201_PLUS}
   *   {$ENDIF}   
   *
   * IMPORTANT: do NOT check this way:
   *   {$IF (FPC_VERSION >= 2) and (FPC_RELEASE >= 0) and (FPC_PATCH >= 1)}
   *     ...
   *   In this case version 3.0.0 does not match because Patch 0 is less than 1.
   *)

  //PPC_VERSION_MAJOR   = @PPC_VERSION_MAJOR@;
  //PPC_VERSION_MINOR   = @PPC_VERSION_MINOR@;
  //PPC_VERSION_RELEASE = @PPC_VERSION_RELEASE@;
  //PPC_VERSION = (PPC_VERSION_MAJOR * VERSION_MAJOR) +
  //              (PPC_VERSION_MINOR * VERSION_MINOR) +
  //              (PPC_VERSION_RELEASE * VERSION_RELEASE);

  {$IFDEF LAZARUS}
  LAZARUS_VERSION = (LAZARUS_VERSION_MAJOR * VERSION_MAJOR) +
                    (LAZARUS_VERSION_MINOR * VERSION_MINOR) +
                    (LAZARUS_VERSION_RELEASE * VERSION_RELEASE);
  {$ENDIF}

  {$IFDEF HaveFFMpeg}

  LIBAVCODEC_VERSION = (LIBAVCODEC_VERSION_MAJOR * VERSION_MAJOR) +
                       (LIBAVCODEC_VERSION_MINOR * VERSION_MINOR) +
                       (LIBAVCODEC_VERSION_RELEASE * VERSION_RELEASE);

  LIBAVFORMAT_VERSION = (LIBAVFORMAT_VERSION_MAJOR * VERSION_MAJOR) +
                        (LIBAVFORMAT_VERSION_MINOR * VERSION_MINOR) +
                        (LIBAVFORMAT_VERSION_RELEASE * VERSION_RELEASE);

  LIBAVUTIL_VERSION = (LIBAVUTIL_VERSION_MAJOR * VERSION_MAJOR) +
                      (LIBAVUTIL_VERSION_MINOR * VERSION_MINOR) +
                      (LIBAVUTIL_VERSION_RELEASE * VERSION_RELEASE);

  {$ENDIF}

  {$IFDEF HaveSWScale}
  LIBSWSCALE_VERSION = (LIBSWSCALE_VERSION_MAJOR * VERSION_MAJOR) +
                       (LIBSWSCALE_VERSION_MINOR * VERSION_MINOR) +
                       (LIBSWSCALE_VERSION_RELEASE * VERSION_RELEASE);
  {$ENDIF}
		      
  {$IFDEF HaveProjectM}  
  PROJECTM_VERSION = (PROJECTM_VERSION_MAJOR * VERSION_MAJOR) +
                     (PROJECTM_VERSION_MINOR * VERSION_MINOR) +
                     (PROJECTM_VERSION_RELEASE * VERSION_RELEASE);
  {$ENDIF}

  {$IFDEF HavePortaudio}  
  PORTAUDIO_VERSION = (PORTAUDIO_VERSION_MAJOR * VERSION_MAJOR) +
                      (PORTAUDIO_VERSION_MINOR * VERSION_MINOR) +
                      (PORTAUDIO_VERSION_RELEASE * VERSION_RELEASE);
  {$ENDIF}

implementation

end.