├── .gitignore ├── LICENSE ├── Makefile.am ├── Makefile.in ├── README.md ├── aclocal.m4 ├── compile ├── configure ├── configure.ac ├── depcomp ├── install-sh ├── missing └── raspi-gpio.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Raspberry Pi Foundation 2 | 3 | Author: James Adams 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of raspi-gpio nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = raspi-gpio 2 | raspi_gpio_SOURCES = raspi-gpio.c 3 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.16.1 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994-2018 Free Software Foundation, Inc. 5 | 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | 17 | VPATH = @srcdir@ 18 | am__is_gnu_make = { \ 19 | if test -z '$(MAKELEVEL)'; then \ 20 | false; \ 21 | elif test -n '$(MAKE_HOST)'; then \ 22 | true; \ 23 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ 24 | true; \ 25 | else \ 26 | false; \ 27 | fi; \ 28 | } 29 | am__make_running_with_option = \ 30 | case $${target_option-} in \ 31 | ?) ;; \ 32 | *) echo "am__make_running_with_option: internal error: invalid" \ 33 | "target option '$${target_option-}' specified" >&2; \ 34 | exit 1;; \ 35 | esac; \ 36 | has_opt=no; \ 37 | sane_makeflags=$$MAKEFLAGS; \ 38 | if $(am__is_gnu_make); then \ 39 | sane_makeflags=$$MFLAGS; \ 40 | else \ 41 | case $$MAKEFLAGS in \ 42 | *\\[\ \ ]*) \ 43 | bs=\\; \ 44 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 45 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 46 | esac; \ 47 | fi; \ 48 | skip_next=no; \ 49 | strip_trailopt () \ 50 | { \ 51 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 52 | }; \ 53 | for flg in $$sane_makeflags; do \ 54 | test $$skip_next = yes && { skip_next=no; continue; }; \ 55 | case $$flg in \ 56 | *=*|--*) continue;; \ 57 | -*I) strip_trailopt 'I'; skip_next=yes;; \ 58 | -*I?*) strip_trailopt 'I';; \ 59 | -*O) strip_trailopt 'O'; skip_next=yes;; \ 60 | -*O?*) strip_trailopt 'O';; \ 61 | -*l) strip_trailopt 'l'; skip_next=yes;; \ 62 | -*l?*) strip_trailopt 'l';; \ 63 | -[dEDm]) skip_next=yes;; \ 64 | -[JT]) skip_next=yes;; \ 65 | esac; \ 66 | case $$flg in \ 67 | *$$target_option*) has_opt=yes; break;; \ 68 | esac; \ 69 | done; \ 70 | test $$has_opt = yes 71 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 72 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 73 | pkgdatadir = $(datadir)/@PACKAGE@ 74 | pkgincludedir = $(includedir)/@PACKAGE@ 75 | pkglibdir = $(libdir)/@PACKAGE@ 76 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 77 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 78 | install_sh_DATA = $(install_sh) -c -m 644 79 | install_sh_PROGRAM = $(install_sh) -c 80 | install_sh_SCRIPT = $(install_sh) -c 81 | INSTALL_HEADER = $(INSTALL_DATA) 82 | transform = $(program_transform_name) 83 | NORMAL_INSTALL = : 84 | PRE_INSTALL = : 85 | POST_INSTALL = : 86 | NORMAL_UNINSTALL = : 87 | PRE_UNINSTALL = : 88 | POST_UNINSTALL = : 89 | bin_PROGRAMS = raspi-gpio$(EXEEXT) 90 | subdir = . 91 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 92 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac 93 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 94 | $(ACLOCAL_M4) 95 | DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ 96 | $(am__configure_deps) $(am__DIST_COMMON) 97 | am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ 98 | configure.lineno config.status.lineno 99 | mkinstalldirs = $(install_sh) -d 100 | CONFIG_CLEAN_FILES = 101 | CONFIG_CLEAN_VPATH_FILES = 102 | am__installdirs = "$(DESTDIR)$(bindir)" 103 | PROGRAMS = $(bin_PROGRAMS) 104 | am_raspi_gpio_OBJECTS = raspi-gpio.$(OBJEXT) 105 | raspi_gpio_OBJECTS = $(am_raspi_gpio_OBJECTS) 106 | raspi_gpio_LDADD = $(LDADD) 107 | AM_V_P = $(am__v_P_@AM_V@) 108 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 109 | am__v_P_0 = false 110 | am__v_P_1 = : 111 | AM_V_GEN = $(am__v_GEN_@AM_V@) 112 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 113 | am__v_GEN_0 = @echo " GEN " $@; 114 | am__v_GEN_1 = 115 | AM_V_at = $(am__v_at_@AM_V@) 116 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 117 | am__v_at_0 = @ 118 | am__v_at_1 = 119 | DEFAULT_INCLUDES = -I.@am__isrc@ 120 | depcomp = $(SHELL) $(top_srcdir)/depcomp 121 | am__maybe_remake_depfiles = depfiles 122 | am__depfiles_remade = ./$(DEPDIR)/raspi-gpio.Po 123 | am__mv = mv -f 124 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 125 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 126 | AM_V_CC = $(am__v_CC_@AM_V@) 127 | am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) 128 | am__v_CC_0 = @echo " CC " $@; 129 | am__v_CC_1 = 130 | CCLD = $(CC) 131 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ 132 | AM_V_CCLD = $(am__v_CCLD_@AM_V@) 133 | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) 134 | am__v_CCLD_0 = @echo " CCLD " $@; 135 | am__v_CCLD_1 = 136 | SOURCES = $(raspi_gpio_SOURCES) 137 | DIST_SOURCES = $(raspi_gpio_SOURCES) 138 | am__can_run_installinfo = \ 139 | case $$AM_UPDATE_INFO_DIR in \ 140 | n|no|NO) false;; \ 141 | *) (install-info --version) >/dev/null 2>&1;; \ 142 | esac 143 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 144 | # Read a list of newline-separated strings from the standard input, 145 | # and print each of them once, without duplicates. Input order is 146 | # *not* preserved. 147 | am__uniquify_input = $(AWK) '\ 148 | BEGIN { nonempty = 0; } \ 149 | { items[$$0] = 1; nonempty = 1; } \ 150 | END { if (nonempty) { for (i in items) print i; }; } \ 151 | ' 152 | # Make sure the list of sources is unique. This is necessary because, 153 | # e.g., the same source file might be shared among _SOURCES variables 154 | # for different programs/libraries. 155 | am__define_uniq_tagged_files = \ 156 | list='$(am__tagged_files)'; \ 157 | unique=`for i in $$list; do \ 158 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 159 | done | $(am__uniquify_input)` 160 | ETAGS = etags 161 | CTAGS = ctags 162 | CSCOPE = cscope 163 | AM_RECURSIVE_TARGETS = cscope 164 | am__DIST_COMMON = $(srcdir)/Makefile.in compile depcomp install-sh \ 165 | missing 166 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 167 | distdir = $(PACKAGE)-$(VERSION) 168 | top_distdir = $(distdir) 169 | am__remove_distdir = \ 170 | if test -d "$(distdir)"; then \ 171 | find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ 172 | && rm -rf "$(distdir)" \ 173 | || { sleep 5 && rm -rf "$(distdir)"; }; \ 174 | else :; fi 175 | am__post_remove_distdir = $(am__remove_distdir) 176 | DIST_ARCHIVES = $(distdir).tar.gz 177 | GZIP_ENV = --best 178 | DIST_TARGETS = dist-gzip 179 | distuninstallcheck_listfiles = find . -type f -print 180 | am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ 181 | | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' 182 | distcleancheck_listfiles = find . -type f -print 183 | ACLOCAL = @ACLOCAL@ 184 | AMTAR = @AMTAR@ 185 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 186 | AUTOCONF = @AUTOCONF@ 187 | AUTOHEADER = @AUTOHEADER@ 188 | AUTOMAKE = @AUTOMAKE@ 189 | AWK = @AWK@ 190 | CC = @CC@ 191 | CCDEPMODE = @CCDEPMODE@ 192 | CFLAGS = @CFLAGS@ 193 | CPPFLAGS = @CPPFLAGS@ 194 | CYGPATH_W = @CYGPATH_W@ 195 | DEFS = @DEFS@ 196 | DEPDIR = @DEPDIR@ 197 | ECHO_C = @ECHO_C@ 198 | ECHO_N = @ECHO_N@ 199 | ECHO_T = @ECHO_T@ 200 | EXEEXT = @EXEEXT@ 201 | INSTALL = @INSTALL@ 202 | INSTALL_DATA = @INSTALL_DATA@ 203 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 204 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 205 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 206 | LDFLAGS = @LDFLAGS@ 207 | LIBOBJS = @LIBOBJS@ 208 | LIBS = @LIBS@ 209 | LTLIBOBJS = @LTLIBOBJS@ 210 | MAKEINFO = @MAKEINFO@ 211 | MKDIR_P = @MKDIR_P@ 212 | OBJEXT = @OBJEXT@ 213 | PACKAGE = @PACKAGE@ 214 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 215 | PACKAGE_NAME = @PACKAGE_NAME@ 216 | PACKAGE_STRING = @PACKAGE_STRING@ 217 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 218 | PACKAGE_URL = @PACKAGE_URL@ 219 | PACKAGE_VERSION = @PACKAGE_VERSION@ 220 | PATH_SEPARATOR = @PATH_SEPARATOR@ 221 | SET_MAKE = @SET_MAKE@ 222 | SHELL = @SHELL@ 223 | STRIP = @STRIP@ 224 | VERSION = @VERSION@ 225 | abs_builddir = @abs_builddir@ 226 | abs_srcdir = @abs_srcdir@ 227 | abs_top_builddir = @abs_top_builddir@ 228 | abs_top_srcdir = @abs_top_srcdir@ 229 | ac_ct_CC = @ac_ct_CC@ 230 | am__include = @am__include@ 231 | am__leading_dot = @am__leading_dot@ 232 | am__quote = @am__quote@ 233 | am__tar = @am__tar@ 234 | am__untar = @am__untar@ 235 | bindir = @bindir@ 236 | build_alias = @build_alias@ 237 | builddir = @builddir@ 238 | datadir = @datadir@ 239 | datarootdir = @datarootdir@ 240 | docdir = @docdir@ 241 | dvidir = @dvidir@ 242 | exec_prefix = @exec_prefix@ 243 | host_alias = @host_alias@ 244 | htmldir = @htmldir@ 245 | includedir = @includedir@ 246 | infodir = @infodir@ 247 | install_sh = @install_sh@ 248 | libdir = @libdir@ 249 | libexecdir = @libexecdir@ 250 | localedir = @localedir@ 251 | localstatedir = @localstatedir@ 252 | mandir = @mandir@ 253 | mkdir_p = @mkdir_p@ 254 | oldincludedir = @oldincludedir@ 255 | pdfdir = @pdfdir@ 256 | prefix = @prefix@ 257 | program_transform_name = @program_transform_name@ 258 | psdir = @psdir@ 259 | runstatedir = @runstatedir@ 260 | sbindir = @sbindir@ 261 | sharedstatedir = @sharedstatedir@ 262 | srcdir = @srcdir@ 263 | sysconfdir = @sysconfdir@ 264 | target_alias = @target_alias@ 265 | top_build_prefix = @top_build_prefix@ 266 | top_builddir = @top_builddir@ 267 | top_srcdir = @top_srcdir@ 268 | raspi_gpio_SOURCES = raspi-gpio.c 269 | all: all-am 270 | 271 | .SUFFIXES: 272 | .SUFFIXES: .c .o .obj 273 | am--refresh: Makefile 274 | @: 275 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 276 | @for dep in $?; do \ 277 | case '$(am__configure_deps)' in \ 278 | *$$dep*) \ 279 | echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ 280 | $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ 281 | && exit 0; \ 282 | exit 1;; \ 283 | esac; \ 284 | done; \ 285 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ 286 | $(am__cd) $(top_srcdir) && \ 287 | $(AUTOMAKE) --foreign Makefile 288 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 289 | @case '$?' in \ 290 | *config.status*) \ 291 | echo ' $(SHELL) ./config.status'; \ 292 | $(SHELL) ./config.status;; \ 293 | *) \ 294 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ 295 | cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ 296 | esac; 297 | 298 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 299 | $(SHELL) ./config.status --recheck 300 | 301 | $(top_srcdir)/configure: $(am__configure_deps) 302 | $(am__cd) $(srcdir) && $(AUTOCONF) 303 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 304 | $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) 305 | $(am__aclocal_m4_deps): 306 | install-binPROGRAMS: $(bin_PROGRAMS) 307 | @$(NORMAL_INSTALL) 308 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 309 | if test -n "$$list"; then \ 310 | echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ 311 | $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ 312 | fi; \ 313 | for p in $$list; do echo "$$p $$p"; done | \ 314 | sed 's/$(EXEEXT)$$//' | \ 315 | while read p p1; do if test -f $$p \ 316 | ; then echo "$$p"; echo "$$p"; else :; fi; \ 317 | done | \ 318 | sed -e 'p;s,.*/,,;n;h' \ 319 | -e 's|.*|.|' \ 320 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ 321 | sed 'N;N;N;s,\n, ,g' | \ 322 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ 323 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ 324 | if ($$2 == $$4) files[d] = files[d] " " $$1; \ 325 | else { print "f", $$3 "/" $$4, $$1; } } \ 326 | END { for (d in files) print "f", d, files[d] }' | \ 327 | while read type dir files; do \ 328 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 329 | test -z "$$files" || { \ 330 | echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ 331 | $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ 332 | } \ 333 | ; done 334 | 335 | uninstall-binPROGRAMS: 336 | @$(NORMAL_UNINSTALL) 337 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 338 | files=`for p in $$list; do echo "$$p"; done | \ 339 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ 340 | -e 's/$$/$(EXEEXT)/' \ 341 | `; \ 342 | test -n "$$list" || exit 0; \ 343 | echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ 344 | cd "$(DESTDIR)$(bindir)" && rm -f $$files 345 | 346 | clean-binPROGRAMS: 347 | -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) 348 | 349 | raspi-gpio$(EXEEXT): $(raspi_gpio_OBJECTS) $(raspi_gpio_DEPENDENCIES) $(EXTRA_raspi_gpio_DEPENDENCIES) 350 | @rm -f raspi-gpio$(EXEEXT) 351 | $(AM_V_CCLD)$(LINK) $(raspi_gpio_OBJECTS) $(raspi_gpio_LDADD) $(LIBS) 352 | 353 | mostlyclean-compile: 354 | -rm -f *.$(OBJEXT) 355 | 356 | distclean-compile: 357 | -rm -f *.tab.c 358 | 359 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raspi-gpio.Po@am__quote@ # am--include-marker 360 | 361 | $(am__depfiles_remade): 362 | @$(MKDIR_P) $(@D) 363 | @echo '# dummy' >$@-t && $(am__mv) $@-t $@ 364 | 365 | am--depfiles: $(am__depfiles_remade) 366 | 367 | .c.o: 368 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 369 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 370 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 371 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 372 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< 373 | 374 | .c.obj: 375 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 376 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 377 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 378 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 379 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 380 | 381 | ID: $(am__tagged_files) 382 | $(am__define_uniq_tagged_files); mkid -fID $$unique 383 | tags: tags-am 384 | TAGS: tags 385 | 386 | tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 387 | set x; \ 388 | here=`pwd`; \ 389 | $(am__define_uniq_tagged_files); \ 390 | shift; \ 391 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 392 | test -n "$$unique" || unique=$$empty_fix; \ 393 | if test $$# -gt 0; then \ 394 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 395 | "$$@" $$unique; \ 396 | else \ 397 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 398 | $$unique; \ 399 | fi; \ 400 | fi 401 | ctags: ctags-am 402 | 403 | CTAGS: ctags 404 | ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 405 | $(am__define_uniq_tagged_files); \ 406 | test -z "$(CTAGS_ARGS)$$unique" \ 407 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 408 | $$unique 409 | 410 | GTAGS: 411 | here=`$(am__cd) $(top_builddir) && pwd` \ 412 | && $(am__cd) $(top_srcdir) \ 413 | && gtags -i $(GTAGS_ARGS) "$$here" 414 | cscope: cscope.files 415 | test ! -s cscope.files \ 416 | || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) 417 | clean-cscope: 418 | -rm -f cscope.files 419 | cscope.files: clean-cscope cscopelist 420 | cscopelist: cscopelist-am 421 | 422 | cscopelist-am: $(am__tagged_files) 423 | list='$(am__tagged_files)'; \ 424 | case "$(srcdir)" in \ 425 | [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ 426 | *) sdir=$(subdir)/$(srcdir) ;; \ 427 | esac; \ 428 | for i in $$list; do \ 429 | if test -f "$$i"; then \ 430 | echo "$(subdir)/$$i"; \ 431 | else \ 432 | echo "$$sdir/$$i"; \ 433 | fi; \ 434 | done >> $(top_builddir)/cscope.files 435 | 436 | distclean-tags: 437 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 438 | -rm -f cscope.out cscope.in.out cscope.po.out cscope.files 439 | 440 | distdir: $(BUILT_SOURCES) 441 | $(MAKE) $(AM_MAKEFLAGS) distdir-am 442 | 443 | distdir-am: $(DISTFILES) 444 | $(am__remove_distdir) 445 | test -d "$(distdir)" || mkdir "$(distdir)" 446 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 447 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 448 | list='$(DISTFILES)'; \ 449 | dist_files=`for file in $$list; do echo $$file; done | \ 450 | sed -e "s|^$$srcdirstrip/||;t" \ 451 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 452 | case $$dist_files in \ 453 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 454 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 455 | sort -u` ;; \ 456 | esac; \ 457 | for file in $$dist_files; do \ 458 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 459 | if test -d $$d/$$file; then \ 460 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 461 | if test -d "$(distdir)/$$file"; then \ 462 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 463 | fi; \ 464 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 465 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 466 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 467 | fi; \ 468 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 469 | else \ 470 | test -f "$(distdir)/$$file" \ 471 | || cp -p $$d/$$file "$(distdir)/$$file" \ 472 | || exit 1; \ 473 | fi; \ 474 | done 475 | -test -n "$(am__skip_mode_fix)" \ 476 | || find "$(distdir)" -type d ! -perm -755 \ 477 | -exec chmod u+rwx,go+rx {} \; -o \ 478 | ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ 479 | ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ 480 | ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ 481 | || chmod -R a+r "$(distdir)" 482 | dist-gzip: distdir 483 | tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz 484 | $(am__post_remove_distdir) 485 | 486 | dist-bzip2: distdir 487 | tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 488 | $(am__post_remove_distdir) 489 | 490 | dist-lzip: distdir 491 | tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz 492 | $(am__post_remove_distdir) 493 | 494 | dist-xz: distdir 495 | tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz 496 | $(am__post_remove_distdir) 497 | 498 | dist-tarZ: distdir 499 | @echo WARNING: "Support for distribution archives compressed with" \ 500 | "legacy program 'compress' is deprecated." >&2 501 | @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 502 | tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z 503 | $(am__post_remove_distdir) 504 | 505 | dist-shar: distdir 506 | @echo WARNING: "Support for shar distribution archives is" \ 507 | "deprecated." >&2 508 | @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 509 | shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz 510 | $(am__post_remove_distdir) 511 | 512 | dist-zip: distdir 513 | -rm -f $(distdir).zip 514 | zip -rq $(distdir).zip $(distdir) 515 | $(am__post_remove_distdir) 516 | 517 | dist dist-all: 518 | $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' 519 | $(am__post_remove_distdir) 520 | 521 | # This target untars the dist file and tries a VPATH configuration. Then 522 | # it guarantees that the distribution is self-contained by making another 523 | # tarfile. 524 | distcheck: dist 525 | case '$(DIST_ARCHIVES)' in \ 526 | *.tar.gz*) \ 527 | eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ 528 | *.tar.bz2*) \ 529 | bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ 530 | *.tar.lz*) \ 531 | lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ 532 | *.tar.xz*) \ 533 | xz -dc $(distdir).tar.xz | $(am__untar) ;;\ 534 | *.tar.Z*) \ 535 | uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ 536 | *.shar.gz*) \ 537 | eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ 538 | *.zip*) \ 539 | unzip $(distdir).zip ;;\ 540 | esac 541 | chmod -R a-w $(distdir) 542 | chmod u+w $(distdir) 543 | mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst 544 | chmod a-w $(distdir) 545 | test -d $(distdir)/_build || exit 0; \ 546 | dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ 547 | && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ 548 | && am__cwd=`pwd` \ 549 | && $(am__cd) $(distdir)/_build/sub \ 550 | && ../../configure \ 551 | $(AM_DISTCHECK_CONFIGURE_FLAGS) \ 552 | $(DISTCHECK_CONFIGURE_FLAGS) \ 553 | --srcdir=../.. --prefix="$$dc_install_base" \ 554 | && $(MAKE) $(AM_MAKEFLAGS) \ 555 | && $(MAKE) $(AM_MAKEFLAGS) dvi \ 556 | && $(MAKE) $(AM_MAKEFLAGS) check \ 557 | && $(MAKE) $(AM_MAKEFLAGS) install \ 558 | && $(MAKE) $(AM_MAKEFLAGS) installcheck \ 559 | && $(MAKE) $(AM_MAKEFLAGS) uninstall \ 560 | && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ 561 | distuninstallcheck \ 562 | && chmod -R a-w "$$dc_install_base" \ 563 | && ({ \ 564 | (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ 565 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ 566 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ 567 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ 568 | distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ 569 | } || { rm -rf "$$dc_destdir"; exit 1; }) \ 570 | && rm -rf "$$dc_destdir" \ 571 | && $(MAKE) $(AM_MAKEFLAGS) dist \ 572 | && rm -rf $(DIST_ARCHIVES) \ 573 | && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ 574 | && cd "$$am__cwd" \ 575 | || exit 1 576 | $(am__post_remove_distdir) 577 | @(echo "$(distdir) archives ready for distribution: "; \ 578 | list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ 579 | sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' 580 | distuninstallcheck: 581 | @test -n '$(distuninstallcheck_dir)' || { \ 582 | echo 'ERROR: trying to run $@ with an empty' \ 583 | '$$(distuninstallcheck_dir)' >&2; \ 584 | exit 1; \ 585 | }; \ 586 | $(am__cd) '$(distuninstallcheck_dir)' || { \ 587 | echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ 588 | exit 1; \ 589 | }; \ 590 | test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ 591 | || { echo "ERROR: files left after uninstall:" ; \ 592 | if test -n "$(DESTDIR)"; then \ 593 | echo " (check DESTDIR support)"; \ 594 | fi ; \ 595 | $(distuninstallcheck_listfiles) ; \ 596 | exit 1; } >&2 597 | distcleancheck: distclean 598 | @if test '$(srcdir)' = . ; then \ 599 | echo "ERROR: distcleancheck can only run from a VPATH build" ; \ 600 | exit 1 ; \ 601 | fi 602 | @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ 603 | || { echo "ERROR: files left in build directory after distclean:" ; \ 604 | $(distcleancheck_listfiles) ; \ 605 | exit 1; } >&2 606 | check-am: all-am 607 | check: check-am 608 | all-am: Makefile $(PROGRAMS) 609 | installdirs: 610 | for dir in "$(DESTDIR)$(bindir)"; do \ 611 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 612 | done 613 | install: install-am 614 | install-exec: install-exec-am 615 | install-data: install-data-am 616 | uninstall: uninstall-am 617 | 618 | install-am: all-am 619 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 620 | 621 | installcheck: installcheck-am 622 | install-strip: 623 | if test -z '$(STRIP)'; then \ 624 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 625 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 626 | install; \ 627 | else \ 628 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 629 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 630 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 631 | fi 632 | mostlyclean-generic: 633 | 634 | clean-generic: 635 | 636 | distclean-generic: 637 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 638 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 639 | 640 | maintainer-clean-generic: 641 | @echo "This command is intended for maintainers to use" 642 | @echo "it deletes files that may require special tools to rebuild." 643 | clean: clean-am 644 | 645 | clean-am: clean-binPROGRAMS clean-generic mostlyclean-am 646 | 647 | distclean: distclean-am 648 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 649 | -rm -f ./$(DEPDIR)/raspi-gpio.Po 650 | -rm -f Makefile 651 | distclean-am: clean-am distclean-compile distclean-generic \ 652 | distclean-tags 653 | 654 | dvi: dvi-am 655 | 656 | dvi-am: 657 | 658 | html: html-am 659 | 660 | html-am: 661 | 662 | info: info-am 663 | 664 | info-am: 665 | 666 | install-data-am: 667 | 668 | install-dvi: install-dvi-am 669 | 670 | install-dvi-am: 671 | 672 | install-exec-am: install-binPROGRAMS 673 | 674 | install-html: install-html-am 675 | 676 | install-html-am: 677 | 678 | install-info: install-info-am 679 | 680 | install-info-am: 681 | 682 | install-man: 683 | 684 | install-pdf: install-pdf-am 685 | 686 | install-pdf-am: 687 | 688 | install-ps: install-ps-am 689 | 690 | install-ps-am: 691 | 692 | installcheck-am: 693 | 694 | maintainer-clean: maintainer-clean-am 695 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 696 | -rm -rf $(top_srcdir)/autom4te.cache 697 | -rm -f ./$(DEPDIR)/raspi-gpio.Po 698 | -rm -f Makefile 699 | maintainer-clean-am: distclean-am maintainer-clean-generic 700 | 701 | mostlyclean: mostlyclean-am 702 | 703 | mostlyclean-am: mostlyclean-compile mostlyclean-generic 704 | 705 | pdf: pdf-am 706 | 707 | pdf-am: 708 | 709 | ps: ps-am 710 | 711 | ps-am: 712 | 713 | uninstall-am: uninstall-binPROGRAMS 714 | 715 | .MAKE: install-am install-strip 716 | 717 | .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles am--refresh check \ 718 | check-am clean clean-binPROGRAMS clean-cscope clean-generic \ 719 | cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ 720 | dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ 721 | distcheck distclean distclean-compile distclean-generic \ 722 | distclean-tags distcleancheck distdir distuninstallcheck dvi \ 723 | dvi-am html html-am info info-am install install-am \ 724 | install-binPROGRAMS install-data install-data-am install-dvi \ 725 | install-dvi-am install-exec install-exec-am install-html \ 726 | install-html-am install-info install-info-am install-man \ 727 | install-pdf install-pdf-am install-ps install-ps-am \ 728 | install-strip installcheck installcheck-am installdirs \ 729 | maintainer-clean maintainer-clean-generic mostlyclean \ 730 | mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ 731 | tags tags-am uninstall uninstall-am uninstall-binPROGRAMS 732 | 733 | .PRECIOUS: Makefile 734 | 735 | 736 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 737 | # Otherwise a system limit (for SysV at least) may be exceeded. 738 | .NOEXPORT: 739 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # raspi-gpio 2 | 3 | Tool to help debug / hack at the BCM283x GPIO. 4 | 5 | You can dump the state of a GPIO or (all GPIOs). 6 | 7 | You can change a GPIO mode and pulls (and level if set as an output). 8 | 9 | Beware this tool writes directly to the BCM283x GPIO registers, ignoring anything else that may be using them (like Linux drivers). 10 | 11 | ## Build from source 12 | 13 | This tool is pre-installed in Raspberry Pi OS, but to build from source, you should be able to build and install raspi-gpio with: 14 | 15 | ```bash 16 | sudo apt install automake 17 | ./configure 18 | make 19 | sudo make install 20 | ``` 21 | 22 | ## Usage 23 | 24 | ``` 25 | Use: 26 | raspi-gpio get [GPIO] 27 | OR 28 | raspi-gpio set [options] 29 | OR 30 | raspi-gpio funcs [GPIO] 31 | OR 32 | raspi-gpio raw 33 | 34 | GPIO is a comma-separated list of pin numbers or ranges (without spaces), 35 | e.g. 4 or 18-21 or 7,9-11 36 | Note that omitting [GPIO] from raspi-gpio get prints all GPIOs. 37 | raspi-gpio funcs will dump all the possible GPIO alt funcions in CSV format 38 | or if [GPIO] is specified the alternate funcs just for that specific GPIO. 39 | 40 | Valid [options] for raspi-gpio set are: 41 | ip set GPIO as input 42 | op set GPIO as output 43 | a0-a5 set GPIO to alternate function alt0-alt5 44 | pu set GPIO in-pad pull up 45 | pd set GPIO pin-pad pull down 46 | pn set GPIO pull none (no pull) 47 | dh set GPIO to drive to high (1) level (only valid if set to be an output) 48 | dl set GPIO to drive low (0) level (only valid if set to be an output) 49 | 50 | Examples: 51 | raspi-gpio get Prints state of all GPIOs one per line 52 | raspi-gpio get 20 Prints state of GPIO20 53 | raspi-gpio get 20,21 Prints state of GPIO20 and GPIO21 54 | raspi-gpio set 20 a5 Set GPIO20 to ALT5 function (GPCLK0) 55 | raspi-gpio set 20 pu Enable GPIO20 ~50k in-pad pull up 56 | raspi-gpio set 20 pd Enable GPIO20 ~50k in-pad pull down 57 | raspi-gpio set 20 op Set GPIO20 to be an output 58 | raspi-gpio set 20 dl Set GPIO20 to output low/zero (must already be set as an output) 59 | raspi-gpio set 20 ip pd Set GPIO20 to input with pull down 60 | raspi-gpio set 35 a0 pu Set GPIO35 to ALT0 function (SPI_CE1_N) with pull up 61 | raspi-gpio set 20 op pn dh Set GPIO20 to ouput with no pull and driving high 62 | ``` 63 | -------------------------------------------------------------------------------- /aclocal.m4: -------------------------------------------------------------------------------- 1 | # generated automatically by aclocal 1.16.1 -*- Autoconf -*- 2 | 3 | # Copyright (C) 1996-2018 Free Software Foundation, Inc. 4 | 5 | # This file is free software; the Free Software Foundation 6 | # gives unlimited permission to copy and/or distribute it, 7 | # with or without modifications, as long as this notice is preserved. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 11 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12 | # PARTICULAR PURPOSE. 13 | 14 | m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) 15 | m4_ifndef([AC_AUTOCONF_VERSION], 16 | [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl 17 | m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, 18 | [m4_warning([this file was generated for autoconf 2.69. 19 | You have another version of autoconf. It may work, but is not guaranteed to. 20 | If you have problems, you may need to regenerate the build system entirely. 21 | To do so, use the procedure documented by the package, typically 'autoreconf'.])]) 22 | 23 | # Copyright (C) 2002-2018 Free Software Foundation, Inc. 24 | # 25 | # This file is free software; the Free Software Foundation 26 | # gives unlimited permission to copy and/or distribute it, 27 | # with or without modifications, as long as this notice is preserved. 28 | 29 | # AM_AUTOMAKE_VERSION(VERSION) 30 | # ---------------------------- 31 | # Automake X.Y traces this macro to ensure aclocal.m4 has been 32 | # generated from the m4 files accompanying Automake X.Y. 33 | # (This private macro should not be called outside this file.) 34 | AC_DEFUN([AM_AUTOMAKE_VERSION], 35 | [am__api_version='1.16' 36 | dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to 37 | dnl require some minimum version. Point them to the right macro. 38 | m4_if([$1], [1.16.1], [], 39 | [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl 40 | ]) 41 | 42 | # _AM_AUTOCONF_VERSION(VERSION) 43 | # ----------------------------- 44 | # aclocal traces this macro to find the Autoconf version. 45 | # This is a private macro too. Using m4_define simplifies 46 | # the logic in aclocal, which can simply ignore this definition. 47 | m4_define([_AM_AUTOCONF_VERSION], []) 48 | 49 | # AM_SET_CURRENT_AUTOMAKE_VERSION 50 | # ------------------------------- 51 | # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. 52 | # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. 53 | AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], 54 | [AM_AUTOMAKE_VERSION([1.16.1])dnl 55 | m4_ifndef([AC_AUTOCONF_VERSION], 56 | [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl 57 | _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) 58 | 59 | # AM_AUX_DIR_EXPAND -*- Autoconf -*- 60 | 61 | # Copyright (C) 2001-2018 Free Software Foundation, Inc. 62 | # 63 | # This file is free software; the Free Software Foundation 64 | # gives unlimited permission to copy and/or distribute it, 65 | # with or without modifications, as long as this notice is preserved. 66 | 67 | # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets 68 | # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to 69 | # '$srcdir', '$srcdir/..', or '$srcdir/../..'. 70 | # 71 | # Of course, Automake must honor this variable whenever it calls a 72 | # tool from the auxiliary directory. The problem is that $srcdir (and 73 | # therefore $ac_aux_dir as well) can be either absolute or relative, 74 | # depending on how configure is run. This is pretty annoying, since 75 | # it makes $ac_aux_dir quite unusable in subdirectories: in the top 76 | # source directory, any form will work fine, but in subdirectories a 77 | # relative path needs to be adjusted first. 78 | # 79 | # $ac_aux_dir/missing 80 | # fails when called from a subdirectory if $ac_aux_dir is relative 81 | # $top_srcdir/$ac_aux_dir/missing 82 | # fails if $ac_aux_dir is absolute, 83 | # fails when called from a subdirectory in a VPATH build with 84 | # a relative $ac_aux_dir 85 | # 86 | # The reason of the latter failure is that $top_srcdir and $ac_aux_dir 87 | # are both prefixed by $srcdir. In an in-source build this is usually 88 | # harmless because $srcdir is '.', but things will broke when you 89 | # start a VPATH build or use an absolute $srcdir. 90 | # 91 | # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, 92 | # iff we strip the leading $srcdir from $ac_aux_dir. That would be: 93 | # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` 94 | # and then we would define $MISSING as 95 | # MISSING="\${SHELL} $am_aux_dir/missing" 96 | # This will work as long as MISSING is not called from configure, because 97 | # unfortunately $(top_srcdir) has no meaning in configure. 98 | # However there are other variables, like CC, which are often used in 99 | # configure, and could therefore not use this "fixed" $ac_aux_dir. 100 | # 101 | # Another solution, used here, is to always expand $ac_aux_dir to an 102 | # absolute PATH. The drawback is that using absolute paths prevent a 103 | # configured tree to be moved without reconfiguration. 104 | 105 | AC_DEFUN([AM_AUX_DIR_EXPAND], 106 | [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl 107 | # Expand $ac_aux_dir to an absolute path. 108 | am_aux_dir=`cd "$ac_aux_dir" && pwd` 109 | ]) 110 | 111 | # AM_CONDITIONAL -*- Autoconf -*- 112 | 113 | # Copyright (C) 1997-2018 Free Software Foundation, Inc. 114 | # 115 | # This file is free software; the Free Software Foundation 116 | # gives unlimited permission to copy and/or distribute it, 117 | # with or without modifications, as long as this notice is preserved. 118 | 119 | # AM_CONDITIONAL(NAME, SHELL-CONDITION) 120 | # ------------------------------------- 121 | # Define a conditional. 122 | AC_DEFUN([AM_CONDITIONAL], 123 | [AC_PREREQ([2.52])dnl 124 | m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], 125 | [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl 126 | AC_SUBST([$1_TRUE])dnl 127 | AC_SUBST([$1_FALSE])dnl 128 | _AM_SUBST_NOTMAKE([$1_TRUE])dnl 129 | _AM_SUBST_NOTMAKE([$1_FALSE])dnl 130 | m4_define([_AM_COND_VALUE_$1], [$2])dnl 131 | if $2; then 132 | $1_TRUE= 133 | $1_FALSE='#' 134 | else 135 | $1_TRUE='#' 136 | $1_FALSE= 137 | fi 138 | AC_CONFIG_COMMANDS_PRE( 139 | [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then 140 | AC_MSG_ERROR([[conditional "$1" was never defined. 141 | Usually this means the macro was only invoked conditionally.]]) 142 | fi])]) 143 | 144 | # Copyright (C) 1999-2018 Free Software Foundation, Inc. 145 | # 146 | # This file is free software; the Free Software Foundation 147 | # gives unlimited permission to copy and/or distribute it, 148 | # with or without modifications, as long as this notice is preserved. 149 | 150 | 151 | # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be 152 | # written in clear, in which case automake, when reading aclocal.m4, 153 | # will think it sees a *use*, and therefore will trigger all it's 154 | # C support machinery. Also note that it means that autoscan, seeing 155 | # CC etc. in the Makefile, will ask for an AC_PROG_CC use... 156 | 157 | 158 | # _AM_DEPENDENCIES(NAME) 159 | # ---------------------- 160 | # See how the compiler implements dependency checking. 161 | # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". 162 | # We try a few techniques and use that to set a single cache variable. 163 | # 164 | # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was 165 | # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular 166 | # dependency, and given that the user is not expected to run this macro, 167 | # just rely on AC_PROG_CC. 168 | AC_DEFUN([_AM_DEPENDENCIES], 169 | [AC_REQUIRE([AM_SET_DEPDIR])dnl 170 | AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl 171 | AC_REQUIRE([AM_MAKE_INCLUDE])dnl 172 | AC_REQUIRE([AM_DEP_TRACK])dnl 173 | 174 | m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], 175 | [$1], [CXX], [depcc="$CXX" am_compiler_list=], 176 | [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], 177 | [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], 178 | [$1], [UPC], [depcc="$UPC" am_compiler_list=], 179 | [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], 180 | [depcc="$$1" am_compiler_list=]) 181 | 182 | AC_CACHE_CHECK([dependency style of $depcc], 183 | [am_cv_$1_dependencies_compiler_type], 184 | [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then 185 | # We make a subdir and do the tests there. Otherwise we can end up 186 | # making bogus files that we don't know about and never remove. For 187 | # instance it was reported that on HP-UX the gcc test will end up 188 | # making a dummy file named 'D' -- because '-MD' means "put the output 189 | # in D". 190 | rm -rf conftest.dir 191 | mkdir conftest.dir 192 | # Copy depcomp to subdir because otherwise we won't find it if we're 193 | # using a relative directory. 194 | cp "$am_depcomp" conftest.dir 195 | cd conftest.dir 196 | # We will build objects and dependencies in a subdirectory because 197 | # it helps to detect inapplicable dependency modes. For instance 198 | # both Tru64's cc and ICC support -MD to output dependencies as a 199 | # side effect of compilation, but ICC will put the dependencies in 200 | # the current directory while Tru64 will put them in the object 201 | # directory. 202 | mkdir sub 203 | 204 | am_cv_$1_dependencies_compiler_type=none 205 | if test "$am_compiler_list" = ""; then 206 | am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` 207 | fi 208 | am__universal=false 209 | m4_case([$1], [CC], 210 | [case " $depcc " in #( 211 | *\ -arch\ *\ -arch\ *) am__universal=true ;; 212 | esac], 213 | [CXX], 214 | [case " $depcc " in #( 215 | *\ -arch\ *\ -arch\ *) am__universal=true ;; 216 | esac]) 217 | 218 | for depmode in $am_compiler_list; do 219 | # Setup a source with many dependencies, because some compilers 220 | # like to wrap large dependency lists on column 80 (with \), and 221 | # we should not choose a depcomp mode which is confused by this. 222 | # 223 | # We need to recreate these files for each test, as the compiler may 224 | # overwrite some of them when testing with obscure command lines. 225 | # This happens at least with the AIX C compiler. 226 | : > sub/conftest.c 227 | for i in 1 2 3 4 5 6; do 228 | echo '#include "conftst'$i'.h"' >> sub/conftest.c 229 | # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with 230 | # Solaris 10 /bin/sh. 231 | echo '/* dummy */' > sub/conftst$i.h 232 | done 233 | echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf 234 | 235 | # We check with '-c' and '-o' for the sake of the "dashmstdout" 236 | # mode. It turns out that the SunPro C++ compiler does not properly 237 | # handle '-M -o', and we need to detect this. Also, some Intel 238 | # versions had trouble with output in subdirs. 239 | am__obj=sub/conftest.${OBJEXT-o} 240 | am__minus_obj="-o $am__obj" 241 | case $depmode in 242 | gcc) 243 | # This depmode causes a compiler race in universal mode. 244 | test "$am__universal" = false || continue 245 | ;; 246 | nosideeffect) 247 | # After this tag, mechanisms are not by side-effect, so they'll 248 | # only be used when explicitly requested. 249 | if test "x$enable_dependency_tracking" = xyes; then 250 | continue 251 | else 252 | break 253 | fi 254 | ;; 255 | msvc7 | msvc7msys | msvisualcpp | msvcmsys) 256 | # This compiler won't grok '-c -o', but also, the minuso test has 257 | # not run yet. These depmodes are late enough in the game, and 258 | # so weak that their functioning should not be impacted. 259 | am__obj=conftest.${OBJEXT-o} 260 | am__minus_obj= 261 | ;; 262 | none) break ;; 263 | esac 264 | if depmode=$depmode \ 265 | source=sub/conftest.c object=$am__obj \ 266 | depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ 267 | $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ 268 | >/dev/null 2>conftest.err && 269 | grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && 270 | grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && 271 | grep $am__obj sub/conftest.Po > /dev/null 2>&1 && 272 | ${MAKE-make} -s -f confmf > /dev/null 2>&1; then 273 | # icc doesn't choke on unknown options, it will just issue warnings 274 | # or remarks (even with -Werror). So we grep stderr for any message 275 | # that says an option was ignored or not supported. 276 | # When given -MP, icc 7.0 and 7.1 complain thusly: 277 | # icc: Command line warning: ignoring option '-M'; no argument required 278 | # The diagnosis changed in icc 8.0: 279 | # icc: Command line remark: option '-MP' not supported 280 | if (grep 'ignoring option' conftest.err || 281 | grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else 282 | am_cv_$1_dependencies_compiler_type=$depmode 283 | break 284 | fi 285 | fi 286 | done 287 | 288 | cd .. 289 | rm -rf conftest.dir 290 | else 291 | am_cv_$1_dependencies_compiler_type=none 292 | fi 293 | ]) 294 | AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) 295 | AM_CONDITIONAL([am__fastdep$1], [ 296 | test "x$enable_dependency_tracking" != xno \ 297 | && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) 298 | ]) 299 | 300 | 301 | # AM_SET_DEPDIR 302 | # ------------- 303 | # Choose a directory name for dependency files. 304 | # This macro is AC_REQUIREd in _AM_DEPENDENCIES. 305 | AC_DEFUN([AM_SET_DEPDIR], 306 | [AC_REQUIRE([AM_SET_LEADING_DOT])dnl 307 | AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl 308 | ]) 309 | 310 | 311 | # AM_DEP_TRACK 312 | # ------------ 313 | AC_DEFUN([AM_DEP_TRACK], 314 | [AC_ARG_ENABLE([dependency-tracking], [dnl 315 | AS_HELP_STRING( 316 | [--enable-dependency-tracking], 317 | [do not reject slow dependency extractors]) 318 | AS_HELP_STRING( 319 | [--disable-dependency-tracking], 320 | [speeds up one-time build])]) 321 | if test "x$enable_dependency_tracking" != xno; then 322 | am_depcomp="$ac_aux_dir/depcomp" 323 | AMDEPBACKSLASH='\' 324 | am__nodep='_no' 325 | fi 326 | AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) 327 | AC_SUBST([AMDEPBACKSLASH])dnl 328 | _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl 329 | AC_SUBST([am__nodep])dnl 330 | _AM_SUBST_NOTMAKE([am__nodep])dnl 331 | ]) 332 | 333 | # Generate code to set up dependency tracking. -*- Autoconf -*- 334 | 335 | # Copyright (C) 1999-2018 Free Software Foundation, Inc. 336 | # 337 | # This file is free software; the Free Software Foundation 338 | # gives unlimited permission to copy and/or distribute it, 339 | # with or without modifications, as long as this notice is preserved. 340 | 341 | # _AM_OUTPUT_DEPENDENCY_COMMANDS 342 | # ------------------------------ 343 | AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], 344 | [{ 345 | # Older Autoconf quotes --file arguments for eval, but not when files 346 | # are listed without --file. Let's play safe and only enable the eval 347 | # if we detect the quoting. 348 | # TODO: see whether this extra hack can be removed once we start 349 | # requiring Autoconf 2.70 or later. 350 | AS_CASE([$CONFIG_FILES], 351 | [*\'*], [eval set x "$CONFIG_FILES"], 352 | [*], [set x $CONFIG_FILES]) 353 | shift 354 | # Used to flag and report bootstrapping failures. 355 | am_rc=0 356 | for am_mf 357 | do 358 | # Strip MF so we end up with the name of the file. 359 | am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` 360 | # Check whether this is an Automake generated Makefile which includes 361 | # dependency-tracking related rules and includes. 362 | # Grep'ing the whole file directly is not great: AIX grep has a line 363 | # limit of 2048, but all sed's we know have understand at least 4000. 364 | sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ 365 | || continue 366 | am_dirpart=`AS_DIRNAME(["$am_mf"])` 367 | am_filepart=`AS_BASENAME(["$am_mf"])` 368 | AM_RUN_LOG([cd "$am_dirpart" \ 369 | && sed -e '/# am--include-marker/d' "$am_filepart" \ 370 | | $MAKE -f - am--depfiles]) || am_rc=$? 371 | done 372 | if test $am_rc -ne 0; then 373 | AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments 374 | for automatic dependency tracking. Try re-running configure with the 375 | '--disable-dependency-tracking' option to at least be able to build 376 | the package (albeit without support for automatic dependency tracking).]) 377 | fi 378 | AS_UNSET([am_dirpart]) 379 | AS_UNSET([am_filepart]) 380 | AS_UNSET([am_mf]) 381 | AS_UNSET([am_rc]) 382 | rm -f conftest-deps.mk 383 | } 384 | ])# _AM_OUTPUT_DEPENDENCY_COMMANDS 385 | 386 | 387 | # AM_OUTPUT_DEPENDENCY_COMMANDS 388 | # ----------------------------- 389 | # This macro should only be invoked once -- use via AC_REQUIRE. 390 | # 391 | # This code is only required when automatic dependency tracking is enabled. 392 | # This creates each '.Po' and '.Plo' makefile fragment that we'll need in 393 | # order to bootstrap the dependency handling code. 394 | AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], 395 | [AC_CONFIG_COMMANDS([depfiles], 396 | [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], 397 | [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) 398 | 399 | # Do all the work for Automake. -*- Autoconf -*- 400 | 401 | # Copyright (C) 1996-2018 Free Software Foundation, Inc. 402 | # 403 | # This file is free software; the Free Software Foundation 404 | # gives unlimited permission to copy and/or distribute it, 405 | # with or without modifications, as long as this notice is preserved. 406 | 407 | # This macro actually does too much. Some checks are only needed if 408 | # your package does certain things. But this isn't really a big deal. 409 | 410 | dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. 411 | m4_define([AC_PROG_CC], 412 | m4_defn([AC_PROG_CC]) 413 | [_AM_PROG_CC_C_O 414 | ]) 415 | 416 | # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) 417 | # AM_INIT_AUTOMAKE([OPTIONS]) 418 | # ----------------------------------------------- 419 | # The call with PACKAGE and VERSION arguments is the old style 420 | # call (pre autoconf-2.50), which is being phased out. PACKAGE 421 | # and VERSION should now be passed to AC_INIT and removed from 422 | # the call to AM_INIT_AUTOMAKE. 423 | # We support both call styles for the transition. After 424 | # the next Automake release, Autoconf can make the AC_INIT 425 | # arguments mandatory, and then we can depend on a new Autoconf 426 | # release and drop the old call support. 427 | AC_DEFUN([AM_INIT_AUTOMAKE], 428 | [AC_PREREQ([2.65])dnl 429 | dnl Autoconf wants to disallow AM_ names. We explicitly allow 430 | dnl the ones we care about. 431 | m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl 432 | AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl 433 | AC_REQUIRE([AC_PROG_INSTALL])dnl 434 | if test "`cd $srcdir && pwd`" != "`pwd`"; then 435 | # Use -I$(srcdir) only when $(srcdir) != ., so that make's output 436 | # is not polluted with repeated "-I." 437 | AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl 438 | # test to see if srcdir already configured 439 | if test -f $srcdir/config.status; then 440 | AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) 441 | fi 442 | fi 443 | 444 | # test whether we have cygpath 445 | if test -z "$CYGPATH_W"; then 446 | if (cygpath --version) >/dev/null 2>/dev/null; then 447 | CYGPATH_W='cygpath -w' 448 | else 449 | CYGPATH_W=echo 450 | fi 451 | fi 452 | AC_SUBST([CYGPATH_W]) 453 | 454 | # Define the identity of the package. 455 | dnl Distinguish between old-style and new-style calls. 456 | m4_ifval([$2], 457 | [AC_DIAGNOSE([obsolete], 458 | [$0: two- and three-arguments forms are deprecated.]) 459 | m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl 460 | AC_SUBST([PACKAGE], [$1])dnl 461 | AC_SUBST([VERSION], [$2])], 462 | [_AM_SET_OPTIONS([$1])dnl 463 | dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. 464 | m4_if( 465 | m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), 466 | [ok:ok],, 467 | [m4_fatal([AC_INIT should be called with package and version arguments])])dnl 468 | AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl 469 | AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl 470 | 471 | _AM_IF_OPTION([no-define],, 472 | [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) 473 | AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl 474 | 475 | # Some tools Automake needs. 476 | AC_REQUIRE([AM_SANITY_CHECK])dnl 477 | AC_REQUIRE([AC_ARG_PROGRAM])dnl 478 | AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) 479 | AM_MISSING_PROG([AUTOCONF], [autoconf]) 480 | AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) 481 | AM_MISSING_PROG([AUTOHEADER], [autoheader]) 482 | AM_MISSING_PROG([MAKEINFO], [makeinfo]) 483 | AC_REQUIRE([AM_PROG_INSTALL_SH])dnl 484 | AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl 485 | AC_REQUIRE([AC_PROG_MKDIR_P])dnl 486 | # For better backward compatibility. To be removed once Automake 1.9.x 487 | # dies out for good. For more background, see: 488 | # 489 | # 490 | AC_SUBST([mkdir_p], ['$(MKDIR_P)']) 491 | # We need awk for the "check" target (and possibly the TAP driver). The 492 | # system "awk" is bad on some platforms. 493 | AC_REQUIRE([AC_PROG_AWK])dnl 494 | AC_REQUIRE([AC_PROG_MAKE_SET])dnl 495 | AC_REQUIRE([AM_SET_LEADING_DOT])dnl 496 | _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], 497 | [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], 498 | [_AM_PROG_TAR([v7])])]) 499 | _AM_IF_OPTION([no-dependencies],, 500 | [AC_PROVIDE_IFELSE([AC_PROG_CC], 501 | [_AM_DEPENDENCIES([CC])], 502 | [m4_define([AC_PROG_CC], 503 | m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl 504 | AC_PROVIDE_IFELSE([AC_PROG_CXX], 505 | [_AM_DEPENDENCIES([CXX])], 506 | [m4_define([AC_PROG_CXX], 507 | m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl 508 | AC_PROVIDE_IFELSE([AC_PROG_OBJC], 509 | [_AM_DEPENDENCIES([OBJC])], 510 | [m4_define([AC_PROG_OBJC], 511 | m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl 512 | AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], 513 | [_AM_DEPENDENCIES([OBJCXX])], 514 | [m4_define([AC_PROG_OBJCXX], 515 | m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl 516 | ]) 517 | AC_REQUIRE([AM_SILENT_RULES])dnl 518 | dnl The testsuite driver may need to know about EXEEXT, so add the 519 | dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This 520 | dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. 521 | AC_CONFIG_COMMANDS_PRE(dnl 522 | [m4_provide_if([_AM_COMPILER_EXEEXT], 523 | [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl 524 | 525 | # POSIX will say in a future version that running "rm -f" with no argument 526 | # is OK; and we want to be able to make that assumption in our Makefile 527 | # recipes. So use an aggressive probe to check that the usage we want is 528 | # actually supported "in the wild" to an acceptable degree. 529 | # See automake bug#10828. 530 | # To make any issue more visible, cause the running configure to be aborted 531 | # by default if the 'rm' program in use doesn't match our expectations; the 532 | # user can still override this though. 533 | if rm -f && rm -fr && rm -rf; then : OK; else 534 | cat >&2 <<'END' 535 | Oops! 536 | 537 | Your 'rm' program seems unable to run without file operands specified 538 | on the command line, even when the '-f' option is present. This is contrary 539 | to the behaviour of most rm programs out there, and not conforming with 540 | the upcoming POSIX standard: 541 | 542 | Please tell bug-automake@gnu.org about your system, including the value 543 | of your $PATH and any error possibly output before this message. This 544 | can help us improve future automake versions. 545 | 546 | END 547 | if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then 548 | echo 'Configuration will proceed anyway, since you have set the' >&2 549 | echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 550 | echo >&2 551 | else 552 | cat >&2 <<'END' 553 | Aborting the configuration process, to ensure you take notice of the issue. 554 | 555 | You can download and install GNU coreutils to get an 'rm' implementation 556 | that behaves properly: . 557 | 558 | If you want to complete the configuration process using your problematic 559 | 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM 560 | to "yes", and re-run configure. 561 | 562 | END 563 | AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) 564 | fi 565 | fi 566 | dnl The trailing newline in this macro's definition is deliberate, for 567 | dnl backward compatibility and to allow trailing 'dnl'-style comments 568 | dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. 569 | ]) 570 | 571 | dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not 572 | dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further 573 | dnl mangled by Autoconf and run in a shell conditional statement. 574 | m4_define([_AC_COMPILER_EXEEXT], 575 | m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) 576 | 577 | # When config.status generates a header, we must update the stamp-h file. 578 | # This file resides in the same directory as the config header 579 | # that is generated. The stamp files are numbered to have different names. 580 | 581 | # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the 582 | # loop where config.status creates the headers, so we can generate 583 | # our stamp files there. 584 | AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], 585 | [# Compute $1's index in $config_headers. 586 | _am_arg=$1 587 | _am_stamp_count=1 588 | for _am_header in $config_headers :; do 589 | case $_am_header in 590 | $_am_arg | $_am_arg:* ) 591 | break ;; 592 | * ) 593 | _am_stamp_count=`expr $_am_stamp_count + 1` ;; 594 | esac 595 | done 596 | echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) 597 | 598 | # Copyright (C) 2001-2018 Free Software Foundation, Inc. 599 | # 600 | # This file is free software; the Free Software Foundation 601 | # gives unlimited permission to copy and/or distribute it, 602 | # with or without modifications, as long as this notice is preserved. 603 | 604 | # AM_PROG_INSTALL_SH 605 | # ------------------ 606 | # Define $install_sh. 607 | AC_DEFUN([AM_PROG_INSTALL_SH], 608 | [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl 609 | if test x"${install_sh+set}" != xset; then 610 | case $am_aux_dir in 611 | *\ * | *\ *) 612 | install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; 613 | *) 614 | install_sh="\${SHELL} $am_aux_dir/install-sh" 615 | esac 616 | fi 617 | AC_SUBST([install_sh])]) 618 | 619 | # Copyright (C) 2003-2018 Free Software Foundation, Inc. 620 | # 621 | # This file is free software; the Free Software Foundation 622 | # gives unlimited permission to copy and/or distribute it, 623 | # with or without modifications, as long as this notice is preserved. 624 | 625 | # Check whether the underlying file-system supports filenames 626 | # with a leading dot. For instance MS-DOS doesn't. 627 | AC_DEFUN([AM_SET_LEADING_DOT], 628 | [rm -rf .tst 2>/dev/null 629 | mkdir .tst 2>/dev/null 630 | if test -d .tst; then 631 | am__leading_dot=. 632 | else 633 | am__leading_dot=_ 634 | fi 635 | rmdir .tst 2>/dev/null 636 | AC_SUBST([am__leading_dot])]) 637 | 638 | # Check to see how 'make' treats includes. -*- Autoconf -*- 639 | 640 | # Copyright (C) 2001-2018 Free Software Foundation, Inc. 641 | # 642 | # This file is free software; the Free Software Foundation 643 | # gives unlimited permission to copy and/or distribute it, 644 | # with or without modifications, as long as this notice is preserved. 645 | 646 | # AM_MAKE_INCLUDE() 647 | # ----------------- 648 | # Check whether make has an 'include' directive that can support all 649 | # the idioms we need for our automatic dependency tracking code. 650 | AC_DEFUN([AM_MAKE_INCLUDE], 651 | [AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) 652 | cat > confinc.mk << 'END' 653 | am__doit: 654 | @echo this is the am__doit target >confinc.out 655 | .PHONY: am__doit 656 | END 657 | am__include="#" 658 | am__quote= 659 | # BSD make does it like this. 660 | echo '.include "confinc.mk" # ignored' > confmf.BSD 661 | # Other make implementations (GNU, Solaris 10, AIX) do it like this. 662 | echo 'include confinc.mk # ignored' > confmf.GNU 663 | _am_result=no 664 | for s in GNU BSD; do 665 | AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) 666 | AS_CASE([$?:`cat confinc.out 2>/dev/null`], 667 | ['0:this is the am__doit target'], 668 | [AS_CASE([$s], 669 | [BSD], [am__include='.include' am__quote='"'], 670 | [am__include='include' am__quote=''])]) 671 | if test "$am__include" != "#"; then 672 | _am_result="yes ($s style)" 673 | break 674 | fi 675 | done 676 | rm -f confinc.* confmf.* 677 | AC_MSG_RESULT([${_am_result}]) 678 | AC_SUBST([am__include])]) 679 | AC_SUBST([am__quote])]) 680 | 681 | # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- 682 | 683 | # Copyright (C) 1997-2018 Free Software Foundation, Inc. 684 | # 685 | # This file is free software; the Free Software Foundation 686 | # gives unlimited permission to copy and/or distribute it, 687 | # with or without modifications, as long as this notice is preserved. 688 | 689 | # AM_MISSING_PROG(NAME, PROGRAM) 690 | # ------------------------------ 691 | AC_DEFUN([AM_MISSING_PROG], 692 | [AC_REQUIRE([AM_MISSING_HAS_RUN]) 693 | $1=${$1-"${am_missing_run}$2"} 694 | AC_SUBST($1)]) 695 | 696 | # AM_MISSING_HAS_RUN 697 | # ------------------ 698 | # Define MISSING if not defined so far and test if it is modern enough. 699 | # If it is, set am_missing_run to use it, otherwise, to nothing. 700 | AC_DEFUN([AM_MISSING_HAS_RUN], 701 | [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl 702 | AC_REQUIRE_AUX_FILE([missing])dnl 703 | if test x"${MISSING+set}" != xset; then 704 | case $am_aux_dir in 705 | *\ * | *\ *) 706 | MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; 707 | *) 708 | MISSING="\${SHELL} $am_aux_dir/missing" ;; 709 | esac 710 | fi 711 | # Use eval to expand $SHELL 712 | if eval "$MISSING --is-lightweight"; then 713 | am_missing_run="$MISSING " 714 | else 715 | am_missing_run= 716 | AC_MSG_WARN(['missing' script is too old or missing]) 717 | fi 718 | ]) 719 | 720 | # Helper functions for option handling. -*- Autoconf -*- 721 | 722 | # Copyright (C) 2001-2018 Free Software Foundation, Inc. 723 | # 724 | # This file is free software; the Free Software Foundation 725 | # gives unlimited permission to copy and/or distribute it, 726 | # with or without modifications, as long as this notice is preserved. 727 | 728 | # _AM_MANGLE_OPTION(NAME) 729 | # ----------------------- 730 | AC_DEFUN([_AM_MANGLE_OPTION], 731 | [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) 732 | 733 | # _AM_SET_OPTION(NAME) 734 | # -------------------- 735 | # Set option NAME. Presently that only means defining a flag for this option. 736 | AC_DEFUN([_AM_SET_OPTION], 737 | [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) 738 | 739 | # _AM_SET_OPTIONS(OPTIONS) 740 | # ------------------------ 741 | # OPTIONS is a space-separated list of Automake options. 742 | AC_DEFUN([_AM_SET_OPTIONS], 743 | [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) 744 | 745 | # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) 746 | # ------------------------------------------- 747 | # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. 748 | AC_DEFUN([_AM_IF_OPTION], 749 | [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) 750 | 751 | # Copyright (C) 1999-2018 Free Software Foundation, Inc. 752 | # 753 | # This file is free software; the Free Software Foundation 754 | # gives unlimited permission to copy and/or distribute it, 755 | # with or without modifications, as long as this notice is preserved. 756 | 757 | # _AM_PROG_CC_C_O 758 | # --------------- 759 | # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC 760 | # to automatically call this. 761 | AC_DEFUN([_AM_PROG_CC_C_O], 762 | [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl 763 | AC_REQUIRE_AUX_FILE([compile])dnl 764 | AC_LANG_PUSH([C])dnl 765 | AC_CACHE_CHECK( 766 | [whether $CC understands -c and -o together], 767 | [am_cv_prog_cc_c_o], 768 | [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) 769 | # Make sure it works both with $CC and with simple cc. 770 | # Following AC_PROG_CC_C_O, we do the test twice because some 771 | # compilers refuse to overwrite an existing .o file with -o, 772 | # though they will create one. 773 | am_cv_prog_cc_c_o=yes 774 | for am_i in 1 2; do 775 | if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ 776 | && test -f conftest2.$ac_objext; then 777 | : OK 778 | else 779 | am_cv_prog_cc_c_o=no 780 | break 781 | fi 782 | done 783 | rm -f core conftest* 784 | unset am_i]) 785 | if test "$am_cv_prog_cc_c_o" != yes; then 786 | # Losing compiler, so override with the script. 787 | # FIXME: It is wrong to rewrite CC. 788 | # But if we don't then we get into trouble of one sort or another. 789 | # A longer-term fix would be to have automake use am__CC in this case, 790 | # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" 791 | CC="$am_aux_dir/compile $CC" 792 | fi 793 | AC_LANG_POP([C])]) 794 | 795 | # For backward compatibility. 796 | AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) 797 | 798 | # Copyright (C) 2001-2018 Free Software Foundation, Inc. 799 | # 800 | # This file is free software; the Free Software Foundation 801 | # gives unlimited permission to copy and/or distribute it, 802 | # with or without modifications, as long as this notice is preserved. 803 | 804 | # AM_RUN_LOG(COMMAND) 805 | # ------------------- 806 | # Run COMMAND, save the exit status in ac_status, and log it. 807 | # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) 808 | AC_DEFUN([AM_RUN_LOG], 809 | [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD 810 | ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD 811 | ac_status=$? 812 | echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD 813 | (exit $ac_status); }]) 814 | 815 | # Check to make sure that the build environment is sane. -*- Autoconf -*- 816 | 817 | # Copyright (C) 1996-2018 Free Software Foundation, Inc. 818 | # 819 | # This file is free software; the Free Software Foundation 820 | # gives unlimited permission to copy and/or distribute it, 821 | # with or without modifications, as long as this notice is preserved. 822 | 823 | # AM_SANITY_CHECK 824 | # --------------- 825 | AC_DEFUN([AM_SANITY_CHECK], 826 | [AC_MSG_CHECKING([whether build environment is sane]) 827 | # Reject unsafe characters in $srcdir or the absolute working directory 828 | # name. Accept space and tab only in the latter. 829 | am_lf=' 830 | ' 831 | case `pwd` in 832 | *[[\\\"\#\$\&\'\`$am_lf]]*) 833 | AC_MSG_ERROR([unsafe absolute working directory name]);; 834 | esac 835 | case $srcdir in 836 | *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) 837 | AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; 838 | esac 839 | 840 | # Do 'set' in a subshell so we don't clobber the current shell's 841 | # arguments. Must try -L first in case configure is actually a 842 | # symlink; some systems play weird games with the mod time of symlinks 843 | # (eg FreeBSD returns the mod time of the symlink's containing 844 | # directory). 845 | if ( 846 | am_has_slept=no 847 | for am_try in 1 2; do 848 | echo "timestamp, slept: $am_has_slept" > conftest.file 849 | set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` 850 | if test "$[*]" = "X"; then 851 | # -L didn't work. 852 | set X `ls -t "$srcdir/configure" conftest.file` 853 | fi 854 | if test "$[*]" != "X $srcdir/configure conftest.file" \ 855 | && test "$[*]" != "X conftest.file $srcdir/configure"; then 856 | 857 | # If neither matched, then we have a broken ls. This can happen 858 | # if, for instance, CONFIG_SHELL is bash and it inherits a 859 | # broken ls alias from the environment. This has actually 860 | # happened. Such a system could not be considered "sane". 861 | AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken 862 | alias in your environment]) 863 | fi 864 | if test "$[2]" = conftest.file || test $am_try -eq 2; then 865 | break 866 | fi 867 | # Just in case. 868 | sleep 1 869 | am_has_slept=yes 870 | done 871 | test "$[2]" = conftest.file 872 | ) 873 | then 874 | # Ok. 875 | : 876 | else 877 | AC_MSG_ERROR([newly created file is older than distributed files! 878 | Check your system clock]) 879 | fi 880 | AC_MSG_RESULT([yes]) 881 | # If we didn't sleep, we still need to ensure time stamps of config.status and 882 | # generated files are strictly newer. 883 | am_sleep_pid= 884 | if grep 'slept: no' conftest.file >/dev/null 2>&1; then 885 | ( sleep 1 ) & 886 | am_sleep_pid=$! 887 | fi 888 | AC_CONFIG_COMMANDS_PRE( 889 | [AC_MSG_CHECKING([that generated files are newer than configure]) 890 | if test -n "$am_sleep_pid"; then 891 | # Hide warnings about reused PIDs. 892 | wait $am_sleep_pid 2>/dev/null 893 | fi 894 | AC_MSG_RESULT([done])]) 895 | rm -f conftest.file 896 | ]) 897 | 898 | # Copyright (C) 2009-2018 Free Software Foundation, Inc. 899 | # 900 | # This file is free software; the Free Software Foundation 901 | # gives unlimited permission to copy and/or distribute it, 902 | # with or without modifications, as long as this notice is preserved. 903 | 904 | # AM_SILENT_RULES([DEFAULT]) 905 | # -------------------------- 906 | # Enable less verbose build rules; with the default set to DEFAULT 907 | # ("yes" being less verbose, "no" or empty being verbose). 908 | AC_DEFUN([AM_SILENT_RULES], 909 | [AC_ARG_ENABLE([silent-rules], [dnl 910 | AS_HELP_STRING( 911 | [--enable-silent-rules], 912 | [less verbose build output (undo: "make V=1")]) 913 | AS_HELP_STRING( 914 | [--disable-silent-rules], 915 | [verbose build output (undo: "make V=0")])dnl 916 | ]) 917 | case $enable_silent_rules in @%:@ ((( 918 | yes) AM_DEFAULT_VERBOSITY=0;; 919 | no) AM_DEFAULT_VERBOSITY=1;; 920 | *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; 921 | esac 922 | dnl 923 | dnl A few 'make' implementations (e.g., NonStop OS and NextStep) 924 | dnl do not support nested variable expansions. 925 | dnl See automake bug#9928 and bug#10237. 926 | am_make=${MAKE-make} 927 | AC_CACHE_CHECK([whether $am_make supports nested variables], 928 | [am_cv_make_support_nested_variables], 929 | [if AS_ECHO([['TRUE=$(BAR$(V)) 930 | BAR0=false 931 | BAR1=true 932 | V=1 933 | am__doit: 934 | @$(TRUE) 935 | .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then 936 | am_cv_make_support_nested_variables=yes 937 | else 938 | am_cv_make_support_nested_variables=no 939 | fi]) 940 | if test $am_cv_make_support_nested_variables = yes; then 941 | dnl Using '$V' instead of '$(V)' breaks IRIX make. 942 | AM_V='$(V)' 943 | AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' 944 | else 945 | AM_V=$AM_DEFAULT_VERBOSITY 946 | AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY 947 | fi 948 | AC_SUBST([AM_V])dnl 949 | AM_SUBST_NOTMAKE([AM_V])dnl 950 | AC_SUBST([AM_DEFAULT_V])dnl 951 | AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl 952 | AC_SUBST([AM_DEFAULT_VERBOSITY])dnl 953 | AM_BACKSLASH='\' 954 | AC_SUBST([AM_BACKSLASH])dnl 955 | _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl 956 | ]) 957 | 958 | # Copyright (C) 2001-2018 Free Software Foundation, Inc. 959 | # 960 | # This file is free software; the Free Software Foundation 961 | # gives unlimited permission to copy and/or distribute it, 962 | # with or without modifications, as long as this notice is preserved. 963 | 964 | # AM_PROG_INSTALL_STRIP 965 | # --------------------- 966 | # One issue with vendor 'install' (even GNU) is that you can't 967 | # specify the program used to strip binaries. This is especially 968 | # annoying in cross-compiling environments, where the build's strip 969 | # is unlikely to handle the host's binaries. 970 | # Fortunately install-sh will honor a STRIPPROG variable, so we 971 | # always use install-sh in "make install-strip", and initialize 972 | # STRIPPROG with the value of the STRIP variable (set by the user). 973 | AC_DEFUN([AM_PROG_INSTALL_STRIP], 974 | [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl 975 | # Installed binaries are usually stripped using 'strip' when the user 976 | # run "make install-strip". However 'strip' might not be the right 977 | # tool to use in cross-compilation environments, therefore Automake 978 | # will honor the 'STRIP' environment variable to overrule this program. 979 | dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. 980 | if test "$cross_compiling" != no; then 981 | AC_CHECK_TOOL([STRIP], [strip], :) 982 | fi 983 | INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" 984 | AC_SUBST([INSTALL_STRIP_PROGRAM])]) 985 | 986 | # Copyright (C) 2006-2018 Free Software Foundation, Inc. 987 | # 988 | # This file is free software; the Free Software Foundation 989 | # gives unlimited permission to copy and/or distribute it, 990 | # with or without modifications, as long as this notice is preserved. 991 | 992 | # _AM_SUBST_NOTMAKE(VARIABLE) 993 | # --------------------------- 994 | # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. 995 | # This macro is traced by Automake. 996 | AC_DEFUN([_AM_SUBST_NOTMAKE]) 997 | 998 | # AM_SUBST_NOTMAKE(VARIABLE) 999 | # -------------------------- 1000 | # Public sister of _AM_SUBST_NOTMAKE. 1001 | AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) 1002 | 1003 | # Check how to create a tarball. -*- Autoconf -*- 1004 | 1005 | # Copyright (C) 2004-2018 Free Software Foundation, Inc. 1006 | # 1007 | # This file is free software; the Free Software Foundation 1008 | # gives unlimited permission to copy and/or distribute it, 1009 | # with or without modifications, as long as this notice is preserved. 1010 | 1011 | # _AM_PROG_TAR(FORMAT) 1012 | # -------------------- 1013 | # Check how to create a tarball in format FORMAT. 1014 | # FORMAT should be one of 'v7', 'ustar', or 'pax'. 1015 | # 1016 | # Substitute a variable $(am__tar) that is a command 1017 | # writing to stdout a FORMAT-tarball containing the directory 1018 | # $tardir. 1019 | # tardir=directory && $(am__tar) > result.tar 1020 | # 1021 | # Substitute a variable $(am__untar) that extract such 1022 | # a tarball read from stdin. 1023 | # $(am__untar) < result.tar 1024 | # 1025 | AC_DEFUN([_AM_PROG_TAR], 1026 | [# Always define AMTAR for backward compatibility. Yes, it's still used 1027 | # in the wild :-( We should find a proper way to deprecate it ... 1028 | AC_SUBST([AMTAR], ['$${TAR-tar}']) 1029 | 1030 | # We'll loop over all known methods to create a tar archive until one works. 1031 | _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' 1032 | 1033 | m4_if([$1], [v7], 1034 | [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], 1035 | 1036 | [m4_case([$1], 1037 | [ustar], 1038 | [# The POSIX 1988 'ustar' format is defined with fixed-size fields. 1039 | # There is notably a 21 bits limit for the UID and the GID. In fact, 1040 | # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 1041 | # and bug#13588). 1042 | am_max_uid=2097151 # 2^21 - 1 1043 | am_max_gid=$am_max_uid 1044 | # The $UID and $GID variables are not portable, so we need to resort 1045 | # to the POSIX-mandated id(1) utility. Errors in the 'id' calls 1046 | # below are definitely unexpected, so allow the users to see them 1047 | # (that is, avoid stderr redirection). 1048 | am_uid=`id -u || echo unknown` 1049 | am_gid=`id -g || echo unknown` 1050 | AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) 1051 | if test $am_uid -le $am_max_uid; then 1052 | AC_MSG_RESULT([yes]) 1053 | else 1054 | AC_MSG_RESULT([no]) 1055 | _am_tools=none 1056 | fi 1057 | AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) 1058 | if test $am_gid -le $am_max_gid; then 1059 | AC_MSG_RESULT([yes]) 1060 | else 1061 | AC_MSG_RESULT([no]) 1062 | _am_tools=none 1063 | fi], 1064 | 1065 | [pax], 1066 | [], 1067 | 1068 | [m4_fatal([Unknown tar format])]) 1069 | 1070 | AC_MSG_CHECKING([how to create a $1 tar archive]) 1071 | 1072 | # Go ahead even if we have the value already cached. We do so because we 1073 | # need to set the values for the 'am__tar' and 'am__untar' variables. 1074 | _am_tools=${am_cv_prog_tar_$1-$_am_tools} 1075 | 1076 | for _am_tool in $_am_tools; do 1077 | case $_am_tool in 1078 | gnutar) 1079 | for _am_tar in tar gnutar gtar; do 1080 | AM_RUN_LOG([$_am_tar --version]) && break 1081 | done 1082 | am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' 1083 | am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' 1084 | am__untar="$_am_tar -xf -" 1085 | ;; 1086 | plaintar) 1087 | # Must skip GNU tar: if it does not support --format= it doesn't create 1088 | # ustar tarball either. 1089 | (tar --version) >/dev/null 2>&1 && continue 1090 | am__tar='tar chf - "$$tardir"' 1091 | am__tar_='tar chf - "$tardir"' 1092 | am__untar='tar xf -' 1093 | ;; 1094 | pax) 1095 | am__tar='pax -L -x $1 -w "$$tardir"' 1096 | am__tar_='pax -L -x $1 -w "$tardir"' 1097 | am__untar='pax -r' 1098 | ;; 1099 | cpio) 1100 | am__tar='find "$$tardir" -print | cpio -o -H $1 -L' 1101 | am__tar_='find "$tardir" -print | cpio -o -H $1 -L' 1102 | am__untar='cpio -i -H $1 -d' 1103 | ;; 1104 | none) 1105 | am__tar=false 1106 | am__tar_=false 1107 | am__untar=false 1108 | ;; 1109 | esac 1110 | 1111 | # If the value was cached, stop now. We just wanted to have am__tar 1112 | # and am__untar set. 1113 | test -n "${am_cv_prog_tar_$1}" && break 1114 | 1115 | # tar/untar a dummy directory, and stop if the command works. 1116 | rm -rf conftest.dir 1117 | mkdir conftest.dir 1118 | echo GrepMe > conftest.dir/file 1119 | AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) 1120 | rm -rf conftest.dir 1121 | if test -s conftest.tar; then 1122 | AM_RUN_LOG([$am__untar /dev/null 2>&1 && break 1125 | fi 1126 | done 1127 | rm -rf conftest.dir 1128 | 1129 | AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) 1130 | AC_MSG_RESULT([$am_cv_prog_tar_$1])]) 1131 | 1132 | AC_SUBST([am__tar]) 1133 | AC_SUBST([am__untar]) 1134 | ]) # _AM_PROG_TAR 1135 | 1136 | -------------------------------------------------------------------------------- /compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Wrapper for compilers which do not understand '-c -o'. 3 | 4 | scriptversion=2018-03-07.03; # UTC 5 | 6 | # Copyright (C) 1999-2018 Free Software Foundation, Inc. 7 | # Written by Tom Tromey . 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | # This file is maintained in Automake, please report 28 | # bugs to or send patches to 29 | # . 30 | 31 | nl=' 32 | ' 33 | 34 | # We need space, tab and new line, in precisely that order. Quoting is 35 | # there to prevent tools from complaining about whitespace usage. 36 | IFS=" "" $nl" 37 | 38 | file_conv= 39 | 40 | # func_file_conv build_file lazy 41 | # Convert a $build file to $host form and store it in $file 42 | # Currently only supports Windows hosts. If the determined conversion 43 | # type is listed in (the comma separated) LAZY, no conversion will 44 | # take place. 45 | func_file_conv () 46 | { 47 | file=$1 48 | case $file in 49 | / | /[!/]*) # absolute file, and not a UNC file 50 | if test -z "$file_conv"; then 51 | # lazily determine how to convert abs files 52 | case `uname -s` in 53 | MINGW*) 54 | file_conv=mingw 55 | ;; 56 | CYGWIN*) 57 | file_conv=cygwin 58 | ;; 59 | *) 60 | file_conv=wine 61 | ;; 62 | esac 63 | fi 64 | case $file_conv/,$2, in 65 | *,$file_conv,*) 66 | ;; 67 | mingw/*) 68 | file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` 69 | ;; 70 | cygwin/*) 71 | file=`cygpath -m "$file" || echo "$file"` 72 | ;; 73 | wine/*) 74 | file=`winepath -w "$file" || echo "$file"` 75 | ;; 76 | esac 77 | ;; 78 | esac 79 | } 80 | 81 | # func_cl_dashL linkdir 82 | # Make cl look for libraries in LINKDIR 83 | func_cl_dashL () 84 | { 85 | func_file_conv "$1" 86 | if test -z "$lib_path"; then 87 | lib_path=$file 88 | else 89 | lib_path="$lib_path;$file" 90 | fi 91 | linker_opts="$linker_opts -LIBPATH:$file" 92 | } 93 | 94 | # func_cl_dashl library 95 | # Do a library search-path lookup for cl 96 | func_cl_dashl () 97 | { 98 | lib=$1 99 | found=no 100 | save_IFS=$IFS 101 | IFS=';' 102 | for dir in $lib_path $LIB 103 | do 104 | IFS=$save_IFS 105 | if $shared && test -f "$dir/$lib.dll.lib"; then 106 | found=yes 107 | lib=$dir/$lib.dll.lib 108 | break 109 | fi 110 | if test -f "$dir/$lib.lib"; then 111 | found=yes 112 | lib=$dir/$lib.lib 113 | break 114 | fi 115 | if test -f "$dir/lib$lib.a"; then 116 | found=yes 117 | lib=$dir/lib$lib.a 118 | break 119 | fi 120 | done 121 | IFS=$save_IFS 122 | 123 | if test "$found" != yes; then 124 | lib=$lib.lib 125 | fi 126 | } 127 | 128 | # func_cl_wrapper cl arg... 129 | # Adjust compile command to suit cl 130 | func_cl_wrapper () 131 | { 132 | # Assume a capable shell 133 | lib_path= 134 | shared=: 135 | linker_opts= 136 | for arg 137 | do 138 | if test -n "$eat"; then 139 | eat= 140 | else 141 | case $1 in 142 | -o) 143 | # configure might choose to run compile as 'compile cc -o foo foo.c'. 144 | eat=1 145 | case $2 in 146 | *.o | *.[oO][bB][jJ]) 147 | func_file_conv "$2" 148 | set x "$@" -Fo"$file" 149 | shift 150 | ;; 151 | *) 152 | func_file_conv "$2" 153 | set x "$@" -Fe"$file" 154 | shift 155 | ;; 156 | esac 157 | ;; 158 | -I) 159 | eat=1 160 | func_file_conv "$2" mingw 161 | set x "$@" -I"$file" 162 | shift 163 | ;; 164 | -I*) 165 | func_file_conv "${1#-I}" mingw 166 | set x "$@" -I"$file" 167 | shift 168 | ;; 169 | -l) 170 | eat=1 171 | func_cl_dashl "$2" 172 | set x "$@" "$lib" 173 | shift 174 | ;; 175 | -l*) 176 | func_cl_dashl "${1#-l}" 177 | set x "$@" "$lib" 178 | shift 179 | ;; 180 | -L) 181 | eat=1 182 | func_cl_dashL "$2" 183 | ;; 184 | -L*) 185 | func_cl_dashL "${1#-L}" 186 | ;; 187 | -static) 188 | shared=false 189 | ;; 190 | -Wl,*) 191 | arg=${1#-Wl,} 192 | save_ifs="$IFS"; IFS=',' 193 | for flag in $arg; do 194 | IFS="$save_ifs" 195 | linker_opts="$linker_opts $flag" 196 | done 197 | IFS="$save_ifs" 198 | ;; 199 | -Xlinker) 200 | eat=1 201 | linker_opts="$linker_opts $2" 202 | ;; 203 | -*) 204 | set x "$@" "$1" 205 | shift 206 | ;; 207 | *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) 208 | func_file_conv "$1" 209 | set x "$@" -Tp"$file" 210 | shift 211 | ;; 212 | *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) 213 | func_file_conv "$1" mingw 214 | set x "$@" "$file" 215 | shift 216 | ;; 217 | *) 218 | set x "$@" "$1" 219 | shift 220 | ;; 221 | esac 222 | fi 223 | shift 224 | done 225 | if test -n "$linker_opts"; then 226 | linker_opts="-link$linker_opts" 227 | fi 228 | exec "$@" $linker_opts 229 | exit 1 230 | } 231 | 232 | eat= 233 | 234 | case $1 in 235 | '') 236 | echo "$0: No command. Try '$0 --help' for more information." 1>&2 237 | exit 1; 238 | ;; 239 | -h | --h*) 240 | cat <<\EOF 241 | Usage: compile [--help] [--version] PROGRAM [ARGS] 242 | 243 | Wrapper for compilers which do not understand '-c -o'. 244 | Remove '-o dest.o' from ARGS, run PROGRAM with the remaining 245 | arguments, and rename the output as expected. 246 | 247 | If you are trying to build a whole package this is not the 248 | right script to run: please start by reading the file 'INSTALL'. 249 | 250 | Report bugs to . 251 | EOF 252 | exit $? 253 | ;; 254 | -v | --v*) 255 | echo "compile $scriptversion" 256 | exit $? 257 | ;; 258 | cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ 259 | icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) 260 | func_cl_wrapper "$@" # Doesn't return... 261 | ;; 262 | esac 263 | 264 | ofile= 265 | cfile= 266 | 267 | for arg 268 | do 269 | if test -n "$eat"; then 270 | eat= 271 | else 272 | case $1 in 273 | -o) 274 | # configure might choose to run compile as 'compile cc -o foo foo.c'. 275 | # So we strip '-o arg' only if arg is an object. 276 | eat=1 277 | case $2 in 278 | *.o | *.obj) 279 | ofile=$2 280 | ;; 281 | *) 282 | set x "$@" -o "$2" 283 | shift 284 | ;; 285 | esac 286 | ;; 287 | *.c) 288 | cfile=$1 289 | set x "$@" "$1" 290 | shift 291 | ;; 292 | *) 293 | set x "$@" "$1" 294 | shift 295 | ;; 296 | esac 297 | fi 298 | shift 299 | done 300 | 301 | if test -z "$ofile" || test -z "$cfile"; then 302 | # If no '-o' option was seen then we might have been invoked from a 303 | # pattern rule where we don't need one. That is ok -- this is a 304 | # normal compilation that the losing compiler can handle. If no 305 | # '.c' file was seen then we are probably linking. That is also 306 | # ok. 307 | exec "$@" 308 | fi 309 | 310 | # Name of file we expect compiler to create. 311 | cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` 312 | 313 | # Create the lock directory. 314 | # Note: use '[/\\:.-]' here to ensure that we don't use the same name 315 | # that we are using for the .o file. Also, base the name on the expected 316 | # object file name, since that is what matters with a parallel build. 317 | lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d 318 | while true; do 319 | if mkdir "$lockdir" >/dev/null 2>&1; then 320 | break 321 | fi 322 | sleep 1 323 | done 324 | # FIXME: race condition here if user kills between mkdir and trap. 325 | trap "rmdir '$lockdir'; exit 1" 1 2 15 326 | 327 | # Run the compile. 328 | "$@" 329 | ret=$? 330 | 331 | if test -f "$cofile"; then 332 | test "$cofile" = "$ofile" || mv "$cofile" "$ofile" 333 | elif test -f "${cofile}bj"; then 334 | test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" 335 | fi 336 | 337 | rmdir "$lockdir" 338 | exit $ret 339 | 340 | # Local Variables: 341 | # mode: shell-script 342 | # sh-indentation: 2 343 | # eval: (add-hook 'before-save-hook 'time-stamp) 344 | # time-stamp-start: "scriptversion=" 345 | # time-stamp-format: "%:y-%02m-%02d.%02H" 346 | # time-stamp-time-zone: "UTC0" 347 | # time-stamp-end: "; # UTC" 348 | # End: 349 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ(2.59) 2 | 3 | AC_INIT([raspi-gpio], [0.2], [serge@raspberrypi.org]) 4 | 5 | AM_INIT_AUTOMAKE([1.9 foreign]) 6 | 7 | AC_PROG_CC 8 | 9 | AC_CONFIG_FILES([Makefile]) 10 | AC_OUTPUT 11 | 12 | -------------------------------------------------------------------------------- /depcomp: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # depcomp - compile a program generating dependencies as side-effects 3 | 4 | scriptversion=2018-03-07.03; # UTC 5 | 6 | # Copyright (C) 1999-2018 Free Software Foundation, Inc. 7 | 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2, or (at your option) 11 | # any later version. 12 | 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | # As a special exception to the GNU General Public License, if you 22 | # distribute this file as part of a program that contains a 23 | # configuration script generated by Autoconf, you may include it under 24 | # the same distribution terms that you use for the rest of that program. 25 | 26 | # Originally written by Alexandre Oliva . 27 | 28 | case $1 in 29 | '') 30 | echo "$0: No command. Try '$0 --help' for more information." 1>&2 31 | exit 1; 32 | ;; 33 | -h | --h*) 34 | cat <<\EOF 35 | Usage: depcomp [--help] [--version] PROGRAM [ARGS] 36 | 37 | Run PROGRAMS ARGS to compile a file, generating dependencies 38 | as side-effects. 39 | 40 | Environment variables: 41 | depmode Dependency tracking mode. 42 | source Source file read by 'PROGRAMS ARGS'. 43 | object Object file output by 'PROGRAMS ARGS'. 44 | DEPDIR directory where to store dependencies. 45 | depfile Dependency file to output. 46 | tmpdepfile Temporary file to use when outputting dependencies. 47 | libtool Whether libtool is used (yes/no). 48 | 49 | Report bugs to . 50 | EOF 51 | exit $? 52 | ;; 53 | -v | --v*) 54 | echo "depcomp $scriptversion" 55 | exit $? 56 | ;; 57 | esac 58 | 59 | # Get the directory component of the given path, and save it in the 60 | # global variables '$dir'. Note that this directory component will 61 | # be either empty or ending with a '/' character. This is deliberate. 62 | set_dir_from () 63 | { 64 | case $1 in 65 | */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; 66 | *) dir=;; 67 | esac 68 | } 69 | 70 | # Get the suffix-stripped basename of the given path, and save it the 71 | # global variable '$base'. 72 | set_base_from () 73 | { 74 | base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` 75 | } 76 | 77 | # If no dependency file was actually created by the compiler invocation, 78 | # we still have to create a dummy depfile, to avoid errors with the 79 | # Makefile "include basename.Plo" scheme. 80 | make_dummy_depfile () 81 | { 82 | echo "#dummy" > "$depfile" 83 | } 84 | 85 | # Factor out some common post-processing of the generated depfile. 86 | # Requires the auxiliary global variable '$tmpdepfile' to be set. 87 | aix_post_process_depfile () 88 | { 89 | # If the compiler actually managed to produce a dependency file, 90 | # post-process it. 91 | if test -f "$tmpdepfile"; then 92 | # Each line is of the form 'foo.o: dependency.h'. 93 | # Do two passes, one to just change these to 94 | # $object: dependency.h 95 | # and one to simply output 96 | # dependency.h: 97 | # which is needed to avoid the deleted-header problem. 98 | { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" 99 | sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" 100 | } > "$depfile" 101 | rm -f "$tmpdepfile" 102 | else 103 | make_dummy_depfile 104 | fi 105 | } 106 | 107 | # A tabulation character. 108 | tab=' ' 109 | # A newline character. 110 | nl=' 111 | ' 112 | # Character ranges might be problematic outside the C locale. 113 | # These definitions help. 114 | upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ 115 | lower=abcdefghijklmnopqrstuvwxyz 116 | digits=0123456789 117 | alpha=${upper}${lower} 118 | 119 | if test -z "$depmode" || test -z "$source" || test -z "$object"; then 120 | echo "depcomp: Variables source, object and depmode must be set" 1>&2 121 | exit 1 122 | fi 123 | 124 | # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 125 | depfile=${depfile-`echo "$object" | 126 | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 127 | tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 128 | 129 | rm -f "$tmpdepfile" 130 | 131 | # Avoid interferences from the environment. 132 | gccflag= dashmflag= 133 | 134 | # Some modes work just like other modes, but use different flags. We 135 | # parameterize here, but still list the modes in the big case below, 136 | # to make depend.m4 easier to write. Note that we *cannot* use a case 137 | # here, because this file can only contain one case statement. 138 | if test "$depmode" = hp; then 139 | # HP compiler uses -M and no extra arg. 140 | gccflag=-M 141 | depmode=gcc 142 | fi 143 | 144 | if test "$depmode" = dashXmstdout; then 145 | # This is just like dashmstdout with a different argument. 146 | dashmflag=-xM 147 | depmode=dashmstdout 148 | fi 149 | 150 | cygpath_u="cygpath -u -f -" 151 | if test "$depmode" = msvcmsys; then 152 | # This is just like msvisualcpp but w/o cygpath translation. 153 | # Just convert the backslash-escaped backslashes to single forward 154 | # slashes to satisfy depend.m4 155 | cygpath_u='sed s,\\\\,/,g' 156 | depmode=msvisualcpp 157 | fi 158 | 159 | if test "$depmode" = msvc7msys; then 160 | # This is just like msvc7 but w/o cygpath translation. 161 | # Just convert the backslash-escaped backslashes to single forward 162 | # slashes to satisfy depend.m4 163 | cygpath_u='sed s,\\\\,/,g' 164 | depmode=msvc7 165 | fi 166 | 167 | if test "$depmode" = xlc; then 168 | # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 169 | gccflag=-qmakedep=gcc,-MF 170 | depmode=gcc 171 | fi 172 | 173 | case "$depmode" in 174 | gcc3) 175 | ## gcc 3 implements dependency tracking that does exactly what 176 | ## we want. Yay! Note: for some reason libtool 1.4 doesn't like 177 | ## it if -MD -MP comes after the -MF stuff. Hmm. 178 | ## Unfortunately, FreeBSD c89 acceptance of flags depends upon 179 | ## the command line argument order; so add the flags where they 180 | ## appear in depend2.am. Note that the slowdown incurred here 181 | ## affects only configure: in makefiles, %FASTDEP% shortcuts this. 182 | for arg 183 | do 184 | case $arg in 185 | -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 186 | *) set fnord "$@" "$arg" ;; 187 | esac 188 | shift # fnord 189 | shift # $arg 190 | done 191 | "$@" 192 | stat=$? 193 | if test $stat -ne 0; then 194 | rm -f "$tmpdepfile" 195 | exit $stat 196 | fi 197 | mv "$tmpdepfile" "$depfile" 198 | ;; 199 | 200 | gcc) 201 | ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 202 | ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 203 | ## (see the conditional assignment to $gccflag above). 204 | ## There are various ways to get dependency output from gcc. Here's 205 | ## why we pick this rather obscure method: 206 | ## - Don't want to use -MD because we'd like the dependencies to end 207 | ## up in a subdir. Having to rename by hand is ugly. 208 | ## (We might end up doing this anyway to support other compilers.) 209 | ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 210 | ## -MM, not -M (despite what the docs say). Also, it might not be 211 | ## supported by the other compilers which use the 'gcc' depmode. 212 | ## - Using -M directly means running the compiler twice (even worse 213 | ## than renaming). 214 | if test -z "$gccflag"; then 215 | gccflag=-MD, 216 | fi 217 | "$@" -Wp,"$gccflag$tmpdepfile" 218 | stat=$? 219 | if test $stat -ne 0; then 220 | rm -f "$tmpdepfile" 221 | exit $stat 222 | fi 223 | rm -f "$depfile" 224 | echo "$object : \\" > "$depfile" 225 | # The second -e expression handles DOS-style file names with drive 226 | # letters. 227 | sed -e 's/^[^:]*: / /' \ 228 | -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 229 | ## This next piece of magic avoids the "deleted header file" problem. 230 | ## The problem is that when a header file which appears in a .P file 231 | ## is deleted, the dependency causes make to die (because there is 232 | ## typically no way to rebuild the header). We avoid this by adding 233 | ## dummy dependencies for each header file. Too bad gcc doesn't do 234 | ## this for us directly. 235 | ## Some versions of gcc put a space before the ':'. On the theory 236 | ## that the space means something, we add a space to the output as 237 | ## well. hp depmode also adds that space, but also prefixes the VPATH 238 | ## to the object. Take care to not repeat it in the output. 239 | ## Some versions of the HPUX 10.20 sed can't process this invocation 240 | ## correctly. Breaking it into two sed invocations is a workaround. 241 | tr ' ' "$nl" < "$tmpdepfile" \ 242 | | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 243 | | sed -e 's/$/ :/' >> "$depfile" 244 | rm -f "$tmpdepfile" 245 | ;; 246 | 247 | hp) 248 | # This case exists only to let depend.m4 do its work. It works by 249 | # looking at the text of this script. This case will never be run, 250 | # since it is checked for above. 251 | exit 1 252 | ;; 253 | 254 | sgi) 255 | if test "$libtool" = yes; then 256 | "$@" "-Wp,-MDupdate,$tmpdepfile" 257 | else 258 | "$@" -MDupdate "$tmpdepfile" 259 | fi 260 | stat=$? 261 | if test $stat -ne 0; then 262 | rm -f "$tmpdepfile" 263 | exit $stat 264 | fi 265 | rm -f "$depfile" 266 | 267 | if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 268 | echo "$object : \\" > "$depfile" 269 | # Clip off the initial element (the dependent). Don't try to be 270 | # clever and replace this with sed code, as IRIX sed won't handle 271 | # lines with more than a fixed number of characters (4096 in 272 | # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 273 | # the IRIX cc adds comments like '#:fec' to the end of the 274 | # dependency line. 275 | tr ' ' "$nl" < "$tmpdepfile" \ 276 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ 277 | | tr "$nl" ' ' >> "$depfile" 278 | echo >> "$depfile" 279 | # The second pass generates a dummy entry for each header file. 280 | tr ' ' "$nl" < "$tmpdepfile" \ 281 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 282 | >> "$depfile" 283 | else 284 | make_dummy_depfile 285 | fi 286 | rm -f "$tmpdepfile" 287 | ;; 288 | 289 | xlc) 290 | # This case exists only to let depend.m4 do its work. It works by 291 | # looking at the text of this script. This case will never be run, 292 | # since it is checked for above. 293 | exit 1 294 | ;; 295 | 296 | aix) 297 | # The C for AIX Compiler uses -M and outputs the dependencies 298 | # in a .u file. In older versions, this file always lives in the 299 | # current directory. Also, the AIX compiler puts '$object:' at the 300 | # start of each line; $object doesn't have directory information. 301 | # Version 6 uses the directory in both cases. 302 | set_dir_from "$object" 303 | set_base_from "$object" 304 | if test "$libtool" = yes; then 305 | tmpdepfile1=$dir$base.u 306 | tmpdepfile2=$base.u 307 | tmpdepfile3=$dir.libs/$base.u 308 | "$@" -Wc,-M 309 | else 310 | tmpdepfile1=$dir$base.u 311 | tmpdepfile2=$dir$base.u 312 | tmpdepfile3=$dir$base.u 313 | "$@" -M 314 | fi 315 | stat=$? 316 | if test $stat -ne 0; then 317 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 318 | exit $stat 319 | fi 320 | 321 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 322 | do 323 | test -f "$tmpdepfile" && break 324 | done 325 | aix_post_process_depfile 326 | ;; 327 | 328 | tcc) 329 | # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 330 | # FIXME: That version still under development at the moment of writing. 331 | # Make that this statement remains true also for stable, released 332 | # versions. 333 | # It will wrap lines (doesn't matter whether long or short) with a 334 | # trailing '\', as in: 335 | # 336 | # foo.o : \ 337 | # foo.c \ 338 | # foo.h \ 339 | # 340 | # It will put a trailing '\' even on the last line, and will use leading 341 | # spaces rather than leading tabs (at least since its commit 0394caf7 342 | # "Emit spaces for -MD"). 343 | "$@" -MD -MF "$tmpdepfile" 344 | stat=$? 345 | if test $stat -ne 0; then 346 | rm -f "$tmpdepfile" 347 | exit $stat 348 | fi 349 | rm -f "$depfile" 350 | # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. 351 | # We have to change lines of the first kind to '$object: \'. 352 | sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" 353 | # And for each line of the second kind, we have to emit a 'dep.h:' 354 | # dummy dependency, to avoid the deleted-header problem. 355 | sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" 356 | rm -f "$tmpdepfile" 357 | ;; 358 | 359 | ## The order of this option in the case statement is important, since the 360 | ## shell code in configure will try each of these formats in the order 361 | ## listed in this file. A plain '-MD' option would be understood by many 362 | ## compilers, so we must ensure this comes after the gcc and icc options. 363 | pgcc) 364 | # Portland's C compiler understands '-MD'. 365 | # Will always output deps to 'file.d' where file is the root name of the 366 | # source file under compilation, even if file resides in a subdirectory. 367 | # The object file name does not affect the name of the '.d' file. 368 | # pgcc 10.2 will output 369 | # foo.o: sub/foo.c sub/foo.h 370 | # and will wrap long lines using '\' : 371 | # foo.o: sub/foo.c ... \ 372 | # sub/foo.h ... \ 373 | # ... 374 | set_dir_from "$object" 375 | # Use the source, not the object, to determine the base name, since 376 | # that's sadly what pgcc will do too. 377 | set_base_from "$source" 378 | tmpdepfile=$base.d 379 | 380 | # For projects that build the same source file twice into different object 381 | # files, the pgcc approach of using the *source* file root name can cause 382 | # problems in parallel builds. Use a locking strategy to avoid stomping on 383 | # the same $tmpdepfile. 384 | lockdir=$base.d-lock 385 | trap " 386 | echo '$0: caught signal, cleaning up...' >&2 387 | rmdir '$lockdir' 388 | exit 1 389 | " 1 2 13 15 390 | numtries=100 391 | i=$numtries 392 | while test $i -gt 0; do 393 | # mkdir is a portable test-and-set. 394 | if mkdir "$lockdir" 2>/dev/null; then 395 | # This process acquired the lock. 396 | "$@" -MD 397 | stat=$? 398 | # Release the lock. 399 | rmdir "$lockdir" 400 | break 401 | else 402 | # If the lock is being held by a different process, wait 403 | # until the winning process is done or we timeout. 404 | while test -d "$lockdir" && test $i -gt 0; do 405 | sleep 1 406 | i=`expr $i - 1` 407 | done 408 | fi 409 | i=`expr $i - 1` 410 | done 411 | trap - 1 2 13 15 412 | if test $i -le 0; then 413 | echo "$0: failed to acquire lock after $numtries attempts" >&2 414 | echo "$0: check lockdir '$lockdir'" >&2 415 | exit 1 416 | fi 417 | 418 | if test $stat -ne 0; then 419 | rm -f "$tmpdepfile" 420 | exit $stat 421 | fi 422 | rm -f "$depfile" 423 | # Each line is of the form `foo.o: dependent.h', 424 | # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 425 | # Do two passes, one to just change these to 426 | # `$object: dependent.h' and one to simply `dependent.h:'. 427 | sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 428 | # Some versions of the HPUX 10.20 sed can't process this invocation 429 | # correctly. Breaking it into two sed invocations is a workaround. 430 | sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ 431 | | sed -e 's/$/ :/' >> "$depfile" 432 | rm -f "$tmpdepfile" 433 | ;; 434 | 435 | hp2) 436 | # The "hp" stanza above does not work with aCC (C++) and HP's ia64 437 | # compilers, which have integrated preprocessors. The correct option 438 | # to use with these is +Maked; it writes dependencies to a file named 439 | # 'foo.d', which lands next to the object file, wherever that 440 | # happens to be. 441 | # Much of this is similar to the tru64 case; see comments there. 442 | set_dir_from "$object" 443 | set_base_from "$object" 444 | if test "$libtool" = yes; then 445 | tmpdepfile1=$dir$base.d 446 | tmpdepfile2=$dir.libs/$base.d 447 | "$@" -Wc,+Maked 448 | else 449 | tmpdepfile1=$dir$base.d 450 | tmpdepfile2=$dir$base.d 451 | "$@" +Maked 452 | fi 453 | stat=$? 454 | if test $stat -ne 0; then 455 | rm -f "$tmpdepfile1" "$tmpdepfile2" 456 | exit $stat 457 | fi 458 | 459 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 460 | do 461 | test -f "$tmpdepfile" && break 462 | done 463 | if test -f "$tmpdepfile"; then 464 | sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" 465 | # Add 'dependent.h:' lines. 466 | sed -ne '2,${ 467 | s/^ *// 468 | s/ \\*$// 469 | s/$/:/ 470 | p 471 | }' "$tmpdepfile" >> "$depfile" 472 | else 473 | make_dummy_depfile 474 | fi 475 | rm -f "$tmpdepfile" "$tmpdepfile2" 476 | ;; 477 | 478 | tru64) 479 | # The Tru64 compiler uses -MD to generate dependencies as a side 480 | # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 481 | # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 482 | # dependencies in 'foo.d' instead, so we check for that too. 483 | # Subdirectories are respected. 484 | set_dir_from "$object" 485 | set_base_from "$object" 486 | 487 | if test "$libtool" = yes; then 488 | # Libtool generates 2 separate objects for the 2 libraries. These 489 | # two compilations output dependencies in $dir.libs/$base.o.d and 490 | # in $dir$base.o.d. We have to check for both files, because 491 | # one of the two compilations can be disabled. We should prefer 492 | # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 493 | # automatically cleaned when .libs/ is deleted, while ignoring 494 | # the former would cause a distcleancheck panic. 495 | tmpdepfile1=$dir$base.o.d # libtool 1.5 496 | tmpdepfile2=$dir.libs/$base.o.d # Likewise. 497 | tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 498 | "$@" -Wc,-MD 499 | else 500 | tmpdepfile1=$dir$base.d 501 | tmpdepfile2=$dir$base.d 502 | tmpdepfile3=$dir$base.d 503 | "$@" -MD 504 | fi 505 | 506 | stat=$? 507 | if test $stat -ne 0; then 508 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 509 | exit $stat 510 | fi 511 | 512 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 513 | do 514 | test -f "$tmpdepfile" && break 515 | done 516 | # Same post-processing that is required for AIX mode. 517 | aix_post_process_depfile 518 | ;; 519 | 520 | msvc7) 521 | if test "$libtool" = yes; then 522 | showIncludes=-Wc,-showIncludes 523 | else 524 | showIncludes=-showIncludes 525 | fi 526 | "$@" $showIncludes > "$tmpdepfile" 527 | stat=$? 528 | grep -v '^Note: including file: ' "$tmpdepfile" 529 | if test $stat -ne 0; then 530 | rm -f "$tmpdepfile" 531 | exit $stat 532 | fi 533 | rm -f "$depfile" 534 | echo "$object : \\" > "$depfile" 535 | # The first sed program below extracts the file names and escapes 536 | # backslashes for cygpath. The second sed program outputs the file 537 | # name when reading, but also accumulates all include files in the 538 | # hold buffer in order to output them again at the end. This only 539 | # works with sed implementations that can handle large buffers. 540 | sed < "$tmpdepfile" -n ' 541 | /^Note: including file: *\(.*\)/ { 542 | s//\1/ 543 | s/\\/\\\\/g 544 | p 545 | }' | $cygpath_u | sort -u | sed -n ' 546 | s/ /\\ /g 547 | s/\(.*\)/'"$tab"'\1 \\/p 548 | s/.\(.*\) \\/\1:/ 549 | H 550 | $ { 551 | s/.*/'"$tab"'/ 552 | G 553 | p 554 | }' >> "$depfile" 555 | echo >> "$depfile" # make sure the fragment doesn't end with a backslash 556 | rm -f "$tmpdepfile" 557 | ;; 558 | 559 | msvc7msys) 560 | # This case exists only to let depend.m4 do its work. It works by 561 | # looking at the text of this script. This case will never be run, 562 | # since it is checked for above. 563 | exit 1 564 | ;; 565 | 566 | #nosideeffect) 567 | # This comment above is used by automake to tell side-effect 568 | # dependency tracking mechanisms from slower ones. 569 | 570 | dashmstdout) 571 | # Important note: in order to support this mode, a compiler *must* 572 | # always write the preprocessed file to stdout, regardless of -o. 573 | "$@" || exit $? 574 | 575 | # Remove the call to Libtool. 576 | if test "$libtool" = yes; then 577 | while test "X$1" != 'X--mode=compile'; do 578 | shift 579 | done 580 | shift 581 | fi 582 | 583 | # Remove '-o $object'. 584 | IFS=" " 585 | for arg 586 | do 587 | case $arg in 588 | -o) 589 | shift 590 | ;; 591 | $object) 592 | shift 593 | ;; 594 | *) 595 | set fnord "$@" "$arg" 596 | shift # fnord 597 | shift # $arg 598 | ;; 599 | esac 600 | done 601 | 602 | test -z "$dashmflag" && dashmflag=-M 603 | # Require at least two characters before searching for ':' 604 | # in the target name. This is to cope with DOS-style filenames: 605 | # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 606 | "$@" $dashmflag | 607 | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" 608 | rm -f "$depfile" 609 | cat < "$tmpdepfile" > "$depfile" 610 | # Some versions of the HPUX 10.20 sed can't process this sed invocation 611 | # correctly. Breaking it into two sed invocations is a workaround. 612 | tr ' ' "$nl" < "$tmpdepfile" \ 613 | | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 614 | | sed -e 's/$/ :/' >> "$depfile" 615 | rm -f "$tmpdepfile" 616 | ;; 617 | 618 | dashXmstdout) 619 | # This case only exists to satisfy depend.m4. It is never actually 620 | # run, as this mode is specially recognized in the preamble. 621 | exit 1 622 | ;; 623 | 624 | makedepend) 625 | "$@" || exit $? 626 | # Remove any Libtool call 627 | if test "$libtool" = yes; then 628 | while test "X$1" != 'X--mode=compile'; do 629 | shift 630 | done 631 | shift 632 | fi 633 | # X makedepend 634 | shift 635 | cleared=no eat=no 636 | for arg 637 | do 638 | case $cleared in 639 | no) 640 | set ""; shift 641 | cleared=yes ;; 642 | esac 643 | if test $eat = yes; then 644 | eat=no 645 | continue 646 | fi 647 | case "$arg" in 648 | -D*|-I*) 649 | set fnord "$@" "$arg"; shift ;; 650 | # Strip any option that makedepend may not understand. Remove 651 | # the object too, otherwise makedepend will parse it as a source file. 652 | -arch) 653 | eat=yes ;; 654 | -*|$object) 655 | ;; 656 | *) 657 | set fnord "$@" "$arg"; shift ;; 658 | esac 659 | done 660 | obj_suffix=`echo "$object" | sed 's/^.*\././'` 661 | touch "$tmpdepfile" 662 | ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 663 | rm -f "$depfile" 664 | # makedepend may prepend the VPATH from the source file name to the object. 665 | # No need to regex-escape $object, excess matching of '.' is harmless. 666 | sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 667 | # Some versions of the HPUX 10.20 sed can't process the last invocation 668 | # correctly. Breaking it into two sed invocations is a workaround. 669 | sed '1,2d' "$tmpdepfile" \ 670 | | tr ' ' "$nl" \ 671 | | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 672 | | sed -e 's/$/ :/' >> "$depfile" 673 | rm -f "$tmpdepfile" "$tmpdepfile".bak 674 | ;; 675 | 676 | cpp) 677 | # Important note: in order to support this mode, a compiler *must* 678 | # always write the preprocessed file to stdout. 679 | "$@" || exit $? 680 | 681 | # Remove the call to Libtool. 682 | if test "$libtool" = yes; then 683 | while test "X$1" != 'X--mode=compile'; do 684 | shift 685 | done 686 | shift 687 | fi 688 | 689 | # Remove '-o $object'. 690 | IFS=" " 691 | for arg 692 | do 693 | case $arg in 694 | -o) 695 | shift 696 | ;; 697 | $object) 698 | shift 699 | ;; 700 | *) 701 | set fnord "$@" "$arg" 702 | shift # fnord 703 | shift # $arg 704 | ;; 705 | esac 706 | done 707 | 708 | "$@" -E \ 709 | | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 710 | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 711 | | sed '$ s: \\$::' > "$tmpdepfile" 712 | rm -f "$depfile" 713 | echo "$object : \\" > "$depfile" 714 | cat < "$tmpdepfile" >> "$depfile" 715 | sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 716 | rm -f "$tmpdepfile" 717 | ;; 718 | 719 | msvisualcpp) 720 | # Important note: in order to support this mode, a compiler *must* 721 | # always write the preprocessed file to stdout. 722 | "$@" || exit $? 723 | 724 | # Remove the call to Libtool. 725 | if test "$libtool" = yes; then 726 | while test "X$1" != 'X--mode=compile'; do 727 | shift 728 | done 729 | shift 730 | fi 731 | 732 | IFS=" " 733 | for arg 734 | do 735 | case "$arg" in 736 | -o) 737 | shift 738 | ;; 739 | $object) 740 | shift 741 | ;; 742 | "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 743 | set fnord "$@" 744 | shift 745 | shift 746 | ;; 747 | *) 748 | set fnord "$@" "$arg" 749 | shift 750 | shift 751 | ;; 752 | esac 753 | done 754 | "$@" -E 2>/dev/null | 755 | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 756 | rm -f "$depfile" 757 | echo "$object : \\" > "$depfile" 758 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 759 | echo "$tab" >> "$depfile" 760 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 761 | rm -f "$tmpdepfile" 762 | ;; 763 | 764 | msvcmsys) 765 | # This case exists only to let depend.m4 do its work. It works by 766 | # looking at the text of this script. This case will never be run, 767 | # since it is checked for above. 768 | exit 1 769 | ;; 770 | 771 | none) 772 | exec "$@" 773 | ;; 774 | 775 | *) 776 | echo "Unknown depmode $depmode" 1>&2 777 | exit 1 778 | ;; 779 | esac 780 | 781 | exit 0 782 | 783 | # Local Variables: 784 | # mode: shell-script 785 | # sh-indentation: 2 786 | # eval: (add-hook 'before-save-hook 'time-stamp) 787 | # time-stamp-start: "scriptversion=" 788 | # time-stamp-format: "%:y-%02m-%02d.%02H" 789 | # time-stamp-time-zone: "UTC0" 790 | # time-stamp-end: "; # UTC" 791 | # End: 792 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2018-03-11.20; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # 'make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | tab=' ' 45 | nl=' 46 | ' 47 | IFS=" $tab$nl" 48 | 49 | # Set DOITPROG to "echo" to test this script. 50 | 51 | doit=${DOITPROG-} 52 | doit_exec=${doit:-exec} 53 | 54 | # Put in absolute file names if you don't have them in your path; 55 | # or use environment vars. 56 | 57 | chgrpprog=${CHGRPPROG-chgrp} 58 | chmodprog=${CHMODPROG-chmod} 59 | chownprog=${CHOWNPROG-chown} 60 | cmpprog=${CMPPROG-cmp} 61 | cpprog=${CPPROG-cp} 62 | mkdirprog=${MKDIRPROG-mkdir} 63 | mvprog=${MVPROG-mv} 64 | rmprog=${RMPROG-rm} 65 | stripprog=${STRIPPROG-strip} 66 | 67 | posix_mkdir= 68 | 69 | # Desired mode of installed file. 70 | mode=0755 71 | 72 | chgrpcmd= 73 | chmodcmd=$chmodprog 74 | chowncmd= 75 | mvcmd=$mvprog 76 | rmcmd="$rmprog -f" 77 | stripcmd= 78 | 79 | src= 80 | dst= 81 | dir_arg= 82 | dst_arg= 83 | 84 | copy_on_change=false 85 | is_target_a_directory=possibly 86 | 87 | usage="\ 88 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 89 | or: $0 [OPTION]... SRCFILES... DIRECTORY 90 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 91 | or: $0 [OPTION]... -d DIRECTORIES... 92 | 93 | In the 1st form, copy SRCFILE to DSTFILE. 94 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 95 | In the 4th, create DIRECTORIES. 96 | 97 | Options: 98 | --help display this help and exit. 99 | --version display version info and exit. 100 | 101 | -c (ignored) 102 | -C install only if different (preserve the last data modification time) 103 | -d create directories instead of installing files. 104 | -g GROUP $chgrpprog installed files to GROUP. 105 | -m MODE $chmodprog installed files to MODE. 106 | -o USER $chownprog installed files to USER. 107 | -s $stripprog installed files. 108 | -t DIRECTORY install into DIRECTORY. 109 | -T report an error if DSTFILE is a directory. 110 | 111 | Environment variables override the default commands: 112 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 113 | RMPROG STRIPPROG 114 | " 115 | 116 | while test $# -ne 0; do 117 | case $1 in 118 | -c) ;; 119 | 120 | -C) copy_on_change=true;; 121 | 122 | -d) dir_arg=true;; 123 | 124 | -g) chgrpcmd="$chgrpprog $2" 125 | shift;; 126 | 127 | --help) echo "$usage"; exit $?;; 128 | 129 | -m) mode=$2 130 | case $mode in 131 | *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) 132 | echo "$0: invalid mode: $mode" >&2 133 | exit 1;; 134 | esac 135 | shift;; 136 | 137 | -o) chowncmd="$chownprog $2" 138 | shift;; 139 | 140 | -s) stripcmd=$stripprog;; 141 | 142 | -t) 143 | is_target_a_directory=always 144 | dst_arg=$2 145 | # Protect names problematic for 'test' and other utilities. 146 | case $dst_arg in 147 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 148 | esac 149 | shift;; 150 | 151 | -T) is_target_a_directory=never;; 152 | 153 | --version) echo "$0 $scriptversion"; exit $?;; 154 | 155 | --) shift 156 | break;; 157 | 158 | -*) echo "$0: invalid option: $1" >&2 159 | exit 1;; 160 | 161 | *) break;; 162 | esac 163 | shift 164 | done 165 | 166 | # We allow the use of options -d and -T together, by making -d 167 | # take the precedence; this is for compatibility with GNU install. 168 | 169 | if test -n "$dir_arg"; then 170 | if test -n "$dst_arg"; then 171 | echo "$0: target directory not allowed when installing a directory." >&2 172 | exit 1 173 | fi 174 | fi 175 | 176 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 177 | # When -d is used, all remaining arguments are directories to create. 178 | # When -t is used, the destination is already specified. 179 | # Otherwise, the last argument is the destination. Remove it from $@. 180 | for arg 181 | do 182 | if test -n "$dst_arg"; then 183 | # $@ is not empty: it contains at least $arg. 184 | set fnord "$@" "$dst_arg" 185 | shift # fnord 186 | fi 187 | shift # arg 188 | dst_arg=$arg 189 | # Protect names problematic for 'test' and other utilities. 190 | case $dst_arg in 191 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 192 | esac 193 | done 194 | fi 195 | 196 | if test $# -eq 0; then 197 | if test -z "$dir_arg"; then 198 | echo "$0: no input file specified." >&2 199 | exit 1 200 | fi 201 | # It's OK to call 'install-sh -d' without argument. 202 | # This can happen when creating conditional directories. 203 | exit 0 204 | fi 205 | 206 | if test -z "$dir_arg"; then 207 | if test $# -gt 1 || test "$is_target_a_directory" = always; then 208 | if test ! -d "$dst_arg"; then 209 | echo "$0: $dst_arg: Is not a directory." >&2 210 | exit 1 211 | fi 212 | fi 213 | fi 214 | 215 | if test -z "$dir_arg"; then 216 | do_exit='(exit $ret); exit $ret' 217 | trap "ret=129; $do_exit" 1 218 | trap "ret=130; $do_exit" 2 219 | trap "ret=141; $do_exit" 13 220 | trap "ret=143; $do_exit" 15 221 | 222 | # Set umask so as not to create temps with too-generous modes. 223 | # However, 'strip' requires both read and write access to temps. 224 | case $mode in 225 | # Optimize common cases. 226 | *644) cp_umask=133;; 227 | *755) cp_umask=22;; 228 | 229 | *[0-7]) 230 | if test -z "$stripcmd"; then 231 | u_plus_rw= 232 | else 233 | u_plus_rw='% 200' 234 | fi 235 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 236 | *) 237 | if test -z "$stripcmd"; then 238 | u_plus_rw= 239 | else 240 | u_plus_rw=,u+rw 241 | fi 242 | cp_umask=$mode$u_plus_rw;; 243 | esac 244 | fi 245 | 246 | for src 247 | do 248 | # Protect names problematic for 'test' and other utilities. 249 | case $src in 250 | -* | [=\(\)!]) src=./$src;; 251 | esac 252 | 253 | if test -n "$dir_arg"; then 254 | dst=$src 255 | dstdir=$dst 256 | test -d "$dstdir" 257 | dstdir_status=$? 258 | else 259 | 260 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 261 | # might cause directories to be created, which would be especially bad 262 | # if $src (and thus $dsttmp) contains '*'. 263 | if test ! -f "$src" && test ! -d "$src"; then 264 | echo "$0: $src does not exist." >&2 265 | exit 1 266 | fi 267 | 268 | if test -z "$dst_arg"; then 269 | echo "$0: no destination specified." >&2 270 | exit 1 271 | fi 272 | dst=$dst_arg 273 | 274 | # If destination is a directory, append the input filename. 275 | if test -d "$dst"; then 276 | if test "$is_target_a_directory" = never; then 277 | echo "$0: $dst_arg: Is a directory" >&2 278 | exit 1 279 | fi 280 | dstdir=$dst 281 | dstbase=`basename "$src"` 282 | case $dst in 283 | */) dst=$dst$dstbase;; 284 | *) dst=$dst/$dstbase;; 285 | esac 286 | dstdir_status=0 287 | else 288 | dstdir=`dirname "$dst"` 289 | test -d "$dstdir" 290 | dstdir_status=$? 291 | fi 292 | fi 293 | 294 | case $dstdir in 295 | */) dstdirslash=$dstdir;; 296 | *) dstdirslash=$dstdir/;; 297 | esac 298 | 299 | obsolete_mkdir_used=false 300 | 301 | if test $dstdir_status != 0; then 302 | case $posix_mkdir in 303 | '') 304 | # Create intermediate dirs using mode 755 as modified by the umask. 305 | # This is like FreeBSD 'install' as of 1997-10-28. 306 | umask=`umask` 307 | case $stripcmd.$umask in 308 | # Optimize common cases. 309 | *[2367][2367]) mkdir_umask=$umask;; 310 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 311 | 312 | *[0-7]) 313 | mkdir_umask=`expr $umask + 22 \ 314 | - $umask % 100 % 40 + $umask % 20 \ 315 | - $umask % 10 % 4 + $umask % 2 316 | `;; 317 | *) mkdir_umask=$umask,go-w;; 318 | esac 319 | 320 | # With -d, create the new directory with the user-specified mode. 321 | # Otherwise, rely on $mkdir_umask. 322 | if test -n "$dir_arg"; then 323 | mkdir_mode=-m$mode 324 | else 325 | mkdir_mode= 326 | fi 327 | 328 | posix_mkdir=false 329 | case $umask in 330 | *[123567][0-7][0-7]) 331 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 332 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 333 | ;; 334 | *) 335 | # Note that $RANDOM variable is not portable (e.g. dash); Use it 336 | # here however when possible just to lower collision chance. 337 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 338 | 339 | trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 340 | 341 | # Because "mkdir -p" follows existing symlinks and we likely work 342 | # directly in world-writeable /tmp, make sure that the '$tmpdir' 343 | # directory is successfully created first before we actually test 344 | # 'mkdir -p' feature. 345 | if (umask $mkdir_umask && 346 | $mkdirprog $mkdir_mode "$tmpdir" && 347 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 348 | then 349 | if test -z "$dir_arg" || { 350 | # Check for POSIX incompatibilities with -m. 351 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 352 | # other-writable bit of parent directory when it shouldn't. 353 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 354 | test_tmpdir="$tmpdir/a" 355 | ls_ld_tmpdir=`ls -ld "$test_tmpdir"` 356 | case $ls_ld_tmpdir in 357 | d????-?r-*) different_mode=700;; 358 | d????-?--*) different_mode=755;; 359 | *) false;; 360 | esac && 361 | $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { 362 | ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` 363 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 364 | } 365 | } 366 | then posix_mkdir=: 367 | fi 368 | rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 369 | else 370 | # Remove any dirs left behind by ancient mkdir implementations. 371 | rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null 372 | fi 373 | trap '' 0;; 374 | esac;; 375 | esac 376 | 377 | if 378 | $posix_mkdir && ( 379 | umask $mkdir_umask && 380 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 381 | ) 382 | then : 383 | else 384 | 385 | # The umask is ridiculous, or mkdir does not conform to POSIX, 386 | # or it failed possibly due to a race condition. Create the 387 | # directory the slow way, step by step, checking for races as we go. 388 | 389 | case $dstdir in 390 | /*) prefix='/';; 391 | [-=\(\)!]*) prefix='./';; 392 | *) prefix='';; 393 | esac 394 | 395 | oIFS=$IFS 396 | IFS=/ 397 | set -f 398 | set fnord $dstdir 399 | shift 400 | set +f 401 | IFS=$oIFS 402 | 403 | prefixes= 404 | 405 | for d 406 | do 407 | test X"$d" = X && continue 408 | 409 | prefix=$prefix$d 410 | if test -d "$prefix"; then 411 | prefixes= 412 | else 413 | if $posix_mkdir; then 414 | (umask=$mkdir_umask && 415 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 416 | # Don't fail if two instances are running concurrently. 417 | test -d "$prefix" || exit 1 418 | else 419 | case $prefix in 420 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 421 | *) qprefix=$prefix;; 422 | esac 423 | prefixes="$prefixes '$qprefix'" 424 | fi 425 | fi 426 | prefix=$prefix/ 427 | done 428 | 429 | if test -n "$prefixes"; then 430 | # Don't fail if two instances are running concurrently. 431 | (umask $mkdir_umask && 432 | eval "\$doit_exec \$mkdirprog $prefixes") || 433 | test -d "$dstdir" || exit 1 434 | obsolete_mkdir_used=true 435 | fi 436 | fi 437 | fi 438 | 439 | if test -n "$dir_arg"; then 440 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 441 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 442 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 443 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 444 | else 445 | 446 | # Make a couple of temp file names in the proper directory. 447 | dsttmp=${dstdirslash}_inst.$$_ 448 | rmtmp=${dstdirslash}_rm.$$_ 449 | 450 | # Trap to clean up those temp files at exit. 451 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 452 | 453 | # Copy the file name to the temp name. 454 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 455 | 456 | # and set any options; do chmod last to preserve setuid bits. 457 | # 458 | # If any of these fail, we abort the whole thing. If we want to 459 | # ignore errors from any of these, just make sure not to ignore 460 | # errors from the above "$doit $cpprog $src $dsttmp" command. 461 | # 462 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 463 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 464 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 465 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 466 | 467 | # If -C, don't bother to copy if it wouldn't change the file. 468 | if $copy_on_change && 469 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 470 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 471 | set -f && 472 | set X $old && old=:$2:$4:$5:$6 && 473 | set X $new && new=:$2:$4:$5:$6 && 474 | set +f && 475 | test "$old" = "$new" && 476 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 477 | then 478 | rm -f "$dsttmp" 479 | else 480 | # Rename the file to the real destination. 481 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 482 | 483 | # The rename failed, perhaps because mv can't rename something else 484 | # to itself, or perhaps because mv is so ancient that it does not 485 | # support -f. 486 | { 487 | # Now remove or move aside any old file at destination location. 488 | # We try this two ways since rm can't unlink itself on some 489 | # systems and the destination file might be busy for other 490 | # reasons. In this case, the final cleanup might fail but the new 491 | # file should still install successfully. 492 | { 493 | test ! -f "$dst" || 494 | $doit $rmcmd -f "$dst" 2>/dev/null || 495 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 496 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 497 | } || 498 | { echo "$0: cannot unlink or rename $dst" >&2 499 | (exit 1); exit 1 500 | } 501 | } && 502 | 503 | # Now rename the file to the real destination. 504 | $doit $mvcmd "$dsttmp" "$dst" 505 | } 506 | fi || exit 1 507 | 508 | trap '' 0 509 | fi 510 | done 511 | 512 | # Local variables: 513 | # eval: (add-hook 'before-save-hook 'time-stamp) 514 | # time-stamp-start: "scriptversion=" 515 | # time-stamp-format: "%:y-%02m-%02d.%02H" 516 | # time-stamp-time-zone: "UTC0" 517 | # time-stamp-end: "; # UTC" 518 | # End: 519 | -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common wrapper for a few potentially missing GNU programs. 3 | 4 | scriptversion=2018-03-07.03; # UTC 5 | 6 | # Copyright (C) 1996-2018 Free Software Foundation, Inc. 7 | # Originally written by Fran,cois Pinard , 1996. 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | if test $# -eq 0; then 28 | echo 1>&2 "Try '$0 --help' for more information" 29 | exit 1 30 | fi 31 | 32 | case $1 in 33 | 34 | --is-lightweight) 35 | # Used by our autoconf macros to check whether the available missing 36 | # script is modern enough. 37 | exit 0 38 | ;; 39 | 40 | --run) 41 | # Back-compat with the calling convention used by older automake. 42 | shift 43 | ;; 44 | 45 | -h|--h|--he|--hel|--help) 46 | echo "\ 47 | $0 [OPTION]... PROGRAM [ARGUMENT]... 48 | 49 | Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50 | to PROGRAM being missing or too old. 51 | 52 | Options: 53 | -h, --help display this help and exit 54 | -v, --version output version information and exit 55 | 56 | Supported PROGRAM values: 57 | aclocal autoconf autoheader autom4te automake makeinfo 58 | bison yacc flex lex help2man 59 | 60 | Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61 | 'g' are ignored when checking the name. 62 | 63 | Send bug reports to ." 64 | exit $? 65 | ;; 66 | 67 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68 | echo "missing $scriptversion (GNU Automake)" 69 | exit $? 70 | ;; 71 | 72 | -*) 73 | echo 1>&2 "$0: unknown '$1' option" 74 | echo 1>&2 "Try '$0 --help' for more information" 75 | exit 1 76 | ;; 77 | 78 | esac 79 | 80 | # Run the given program, remember its exit status. 81 | "$@"; st=$? 82 | 83 | # If it succeeded, we are done. 84 | test $st -eq 0 && exit 0 85 | 86 | # Also exit now if we it failed (or wasn't found), and '--version' was 87 | # passed; such an option is passed most likely to detect whether the 88 | # program is present and works. 89 | case $2 in --version|--help) exit $st;; esac 90 | 91 | # Exit code 63 means version mismatch. This often happens when the user 92 | # tries to use an ancient version of a tool on a file that requires a 93 | # minimum version. 94 | if test $st -eq 63; then 95 | msg="probably too old" 96 | elif test $st -eq 127; then 97 | # Program was missing. 98 | msg="missing on your system" 99 | else 100 | # Program was found and executed, but failed. Give up. 101 | exit $st 102 | fi 103 | 104 | perl_URL=https://www.perl.org/ 105 | flex_URL=https://github.com/westes/flex 106 | gnu_software_URL=https://www.gnu.org/software 107 | 108 | program_details () 109 | { 110 | case $1 in 111 | aclocal|automake) 112 | echo "The '$1' program is part of the GNU Automake package:" 113 | echo "<$gnu_software_URL/automake>" 114 | echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115 | echo "<$gnu_software_URL/autoconf>" 116 | echo "<$gnu_software_URL/m4/>" 117 | echo "<$perl_URL>" 118 | ;; 119 | autoconf|autom4te|autoheader) 120 | echo "The '$1' program is part of the GNU Autoconf package:" 121 | echo "<$gnu_software_URL/autoconf/>" 122 | echo "It also requires GNU m4 and Perl in order to run:" 123 | echo "<$gnu_software_URL/m4/>" 124 | echo "<$perl_URL>" 125 | ;; 126 | esac 127 | } 128 | 129 | give_advice () 130 | { 131 | # Normalize program name to check for. 132 | normalized_program=`echo "$1" | sed ' 133 | s/^gnu-//; t 134 | s/^gnu//; t 135 | s/^g//; t'` 136 | 137 | printf '%s\n' "'$1' is $msg." 138 | 139 | configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140 | case $normalized_program in 141 | autoconf*) 142 | echo "You should only need it if you modified 'configure.ac'," 143 | echo "or m4 files included by it." 144 | program_details 'autoconf' 145 | ;; 146 | autoheader*) 147 | echo "You should only need it if you modified 'acconfig.h' or" 148 | echo "$configure_deps." 149 | program_details 'autoheader' 150 | ;; 151 | automake*) 152 | echo "You should only need it if you modified 'Makefile.am' or" 153 | echo "$configure_deps." 154 | program_details 'automake' 155 | ;; 156 | aclocal*) 157 | echo "You should only need it if you modified 'acinclude.m4' or" 158 | echo "$configure_deps." 159 | program_details 'aclocal' 160 | ;; 161 | autom4te*) 162 | echo "You might have modified some maintainer files that require" 163 | echo "the 'autom4te' program to be rebuilt." 164 | program_details 'autom4te' 165 | ;; 166 | bison*|yacc*) 167 | echo "You should only need it if you modified a '.y' file." 168 | echo "You may want to install the GNU Bison package:" 169 | echo "<$gnu_software_URL/bison/>" 170 | ;; 171 | lex*|flex*) 172 | echo "You should only need it if you modified a '.l' file." 173 | echo "You may want to install the Fast Lexical Analyzer package:" 174 | echo "<$flex_URL>" 175 | ;; 176 | help2man*) 177 | echo "You should only need it if you modified a dependency" \ 178 | "of a man page." 179 | echo "You may want to install the GNU Help2man package:" 180 | echo "<$gnu_software_URL/help2man/>" 181 | ;; 182 | makeinfo*) 183 | echo "You should only need it if you modified a '.texi' file, or" 184 | echo "any other file indirectly affecting the aspect of the manual." 185 | echo "You might want to install the Texinfo package:" 186 | echo "<$gnu_software_URL/texinfo/>" 187 | echo "The spurious makeinfo call might also be the consequence of" 188 | echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189 | echo "want to install GNU make:" 190 | echo "<$gnu_software_URL/make/>" 191 | ;; 192 | *) 193 | echo "You might have modified some files without having the proper" 194 | echo "tools for further handling them. Check the 'README' file, it" 195 | echo "often tells you about the needed prerequisites for installing" 196 | echo "this package. You may also peek at any GNU archive site, in" 197 | echo "case some other package contains this missing '$1' program." 198 | ;; 199 | esac 200 | } 201 | 202 | give_advice "$1" | sed -e '1s/^/WARNING: /' \ 203 | -e '2,$s/^/ /' >&2 204 | 205 | # Propagate the correct exit status (expected to be 127 for a program 206 | # not found, 63 for a program that failed due to version mismatch). 207 | exit $st 208 | 209 | # Local variables: 210 | # eval: (add-hook 'before-save-hook 'time-stamp) 211 | # time-stamp-start: "scriptversion=" 212 | # time-stamp-format: "%:y-%02m-%02d.%02H" 213 | # time-stamp-time-zone: "UTC0" 214 | # time-stamp-end: "; # UTC" 215 | # End: 216 | -------------------------------------------------------------------------------- /raspi-gpio.c: -------------------------------------------------------------------------------- 1 | /* 2 | Reads GPIO state and dumps to console. 3 | Allows GPIO hacking to set and get GPIO state. 4 | Author: James Adams 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #define GPIO_BASE_OFFSET 0x00200000 20 | 21 | #define DRIVE_UNSET -1 22 | #define DRIVE_LOW 0 23 | #define DRIVE_HIGH 1 24 | 25 | #define PULL_UNSET -1 26 | #define PULL_NONE 0 27 | #define PULL_DOWN 1 28 | #define PULL_UP 2 29 | 30 | #define FUNC_UNSET -1 31 | #define FUNC_IP 0 32 | #define FUNC_OP 1 33 | #define FUNC_ALT(x) (2 + (x)) 34 | #define FUNC_A0 FUNC_ALT(0) 35 | #define FUNC_A1 FUNC_ALT(1) 36 | #define FUNC_A2 FUNC_ALT(2) 37 | #define FUNC_A3 FUNC_ALT(3) 38 | #define FUNC_A4 FUNC_ALT(4) 39 | #define FUNC_A5 FUNC_ALT(5) 40 | 41 | /* 2835 register offsets */ 42 | #define GPFSEL0 0 43 | #define GPFSEL1 1 44 | #define GPFSEL2 2 45 | #define GPFSEL3 3 46 | #define GPFSEL4 4 47 | #define GPFSEL5 5 48 | #define GPSET0 7 49 | #define GPSET1 8 50 | #define GPCLR0 10 51 | #define GPCLR1 11 52 | #define GPLEV0 13 53 | #define GPLEV1 14 54 | #define GPPUD 37 55 | #define GPPUDCLK0 38 56 | #define GPPUDCLK1 39 57 | 58 | /* 2711 has a different mechanism for pin pull-up/down/enable */ 59 | #define GPPUPPDN0 57 /* Pin pull-up/down for pins 15:0 */ 60 | #define GPPUPPDN1 58 /* Pin pull-up/down for pins 31:16 */ 61 | #define GPPUPPDN2 59 /* Pin pull-up/down for pins 47:32 */ 62 | #define GPPUPPDN3 60 /* Pin pull-up/down for pins 57:48 */ 63 | 64 | struct gpio_chip 65 | { 66 | const char *name; 67 | uint32_t reg_base; 68 | uint32_t reg_size; 69 | unsigned int gpio_count; 70 | unsigned int fsel_count; 71 | const char *info_header; 72 | const char **alt_names; 73 | const int *default_pulls; 74 | 75 | int (*get_level)(struct gpio_chip *chip, unsigned int gpio); 76 | int (*get_fsel)(struct gpio_chip *chip, unsigned int gpio); 77 | int (*get_pull)(struct gpio_chip *chip, unsigned int gpio); 78 | int (*set_level)(struct gpio_chip *chip, unsigned int gpio, int level); 79 | int (*set_fsel)(struct gpio_chip *chip, unsigned int gpio, int fsel); 80 | int (*set_pull)(struct gpio_chip *chip, unsigned int gpio, int pull); 81 | int (*next_reg)(int reg); 82 | 83 | volatile uint32_t *base; 84 | }; 85 | 86 | static int bcm2835_get_level(struct gpio_chip *chip, unsigned int gpio); 87 | static int bcm2835_get_fsel(struct gpio_chip *chip, unsigned int gpio); 88 | static int bcm2835_get_pull(struct gpio_chip *chip, unsigned int gpio); 89 | static int bcm2835_set_level(struct gpio_chip *chip, unsigned int gpio, int level); 90 | static int bcm2835_set_fsel(struct gpio_chip *chip, unsigned int gpio, int fsel); 91 | static int bcm2835_set_pull(struct gpio_chip *chip, unsigned int gpio, int pull); 92 | static int bcm2835_next_reg(int reg); 93 | 94 | static int bcm2711_get_pull(struct gpio_chip *chip, unsigned int gpio); 95 | static int bcm2711_set_pull(struct gpio_chip *chip, unsigned int gpio, int pull); 96 | static int bcm2711_next_reg(int reg); 97 | 98 | static const char *gpio_alt_names_2835[54*6] = 99 | { 100 | "SDA0" , "SA5" , "PCLK" , "AVEOUT_VCLK" , "AVEIN_VCLK" , 0 , 101 | "SCL0" , "SA4" , "DE" , "AVEOUT_DSYNC" , "AVEIN_DSYNC", 0 , 102 | "SDA1" , "SA3" , "LCD_VSYNC" , "AVEOUT_VSYNC" , "AVEIN_VSYNC", 0 , 103 | "SCL1" , "SA2" , "LCD_HSYNC" , "AVEOUT_HSYNC" , "AVEIN_HSYNC", 0 , 104 | "GPCLK0" , "SA1" , "DPI_D0" , "AVEOUT_VID0" , "AVEIN_VID0" , "ARM_TDI" , 105 | "GPCLK1" , "SA0" , "DPI_D1" , "AVEOUT_VID1" , "AVEIN_VID1" , "ARM_TDO" , 106 | "GPCLK2" , "SOE_N_SE" , "DPI_D2" , "AVEOUT_VID2" , "AVEIN_VID2" , "ARM_RTCK" , 107 | "SPI0_CE1_N", "SWE_N_SRW_N", "DPI_D3" , "AVEOUT_VID3" , "AVEIN_VID3" , 0 , 108 | "SPI0_CE0_N", "SD0" , "DPI_D4" , "AVEOUT_VID4" , "AVEIN_VID4" , 0 , 109 | "SPI0_MISO" , "SD1" , "DPI_D5" , "AVEOUT_VID5" , "AVEIN_VID5" , 0 , 110 | "SPI0_MOSI" , "SD2" , "DPI_D6" , "AVEOUT_VID6" , "AVEIN_VID6" , 0 , 111 | "SPI0_SCLK" , "SD3" , "DPI_D7" , "AVEOUT_VID7" , "AVEIN_VID7" , 0 , 112 | "PWM0" , "SD4" , "DPI_D8" , "AVEOUT_VID8" , "AVEIN_VID8" , "ARM_TMS" , 113 | "PWM1" , "SD5" , "DPI_D9" , "AVEOUT_VID9" , "AVEIN_VID9" , "ARM_TCK" , 114 | "TXD0" , "SD6" , "DPI_D10" , "AVEOUT_VID10" , "AVEIN_VID10", "TXD1" , 115 | "RXD0" , "SD7" , "DPI_D11" , "AVEOUT_VID11" , "AVEIN_VID11", "RXD1" , 116 | "FL0" , "SD8" , "DPI_D12" , "CTS0" , "SPI1_CE2_N" , "CTS1" , 117 | "FL1" , "SD9" , "DPI_D13" , "RTS0" , "SPI1_CE1_N" , "RTS1" , 118 | "PCM_CLK" , "SD10" , "DPI_D14" , "I2CSL_SDA_MOSI", "SPI1_CE0_N" , "PWM0" , 119 | "PCM_FS" , "SD11" , "DPI_D15" , "I2CSL_SCL_SCLK", "SPI1_MISO" , "PWM1" , 120 | "PCM_DIN" , "SD12" , "DPI_D16" , "I2CSL_MISO" , "SPI1_MOSI" , "GPCLK0" , 121 | "PCM_DOUT" , "SD13" , "DPI_D17" , "I2CSL_CE_N" , "SPI1_SCLK" , "GPCLK1" , 122 | "SD0_CLK" , "SD14" , "DPI_D18" , "SD1_CLK" , "ARM_TRST" , 0 , 123 | "SD0_CMD" , "SD15" , "DPI_D19" , "SD1_CMD" , "ARM_RTCK" , 0 , 124 | "SD0_DAT0" , "SD16" , "DPI_D20" , "SD1_DAT0" , "ARM_TDO" , 0 , 125 | "SD0_DAT1" , "SD17" , "DPI_D21" , "SD1_DAT1" , "ARM_TCK" , 0 , 126 | "SD0_DAT2" , "TE0" , "DPI_D22" , "SD1_DAT2" , "ARM_TDI" , 0 , 127 | "SD0_DAT3" , "TE1" , "DPI_D23" , "SD1_DAT3" , "ARM_TMS" , 0 , 128 | "SDA0" , "SA5" , "PCM_CLK" , "FL0" , 0 , 0 , 129 | "SCL0" , "SA4" , "PCM_FS" , "FL1" , 0 , 0 , 130 | "TE0" , "SA3" , "PCM_DIN" , "CTS0" , 0 , "CTS1" , 131 | "FL0" , "SA2" , "PCM_DOUT" , "RTS0" , 0 , "RTS1" , 132 | "GPCLK0" , "SA1" , "RING_OCLK" , "TXD0" , 0 , "TXD1" , 133 | "FL1" , "SA0" , "TE1" , "RXD0" , 0 , "RXD1" , 134 | "GPCLK0" , "SOE_N_SE" , "TE2" , "SD1_CLK" , 0 , 0 , 135 | "SPI0_CE1_N", "SWE_N_SRW_N", 0 , "SD1_CMD" , 0 , 0 , 136 | "SPI0_CE0_N", "SD0" , "TXD0" , "SD1_DAT0" , 0 , 0 , 137 | "SPI0_MISO" , "SD1" , "RXD0" , "SD1_DAT1" , 0 , 0 , 138 | "SPI0_MOSI" , "SD2" , "RTS0" , "SD1_DAT2" , 0 , 0 , 139 | "SPI0_SCLK" , "SD3" , "CTS0" , "SD1_DAT3" , 0 , 0 , 140 | "PWM0" , "SD4" , 0 , "SD1_DAT4" , "SPI2_MISO" , "TXD1" , 141 | "PWM1" , "SD5" , "TE0" , "SD1_DAT5" , "SPI2_MOSI" , "RXD1" , 142 | "GPCLK1" , "SD6" , "TE1" , "SD1_DAT6" , "SPI2_SCLK" , "RTS1" , 143 | "GPCLK2" , "SD7" , "TE2" , "SD1_DAT7" , "SPI2_CE0_N" , "CTS1" , 144 | "GPCLK1" , "SDA0" , "SDA1" , "TE0" , "SPI2_CE1_N" , 0 , 145 | "PWM1" , "SCL0" , "SCL1" , "TE1" , "SPI2_CE2_N" , 0 , 146 | "SDA0" , "SDA1" , "SPI0_CE0_N", 0 , 0 , "SPI2_CE1_N", 147 | "SCL0" , "SCL1" , "SPI0_MISO" , 0 , 0 , "SPI2_CE0_N", 148 | "SD0_CLK" , "FL0" , "SPI0_MOSI" , "SD1_CLK" , "ARM_TRST" , "SPI2_SCLK" , 149 | "SD0_CMD" , "GPCLK0" , "SPI0_SCLK" , "SD1_CMD" , "ARM_RTCK" , "SPI2_MOSI" , 150 | "SD0_DAT0" , "GPCLK1" , "PCM_CLK" , "SD1_DAT0" , "ARM_TDO" , 0 , 151 | "SD0_DAT1" , "GPCLK2" , "PCM_FS" , "SD1_DAT1" , "ARM_TCK" , 0 , 152 | "SD0_DAT2" , "PWM0" , "PCM_DIN" , "SD1_DAT2" , "ARM_TDI" , 0 , 153 | "SD0_DAT3" , "PWM1" , "PCM_DOUT" , "SD1_DAT3" , "ARM_TMS" , 0 154 | }; 155 | 156 | static const char *gpio_alt_names_2711[54*6] = 157 | { 158 | "SDA0" , "SA5" , "PCLK" , "SPI3_CE0_N" , "TXD2" , "SDA6" , 159 | "SCL0" , "SA4" , "DE" , "SPI3_MISO" , "RXD2" , "SCL6" , 160 | "SDA1" , "SA3" , "LCD_VSYNC" , "SPI3_MOSI" , "CTS2" , "SDA3" , 161 | "SCL1" , "SA2" , "LCD_HSYNC" , "SPI3_SCLK" , "RTS2" , "SCL3" , 162 | "GPCLK0" , "SA1" , "DPI_D0" , "SPI4_CE0_N" , "TXD3" , "SDA3" , 163 | "GPCLK1" , "SA0" , "DPI_D1" , "SPI4_MISO" , "RXD3" , "SCL3" , 164 | "GPCLK2" , "SOE_N_SE" , "DPI_D2" , "SPI4_MOSI" , "CTS3" , "SDA4" , 165 | "SPI0_CE1_N", "SWE_N_SRW_N", "DPI_D3" , "SPI4_SCLK" , "RTS3" , "SCL4" , 166 | "SPI0_CE0_N", "SD0" , "DPI_D4" , "I2CSL_CE_N" , "TXD4" , "SDA4" , 167 | "SPI0_MISO" , "SD1" , "DPI_D5" , "I2CSL_SDI_MISO", "RXD4" , "SCL4" , 168 | "SPI0_MOSI" , "SD2" , "DPI_D6" , "I2CSL_SDA_MOSI", "CTS4" , "SDA5" , 169 | "SPI0_SCLK" , "SD3" , "DPI_D7" , "I2CSL_SCL_SCLK", "RTS4" , "SCL5" , 170 | "PWM0_0" , "SD4" , "DPI_D8" , "SPI5_CE0_N" , "TXD5" , "SDA5" , 171 | "PWM0_1" , "SD5" , "DPI_D9" , "SPI5_MISO" , "RXD5" , "SCL5" , 172 | "TXD0" , "SD6" , "DPI_D10" , "SPI5_MOSI" , "CTS5" , "TXD1" , 173 | "RXD0" , "SD7" , "DPI_D11" , "SPI5_SCLK" , "RTS5" , "RXD1" , 174 | 0 , "SD8" , "DPI_D12" , "CTS0" , "SPI1_CE2_N" , "CTS1" , 175 | 0 , "SD9" , "DPI_D13" , "RTS0" , "SPI1_CE1_N" , "RTS1" , 176 | "PCM_CLK" , "SD10" , "DPI_D14" , "SPI6_CE0_N" , "SPI1_CE0_N" , "PWM0_0" , 177 | "PCM_FS" , "SD11" , "DPI_D15" , "SPI6_MISO" , "SPI1_MISO" , "PWM0_1" , 178 | "PCM_DIN" , "SD12" , "DPI_D16" , "SPI6_MOSI" , "SPI1_MOSI" , "GPCLK0" , 179 | "PCM_DOUT" , "SD13" , "DPI_D17" , "SPI6_SCLK" , "SPI1_SCLK" , "GPCLK1" , 180 | "SD0_CLK" , "SD14" , "DPI_D18" , "SD1_CLK" , "ARM_TRST" , "SDA6" , 181 | "SD0_CMD" , "SD15" , "DPI_D19" , "SD1_CMD" , "ARM_RTCK" , "SCL6" , 182 | "SD0_DAT0" , "SD16" , "DPI_D20" , "SD1_DAT0" , "ARM_TDO" , "SPI3_CE1_N" , 183 | "SD0_DAT1" , "SD17" , "DPI_D21" , "SD1_DAT1" , "ARM_TCK" , "SPI4_CE1_N" , 184 | "SD0_DAT2" , 0 , "DPI_D22" , "SD1_DAT2" , "ARM_TDI" , "SPI5_CE1_N" , 185 | "SD0_DAT3" , 0 , "DPI_D23" , "SD1_DAT3" , "ARM_TMS" , "SPI6_CE1_N" , 186 | "SDA0" , "SA5" , "PCM_CLK" , 0 , "MII_A_RX_ERR" , "RGMII_MDIO" , 187 | "SCL0" , "SA4" , "PCM_FS" , 0 , "MII_A_TX_ERR" , "RGMII_MDC" , 188 | 0 , "SA3" , "PCM_DIN" , "CTS0" , "MII_A_CRS" , "CTS1" , 189 | 0 , "SA2" , "PCM_DOUT" , "RTS0" , "MII_A_COL" , "RTS1" , 190 | "GPCLK0" , "SA1" , 0 , "TXD0" , "SD_CARD_PRES" , "TXD1" , 191 | 0 , "SA0" , 0 , "RXD0" , "SD_CARD_WRPROT" , "RXD1" , 192 | "GPCLK0" , "SOE_N_SE" , 0 , "SD1_CLK" , "SD_CARD_LED" , "RGMII_IRQ" , 193 | "SPI0_CE1_N", "SWE_N_SRW_N", 0 , "SD1_CMD" , "RGMII_START_STOP", 0 , 194 | "SPI0_CE0_N", "SD0" , "TXD0" , "SD1_DAT0" , "RGMII_RX_OK" , "MII_A_RX_ERR", 195 | "SPI0_MISO" , "SD1" , "RXD0" , "SD1_DAT1" , "RGMII_MDIO" , "MII_A_TX_ERR", 196 | "SPI0_MOSI" , "SD2" , "RTS0" , "SD1_DAT2" , "RGMII_MDC" , "MII_A_CRS" , 197 | "SPI0_SCLK" , "SD3" , "CTS0" , "SD1_DAT3" , "RGMII_IRQ" , "MII_A_COL" , 198 | "PWM1_0" , "SD4" , 0 , "SD1_DAT4" , "SPI0_MISO" , "TXD1" , 199 | "PWM1_1" , "SD5" , 0 , "SD1_DAT5" , "SPI0_MOSI" , "RXD1" , 200 | "GPCLK1" , "SD6" , 0 , "SD1_DAT6" , "SPI0_SCLK" , "RTS1" , 201 | "GPCLK2" , "SD7" , 0 , "SD1_DAT7" , "SPI0_CE0_N" , "CTS1" , 202 | "GPCLK1" , "SDA0" , "SDA1" , 0 , "SPI0_CE1_N" , "SD_CARD_VOLT", 203 | "PWM0_1" , "SCL0" , "SCL1" , 0 , "SPI0_CE2_N" , "SD_CARD_PWR0", 204 | "SDA0" , "SDA1" , "SPI0_CE0_N", 0 , 0 , "SPI2_CE1_N" , 205 | "SCL0" , "SCL1" , "SPI0_MISO" , 0 , 0 , "SPI2_CE0_N" , 206 | "SD0_CLK" , 0 , "SPI0_MOSI" , "SD1_CLK" , "ARM_TRST" , "SPI2_SCLK" , 207 | "SD0_CMD" , "GPCLK0" , "SPI0_SCLK" , "SD1_CMD" , "ARM_RTCK" , "SPI2_MOSI" , 208 | "SD0_DAT0" , "GPCLK1" , "PCM_CLK" , "SD1_DAT0" , "ARM_TDO" , "SPI2_MISO" , 209 | "SD0_DAT1" , "GPCLK2" , "PCM_FS" , "SD1_DAT1" , "ARM_TCK" , "SD_CARD_LED" , 210 | "SD0_DAT2" , "PWM0_0" , "PCM_DIN" , "SD1_DAT2" , "ARM_TDI" , 0 , 211 | "SD0_DAT3" , "PWM0_1" , "PCM_DOUT" , "SD1_DAT3" , "ARM_TMS" , 0 , 212 | }; 213 | 214 | static const char *gpio_pull_names[4] = 215 | { 216 | "NONE", "DOWN", "UP", "?" 217 | }; 218 | 219 | /* 0 = none, 1 = down, 2 = up */ 220 | static const int gpio_default_pullstate_2835[54] = 221 | { 222 | 2,2,2,2,2,2,2,2,2, /*GPIO0-8 UP*/ 223 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /*GPIO9-27 DOWN*/ 224 | 0,0, /*GPIO28-29 NONE*/ 225 | 1,1,1,1, /*GPIO30-33 DOWN*/ 226 | 2,2,2, /*GPIO34-36 UP*/ 227 | 1,1,1,1,1,1,1, /*GPIO37-43 DOWN*/ 228 | 0,0, /*GPIO44-45 NONE*/ 229 | 2,2,2,2,2,2,2,2 /*GPIO46-53 UP*/ 230 | }; 231 | 232 | struct gpio_chip gpio_chip_2835 = 233 | { 234 | "bcm2835", 235 | 0x00200000, 236 | 0x1000, 237 | 54, 238 | 6, 239 | "GPIO, DEFAULT PULL, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5", 240 | gpio_alt_names_2835, 241 | gpio_default_pullstate_2835, 242 | bcm2835_get_level, 243 | bcm2835_get_fsel, 244 | bcm2835_get_pull, 245 | bcm2835_set_level, 246 | bcm2835_set_fsel, 247 | bcm2835_set_pull, 248 | bcm2835_next_reg, 249 | }; 250 | 251 | struct gpio_chip gpio_chip_2711 = 252 | { 253 | "bcm2711", 254 | 0x00200000, 255 | 0x1000, 256 | 54, 257 | 6, 258 | "GPIO, DEFAULT PULL, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5", 259 | gpio_alt_names_2711, 260 | gpio_default_pullstate_2835, 261 | bcm2835_get_level, 262 | bcm2835_get_fsel, 263 | bcm2711_get_pull, 264 | bcm2835_set_level, 265 | bcm2835_set_fsel, 266 | bcm2711_set_pull, 267 | bcm2711_next_reg, 268 | }; 269 | 270 | struct gpio_chip *chip; 271 | 272 | void print_gpio_alts_info(struct gpio_chip *chip, int gpio) 273 | { 274 | int alt; 275 | printf("%d, %s", gpio, gpio_pull_names[chip->default_pulls[gpio]]); 276 | for (alt = 0; alt < 6; alt++) 277 | { 278 | const char *name = chip->alt_names[gpio * chip->fsel_count + alt]; 279 | printf(", %s", name ? name : "-"); 280 | } 281 | printf("\n"); 282 | } 283 | 284 | struct gpio_chip *get_gpio_chip(void) 285 | { 286 | struct gpio_chip *chip; 287 | const char *revision_file = "/proc/device-tree/system/linux,revision"; 288 | uint8_t revision[4] = { 0 }; 289 | uint32_t cpu = 0; 290 | FILE *fd; 291 | 292 | if ((fd = fopen(revision_file, "rb")) == NULL) 293 | { 294 | printf("Can't open '%s'\n", revision_file); 295 | } 296 | else 297 | { 298 | if (fread(revision, 1, sizeof(revision), fd) == 4) 299 | cpu = (revision[2] >> 4) & 0xf; 300 | else 301 | printf("Revision data too short\n"); 302 | 303 | fclose(fd); 304 | } 305 | 306 | switch (cpu) 307 | { 308 | case 0: /* BCM2835 */ 309 | chip = &gpio_chip_2835; 310 | chip->reg_base = 0x20000000 + GPIO_BASE_OFFSET; 311 | break; 312 | case 1: /* BCM2836 */ 313 | case 2: /* BCM2837 */ 314 | chip = &gpio_chip_2835; 315 | chip->reg_base = 0x3f000000 + GPIO_BASE_OFFSET; 316 | break; 317 | case 3: /* BCM2711 */ 318 | chip = &gpio_chip_2711; 319 | chip->reg_base = 0xfe000000 + GPIO_BASE_OFFSET; 320 | break; 321 | case 4: /* BCM2712 */ 322 | printf("raspi-gpio is not supported on Pi 5 - use `pinctrl`\n"); 323 | exit(1); 324 | default: 325 | printf("Unrecognised revision code\n"); 326 | exit(1); 327 | } 328 | 329 | return chip; 330 | } 331 | 332 | const char *gpio_fsel_to_namestr(unsigned int gpio, int fsel) 333 | { 334 | const char *name = NULL; 335 | static char alt_str[16]; 336 | 337 | if (gpio >= chip->gpio_count) 338 | return NULL; 339 | 340 | if (fsel == FUNC_IP) 341 | return "INPUT"; 342 | else if (fsel == FUNC_OP) 343 | return "OUTPUT"; 344 | 345 | fsel -= FUNC_A0; 346 | if (fsel >= 0 && fsel < chip->fsel_count) 347 | name = chip->alt_names[gpio * chip->fsel_count + fsel]; 348 | if (!name) 349 | { 350 | sprintf(alt_str, "alt%d", fsel); 351 | name = alt_str; 352 | } 353 | 354 | return name; 355 | } 356 | 357 | void print_raw_gpio_regs(struct gpio_chip *chip) 358 | { 359 | int i = -1; 360 | 361 | while (1) 362 | { 363 | int new_i = chip->next_reg(i++); 364 | 365 | if (new_i < 0) 366 | break; 367 | if (new_i != i) 368 | { 369 | /* Change rows if needed */ 370 | if ((i & ~3) != (new_i & ~3)) /* Not on the same row */ 371 | { 372 | if (i & 3) /* This row has been started */ 373 | printf("\n"); 374 | i = new_i & ~3; 375 | } 376 | } 377 | if ((i & 3) == 0) 378 | printf("%02x:", i * 4); 379 | if (new_i != i) 380 | { 381 | /* Insert padding if needed */ 382 | printf("%*s", (new_i - i) * 9, ""); 383 | i = new_i; 384 | } 385 | 386 | printf(" %08x", chip->base[i]); 387 | 388 | if ((i & 3) == 3) 389 | printf("\n"); 390 | } 391 | if (i & 3) 392 | printf("\n"); 393 | } 394 | 395 | void print_help() 396 | { 397 | char *name = "raspi-gpio"; /* in case we want to rename */ 398 | printf("\n"); 399 | printf("WARNING! %s set writes directly to the GPIO control registers\n", name); 400 | printf("ignoring whatever else may be using them (such as Linux drivers) -\n"); 401 | printf("it is designed as a debug tool, only use it if you know what you\n"); 402 | printf("are doing and at your own risk!\n"); 403 | printf("\n"); 404 | printf("The %s tool is designed to help hack / debug BCM283x GPIO.\n", name); 405 | printf("Running %s with the help argument prints this help.\n", name); 406 | printf("%s can get and print the state of a GPIO (or all GPIOs)\n", name); 407 | printf("and can be used to set the function, pulls and value of a GPIO.\n"); 408 | printf("%s must be run as root.\n", name); 409 | printf("Use:\n"); 410 | printf(" %s [] get [GPIO]\n", name); 411 | printf("OR\n"); 412 | printf(" %s [] set [options]\n", name); 413 | printf("OR\n"); 414 | printf(" %s [] funcs [GPIO]\n", name); 415 | printf("OR\n"); 416 | printf(" %s [] raw\n", name); 417 | printf("\n"); 418 | printf(" is an option GPIO chip index (default 0)\n"); 419 | printf("GPIO is a comma-separated list of pin numbers or ranges (without spaces),\n"); 420 | printf("e.g. 4 or 18-21 or 7,9-11\n"); 421 | printf("Note that omitting [GPIO] from %s get prints all GPIOs.\n", name); 422 | printf("%s funcs will dump all the possible GPIO alt funcions in CSV format\n", name); 423 | printf("or if [GPIO] is specified the alternate funcs just for that specific GPIO.\n"); 424 | printf("Valid [options] for %s set are:\n", name); 425 | printf(" ip set GPIO as input\n"); 426 | printf(" op set GPIO as output\n"); 427 | printf(" a0-a5 set GPIO to alternate function alt0-alt5\n"); 428 | printf(" pu set GPIO in-pad pull up\n"); 429 | printf(" pd set GPIO in-pad pull down\n"); 430 | printf(" pn set GPIO pull none (no pull)\n"); 431 | printf(" dh set GPIO to drive to high (1) level (only valid if set to be an output)\n"); 432 | printf(" dl set GPIO to drive low (0) level (only valid if set to be an output)\n"); 433 | printf("Examples:\n"); 434 | printf(" %s get Prints state of all GPIOs one per line\n", name); 435 | printf(" %s get 20 Prints state of GPIO20\n", name); 436 | printf(" %s get 20,21 Prints state of GPIO20 and GPIO21\n", name); 437 | printf(" %s set 20 a5 Set GPIO20 to ALT5 function (GPCLK0)\n", name); 438 | printf(" %s set 20 pu Enable GPIO20 ~50k in-pad pull up\n", name); 439 | printf(" %s set 20 pd Enable GPIO20 ~50k in-pad pull down\n", name); 440 | printf(" %s set 20 op Set GPIO20 to be an output\n", name); 441 | printf(" %s set 20 dl Set GPIO20 to output low/zero (must already be set as an output)\n", name); 442 | printf(" %s set 20 ip pd Set GPIO20 to input with pull down\n", name); 443 | printf(" %s set 35 a0 pu Set GPIO35 to ALT0 function (SPI_CE1_N) with pull up\n", name); 444 | printf(" %s set 20 op pn dh Set GPIO20 to ouput with no pull and driving high\n", name); 445 | } 446 | 447 | int gpio_get(unsigned int gpio) 448 | { 449 | const char *name; 450 | int level; 451 | int fsel; 452 | int pull; 453 | 454 | fsel = chip->get_fsel(chip, gpio); 455 | name = gpio_fsel_to_namestr(gpio, fsel); 456 | level = chip->get_level(chip, gpio); 457 | 458 | printf("GPIO %d: level=%d", gpio, level); 459 | 460 | if (fsel >= FUNC_A0) 461 | printf(" alt=%d", fsel - FUNC_A0); 462 | printf(" func=%s", name); 463 | 464 | pull = chip->get_pull(chip, gpio); 465 | if (pull != PULL_UNSET) 466 | printf(" pull=%s", gpio_pull_names[pull & 3]); 467 | printf("\n"); 468 | return 0; 469 | } 470 | 471 | int gpio_set(unsigned int gpio, int fsparam, int drive, int pull) 472 | { 473 | if (fsparam != FUNC_UNSET) 474 | chip->set_fsel(chip, gpio, fsparam); 475 | 476 | if (drive != DRIVE_UNSET) 477 | { 478 | if (chip->get_fsel(chip, gpio) == FUNC_OP) 479 | { 480 | chip->set_level(chip, gpio, drive); 481 | } 482 | else 483 | { 484 | printf("Can't set pin value, not an output\n"); 485 | return 1; 486 | } 487 | } 488 | 489 | if (pull != PULL_UNSET) 490 | return chip->set_pull(chip, gpio, pull); 491 | 492 | return 0; 493 | } 494 | 495 | int main(int argc, char *argv[]) 496 | { 497 | int fd; 498 | int ret; 499 | 500 | /* arg parsing */ 501 | 502 | int set = 0; 503 | int get = 0; 504 | int funcs = 0; 505 | int raw = 0; 506 | int pull = PULL_UNSET; 507 | int fsparam = FUNC_UNSET; 508 | int drive = DRIVE_UNSET; 509 | uint32_t gpiomask[2] = { 0, 0 }; /* Enough for 0-53 */ 510 | int all_pins = 0; 511 | 512 | const char *cmd; 513 | 514 | argv++; 515 | argc--; 516 | 517 | if (!argc) 518 | { 519 | printf("No arguments given - try \"raspi-gpio help\"\n"); 520 | return 1; 521 | } 522 | 523 | cmd = *(argv++); 524 | argc--; 525 | 526 | if (strcmp(cmd, "help") == 0) 527 | { 528 | print_help(); 529 | return 0; 530 | } 531 | 532 | chip = get_gpio_chip(); 533 | 534 | /* argc 2 or greater, next arg must be set, get or help */ 535 | get = strcmp(cmd, "get") == 0; 536 | set = strcmp(cmd, "set") == 0; 537 | funcs = strcmp(cmd, "funcs") == 0; 538 | raw = strcmp(cmd, "raw") == 0; 539 | if (!set && !get && !funcs && !raw) 540 | { 541 | printf("Unknown argument \"%s\" try \"raspi-gpio help\"\n", cmd); 542 | return 1; 543 | } 544 | 545 | if ((get || funcs) && (argc > 1)) 546 | { 547 | printf("Too many arguments\n"); 548 | return 1; 549 | } 550 | 551 | if (!argc && set) 552 | { 553 | printf("Need GPIO number to set\n"); 554 | return 1; 555 | } 556 | 557 | if (argc) /* expect pin number(s) next */ 558 | { 559 | char *p = *(argv++); 560 | argc--; 561 | 562 | while (p) 563 | { 564 | int pin, pin2, len; 565 | ret = sscanf(p, "%d%n", &pin, &len); 566 | if (ret != 1 || pin >= chip->gpio_count) 567 | break; 568 | p += len; 569 | 570 | if (*p == '-') 571 | { 572 | p++; 573 | ret = sscanf(p, "%d%n", &pin2, &len); 574 | if (ret != 1 || pin2 >= chip->gpio_count) 575 | break; 576 | if (pin2 < pin) 577 | { 578 | int tmp = pin2; 579 | pin2 = pin; 580 | pin = tmp; 581 | } 582 | p += len; 583 | } 584 | else 585 | { 586 | pin2 = pin; 587 | } 588 | while (pin <= pin2) 589 | { 590 | gpiomask[pin/32] |= (1 << (pin % 32)); 591 | pin++; 592 | } 593 | if (*p == '\0') 594 | { 595 | p = NULL; 596 | } 597 | else 598 | { 599 | if (*p != ',') 600 | break; 601 | p++; 602 | } 603 | } 604 | if (p) 605 | { 606 | printf("Unknown GPIO \"%s\"\n", p); 607 | return 1; 608 | } 609 | } 610 | 611 | if (set && !argc) 612 | { 613 | printf("Nothing to set\n"); 614 | return 1; 615 | } 616 | 617 | /* parse remaining args */ 618 | while (argc) 619 | { 620 | const char *arg = *(argv++); 621 | argc--; 622 | 623 | if (strcmp(arg, "dh") == 0) 624 | drive = DRIVE_HIGH; 625 | else if (strcmp(arg, "dl") == 0) 626 | drive = DRIVE_LOW; 627 | else if (strcmp(arg, "ip") == 0) 628 | fsparam = FUNC_IP; 629 | else if (strcmp(arg, "op") == 0) 630 | fsparam = FUNC_OP; 631 | else if (strcmp(arg, "a0") == 0) 632 | fsparam = FUNC_A0; 633 | else if (strcmp(arg, "a1") == 0) 634 | fsparam = FUNC_A1; 635 | else if (strcmp(arg, "a2") == 0) 636 | fsparam = FUNC_A2; 637 | else if (strcmp(arg, "a3") == 0) 638 | fsparam = FUNC_A3; 639 | else if (strcmp(arg, "a4") == 0) 640 | fsparam = FUNC_A4; 641 | else if (strcmp(arg, "a5") == 0) 642 | fsparam = FUNC_A5; 643 | else if (strcmp(arg, "pu") == 0) 644 | pull = PULL_UP; 645 | else if (strcmp(arg, "pd") == 0) 646 | pull = PULL_DOWN; 647 | else if (strcmp(arg, "pn") == 0) 648 | pull = PULL_NONE; 649 | else 650 | { 651 | printf("Unknown argument \"%s\"\n", arg); 652 | return 1; 653 | } 654 | } 655 | 656 | if (fsparam >= FUNC_A0 && (fsparam - FUNC_A0) >= chip->fsel_count) 657 | { 658 | printf("Alt function a%d out of range\n", fsparam - FUNC_A0); 659 | return 1; 660 | } 661 | /* end arg parsing */ 662 | 663 | all_pins = !(gpiomask[0] | gpiomask[1]); 664 | 665 | if (funcs) 666 | { 667 | int pin; 668 | 669 | printf("GPIO, DEFAULT PULL, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5\n"); 670 | for (pin = 0; pin < chip->gpio_count; pin++) 671 | { 672 | if (all_pins || gpiomask[pin / 32] & (1 << (pin % 32))) 673 | print_gpio_alts_info(chip, pin); 674 | } 675 | goto deprecation_check; 676 | } 677 | 678 | /* Check for /dev/gpiomem, else we need root access for /dev/mem */ 679 | if ((fd = open ("/dev/gpiomem", O_RDWR | O_SYNC | O_CLOEXEC) ) >= 0) 680 | { 681 | chip->base = (uint32_t *)mmap(0, chip->reg_size, 682 | PROT_READ|PROT_WRITE, MAP_SHARED, 683 | fd, 0); 684 | } 685 | else 686 | { 687 | if (geteuid()) 688 | { 689 | printf("Must be root\n"); 690 | return 1; 691 | } 692 | 693 | if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0) 694 | { 695 | printf("Unable to open /dev/mem: %s\n", strerror (errno)); 696 | return 1; 697 | } 698 | 699 | chip->base = (uint32_t *)mmap(0, chip->reg_size, 700 | PROT_READ|PROT_WRITE, MAP_SHARED, 701 | fd, chip->reg_base); 702 | } 703 | 704 | if (chip->base == (uint32_t *)-1) 705 | { 706 | printf("mmap (GPIO) failed: %s\n", strerror (errno)); 707 | return 1; 708 | } 709 | 710 | if (set || get) 711 | { 712 | int pin; 713 | for (pin = 0; pin < chip->gpio_count; pin++) 714 | { 715 | if (all_pins) 716 | { 717 | if (pin==0) printf("BANK0 (GPIO 0 to 27):\n"); 718 | if (pin==28) printf("BANK1 (GPIO 28 to 45):\n"); 719 | if (pin==46) printf("BANK2 (GPIO 46 to 53):\n"); 720 | } 721 | else if (!(gpiomask[pin / 32] & (1 << (pin % 32)))) 722 | { 723 | continue; 724 | } 725 | if (get) 726 | { 727 | if (gpio_get(pin)) 728 | return 1; 729 | } 730 | else 731 | { 732 | if (gpio_set(pin, fsparam, drive, pull)) 733 | return 1; 734 | } 735 | } 736 | } 737 | 738 | if (raw) 739 | print_raw_gpio_regs(chip); 740 | 741 | deprecation_check: 742 | if (isatty(STDOUT_FILENO)) 743 | { 744 | fd = open("/tmp/raspi-gpio-deprecated", O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); 745 | if (fd >= 0) 746 | { 747 | printf("[ raspi-gpio is deprecated - try `pinctrl` instead ]\n"); 748 | close(fd); 749 | } 750 | } 751 | 752 | return 0; 753 | } 754 | 755 | static int bcm2835_get_level(struct gpio_chip *chip, unsigned int gpio) 756 | { 757 | if (gpio >= chip->gpio_count) 758 | return -1; 759 | 760 | return (chip->base[GPLEV0 + (gpio / 32)] >> (gpio % 32)) & 1; 761 | } 762 | 763 | static int bcm2835_get_fsel(struct gpio_chip *chip, unsigned int gpio) 764 | { 765 | /* GPFSEL0-5 with 10 sels per reg, 3 bits per sel (so bits 0:29 used) */ 766 | uint32_t reg = GPFSEL0 + (gpio / 10); 767 | uint32_t lsb = (gpio % 10) * 3; 768 | 769 | if (gpio < chip->gpio_count) 770 | { 771 | switch ((chip->base[reg] >> lsb) & 7) 772 | { 773 | case 0: return FUNC_IP; 774 | case 1: return FUNC_OP; 775 | case 2: return FUNC_A5; 776 | case 3: return FUNC_A4; 777 | case 4: return FUNC_A0; 778 | case 5: return FUNC_A1; 779 | case 6: return FUNC_A2; 780 | case 7: return FUNC_A3; 781 | } 782 | } 783 | 784 | return -1; 785 | } 786 | 787 | static int bcm2835_get_pull(struct gpio_chip *chip, unsigned int gpio) 788 | { 789 | /* This is a write-only mechanism */ 790 | return PULL_UNSET; 791 | } 792 | 793 | static int bcm2835_set_level(struct gpio_chip *chip, unsigned int gpio, int level) 794 | { 795 | if (gpio >= chip->gpio_count) 796 | return -1; 797 | 798 | chip->base[(level ? GPSET0 : GPCLR0) + (gpio / 32)] = (1 << (gpio % 32)); 799 | 800 | return 0; 801 | } 802 | 803 | static int bcm2835_set_fsel(struct gpio_chip *chip, unsigned int gpio, int fsel) 804 | { 805 | /* GPFSEL0-5 with 10 sels per reg, 3 bits per sel (so bits 0:29 used) */ 806 | uint32_t reg = GPFSEL0 + (gpio / 10); 807 | uint32_t lsb = (gpio % 10) * 3; 808 | 809 | switch (fsel) 810 | { 811 | case FUNC_IP: fsel = 0; break; 812 | case FUNC_OP: fsel = 1; break; 813 | case FUNC_A0: fsel = 4; break; 814 | case FUNC_A1: fsel = 5; break; 815 | case FUNC_A2: fsel = 6; break; 816 | case FUNC_A3: fsel = 7; break; 817 | case FUNC_A4: fsel = 3; break; 818 | case FUNC_A5: fsel = 2; break; 819 | default: 820 | return -1; 821 | } 822 | 823 | if (gpio < chip->gpio_count) 824 | { 825 | chip->base[reg] = (chip->base[reg] & ~(0x7 << lsb)) | (fsel << lsb); 826 | return 0; 827 | } 828 | 829 | return -1; 830 | } 831 | 832 | static int bcm2835_set_pull(struct gpio_chip *chip, unsigned int gpio, int pull) 833 | { 834 | int clkreg = GPPUDCLK0 + (gpio / 32); 835 | int clkbit = 1 << (gpio % 32); 836 | 837 | if (gpio >= chip->gpio_count) 838 | return -1; 839 | 840 | if (pull < 0 || pull > 2) return -1; 841 | 842 | chip->base[GPPUD] = pull; 843 | usleep(10); 844 | chip->base[clkreg] = clkbit; 845 | usleep(10); 846 | chip->base[GPPUD] = 0; 847 | usleep(10); 848 | chip->base[clkreg] = 0; 849 | usleep(10); 850 | 851 | return 0; 852 | } 853 | 854 | static int bcm2835_next_reg(int reg) 855 | { 856 | if (reg < 0) 857 | return 0; 858 | else if (reg == GPPUDCLK1) 859 | return -1; 860 | return reg + 1; 861 | } 862 | 863 | static int bcm2711_get_pull(struct gpio_chip *chip, unsigned int gpio) 864 | { 865 | int reg = GPPUPPDN0 + (gpio / 16); 866 | int lsb = (gpio % 16) * 2; 867 | 868 | if (gpio >= chip->gpio_count) 869 | return -1; 870 | 871 | switch ((chip->base[reg] >> lsb) & 3) 872 | { 873 | case 0: return PULL_NONE; 874 | case 1: return PULL_UP; 875 | case 2: return PULL_DOWN; 876 | } 877 | return -1; 878 | } 879 | 880 | static int bcm2711_set_pull(struct gpio_chip *chip, unsigned int gpio, int pull) 881 | { 882 | int reg = GPPUPPDN0 + (gpio / 16); 883 | int lsb = (gpio % 16) * 2; 884 | 885 | if (gpio >= chip->gpio_count) 886 | return -1; 887 | 888 | switch (pull) 889 | { 890 | case PULL_NONE: 891 | pull = 0; 892 | break; 893 | case PULL_UP: 894 | pull = 1; 895 | break; 896 | case PULL_DOWN: 897 | pull = 2; 898 | break; 899 | default: 900 | return -1; 901 | } 902 | 903 | chip->base[reg] = (chip->base[reg] & ~(3 << lsb)) | (pull << lsb); 904 | 905 | return 0; 906 | } 907 | 908 | static int bcm2711_next_reg(int reg) 909 | { 910 | /* Skip over non-GPIO registers */ 911 | if (reg < 0) 912 | return 0; 913 | else if (reg == GPPUPPDN3) 914 | return -1; 915 | else if (reg == GPPUDCLK1) 916 | return GPPUPPDN0; 917 | return reg + 1; 918 | } 919 | --------------------------------------------------------------------------------