blob: 98a0e6995cc82a8135601d5445e7db9f81dc3262 [file] [log] [blame]
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +02001AC_INIT([open_pdks], [1.0], [github.com/RTimothyEdwards/open_pdks])
2
Tim Edwards66e53e52021-01-24 21:21:36 -05003## REQUIRES: https://www.gnu.org/software/autoconf-archive/ax_python_module.html#ax_python_module
4AM_PATH_PYTHON([3.4])
5AX_PYTHON_MODULE([distutils],[])
6
7realpath() {
8 # Cross-platform, handles ~
9 python3 -c 'import os,sys;print(os.path.realpath(os.path.expanduser(sys.argv@<:@1@:>@)))' $1
10}
11
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020012# detect PDKs based on directories that include Makefile.in files
Tim Edwards8292c902020-12-24 16:25:25 -050013m4_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 +020014
Tim Edwards8292c902020-12-24 16:25:25 -050015# define tools
Tim Edwardsccaea722020-12-24 10:59:42 -050016# define tools to install setup files for. This does not imply that the tools are
17# available on the system; just that open_pdks will install the setup files for them.
18m4_define([M4_GET_TOOLS], [m4_normalize(m4_esyscmd(cat ./tools.txt | tr "\n" " "))])
19
Tim Edwards7cbaaba2020-08-05 12:19:18 -040020# check for the source and install paths for each PDK.
Tim Edwards8292c902020-12-24 16:25:25 -050021AC_DEFUN([M4_GEN_WITH_PDK_ARGS], [
22
23 # --enable-pdk-[pdk]=/path/to/pdk
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020024 m4_foreach_w(pdk, $1, [
Tim Edwards1168a8b2021-02-10 22:06:54 -050025 echo "Checking technology pdk..."
26 m4_define([pdkvar], [m4_normalize(m4_esyscmd(echo pdk | tr "a-z-" "A-Z_"))])
Tim Edwards8292c902020-12-24 16:25:25 -050027
28 pdkvar[]_SOURCE_PATH=""
Tim Edwards7e0a6442021-02-11 15:37:42 -050029 pdkvar[]_LOCAL_PATH="/usr/share/[pdk]"
Tim Edwards8292c902020-12-24 16:25:25 -050030 pdkvar[]_DIST_PATH=""
31 pdkvar[]_LINK_TARGETS="none"
Tim Edwards7e0a6442021-02-11 15:37:42 -050032 pdkvar[]_AUTO="0"
Tim Edwardsdebc0a42020-12-28 22:11:40 -050033
Tim Edwards8292c902020-12-24 16:25:25 -050034 AC_ARG_ENABLE(pdk-[pdk],
35 [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)")],
36 [
37 if test "$enableval" == "yes" -o "$enableval" == "YES"; then
Tim Edwards7e0a6442021-02-11 15:37:42 -050038 export pdkvar[]_SOURCE_PATH=../sources/pdk-[pdk]
39 pdkvar[]_AUTO="1"
Tim Edwards8292c902020-12-24 16:25:25 -050040 elif test "$enableval" == "no" -o "$enableval" == "NO"; then
41 echo "Disabling pdk..."
42 else
Tim Edwardsbb8ab292021-01-22 10:19:40 -050043 pdkvar[]_SOURCE_PATH=$enableval
Tim Edwards8292c902020-12-24 16:25:25 -050044 fi
45 ], [
Tim Edwards8292c902020-12-24 16:25:25 -050046 ]
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +020047 )
Tim Edwards8292c902020-12-24 16:25:25 -050048 # # Require this argument
Tim Edwards7cbaaba2020-08-05 12:19:18 -040049
Tim Edwards8292c902020-12-24 16:25:25 -050050 if @<:@ "$[]pdkvar[]_SOURCE_PATH" != "" @:>@; then
Tim Edwards66e53e52021-01-24 21:21:36 -050051 pdkvar[]_SOURCE_PATH=`realpath $[]pdkvar[]_SOURCE_PATH`
52 pdkvar[]_BASENAME=`basename $[]pdkvar[]_SOURCE_PATH`
53 if @<:@ "$[]pdkvar[]_BASENAME" = "libraries" @:>@; then
54 pdkvar[]_SOURCE_PATH=`dirname $[]pdkvar[]_SOURCE_PATH`
55 fi
Tim Edwards6ee11532021-02-11 12:29:33 -050056 # Basic check that the PDK path exists, unless depending on Makefile
57 # to download it automatically.
Tim Edwards7e0a6442021-02-11 15:37:42 -050058 if @<:@ "$[]pdkvar[]_AUTO" = "0" @:>@; then
Tim Edwards6ee11532021-02-11 12:29:33 -050059 AC_MSG_NOTICE([Checking specified path for 'pdk' at $[]pdkvar[]_SOURCE_PATH])
60 AC_CHECK_FILE($pdkvar[]_SOURCE_PATH,[
61 AC_MSG_NOTICE(['pdk' source path found at $pdkvar[]_SOURCE_PATH])
62 ], [
63 AC_MSG_ERROR([Specified path for 'pdk' at $pdkvar[]_SOURCE_PATH not found])
64 ])
65 else
66 AC_MSG_NOTICE([PDK 'pdk' will be downloaded automatically during make.])
67 fi
Tim Edwards7cbaaba2020-08-05 12:19:18 -040068
Tim Edwards8292c902020-12-24 16:25:25 -050069 # --with-pdk-local-path=PDK_LOCAL_PATH
70 AC_ARG_WITH(pdk-local-path,
71 [AS_HELP_STRING([--with-pdk-local-path=/path/to/install/pdk], "run-time location of the PDK")],
72 [pdkvar[]_LOCAL_PATH=$withval]
73 )
74
75 # Require this argument
76 AC_MSG_NOTICE([Checking whether local path is specified for 'pdk'])
77 if test "x$[]pdkvar[]_LOCAL_PATH" == "x" ; then
78 AC_MSG_ERROR([Option --with-pdk-local-path=<path> not specified!])
79 pdkvar[]_LOCAL_PATH=""
80 else
Tim Edwards7e0a6442021-02-11 15:37:42 -050081 AC_MSG_NOTICE([Install path for 'pdk' is $[]pdkvar[]_LOCAL_PATH])
Tim Edwards66e53e52021-01-24 21:21:36 -050082 pdkvar[]_LOCAL_PATH=`realpath $[]pdkvar[]_LOCAL_PATH`
Tim Edwards8292c902020-12-24 16:25:25 -050083 fi
Tim Edwards7cbaaba2020-08-05 12:19:18 -040084
Tim Edwards8292c902020-12-24 16:25:25 -050085 # --with-pdk-dist-path=PDK_DIST_PATH
86 AC_ARG_WITH(pdk-dist-path,
87 [AS_HELP_STRING([--with-pdk-dist-path=/path/to/install/pdk], "staging location to install the PDK for distribution (optional)")],
88 [pdkvar[]_DIST_PATH=$withval]
89 )
Tim Edwards8292c902020-12-24 16:25:25 -050090
91 # "Require" this argument
92 AC_MSG_NOTICE([Checking whether distribution path is specified for 'pdk'])
93 if test "x$[]pdkvar[]_DIST_PATH" == "x" ; then
94 AC_MSG_NOTICE([Option --with-pdk-dist-path=<path> not specified. Local install only.])
95 pdkvar[]_DIST_PATH=""
96 else
Tim Edwards66e53e52021-01-24 21:21:36 -050097 pdkvar[]_DIST_PATH=`realpath $[]pdkvar[]_DIST_PATH`
Tim Edwards8292c902020-12-24 16:25:25 -050098 fi
Tim Edwards7cbaaba2020-08-05 12:19:18 -040099
Tim Edwards8292c902020-12-24 16:25:25 -0500100 # --with-pdk-link-targets=PDK_LINK_TARGETS
101 AC_ARG_WITH(pdk-link-targets,
102 [AS_HELP_STRING([--with-pdk-link-targets=none|source], "make symbolic links to existing files @<:@default=none@:>@")],
103 [[]pdkvar[]_LINK_TARGETS=$with_[]pdk[]_link_targets]
104 )
105 AC_SUBST([]pdkvar[]_LINK_TARGETS)
106 AC_MSG_NOTICE([Link targets set to $pdkvar[]_LINK_TARGETS])
107 fi
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400108
Tim Edwards8292c902020-12-24 16:25:25 -0500109 AC_SUBST(pdkvar[]_SOURCE_PATH)
110 AC_SUBST(pdkvar[]_LOCAL_PATH)
111 AC_SUBST(pdkvar[]_DIST_PATH)
112 AC_SUBST(pdkvar[]_LINK_TARGETS)
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200113 ])
114])
115
116AC_MSG_NOTICE([Found technology directories: M4_GET_TECHS()])
117
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400118M4_GEN_WITH_PDK_ARGS(M4_GET_TECHS())
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200119
Tim Edwards8292c902020-12-24 16:25:25 -0500120# Set variables for tool setups
121AC_DEFUN([M4_GEN_WITH_TOOLS], [
122 m4_foreach_w(tool, $1, [
Tim Edwards1168a8b2021-02-10 22:06:54 -0500123 m4_define([toolvar], [m4_normalize(m4_esyscmd(echo tool | tr "a-z-" "A-Z_"))])
Tim Edwards8292c902020-12-24 16:25:25 -0500124
125 toolvar[]_DISABLED=0
126 AC_ARG_ENABLE(tool,
127 AS_HELP_STRING(
128 --enable-tool
Tim Edwards1168a8b2021-02-10 22:06:54 -0500129 Enable or disable tool setup @<:@default=enabled@:>@
Tim Edwards8292c902020-12-24 16:25:25 -0500130 ), [
131 if test "$enableval" == "no" -o "$enableval" == "NO"; then
132 toolvar[]_DISABLED=1
133 fi
134 ]
135 )
136 AC_SUBST(toolvar[]_DISABLED)
137 ])
138])
139
140AC_MSG_NOTICE([Found tools: M4_GET_TOOLS()])
141
142M4_GEN_WITH_TOOLS(M4_GET_TOOLS())
143
144# Magic
145AC_PATH_PROG(MAGIC, magic)
146if test -z "$MAGIC"; then
147 AC_MSG_ERROR([You need 'magic' to generate the needed various cell views.])
148fi
Ahmed Ghazy32385482021-01-19 20:38:14 +0200149AC_PATH_PROG(PATCH, patch)
150if test -z "$PATCH"; then
151 AC_MSG_ERROR([You need 'patch' to apply patches.])
152fi
Tim Edwards8292c902020-12-24 16:25:25 -0500153
154# Other installations (libraries or tools if applicable)
Tim Edwards8292c902020-12-24 16:25:25 -0500155AC_DEFUN([M4_GEN_INSTALLATION], [
156 m4_define([target], $1)
Tim Edwards1168a8b2021-02-10 22:06:54 -0500157 m4_define([targetvar], [m4_normalize(m4_esyscmd(echo target | tr "a-z-" "A-Z_"))])
Tim Edwards8292c902020-12-24 16:25:25 -0500158 m4_define([flag], $2)
Tim Edwards6ee11532021-02-11 12:29:33 -0500159 m4_define([location], $3)
Tim Edwards8292c902020-12-24 16:25:25 -0500160
Tim Edwards6ee11532021-02-11 12:29:33 -0500161 # echo target targetvar flag location
Tim Edwards8292c902020-12-24 16:25:25 -0500162
163 targetvar[]_PATH=""
Tim Edwards8292c902020-12-24 16:25:25 -0500164
165 AC_ARG_ENABLE(
166 flag,
167 AS_HELP_STRING(
168 [--enable-flag@<:@=path@:>@],
169 [Install target. If path is omitted, it'll be downloaded. @<:@default=disabled@:>@]
170 ), [
171 if test "$enableval" == "yes" -o "$enableval" == "YES"; then
Tim Edwards7e0a6442021-02-11 15:37:42 -0500172 AC_MSG_NOTICE([Package 'target' will be installed automatically during make.])
Tim Edwards6ee11532021-02-11 12:29:33 -0500173 export targetvar[]_PATH=location/target
Tim Edwards8292c902020-12-24 16:25:25 -0500174 elif test "$enableval" == "no" -o "$enableval" == "NO"; then
Tim Edwards7e0a6442021-02-11 15:37:42 -0500175 AC_MSG_NOTICE([Disabling package 'target'])
176 export targetvar[]_PATH=""
Tim Edwards8292c902020-12-24 16:25:25 -0500177 else
178 targetvar[]_PATH=$enableval
Tim Edwards7e0a6442021-02-11 15:37:42 -0500179 AC_MSG_NOTICE([Enabling package 'target' at $[]targetvar[]_PATH])
Tim Edwards8292c902020-12-24 16:25:25 -0500180 fi
Tim Edwards66e53e52021-01-24 21:21:36 -0500181 targetvar[]_PATH=`realpath $[]targetvar[]_PATH`
Tim Edwards7e0a6442021-02-11 15:37:42 -0500182 ],[
183 AC_MSG_NOTICE([Package 'target' will be installed automatically during make.])
184 targetvar[]_PATH=location/target
185 ]
Tim Edwards8292c902020-12-24 16:25:25 -0500186 )
187
Tim Edwards6ee11532021-02-11 12:29:33 -0500188 $4
Tim Edwards8292c902020-12-24 16:25:25 -0500189
190 AC_SUBST(targetvar[]_PATH)
191])
192
Tim Edwards6ee11532021-02-11 12:29:33 -0500193M4_GEN_INSTALLATION(sky130_ml_xx_hd, alpha-sky130, ../sources)
194M4_GEN_INSTALLATION(xschem_sky130, xschem-sky130, ../sources)
Tim Edwards8292c902020-12-24 16:25:25 -0500195
Tim Edwardsccaea722020-12-24 10:59:42 -0500196AC_DEFUN([M4_GEN_WITH_TOOLS], [
197 m4_foreach_w(tool, $1, [
Tim Edwards1168a8b2021-02-10 22:06:54 -0500198 m4_define([toolvar], [m4_normalize(m4_esyscmd(echo tool | tr "a-z-" "A-Z_"))])
Tim Edwardsccaea722020-12-24 10:59:42 -0500199
200 toolvar[]_DISABLED=0
201 AC_ARG_ENABLE(tool,
202 AS_HELP_STRING(
203 --enable-tool --disable-tool,
Tim Edwards1168a8b2021-02-10 22:06:54 -0500204 Enable or disable tool setup @<:@default=enabled@:>@
Tim Edwardsccaea722020-12-24 10:59:42 -0500205 ),
206 [
207 if test "$enableval" == "no" -o "$enableval" == "NO"; then
208 toolvar[]_DISABLED=1
209 fi
210 ],
211 )
212 AC_SUBST(toolvar[]_DISABLED)
213 ])
214])
215
216AC_MSG_NOTICE([Tools enabled for PDK setup installation: M4_GET_TOOLS()])
217
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400218# Check for "--with-ef-style"
219EF_STYLE=0
Tim Edwards8292c902020-12-24 16:25:25 -0500220AC_ARG_WITH(
221 [ef-style],
222 AS_HELP_STRING(
223 [--with-ef-style],
224 [Use efabless style file system structure @<:@default=no@:>@]
225 ), [
226 pdks_ef_style=$withval
227 if test "$withval" == "yes" -o "$withval" == "YES"; then
228 EF_STYLE=1
229 fi
230 ],
231)
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200232
Tim Edwards7cbaaba2020-08-05 12:19:18 -0400233AC_SUBST(EF_STYLE)
Ahmed Ghazy6dc7ebf2020-07-29 16:52:14 +0200234
235MAKEFILES=$(find .. -name "Makefile.in" | sed 's/\(.*\)\.in/\1/g')
236AC_CONFIG_FILES($MAKEFILES)
237
238AC_OUTPUT
239
240AC_MSG_RESULT(Build configured successfully)