source: branches/FACT++_lidctrl_usb/pal/SConstruct@ 18716

Last change on this file since 18716 was 18347, checked in by tbretz, 9 years ago
File size: 5.4 KB
Line 
1# PAL SConstruct file
2import os
3
4version = "0.9.2"
5
6def CheckStarlink(context):
7 context.Message( "Checking for Starlink environment...")
8 if "STARLINK_DIR" in os.environ:
9 star_root = os.environ["STARCONF_DEFAULT_PREFIX"]
10 star_lib = os.path.join(star_root, "lib")
11 star_inc = os.path.join(star_root, "include")
12 star_share = os.path.join(star_root, "share")
13 star_bin = os.path.join(star_root, "bin")
14 context.env.PrependENVPath('PATH', star_bin)
15 context.Result(star_root)
16 context.env.Replace(PREFIX = star_root)
17 context.env.Append(CPPPATH=star_inc, LIBPATH=star_lib)
18 return { "root": star_root,
19 "lib": star_lib,
20 "include": star_inc,
21 "bin": star_bin,
22 "share": star_share, }
23 context.Result("failed")
24 return None
25
26# Allow --prefix to be specified. We don't use it in Starlink mode
27# though
28AddOption('--prefix',
29 dest='prefix',
30 type='string',
31 nargs=1,
32 action='store',
33 metavar='DIR',
34 help='installation prefix')
35
36env = Environment(PREFIX = "/usr/local" ) # Initialise the environment
37
38prefix = GetOption("prefix")
39if prefix:
40 env.Replace(PREFIX = prefix)
41
42
43# Basic configure checks: but not if --help or --clean
44if not GetOption("help") and not GetOption("clean"):
45 conf = Configure(env, custom_tests = {"CheckStarlink": CheckStarlink} )
46
47 if not conf.CheckCC():
48 print("!! Your compiler and/or environment is not correctly configured.")
49 Exit(0)
50
51 if conf.CheckFunc("copysign"):
52 conf.env.Append(CPPDEFINES={"HAVE_COPYSIGN": 1})
53
54 if conf.CheckFunc("isblank"):
55 conf.env.Append(CPPDEFINES={"HAVE_ISBLANK": 1})
56
57 if conf.CheckFunc("strlcpy"):
58 conf.env.Append(CPPDEFINES={"HAVE_STRLCPY": 1})
59
60 # Force -lm if we need it
61 conf.CheckLib("m","sin")
62
63 # Try to look in current directory
64 conf.env.Append(LIBPATH=["."])
65 conf.env.Append(CPPPATH=["."])
66
67 # If we are in a Starlink environment we know we have
68 # ERFA so just set things up for that. This should be done
69 # using a general SCons "are we starlink" plugin
70 starlink = conf.CheckStarlink()
71 if starlink is not None:
72 conf.env.Append(LIBS=["erfa"])
73 conf.env.Append(CPPDEFINES={"HAVE_STAR_UTIL": 1})
74 conf.env.Append(LIBS=["starutil"])
75 else:
76 # Allow PREFIX to work
77 conf.env.Append(CPPPATH=[os.path.join("$PREFIX", "include")])
78 conf.env.Append(LIBPATH=[os.path.join("$PREFIX", "lib")])
79
80 # Maybe starutil will be available
81 if conf.CheckLib("starutil"):
82 conf.env.Append(CPPDEFINES={"HAVE_STAR_UTIL": 1})
83
84 # Need to look for ERFA vs SOFA
85 if not conf.CheckLib("erfa","eraCal2jd"):
86 if conf.CheckLib("sofa_c","iauCal2jd"):
87 conf.env.Append(CPPDEFINES={"HAVE_SOFA_H": 1})
88 else:
89 print("!! Neither ERFA not SOFA library located. Can not continue. !!")
90 Exit(0)
91
92 env = conf.Finish()
93
94# PAL source code
95libpal_sources = [
96 "pal1Atms.c",
97 "pal1Atmt.c",
98 "palAddet.c",
99 "palAirmas.c",
100 "palAltaz.c",
101 "palAmp.c",
102 "palAmpqk.c",
103 "palAop.c",
104 "palAoppa.c",
105 "palAoppat.c",
106 "palAopqk.c",
107 "palAtmdsp.c",
108 "palCaldj.c",
109 "palDafin.c",
110 "palDat.c",
111 "palDe2h.c",
112 "palDeuler.c",
113 "palDfltin.c",
114 "palDh2e.c",
115 "palDjcal.c",
116 "palDmat.c",
117 "palDmoon.c",
118 "palDrange.c",
119 "palDs2tp.c",
120 "palDt.c",
121 "palDtp2s.c",
122 "palDtps2c.c",
123 "palDtt.c",
124 "palEcmat.c",
125 "palEl2ue.c",
126 "palEpco.c",
127 "palEpv.c",
128 "palEqecl.c",
129 "palEqgal.c",
130 "palEtrms.c",
131 "palEvp.c",
132 "palFk45z.c",
133 "palFk524.c",
134 "palFk54z.c",
135 "palGaleq.c",
136 "palGalsup.c",
137 "palGe50.c",
138 "palGeoc.c",
139 "palIntin.c",
140 "palMap.c",
141 "palMappa.c",
142 "palMapqk.c",
143 "palMapqkz.c",
144 "palNut.c",
145 "palNutc.c",
146 "palOap.c",
147 "palOapqk.c",
148 "palObs.c",
149 "palOne2One.c",
150 "palPa.c",
151 "palPertel.c",
152 "palPertue.c",
153 "palPlanel.c",
154 "palPlanet.c",
155 "palPlante.c",
156 "palPlantu.c",
157 "palPm.c",
158 "palPolmo.c",
159 "palPrebn.c",
160 "palPrec.c",
161 "palPreces.c",
162 "palPrenut.c",
163 "palPv2el.c",
164 "palPv2ue.c",
165 "palPvobs.c",
166 "palRdplan.c",
167 "palRefco.c",
168 "palRefro.c",
169 "palRefv.c",
170 "palRefz.c",
171 "palRverot.c",
172 "palRvgalc.c",
173 "palRvlg.c",
174 "palRvlsrd.c",
175 "palRvlsrk.c",
176 "palSubet.c",
177 "palSupgal.c",
178 "palUe2el.c",
179 "palUe2pv.c",
180 ]
181
182sun267_sources = [ "sun267.tex" ]
183sun267_pdf = env.PDF( sun267_sources )
184Default(sun267_pdf)
185
186# Compiler should look in current directory for header files
187
188staticpal = env.StaticLibrary(target="pal", source=libpal_sources)
189sharedpal = env.SharedLibrary( target="pal", source = libpal_sources,
190 SHLIBVERSION=version )
191
192palTest = env.Program("palTest", "palTest.c", LIBS=["pal"] )
193test_alias = Alias("test", [palTest], palTest[0].abspath)
194AlwaysBuild(test_alias)
195
196installed_sharedlib = env.InstallVersionedLib(os.path.join("$PREFIX","lib"),
197 [sharedpal], SHLIBVERSION=version )
198installed_staticlib = env.Install("$PREFIX/lib", [staticpal] )
199
200# Just build the library by default
201Default(sharedpal)
202Default(staticpal)
203
204# install on request
205if "install" in COMMAND_LINE_TARGETS:
206 env.Alias( "install", "$PREFIX" )
207 Default(installed_sharedlib, installed_staticlib)
208
Note: See TracBrowser for help on using the repository browser.