blob: 7f1ba4bcd4d464f41312b79c14acfec952056516 [file] [log] [blame]
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +02001AC_INIT([open_pdks], [1.0], [github.com/RTimothyEdwards/open_pdks])
2
Tim Edwards6fce4f12021-08-20 15:24:12 -04003# AC_PREFIX_DEFAULT(/usr)
Tim Edwards44e7efa2021-08-20 13:20:55 -04004AC_CONFIG_MACRO_DIR(m4)
Tim Edwards053cff32021-03-13 17:17:36 -05005
Tim Edwards66e53e52021-01-24 21:21:36 -05006## REQUIRES: https://www.gnu.org/software/autoconf-archive/ax_python_module.html#ax_python_module
7AM_PATH_PYTHON([3.4])
8AX_PYTHON_MODULE([distutils],[])
9
Tim Edwards665c3fd2021-05-02 20:20:27 -040010# Check for Mac OS X gsed vs. sed
11m4_ifndef([AC_PROG_SED],
12 [AC_DEFUN([AC_PROG_SED],[AC_ARG_VAR([SED])
13 AC_CHECK_PROGS([SED],[gsed sed])])])
14
15AC_PROG_SED
16AC_SUBST(SED)
17
Tim Edwards66e53e52021-01-24 21:21:36 -050018realpath() {
19 # Cross-platform, handles ~
20 python3 -c 'import os,sys;print(os.path.realpath(os.path.expanduser(sys.argv@<:@1@:>@)))' $1
21}
22
Tim Edwards3c02c082021-11-26 13:48:33 -050023ENABLED_TECHS=
24
Tim Edwards062fbb12021-11-26 15:44:59 -050025# Export the open_pdks top level directory
26OPENPDKS_TOP=`cd .. && pwd`
27
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020028# detect PDKs based on directories that include Makefile.in files
Tim Edwards3c02c082021-11-26 13:48:33 -050029m4_define([M4_GET_TECHS], [m4_normalize(m4_esyscmd(cd .. && find -H * -mindepth 1 -maxdepth 1 -name "Makefile.in" -exec dirname {} \; | tr "\n" " "))])
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020030
Tim Edwards8292c902020-12-24 16:25:25 -050031# define tools
Tim Edwardsccaea722020-12-24 10:59:42 -050032# define tools to install setup files for. This does not imply that the tools are
33# available on the system; just that open_pdks will install the setup files for them.
34m4_define([M4_GET_TOOLS], [m4_normalize(m4_esyscmd(cat ./tools.txt | tr "\n" " "))])
35
Tim Edwards7cbaaba2020-08-05 12:19:18 -040036# check for the source and install paths for each PDK.
Tim Edwards8292c902020-12-24 16:25:25 -050037AC_DEFUN([M4_GEN_WITH_PDK_ARGS], [
38
39 # --enable-pdk-[pdk]=/path/to/pdk
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020040 m4_foreach_w(pdk, $1, [
Tim Edwards1168a8b2021-02-10 22:06:54 -050041 echo "Checking technology pdk..."
42 m4_define([pdkvar], [m4_normalize(m4_esyscmd(echo pdk | tr "a-z-" "A-Z_"))])
Tim Edwards8292c902020-12-24 16:25:25 -050043
44 pdkvar[]_SOURCE_PATH=""
Tim Edwards8292c902020-12-24 16:25:25 -050045 pdkvar[]_LINK_TARGETS="none"
Tim 'mithro' Ansell3c6913c2021-06-13 10:35:33 -070046 pdkvar[]_AUTO="0"
Tim Edwardsdebc0a42020-12-28 22:11:40 -050047
Tim Edwards8292c902020-12-24 16:25:25 -050048 AC_ARG_ENABLE(pdk-[pdk],
49 [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)")],
50 [
51 if test "$enableval" == "yes" -o "$enableval" == "YES"; then
Tim Edwards7e0a6442021-02-11 15:37:42 -050052 export pdkvar[]_SOURCE_PATH=../sources/pdk-[pdk]
Tim 'mithro' Ansell3c6913c2021-06-13 10:35:33 -070053 pdkvar[]_AUTO="1"
Tim Edwards3c02c082021-11-26 13:48:33 -050054 ENABLED_TECHS="$ENABLED_TECHS pdk"
Tim Edwards8292c902020-12-24 16:25:25 -050055 elif test "$enableval" == "no" -o "$enableval" == "NO"; then
56 echo "Disabling pdk..."
57 else
Tim Edwardsbb8ab292021-01-22 10:19:40 -050058 pdkvar[]_SOURCE_PATH=$enableval
Tim Edwards3c02c082021-11-26 13:48:33 -050059 ENABLED_TECHS="$ENABLED_TECHS pdk"
Tim Edwards8292c902020-12-24 16:25:25 -050060 fi
61 ], [
Tim Edwards8292c902020-12-24 16:25:25 -050062 ]
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020063 )
Tim Edwards7cbaaba2020-08-05 12:19:18 -040064
Tim Edwards8292c902020-12-24 16:25:25 -050065 if @<:@ "$[]pdkvar[]_SOURCE_PATH" != "" @:>@; then
Tim Edwards66e53e52021-01-24 21:21:36 -050066 pdkvar[]_SOURCE_PATH=`realpath $[]pdkvar[]_SOURCE_PATH`
67 pdkvar[]_BASENAME=`basename $[]pdkvar[]_SOURCE_PATH`
68 if @<:@ "$[]pdkvar[]_BASENAME" = "libraries" @:>@; then
69 pdkvar[]_SOURCE_PATH=`dirname $[]pdkvar[]_SOURCE_PATH`
70 fi
Tim Edwards6ee11532021-02-11 12:29:33 -050071 # Basic check that the PDK path exists, unless depending on Makefile
72 # to download it automatically.
Tim Edwards7e0a6442021-02-11 15:37:42 -050073 if @<:@ "$[]pdkvar[]_AUTO" = "0" @:>@; then
Tim Edwards6ee11532021-02-11 12:29:33 -050074 AC_MSG_NOTICE([Checking specified path for 'pdk' at $[]pdkvar[]_SOURCE_PATH])
75 AC_CHECK_FILE($pdkvar[]_SOURCE_PATH,[
76 AC_MSG_NOTICE(['pdk' source path found at $pdkvar[]_SOURCE_PATH])
77 ], [
78 AC_MSG_ERROR([Specified path for 'pdk' at $pdkvar[]_SOURCE_PATH not found])
79 ])
80 else
81 AC_MSG_NOTICE([PDK 'pdk' will be downloaded automatically during make.])
82 fi
Tim Edwards7cbaaba2020-08-05 12:19:18 -040083
Tim Edwards8292c902020-12-24 16:25:25 -050084 # --with-pdk-link-targets=PDK_LINK_TARGETS
85 AC_ARG_WITH(pdk-link-targets,
86 [AS_HELP_STRING([--with-pdk-link-targets=none|source], "make symbolic links to existing files @<:@default=none@:>@")],
87 [[]pdkvar[]_LINK_TARGETS=$with_[]pdk[]_link_targets]
88 )
89 AC_SUBST([]pdkvar[]_LINK_TARGETS)
90 AC_MSG_NOTICE([Link targets set to $pdkvar[]_LINK_TARGETS])
91 fi
Tim Edwards7cbaaba2020-08-05 12:19:18 -040092
Tim Edwards8292c902020-12-24 16:25:25 -050093 AC_SUBST(pdkvar[]_SOURCE_PATH)
Tim Edwards8292c902020-12-24 16:25:25 -050094 AC_SUBST(pdkvar[]_LINK_TARGETS)
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020095 ])
96])
97
98AC_MSG_NOTICE([Found technology directories: M4_GET_TECHS()])
99
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400100M4_GEN_WITH_PDK_ARGS(M4_GET_TECHS())
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200101
Tim Edwards3c02c082021-11-26 13:48:33 -0500102# Export the list of known technologies to the Makefile
103ALL_TECHS="M4_GET_TECHS()"
104AC_SUBST(ALL_TECHS)
105
Tim Edwards8292c902020-12-24 16:25:25 -0500106# Set variables for tool setups
107AC_DEFUN([M4_GEN_WITH_TOOLS], [
108 m4_foreach_w(tool, $1, [
Tim Edwards1168a8b2021-02-10 22:06:54 -0500109 m4_define([toolvar], [m4_normalize(m4_esyscmd(echo tool | tr "a-z-" "A-Z_"))])
Tim Edwards8292c902020-12-24 16:25:25 -0500110
111 toolvar[]_DISABLED=0
112 AC_ARG_ENABLE(tool,
113 AS_HELP_STRING(
114 --enable-tool
Tim Edwards1168a8b2021-02-10 22:06:54 -0500115 Enable or disable tool setup @<:@default=enabled@:>@
Tim Edwards8292c902020-12-24 16:25:25 -0500116 ), [
117 if test "$enableval" == "no" -o "$enableval" == "NO"; then
118 toolvar[]_DISABLED=1
119 fi
120 ]
121 )
122 AC_SUBST(toolvar[]_DISABLED)
123 ])
124])
125
126AC_MSG_NOTICE([Found tools: M4_GET_TOOLS()])
127
128M4_GEN_WITH_TOOLS(M4_GET_TOOLS())
129
130# Magic
131AC_PATH_PROG(MAGIC, magic)
132if test -z "$MAGIC"; then
133 AC_MSG_ERROR([You need 'magic' to generate the needed various cell views.])
134fi
Ahmed Ghazy32385482021-01-19 20:38:14 +0200135AC_PATH_PROG(PATCH, patch)
136if test -z "$PATCH"; then
137 AC_MSG_ERROR([You need 'patch' to apply patches.])
138fi
Tim Edwards8292c902020-12-24 16:25:25 -0500139
140# Other installations (libraries or tools if applicable)
Tim Edwards8292c902020-12-24 16:25:25 -0500141AC_DEFUN([M4_GEN_INSTALLATION], [
142 m4_define([target], $1)
Tim Edwards1168a8b2021-02-10 22:06:54 -0500143 m4_define([targetvar], [m4_normalize(m4_esyscmd(echo target | tr "a-z-" "A-Z_"))])
Tim Edwards8292c902020-12-24 16:25:25 -0500144 m4_define([flag], $2)
Tim Edwards6ee11532021-02-11 12:29:33 -0500145 m4_define([location], $3)
Tim Edwards8292c902020-12-24 16:25:25 -0500146
Tim Edwards6ee11532021-02-11 12:29:33 -0500147 # echo target targetvar flag location
Tim Edwards8292c902020-12-24 16:25:25 -0500148
149 targetvar[]_PATH=""
Tim Edwards8292c902020-12-24 16:25:25 -0500150
151 AC_ARG_ENABLE(
152 flag,
153 AS_HELP_STRING(
154 [--enable-flag@<:@=path@:>@],
Tim Edwardscdfec5e2021-04-22 20:59:13 -0400155 [Install target. If path is omitted, the repository will be downloaded. @<:@default=enabled@:>@]
Tim Edwards8292c902020-12-24 16:25:25 -0500156 ), [
157 if test "$enableval" == "yes" -o "$enableval" == "YES"; then
Tim Edwards7e0a6442021-02-11 15:37:42 -0500158 AC_MSG_NOTICE([Package 'target' will be installed automatically during make.])
Tim Edwards6ee11532021-02-11 12:29:33 -0500159 export targetvar[]_PATH=location/target
Tim Edwards8292c902020-12-24 16:25:25 -0500160 elif test "$enableval" == "no" -o "$enableval" == "NO"; then
Tim Edwards7e0a6442021-02-11 15:37:42 -0500161 AC_MSG_NOTICE([Disabling package 'target'])
162 export targetvar[]_PATH=""
Tim Edwards8292c902020-12-24 16:25:25 -0500163 else
164 targetvar[]_PATH=$enableval
Tim Edwards7e0a6442021-02-11 15:37:42 -0500165 AC_MSG_NOTICE([Enabling package 'target' at $[]targetvar[]_PATH])
Tim Edwards8292c902020-12-24 16:25:25 -0500166 fi
Tim Edwards66e53e52021-01-24 21:21:36 -0500167 targetvar[]_PATH=`realpath $[]targetvar[]_PATH`
Tim Edwards7e0a6442021-02-11 15:37:42 -0500168 ],[
169 AC_MSG_NOTICE([Package 'target' will be installed automatically during make.])
170 targetvar[]_PATH=location/target
171 ]
Tim Edwards8292c902020-12-24 16:25:25 -0500172 )
173
Tim Edwards6ee11532021-02-11 12:29:33 -0500174 $4
Tim Edwards8292c902020-12-24 16:25:25 -0500175
176 AC_SUBST(targetvar[]_PATH)
177])
178
Tim Edwardscdfec5e2021-04-22 20:59:13 -0400179# Optional installations (like the above, but disabled by default)
180AC_DEFUN([M4_OPT_INSTALLATION], [
181 m4_define([target], $1)
182 m4_define([targetvar], [m4_normalize(m4_esyscmd(echo target | tr "a-z-" "A-Z_"))])
183 m4_define([flag], $2)
184 m4_define([location], $3)
185
186 # echo target targetvar flag location
187
188 targetvar[]_PATH=""
189
190 AC_ARG_ENABLE(
191 flag,
192 AS_HELP_STRING(
193 [--enable-flag@<:@=path@:>@],
Tim Edwards980e8f32021-04-28 10:37:56 -0400194 [Install target. If path is omitted, the repository will be downloaded. @<:@default=disabled@:>@]
Tim Edwardscdfec5e2021-04-22 20:59:13 -0400195 ), [
196 if test "$enableval" == "yes" -o "$enableval" == "YES"; then
197 AC_MSG_NOTICE([Package 'target' will be installed automatically during make.])
198 export targetvar[]_PATH=location/target
199 elif test "$enableval" == "no" -o "$enableval" == "NO"; then
200 AC_MSG_NOTICE([Disabling package 'target'])
201 export targetvar[]_PATH=""
202 else
203 targetvar[]_PATH=$enableval
204 AC_MSG_NOTICE([Enabling package 'target' at $[]targetvar[]_PATH])
205 fi
206 targetvar[]_PATH=`realpath $[]targetvar[]_PATH`
207 ],[
208 AC_MSG_NOTICE([Package 'target' will not be installed.])
209 ]
210 )
211
212 $4
213
214 AC_SUBST(targetvar[]_PATH)
215])
216
Tim Edwards6ee11532021-02-11 12:29:33 -0500217M4_GEN_INSTALLATION(sky130_ml_xx_hd, alpha-sky130, ../sources)
218M4_GEN_INSTALLATION(xschem_sky130, xschem-sky130, ../sources)
Tim Edwards8292c902020-12-24 16:25:25 -0500219
Tim Edwardscdfec5e2021-04-22 20:59:13 -0400220M4_OPT_INSTALLATION(sky130_sram_macros, sram-sky130, ../sources)
Tim Edwardscdfec5e2021-04-22 20:59:13 -0400221M4_OPT_INSTALLATION(sky130_osu_t12, osu-t12-sky130, ../sources)
222M4_OPT_INSTALLATION(sky130_osu_t15, osu-t15-sky130, ../sources)
223M4_OPT_INSTALLATION(sky130_osu_t18, osu-t18-sky130, ../sources)
224
Tim Edwardsccaea722020-12-24 10:59:42 -0500225AC_DEFUN([M4_GEN_WITH_TOOLS], [
226 m4_foreach_w(tool, $1, [
Tim Edwards1168a8b2021-02-10 22:06:54 -0500227 m4_define([toolvar], [m4_normalize(m4_esyscmd(echo tool | tr "a-z-" "A-Z_"))])
Tim Edwardsccaea722020-12-24 10:59:42 -0500228
229 toolvar[]_DISABLED=0
230 AC_ARG_ENABLE(tool,
231 AS_HELP_STRING(
232 --enable-tool --disable-tool,
Tim Edwards1168a8b2021-02-10 22:06:54 -0500233 Enable or disable tool setup @<:@default=enabled@:>@
Tim Edwardsccaea722020-12-24 10:59:42 -0500234 ),
235 [
236 if test "$enableval" == "no" -o "$enableval" == "NO"; then
237 toolvar[]_DISABLED=1
238 fi
239 ],
240 )
241 AC_SUBST(toolvar[]_DISABLED)
242 ])
243])
244
245AC_MSG_NOTICE([Tools enabled for PDK setup installation: M4_GET_TOOLS()])
246
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400247# Check for "--with-ef-style"
248EF_STYLE=0
Tim Edwards8292c902020-12-24 16:25:25 -0500249AC_ARG_WITH(
250 [ef-style],
251 AS_HELP_STRING(
252 [--with-ef-style],
253 [Use efabless style file system structure @<:@default=no@:>@]
254 ), [
255 pdks_ef_style=$withval
256 if test "$withval" == "yes" -o "$withval" == "YES"; then
257 EF_STYLE=1
258 fi
259 ],
260)
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200261
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400262AC_SUBST(EF_STYLE)
Tim Edwards3c02c082021-11-26 13:48:33 -0500263# Export the list of enabled technologies to the Makefile
264AC_SUBST(ENABLED_TECHS)
Tim Edwards062fbb12021-11-26 15:44:59 -0500265# Export the top level directory of open_pdks
266AC_SUBST(OPENPDKS_TOP)
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200267
Tim Edwards3c02c082021-11-26 13:48:33 -0500268MAKEFILES=$(find -L .. -name "Makefile.in" | sed 's/\(.*\)\.in/\1/g')
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200269AC_CONFIG_FILES($MAKEFILES)
270
271AC_OUTPUT
272
273AC_MSG_RESULT(Build configured successfully)