blob: a4f07d247eaf1ebc128470e318c517b8c3611cca [file] [log] [blame]
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +02001AC_INIT([open_pdks], [1.0], [github.com/RTimothyEdwards/open_pdks])
2
Tim Edwards053cff32021-03-13 17:17:36 -05003AC_PREFIX_DEFAULT(/usr/share)
4
Tim Edwards66e53e52021-01-24 21:21:36 -05005## REQUIRES: https://www.gnu.org/software/autoconf-archive/ax_python_module.html#ax_python_module
6AM_PATH_PYTHON([3.4])
7AX_PYTHON_MODULE([distutils],[])
8
Tim Edwards665c3fd2021-05-02 20:20:27 -04009# Check for Mac OS X gsed vs. sed
10m4_ifndef([AC_PROG_SED],
11 [AC_DEFUN([AC_PROG_SED],[AC_ARG_VAR([SED])
12 AC_CHECK_PROGS([SED],[gsed sed])])])
13
14AC_PROG_SED
15AC_SUBST(SED)
16
Tim Edwards66e53e52021-01-24 21:21:36 -050017realpath() {
18 # Cross-platform, handles ~
19 python3 -c 'import os,sys;print(os.path.realpath(os.path.expanduser(sys.argv@<:@1@:>@)))' $1
20}
21
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020022# detect PDKs based on directories that include Makefile.in files
Tim Edwards8292c902020-12-24 16:25:25 -050023m4_define([M4_GET_TECHS], [m4_normalize(m4_esyscmd(cd .. && find * -mindepth 1 -maxdepth 1 -name "Makefile.in" -exec dirname {} \; | tr "\n" " "))])
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020024
Tim Edwards8292c902020-12-24 16:25:25 -050025# define tools
Tim Edwardsccaea722020-12-24 10:59:42 -050026# define tools to install setup files for. This does not imply that the tools are
27# available on the system; just that open_pdks will install the setup files for them.
28m4_define([M4_GET_TOOLS], [m4_normalize(m4_esyscmd(cat ./tools.txt | tr "\n" " "))])
29
Tim Edwards7cbaaba2020-08-05 12:19:18 -040030# check for the source and install paths for each PDK.
Tim Edwards8292c902020-12-24 16:25:25 -050031AC_DEFUN([M4_GEN_WITH_PDK_ARGS], [
32
33 # --enable-pdk-[pdk]=/path/to/pdk
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020034 m4_foreach_w(pdk, $1, [
Tim Edwards1168a8b2021-02-10 22:06:54 -050035 echo "Checking technology pdk..."
36 m4_define([pdkvar], [m4_normalize(m4_esyscmd(echo pdk | tr "a-z-" "A-Z_"))])
Tim Edwards8292c902020-12-24 16:25:25 -050037
38 pdkvar[]_SOURCE_PATH=""
Tim Edwards7e0a6442021-02-11 15:37:42 -050039 pdkvar[]_LOCAL_PATH="/usr/share/[pdk]"
Tim Edwards8292c902020-12-24 16:25:25 -050040 pdkvar[]_DIST_PATH=""
41 pdkvar[]_LINK_TARGETS="none"
Tim Edwards7e0a6442021-02-11 15:37:42 -050042 pdkvar[]_AUTO="0"
Tim Edwardsdebc0a42020-12-28 22:11:40 -050043
Tim Edwards8292c902020-12-24 16:25:25 -050044 AC_ARG_ENABLE(pdk-[pdk],
45 [AS_HELP_STRING([--enable-pdk-[pdk]=@<:@/path/to/pdk/@:>@ --disable-pdk-[pdk]], "location of the source files for the pdk (pdks with a [pdk]_url file can automatically download them if the path is omitted)")],
46 [
47 if test "$enableval" == "yes" -o "$enableval" == "YES"; then
Tim Edwards7e0a6442021-02-11 15:37:42 -050048 export pdkvar[]_SOURCE_PATH=../sources/pdk-[pdk]
49 pdkvar[]_AUTO="1"
Tim Edwards8292c902020-12-24 16:25:25 -050050 elif test "$enableval" == "no" -o "$enableval" == "NO"; then
51 echo "Disabling pdk..."
52 else
Tim Edwardsbb8ab292021-01-22 10:19:40 -050053 pdkvar[]_SOURCE_PATH=$enableval
Tim Edwards8292c902020-12-24 16:25:25 -050054 fi
55 ], [
Tim Edwards8292c902020-12-24 16:25:25 -050056 ]
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020057 )
Tim Edwards8292c902020-12-24 16:25:25 -050058 # # Require this argument
Tim Edwards7cbaaba2020-08-05 12:19:18 -040059
Tim Edwards8292c902020-12-24 16:25:25 -050060 if @<:@ "$[]pdkvar[]_SOURCE_PATH" != "" @:>@; then
Tim Edwards66e53e52021-01-24 21:21:36 -050061 pdkvar[]_SOURCE_PATH=`realpath $[]pdkvar[]_SOURCE_PATH`
62 pdkvar[]_BASENAME=`basename $[]pdkvar[]_SOURCE_PATH`
63 if @<:@ "$[]pdkvar[]_BASENAME" = "libraries" @:>@; then
64 pdkvar[]_SOURCE_PATH=`dirname $[]pdkvar[]_SOURCE_PATH`
65 fi
Tim Edwards6ee11532021-02-11 12:29:33 -050066 # Basic check that the PDK path exists, unless depending on Makefile
67 # to download it automatically.
Tim Edwards7e0a6442021-02-11 15:37:42 -050068 if @<:@ "$[]pdkvar[]_AUTO" = "0" @:>@; then
Tim Edwards6ee11532021-02-11 12:29:33 -050069 AC_MSG_NOTICE([Checking specified path for 'pdk' at $[]pdkvar[]_SOURCE_PATH])
70 AC_CHECK_FILE($pdkvar[]_SOURCE_PATH,[
71 AC_MSG_NOTICE(['pdk' source path found at $pdkvar[]_SOURCE_PATH])
72 ], [
73 AC_MSG_ERROR([Specified path for 'pdk' at $pdkvar[]_SOURCE_PATH not found])
74 ])
75 else
76 AC_MSG_NOTICE([PDK 'pdk' will be downloaded automatically during make.])
77 fi
Tim Edwards7cbaaba2020-08-05 12:19:18 -040078
Tim Edwards8292c902020-12-24 16:25:25 -050079 # --with-pdk-dist-path=PDK_DIST_PATH
80 AC_ARG_WITH(pdk-dist-path,
81 [AS_HELP_STRING([--with-pdk-dist-path=/path/to/install/pdk], "staging location to install the PDK for distribution (optional)")],
82 [pdkvar[]_DIST_PATH=$withval]
83 )
Tim Edwards8292c902020-12-24 16:25:25 -050084
85 # "Require" this argument
86 AC_MSG_NOTICE([Checking whether distribution path is specified for 'pdk'])
87 if test "x$[]pdkvar[]_DIST_PATH" == "x" ; then
88 AC_MSG_NOTICE([Option --with-pdk-dist-path=<path> not specified. Local install only.])
89 pdkvar[]_DIST_PATH=""
90 else
Tim Edwards66e53e52021-01-24 21:21:36 -050091 pdkvar[]_DIST_PATH=`realpath $[]pdkvar[]_DIST_PATH`
Tim Edwards8292c902020-12-24 16:25:25 -050092 fi
Tim Edwards7cbaaba2020-08-05 12:19:18 -040093
Tim Edwards290487a2021-05-17 09:57:30 -040094 # --with-pdk-local-path=PDK_LOCAL_PATH
95 AC_ARG_WITH(pdk-local-path,
96 [AS_HELP_STRING([--with-pdk-local-path=/path/to/install/pdk], "run-time location of the PDK")],
97 [pdkvar[]_LOCAL_PATH=$withval]
98 )
99
100 # Require this argument
101 AC_MSG_NOTICE([Checking whether local path is specified for 'pdk'])
102 if test "x$[]pdkvar[]_LOCAL_PATH" == "x" ; then
103 AC_MSG_ERROR([Option --with-pdk-local-path=<path> not specified!])
104 pdkvar[]_LOCAL_PATH=""
105 else
106 AC_MSG_NOTICE([Install path for 'pdk' is $[]pdkvar[]_LOCAL_PATH])
107 # If dist-path is specified then do not try to expand local-path
108 if test "$[]pdkvar[]_DIST_PATH" == "" ; then
109 pdkvar[]_LOCAL_PATH=`realpath $[]pdkvar[]_LOCAL_PATH`
110 fi
111 fi
112
Tim Edwards8292c902020-12-24 16:25:25 -0500113 # --with-pdk-link-targets=PDK_LINK_TARGETS
114 AC_ARG_WITH(pdk-link-targets,
115 [AS_HELP_STRING([--with-pdk-link-targets=none|source], "make symbolic links to existing files @<:@default=none@:>@")],
116 [[]pdkvar[]_LINK_TARGETS=$with_[]pdk[]_link_targets]
117 )
118 AC_SUBST([]pdkvar[]_LINK_TARGETS)
119 AC_MSG_NOTICE([Link targets set to $pdkvar[]_LINK_TARGETS])
120 fi
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400121
Tim Edwards8292c902020-12-24 16:25:25 -0500122 AC_SUBST(pdkvar[]_SOURCE_PATH)
123 AC_SUBST(pdkvar[]_LOCAL_PATH)
124 AC_SUBST(pdkvar[]_DIST_PATH)
125 AC_SUBST(pdkvar[]_LINK_TARGETS)
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200126 ])
127])
128
129AC_MSG_NOTICE([Found technology directories: M4_GET_TECHS()])
130
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400131M4_GEN_WITH_PDK_ARGS(M4_GET_TECHS())
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200132
Tim Edwards8292c902020-12-24 16:25:25 -0500133# Set variables for tool setups
134AC_DEFUN([M4_GEN_WITH_TOOLS], [
135 m4_foreach_w(tool, $1, [
Tim Edwards1168a8b2021-02-10 22:06:54 -0500136 m4_define([toolvar], [m4_normalize(m4_esyscmd(echo tool | tr "a-z-" "A-Z_"))])
Tim Edwards8292c902020-12-24 16:25:25 -0500137
138 toolvar[]_DISABLED=0
139 AC_ARG_ENABLE(tool,
140 AS_HELP_STRING(
141 --enable-tool
Tim Edwards1168a8b2021-02-10 22:06:54 -0500142 Enable or disable tool setup @<:@default=enabled@:>@
Tim Edwards8292c902020-12-24 16:25:25 -0500143 ), [
144 if test "$enableval" == "no" -o "$enableval" == "NO"; then
145 toolvar[]_DISABLED=1
146 fi
147 ]
148 )
149 AC_SUBST(toolvar[]_DISABLED)
150 ])
151])
152
153AC_MSG_NOTICE([Found tools: M4_GET_TOOLS()])
154
155M4_GEN_WITH_TOOLS(M4_GET_TOOLS())
156
157# Magic
158AC_PATH_PROG(MAGIC, magic)
159if test -z "$MAGIC"; then
160 AC_MSG_ERROR([You need 'magic' to generate the needed various cell views.])
161fi
Ahmed Ghazy32385482021-01-19 20:38:14 +0200162AC_PATH_PROG(PATCH, patch)
163if test -z "$PATCH"; then
164 AC_MSG_ERROR([You need 'patch' to apply patches.])
165fi
Tim Edwards8292c902020-12-24 16:25:25 -0500166
167# Other installations (libraries or tools if applicable)
Tim Edwards8292c902020-12-24 16:25:25 -0500168AC_DEFUN([M4_GEN_INSTALLATION], [
169 m4_define([target], $1)
Tim Edwards1168a8b2021-02-10 22:06:54 -0500170 m4_define([targetvar], [m4_normalize(m4_esyscmd(echo target | tr "a-z-" "A-Z_"))])
Tim Edwards8292c902020-12-24 16:25:25 -0500171 m4_define([flag], $2)
Tim Edwards6ee11532021-02-11 12:29:33 -0500172 m4_define([location], $3)
Tim Edwards8292c902020-12-24 16:25:25 -0500173
Tim Edwards6ee11532021-02-11 12:29:33 -0500174 # echo target targetvar flag location
Tim Edwards8292c902020-12-24 16:25:25 -0500175
176 targetvar[]_PATH=""
Tim Edwards8292c902020-12-24 16:25:25 -0500177
178 AC_ARG_ENABLE(
179 flag,
180 AS_HELP_STRING(
181 [--enable-flag@<:@=path@:>@],
Tim Edwardscdfec5e2021-04-22 20:59:13 -0400182 [Install target. If path is omitted, the repository will be downloaded. @<:@default=enabled@:>@]
Tim Edwards8292c902020-12-24 16:25:25 -0500183 ), [
184 if test "$enableval" == "yes" -o "$enableval" == "YES"; then
Tim Edwards7e0a6442021-02-11 15:37:42 -0500185 AC_MSG_NOTICE([Package 'target' will be installed automatically during make.])
Tim Edwards6ee11532021-02-11 12:29:33 -0500186 export targetvar[]_PATH=location/target
Tim Edwards8292c902020-12-24 16:25:25 -0500187 elif test "$enableval" == "no" -o "$enableval" == "NO"; then
Tim Edwards7e0a6442021-02-11 15:37:42 -0500188 AC_MSG_NOTICE([Disabling package 'target'])
189 export targetvar[]_PATH=""
Tim Edwards8292c902020-12-24 16:25:25 -0500190 else
191 targetvar[]_PATH=$enableval
Tim Edwards7e0a6442021-02-11 15:37:42 -0500192 AC_MSG_NOTICE([Enabling package 'target' at $[]targetvar[]_PATH])
Tim Edwards8292c902020-12-24 16:25:25 -0500193 fi
Tim Edwards66e53e52021-01-24 21:21:36 -0500194 targetvar[]_PATH=`realpath $[]targetvar[]_PATH`
Tim Edwards7e0a6442021-02-11 15:37:42 -0500195 ],[
196 AC_MSG_NOTICE([Package 'target' will be installed automatically during make.])
197 targetvar[]_PATH=location/target
198 ]
Tim Edwards8292c902020-12-24 16:25:25 -0500199 )
200
Tim Edwards6ee11532021-02-11 12:29:33 -0500201 $4
Tim Edwards8292c902020-12-24 16:25:25 -0500202
203 AC_SUBST(targetvar[]_PATH)
204])
205
Tim Edwardscdfec5e2021-04-22 20:59:13 -0400206# Optional installations (like the above, but disabled by default)
207AC_DEFUN([M4_OPT_INSTALLATION], [
208 m4_define([target], $1)
209 m4_define([targetvar], [m4_normalize(m4_esyscmd(echo target | tr "a-z-" "A-Z_"))])
210 m4_define([flag], $2)
211 m4_define([location], $3)
212
213 # echo target targetvar flag location
214
215 targetvar[]_PATH=""
216
217 AC_ARG_ENABLE(
218 flag,
219 AS_HELP_STRING(
220 [--enable-flag@<:@=path@:>@],
Tim Edwards980e8f32021-04-28 10:37:56 -0400221 [Install target. If path is omitted, the repository will be downloaded. @<:@default=disabled@:>@]
Tim Edwardscdfec5e2021-04-22 20:59:13 -0400222 ), [
223 if test "$enableval" == "yes" -o "$enableval" == "YES"; then
224 AC_MSG_NOTICE([Package 'target' will be installed automatically during make.])
225 export targetvar[]_PATH=location/target
226 elif test "$enableval" == "no" -o "$enableval" == "NO"; then
227 AC_MSG_NOTICE([Disabling package 'target'])
228 export targetvar[]_PATH=""
229 else
230 targetvar[]_PATH=$enableval
231 AC_MSG_NOTICE([Enabling package 'target' at $[]targetvar[]_PATH])
232 fi
233 targetvar[]_PATH=`realpath $[]targetvar[]_PATH`
234 ],[
235 AC_MSG_NOTICE([Package 'target' will not be installed.])
236 ]
237 )
238
239 $4
240
241 AC_SUBST(targetvar[]_PATH)
242])
243
Tim Edwards6ee11532021-02-11 12:29:33 -0500244M4_GEN_INSTALLATION(sky130_ml_xx_hd, alpha-sky130, ../sources)
245M4_GEN_INSTALLATION(xschem_sky130, xschem-sky130, ../sources)
Tim Edwards8292c902020-12-24 16:25:25 -0500246
Tim Edwardscdfec5e2021-04-22 20:59:13 -0400247M4_OPT_INSTALLATION(sky130_sram_macros, sram-sky130, ../sources)
248M4_OPT_INSTALLATION(sky130_osu, osu-sky130, ../sources)
249M4_OPT_INSTALLATION(sky130_osu_t12, osu-t12-sky130, ../sources)
250M4_OPT_INSTALLATION(sky130_osu_t15, osu-t15-sky130, ../sources)
251M4_OPT_INSTALLATION(sky130_osu_t18, osu-t18-sky130, ../sources)
252
Tim Edwardsccaea722020-12-24 10:59:42 -0500253AC_DEFUN([M4_GEN_WITH_TOOLS], [
254 m4_foreach_w(tool, $1, [
Tim Edwards1168a8b2021-02-10 22:06:54 -0500255 m4_define([toolvar], [m4_normalize(m4_esyscmd(echo tool | tr "a-z-" "A-Z_"))])
Tim Edwardsccaea722020-12-24 10:59:42 -0500256
257 toolvar[]_DISABLED=0
258 AC_ARG_ENABLE(tool,
259 AS_HELP_STRING(
260 --enable-tool --disable-tool,
Tim Edwards1168a8b2021-02-10 22:06:54 -0500261 Enable or disable tool setup @<:@default=enabled@:>@
Tim Edwardsccaea722020-12-24 10:59:42 -0500262 ),
263 [
264 if test "$enableval" == "no" -o "$enableval" == "NO"; then
265 toolvar[]_DISABLED=1
266 fi
267 ],
268 )
269 AC_SUBST(toolvar[]_DISABLED)
270 ])
271])
272
273AC_MSG_NOTICE([Tools enabled for PDK setup installation: M4_GET_TOOLS()])
274
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400275# Check for "--with-ef-style"
276EF_STYLE=0
Tim Edwards8292c902020-12-24 16:25:25 -0500277AC_ARG_WITH(
278 [ef-style],
279 AS_HELP_STRING(
280 [--with-ef-style],
281 [Use efabless style file system structure @<:@default=no@:>@]
282 ), [
283 pdks_ef_style=$withval
284 if test "$withval" == "yes" -o "$withval" == "YES"; then
285 EF_STYLE=1
286 fi
287 ],
288)
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200289
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400290AC_SUBST(EF_STYLE)
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200291
292MAKEFILES=$(find .. -name "Makefile.in" | sed 's/\(.*\)\.in/\1/g')
293AC_CONFIG_FILES($MAKEFILES)
294
295AC_OUTPUT
296
297AC_MSG_RESULT(Build configured successfully)