├── .ccls ├── .clangd ├── .dir-locals.el ├── .gitignore ├── AUTHORS ├── Basic.mk.template ├── COPYING ├── ChangeLog.1 ├── ChangeLog.2 ├── ChangeLog.3 ├── Makefile.am ├── NEWS ├── README.DOS ├── README.OS2 ├── README.VMS ├── README.W32 ├── README.customs ├── README.git ├── README.in ├── README.zOS ├── TODO.private ├── autogen.sh ├── autopull.sh ├── bootstrap ├── bootstrap-funclib.sh ├── bootstrap.bat ├── bootstrap.conf ├── build.cfg.in ├── build.sh ├── build_w32.bat ├── builddos.bat ├── configure.ac ├── doc ├── .gitignore ├── Makefile.am ├── make.1 └── make.texi ├── gl ├── .gitignore ├── README ├── lib │ ├── fnmatch.c │ ├── fnmatch.in.h │ ├── glob.c │ └── glob.in.h ├── m4 │ ├── acinclude.m4 │ ├── dospaths.m4 │ └── getloadavg.m4 └── modules │ ├── concat-filename │ ├── findprog-in │ ├── getloadavg │ ├── make-glob │ └── make-macros ├── maintMakefile ├── make-gdb.py ├── makefile.com ├── mk ├── Posix.mk.in ├── VMS.mk ├── Windows32.mk └── msdosdjgpp.mk ├── po ├── .gitignore ├── LINGUAS └── POTFILES.in ├── prepare_vms.com ├── scripts └── copyright-update ├── src ├── ar.c ├── arscan.c ├── commands.c ├── commands.h ├── config.h-vms ├── config.h.W32 ├── configh.dos ├── debug.h ├── default.c ├── dep.h ├── dir.c ├── expand.c ├── file.c ├── filedef.h ├── function.c ├── getopt.c ├── getopt.h ├── getopt1.c ├── gettext.h ├── gmk-default.scm ├── gnumake.h ├── guile.c ├── hash.c ├── hash.h ├── implicit.c ├── job.c ├── job.h ├── load.c ├── loadapi.c ├── main.c ├── makeint.h ├── misc.c ├── mkconfig.h.in ├── mkcustom.h ├── os.h ├── output.c ├── output.h ├── posixos.c ├── read.c ├── remake.c ├── remote-cstms.c ├── remote-stub.c ├── rule.c ├── rule.h ├── shuffle.c ├── shuffle.h ├── signame.c ├── strcache.c ├── variable.c ├── variable.h ├── version.c ├── vms_exit.c ├── vms_export_symbol.c ├── vms_progname.c ├── vmsdir.h ├── vmsfunctions.c ├── vmsify.c ├── vmsjobs.c ├── vpath.c ├── w32 │ ├── compat │ │ ├── dirent.c │ │ └── posixfcn.c │ ├── include │ │ ├── dirent.h │ │ ├── dlfcn.h │ │ ├── pathstuff.h │ │ ├── sub_proc.h │ │ └── w32err.h │ ├── pathstuff.c │ ├── subproc │ │ ├── misc.c │ │ ├── proc.h │ │ ├── sub_proc.c │ │ └── w32err.c │ ├── utf8.manifest │ ├── utf8.rc │ └── w32os.c ├── warning.c └── warning.h ├── tests ├── .gitignore ├── ChangeLog.1 ├── NEWS ├── README ├── config-flags.pm.W32 ├── config-flags.pm.in ├── config_flags_pm.com ├── guile.supp ├── mkshadow ├── run_make_tests ├── run_make_tests.bat ├── run_make_tests.com ├── run_make_tests.pl ├── scripts │ ├── features │ │ ├── archives │ │ ├── comments │ │ ├── conditionals │ │ ├── default_names │ │ ├── dircache │ │ ├── double_colon │ │ ├── echoing │ │ ├── errors │ │ ├── escape │ │ ├── exec │ │ ├── expand │ │ ├── export │ │ ├── grouped_targets │ │ ├── implicit_search │ │ ├── include │ │ ├── jobserver │ │ ├── load │ │ ├── loadapi │ │ ├── mult_rules │ │ ├── mult_targets │ │ ├── order_only │ │ ├── output-sync │ │ ├── override │ │ ├── parallelism │ │ ├── patspecific_vars │ │ ├── patternrules │ │ ├── quoting │ │ ├── recursion │ │ ├── reinvoke │ │ ├── rule_glob │ │ ├── se_explicit │ │ ├── se_implicit │ │ ├── se_statpat │ │ ├── shell_assignment │ │ ├── statipattrules │ │ ├── suffixrules │ │ ├── targetvars │ │ ├── temp_stdin │ │ ├── utf8 │ │ ├── varnesting │ │ ├── vpath │ │ ├── vpathgpath │ │ └── vpathplus │ ├── functions │ │ ├── abspath │ │ ├── addprefix │ │ ├── addsuffix │ │ ├── andor │ │ ├── basename │ │ ├── call │ │ ├── dir │ │ ├── error │ │ ├── eval │ │ ├── file │ │ ├── filter-out │ │ ├── findstring │ │ ├── flavor │ │ ├── foreach │ │ ├── guile │ │ ├── if │ │ ├── intcmp │ │ ├── join │ │ ├── let │ │ ├── notdir │ │ ├── origin │ │ ├── realpath │ │ ├── shell │ │ ├── sort │ │ ├── strip │ │ ├── substitution │ │ ├── suffix │ │ ├── value │ │ ├── warning │ │ ├── wildcard │ │ └── word │ ├── misc │ │ ├── bs-nl │ │ ├── close_stdout │ │ ├── failure │ │ ├── fopen-fail │ │ ├── general1 │ │ ├── general2 │ │ ├── general3 │ │ ├── general4 │ │ └── utf8 │ ├── options │ │ ├── dash-B │ │ ├── dash-C │ │ ├── dash-I │ │ ├── dash-W │ │ ├── dash-d │ │ ├── dash-e │ │ ├── dash-f │ │ ├── dash-k │ │ ├── dash-l │ │ ├── dash-n │ │ ├── dash-q │ │ ├── dash-r │ │ ├── dash-s │ │ ├── dash-t │ │ ├── eval │ │ ├── general │ │ ├── print-directory │ │ ├── print-targets │ │ ├── shuffle │ │ ├── symlinks │ │ └── warn │ ├── targets │ │ ├── DEFAULT │ │ ├── DELETE_ON_ERROR │ │ ├── FORCE │ │ ├── IGNORE │ │ ├── INTERMEDIATE │ │ ├── NOTINTERMEDIATE │ │ ├── ONESHELL │ │ ├── PHONY │ │ ├── POSIX │ │ ├── SECONDARY │ │ ├── SILENT │ │ ├── WAIT │ │ └── clean │ ├── test_template │ ├── variables │ │ ├── CURDIR │ │ ├── DEFAULT_GOAL │ │ ├── EXTRA_PREREQS │ │ ├── GNUMAKEFLAGS │ │ ├── INCLUDE_DIRS │ │ ├── LIBPATTERNS │ │ ├── MAKE │ │ ├── MAKECMDGOALS │ │ ├── MAKEFILES │ │ ├── MAKEFLAGS │ │ ├── MAKELEVEL │ │ ├── MAKE_RESTARTS │ │ ├── MFILE_LIST │ │ ├── SHELL │ │ ├── WARNINGS │ │ ├── append │ │ ├── automatic │ │ ├── conditional │ │ ├── define │ │ ├── flavors │ │ ├── negative │ │ ├── private │ │ ├── special │ │ └── undefine │ └── vms │ │ └── library ├── test_driver.pl └── thelp.pl └── vms_export_symbol_test.com /.ccls: -------------------------------------------------------------------------------- 1 | clang 2 | %h --include=makeint.h 3 | -DHAVE_CONFIG_H 4 | -Isrc 5 | -Ilib 6 | -DLIBDIR="/usr/local/lib" 7 | -DLOCALEDIR="/usr/local/share/locale" 8 | -DMAKE_MAINTAINER_MODE 9 | -pthread 10 | -isystem 11 | /usr/include/guile/2.0 12 | -Wall 13 | -Wextra 14 | -Werror 15 | -Wwrite-strings 16 | -Wshadow 17 | -Wdeclaration-after-statement 18 | -Wbad-function-cast 19 | -Wformat-security 20 | -Wtype-limits 21 | -Wunused-but-set-parameter 22 | -Wlogical-op 23 | -Wpointer-arith 24 | -Wignored-qualifiers 25 | -Wformat-signedness 26 | -Wduplicated-cond 27 | -Wno-address 28 | -Wno-string-compare 29 | -------------------------------------------------------------------------------- /.clangd: -------------------------------------------------------------------------------- 1 | CompileFlags: 2 | Add: [-xc, -DHAVE_CONFIG_H, -DMAKE_MAINTAINER_MODE, -DLIBDIR="/usr/local/lib", -DLOCALEDIR="/usr/local/share/locale", -I../src, -Isrc, -I../lib, -Ilib, -Wall, -Wextra, -Wwrite-strings, -Wshadow, -Wdeclaration-after-statement, -Wbad-function-cast, -Wformat-security, -Wtype-limits, -Wunused-but-set-parameter, -Wlogical-op, -Wpointer-arith, -Wignored-qualifiers, -Wformat-signedness, -Wduplicated-cond, -Wno-string-compare, -Wno-unused-includes] 3 | 4 | --- 5 | If: 6 | PathMatch: .*\.h 7 | CompileFlags: 8 | Add: [-xc-header, --include=makeint.h] 9 | 10 | --- 11 | If: 12 | PathMatch: .*/makeint\.h 13 | Diagnostics: 14 | UnusedIncludes: None 15 | -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ( 2 | (nil . ((bug-reference-bug-regexp . "\\(\\bSV[- ]\\([0-9]+\\)\\)") 3 | (bug-reference-url-format . "https://savannah.gnu.org/bugs/?%s") 4 | (ccls-initialization-options 5 | . (:index (:threads 6 6 | :initialBlacklist ["/make-[0-9]" "tests/work/" "/\\.deps" 7 | "/\\..*cache" "/\\.git"]))) 8 | (lsp-file-watch-ignored-directories 9 | . ("[/\\\\]\\.git$" 10 | "[/\\\\]\\..*cache$" 11 | ;; autotools content 12 | "[/\\\\]\\.deps$" 13 | "[/\\\\]autom4te\\.cache$" 14 | "[/\\\\]build-aux$" 15 | ;; make-specific content 16 | "[/\\\\]doc[/\\\\]manual$" 17 | "[/\\\\]tests[/\\\\]work$" 18 | "[/\\\\]make-[0-9]")) 19 | )) 20 | (c-mode . ((c-file-style . "gnu"))) 21 | ) 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Development artifacts 2 | ID 3 | TAGS 4 | GPATH 5 | GRTAGS 6 | GTAGS 7 | .*cache 8 | .*gdbinit 9 | .gdb_history 10 | .vscode 11 | *~ 12 | #* 13 | .#* 14 | *.diff 15 | *.patch 16 | *.orig 17 | *.rej 18 | 19 | # Configure artifacts 20 | /lib/ 21 | /m4/ 22 | ABOUT-NLS 23 | INSTALL 24 | Makefile 25 | Makefile.in 26 | Basic.mk 27 | aclocal.m4 28 | autom4te.cache/ 29 | build-aux/ 30 | config.cache 31 | config.h 32 | config.h.in 33 | config.log 34 | config.status 35 | configure 36 | /mk/Posix.mk 37 | stamp-* 38 | .dirstamp 39 | gnulib 40 | *.sed 41 | 42 | # Build artifacts 43 | .deps/ 44 | gmk-default.h 45 | loadavg 46 | make 47 | *.i 48 | *.o 49 | *.a 50 | *.exe 51 | *.dll.a 52 | *.obj 53 | *.lib 54 | *.pdb 55 | *.sbr 56 | 57 | # Windows build artifacts 58 | WinDebug/ 59 | WinRel/ 60 | GccDebug/ 61 | GccRel/ 62 | TccDebug/ 63 | TccRel/ 64 | 65 | # Test artifacts 66 | makeerror-* 67 | test-suite.log 68 | 69 | # Distribution artifacts 70 | .dep_segment 71 | .check-git-HEAD 72 | ChangeLog 73 | README 74 | build.cfg 75 | mkconfig.h 76 | make-[0-9]*/ 77 | make-[0-9]*.tar.* 78 | checkcfg.*.log 79 | -------------------------------------------------------------------------------- /ChangeLog.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mirror/make/c63a5bc6a2881d515bb3020ed477fcba08fb2f3d/ChangeLog.2 -------------------------------------------------------------------------------- /README.zOS: -------------------------------------------------------------------------------- 1 | -*-text-*- 2 | GNU Make has been ported to z/OS, tested on z/OS V2R4. 3 | 4 | 5 | PREREQUISITES 6 | ------------- 7 | Building GNU Make requires certain tools be installed on your z/OS system. 8 | These tools can be downloaded from: https://github.com/ZOSOpenTools 9 | For detailed instructions on how to set up these tools, visit 10 | https://zosopentools.github.io/meta/#/Guides/Pre-req 11 | 12 | You will need curl, tar, and gzip to download and unpack the GNU Make release 13 | package, but presumably you've already worked this out if you're reading this 14 | document! 15 | 16 | You will need the IBM C/C++ compiler. You can download a web deliverable 17 | add-on feature to your XL C/C++ compiler here: 18 | https://www-40.ibm.com/servers/resourcelink/svc00100.nsf/pages/xlCC++V241ForZOsV24 19 | 20 | Alternatively, you can install and manage C/C++ for Open Enterprise Languages 21 | on z/OS using RedHat OpenShift Container Platform and IBM Z and Cloud 22 | Modernization Stack. 23 | 24 | GNU Make has a dependency on the ZOSLIB library, which is documented here: 25 | https://zosopentools.github.io/meta/#/Guides/Zoslib. 26 | 27 | To obtain the latest release of zoslib, you can download it from here: 28 | https://github.com/ZOSOpenTools/zoslibport/releases. 29 | 30 | 31 | BUILDING 32 | -------- 33 | If you are trying to build from a checked-out Git workspace, see README.git. 34 | 35 | Before building GNU Make, you will need to ensure that the following 36 | environment variables are set, to turn on z/OS enhanced ASCII support: 37 | 38 | export _BPXK_AUTOCVT=ON 39 | export _CEE_RUNOPTS="$_CEE_RUNOPTS FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)" 40 | export _TAG_REDIR_ERR=txt 41 | export _TAG_REDIR_IN=txt 42 | export _TAG_REDIR_OUT=txt 43 | 44 | To ensure proper functioning of xlclang, set the following environment 45 | variables before building: 46 | 47 | export _CC_CCMODE=1 48 | export _C89_CCMODE=1 49 | export _CXX_CCMODE=1 50 | 51 | Set PATH_TO_ZOSLIB to the location of your zoslib installation; e.g.: 52 | 53 | PATH_TO_ZOSLIB=$HOME/zopen/prod/zoslib 54 | 55 | Invoke ./configure as follows: 56 | 57 | ./configure \ 58 | CC=xlclang \ 59 | CPPFLAGS="-DNSIG=42 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE -D_OPEN_SYS_FILE_EXT=1 -D_AE_BIMODAL=1 -D_ENHANCED_ASCII_EXT=0xFFFFFFF -DZOSLIB_OVERRIDE_CLIB=1" \ 60 | CFLAGS="-qascii -std=gnu11 -qnocsect -qenum=int -I$PATH_TO_ZOSLIB/include" \ 61 | LDFLAGS="-L$PATH_TO_ZOSLIB/lib" \ 62 | LIBS="-lzoslib $PATH_TO_ZOSLIB/lib/CXXRT64.x" 63 | 64 | If you have an instance of make already available you can build with: 65 | 66 | make 67 | 68 | If not, you can build with: 69 | 70 | ./build.sh 71 | 72 | 73 | TESTING 74 | ------- 75 | To run the regression tests you'll need to install Perl and enable it. 76 | Then you can run: 77 | 78 | ./make check 79 | 80 | 81 | INSTALLING 82 | ---------- 83 | Copy the "make" program to wherever you want it to be installed, on your PATH. 84 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Convenience script for regenerating all autogeneratable files that are 3 | # omitted from the version control repository. In particular, this script 4 | # also regenerates all aclocal.m4, config.h.in, Makefile.in, configure files 5 | # with new versions of autoconf or automake. 6 | 7 | # Copyright (C) 2003-2024 Free Software Foundation, Inc. 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 3 of the License, or 12 | # (at your option) 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 | # Originally written by Paul Eggert. The canonical version of this 23 | # script is maintained as top/autogen.sh in gnulib. However, to be 24 | # useful to your package, you should place a copy of it under version 25 | # control in the top-level directory of your package. The intent is 26 | # that all customization can be done with a bootstrap.conf file also 27 | # maintained in your version control; gnulib comes with a template 28 | # build-aux/bootstrap.conf to get you started. 29 | # 30 | # Alternatively, you can use an autogen.sh script that is specific 31 | # to your package. 32 | 33 | me="$0" 34 | medir=`dirname "$me"` 35 | 36 | # Read the function library and the configuration. 37 | . "$medir"/bootstrap-funclib.sh 38 | 39 | autogen "$@" 40 | -------------------------------------------------------------------------------- /autopull.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Convenience script for fetching auxiliary files that are omitted from 3 | # the version control repository of this package. 4 | 5 | # Copyright (C) 2003-2024 Free Software Foundation, Inc. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | 20 | # Originally written by Paul Eggert. The canonical version of this 21 | # script is maintained as top/autopull.sh in gnulib. However, to be 22 | # useful to your package, you should place a copy of it under version 23 | # control in the top-level directory of your package. The intent is 24 | # that all customization can be done with a bootstrap.conf file also 25 | # maintained in your version control; gnulib comes with a template 26 | # build-aux/bootstrap.conf to get you started. 27 | # 28 | # Alternatively, you can use an autopull.sh script that is specific 29 | # to your package. 30 | 31 | me="$0" 32 | medir=`dirname "$me"` 33 | 34 | # Read the function library and the configuration. 35 | . "$medir"/bootstrap-funclib.sh 36 | 37 | autopull "$@" 38 | -------------------------------------------------------------------------------- /bootstrap.conf: -------------------------------------------------------------------------------- 1 | # Bootstrap configuration. -*-shell-script-*- 2 | 3 | # Copyright (C) 2018-2024 Free Software Foundation, Inc. 4 | 5 | # GNU Make is free software: you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 3 of the License, or (at your option) 8 | # any later version. 9 | 10 | # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | # details. 14 | 15 | # You should have received a copy of the GNU General Public License along with 16 | # this program. If not, see . 17 | 18 | # Allow bootstrap to know that this is not a package 19 | checkout_only_file=README.git 20 | 21 | # Choose a specific version of gnulib, when checking out 22 | GNULIB_REVISION=stable-202401 23 | 24 | # Always copy files rather than symlink 25 | copy=true 26 | 27 | # Additional xgettext options to use. Use "\\\newline" to break lines. 28 | # Ensure that all our magical output macros are correctly marked as 29 | # C (printf) format strings. 30 | XGETTEXT_OPTIONS='\\\ 31 | --from-code=UTF-8\\\ 32 | --flag=_:1:pass-c-format\\\ 33 | --flag=N_:1:pass-c-format\\\ 34 | --flag=DB:2:c-format --flag=DBF:2:c-format --flag=DBS:2:c-format\\\ 35 | --flag=O:3:c-format --flag=OSN:3:c-format --flag=ONS:3:c-format\\\ 36 | --flag=OS:3:c-format --flag=OSS:3:c-format --flag=OSSS:3:c-format\\\ 37 | --flag=ON:3:c-format --flag=ONN:3:c-format\\\ 38 | ' 39 | 40 | # We manage our own .gitignore files 41 | vc_ignore= 42 | 43 | # Build prerequisites 44 | buildreq="\ 45 | autoconf 2.69 46 | automake 1.16.1 47 | " 48 | 49 | gnulib_name=libgnu 50 | gnulib_files="doc/make-stds.texi m4/sig_atomic_t.m4" 51 | 52 | # Using the full strtoll module pulls in a lot of stuff. But, it's pretty 53 | # simple to use just the base source file, so pull that. We'll use it in 54 | # src/misc.c if strtoll() is not found. 55 | gnulib_files="$gnulib_files lib/strtol.c" 56 | 57 | gnulib_modules="\ 58 | alloca 59 | fdl 60 | findprog-in 61 | getloadavg 62 | host-cpu-c-abi 63 | largefile 64 | make-glob 65 | make-macros" 66 | -------------------------------------------------------------------------------- /build.cfg.in: -------------------------------------------------------------------------------- 1 | # Configuration for building GNU Make in the absence of any 'make' program. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1993-2024 Free Software Foundation, Inc. 5 | # This file is part of GNU Make. 6 | # 7 | # GNU Make is free software; you can redistribute it and/or modify it under 8 | # the terms of the GNU General Public License as published by the Free Software 9 | # Foundation; either version 3 of the License, or (at your option) any later 10 | # version. 11 | # 12 | # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 | # details. 16 | # 17 | # You should have received a copy of the GNU General Public License along with 18 | # this program. If not, see . 19 | 20 | # See Makefile.in for comments describing these variables. 21 | 22 | top_srcdir='@top_srcdir@' 23 | 24 | prefix='@prefix@' 25 | exec_prefix=`eval echo @exec_prefix@` 26 | 27 | CC='@CC@' 28 | AR='@AR@' 29 | CFLAGS='@CFLAGS@ @GUILE_CFLAGS@' 30 | CPPFLAGS='@CPPFLAGS@' 31 | DEFS='@DEFS@' 32 | ARFLAGS='@ARFLAGS@' 33 | LDFLAGS='@AM_LDFLAGS@ @LDFLAGS@' 34 | ALLOCA='@ALLOCA@' 35 | LOADLIBES='@LIBS@ @GUILE_LIBS@ @LIBINTL@' 36 | REMOTE='@REMOTE@' 37 | OBJEXT='@OBJEXT@' 38 | EXEEXT='@EXEEXT@' 39 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | manual/ 2 | make.t2d/ 3 | make.t2p/ 4 | gendocs_template 5 | fdl.texi 6 | make-stds.texi 7 | stamp-vti 8 | version.texi 9 | make.info* 10 | make*.html 11 | make.aux 12 | make.cp 13 | make.cps 14 | make.dvi 15 | make.fn 16 | make.fns 17 | make.ky 18 | make.log 19 | make.pdf 20 | make.pg 21 | make.ps 22 | make.toc 23 | make.tp 24 | make.vr 25 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | # -*-Makefile-*-, or close enough 2 | # Copyright (C) 2000-2024 Free Software Foundation, Inc. 3 | # This file is part of GNU Make. 4 | # 5 | # GNU Make is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free Software 7 | # Foundation; either version 3 of the License, or (at your option) any later 8 | # version. 9 | # 10 | # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | # details. 14 | # 15 | # You should have received a copy of the GNU General Public License along with 16 | # this program. If not, see . 17 | 18 | TEXI2HTML = texi2html 19 | TEXI2HTML_FLAGS = -split_chapter 20 | 21 | info_TEXINFOS = make.texi 22 | make_TEXINFOS = fdl.texi make-stds.texi 23 | 24 | CLEANFILES = make*.html 25 | -------------------------------------------------------------------------------- /gl/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | #* 3 | .#* 4 | .*cache 5 | *.diff 6 | *.patch 7 | *.orig 8 | *.rej 9 | *.out 10 | *.log 11 | -------------------------------------------------------------------------------- /gl/README: -------------------------------------------------------------------------------- 1 | 04 July 2022 -*-text-*- 2 | 3 | The gnulib project provides a fantastic array of modules that can support both 4 | POSIX and also extended features for GNU software. 5 | 6 | Unfortunately using it in GNU make is problematic: GNU make is a foundational 7 | utility (if you don't have a "make" program you pretty much can't build any 8 | software), one of our goals in GNU make is to provide scripts (e.g., 9 | "build.sh") that will build GNU make without needing an instance of make. 10 | 11 | Instead of running "./configure && make", you should be able to run 12 | "./configure && ./build.sh" and get a build of GNU make as a result. 13 | 14 | However, more and more gnulib modules are relying not on M4 macros and 15 | the configure script to manage their configuration, but in addition special 16 | makefile recipes that perform various post-configure operations. Since we 17 | don't have an instance of "make", we cannot use these modules as-is. 18 | 19 | There are various options we could choose for solving this: 20 | 21 | - Avoid gnulib modules and write our own portability interfaces. 22 | I really am not too excited about this. 23 | 24 | - Give up on "build.sh" and require users to already have "make". 25 | The argument here is that you must already have a compiler, and it couldn't 26 | have been built without "make", and/or if you build it with a cross-compiler 27 | then you should be able to use that cross-development environment to build 28 | GNU make as well. 29 | 30 | - Provide a "mini-make" with just enough functionality to support the gnulib 31 | makefiles but no extra features, that didn't need any complex gnulib 32 | modules. As with the first option, I'm not too excited about this. 33 | 34 | Although arguably the second option is the sane one, I'm not really excited 35 | about any of them for the time being. So I elected to try something between 36 | the first and second options: 37 | 38 | The gnulib-port Git branch will contain unmodified copies of gnulib modules 39 | that we want to use with GNU make. From there, we merge them into the main 40 | Git branch then modify / simplify them to avoid unnecessary extra modules and 41 | allow "build.sh" to be used. 42 | 43 | By keeping the unmodified versions on the gnulib-port branch, we enable Git 44 | merge facilities to merge in new versions as follows: 45 | 46 | * Check out the gnulib-port branch 47 | 48 | * Update its content with any updates to gnulib modules. Something like: 49 | ( 50 | cd gl \ 51 | && find */. -type f \ 52 | | while read fn; do 53 | test -f "$GNULIB_SRCDIR/$fn" && cp "$GNULIB_SRCDIR/$fn" "$fn" 54 | done 55 | ) 56 | 57 | * Commit the changes _without modification_ 58 | 59 | * Check out the main branch 60 | 61 | * Run "git merge --no-ff gnulib-port" to merge in the changes 62 | 63 | * Resolve any conflicts and commit the merge. 64 | 65 | -- pds 66 | -------------------------------------------------------------------------------- /gl/lib/fnmatch.in.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2023 Free Software 2 | Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public License 16 | along with this library; see the file COPYING.LIB. If not, write to the Free 17 | Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 18 | USA. */ 19 | 20 | #ifndef _FNMATCH_H 21 | #define _FNMATCH_H 1 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* We #undef these before defining them because some losing systems 28 | (HP-UX A.08.07 for example) define these in . */ 29 | #undef FNM_PATHNAME 30 | #undef FNM_NOESCAPE 31 | #undef FNM_PERIOD 32 | 33 | /* Bits set in the FLAGS argument to `fnmatch'. */ 34 | #define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ 35 | #define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ 36 | #define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ 37 | 38 | #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE 39 | # define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ 40 | # define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ 41 | # define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ 42 | #endif 43 | 44 | /* Value returned by `fnmatch' if STRING does not match PATTERN. */ 45 | #define FNM_NOMATCH 1 46 | 47 | /* This value is returned if the implementation does not support 48 | `fnmatch'. Since this is not the case here it will never be 49 | returned but the conformance test suites still require the symbol 50 | to be defined. */ 51 | #ifdef _XOPEN_SOURCE 52 | # define FNM_NOSYS (-1) 53 | #endif 54 | 55 | /* Match NAME against the filename pattern PATTERN, 56 | returning zero if it matches, FNM_NOMATCH if not. */ 57 | extern int fnmatch (const char *pattern, const char *name, int flags); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* fnmatch.h */ 64 | -------------------------------------------------------------------------------- /gl/m4/dospaths.m4: -------------------------------------------------------------------------------- 1 | # Test if the system uses DOS-style pathnames (drive specs and backslashes) 2 | # By Paul Smith . Based on dos.m4 by Jim Meyering. 3 | # 4 | # Copyright (C) 1993-2024 Free Software Foundation, Inc. 5 | # This file is part of GNU Make. 6 | # 7 | # GNU Make is free software; you can redistribute it and/or modify it under 8 | # the terms of the GNU General Public License as published by the Free Software 9 | # Foundation; either version 3 of the License, or (at your option) any later 10 | # version. 11 | # 12 | # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 | # details. 16 | # 17 | # You should have received a copy of the GNU General Public License along with 18 | # this program. If not, see . 19 | 20 | AC_DEFUN([pds_AC_DOS_PATHS], [ 21 | AC_CACHE_CHECK([whether system uses MSDOS-style paths], [ac_cv_dos_paths], [ 22 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 23 | #if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __EMX__ && !defined __MSYS__ && !defined __CYGWIN__ 24 | neither MSDOS nor Windows nor OS2 25 | #endif 26 | ]])], 27 | [ac_cv_dos_paths=yes], 28 | [ac_cv_dos_paths=no])]) 29 | 30 | AS_IF([test x"$ac_cv_dos_paths" = xyes], 31 | [ AC_DEFINE_UNQUOTED([HAVE_DOS_PATHS], 1, 32 | [Define if the system uses DOS-style pathnames.])]) 33 | ]) 34 | -------------------------------------------------------------------------------- /gl/modules/concat-filename: -------------------------------------------------------------------------------- 1 | Description: 2 | Construct a full filename by concatenating a directory name, a relative 3 | filename, and a suffix. 4 | 5 | Files: 6 | lib/concat-filename.h 7 | lib/concat-filename.c 8 | 9 | Depends-on: 10 | filename 11 | 12 | configure.ac: 13 | 14 | Makefile.am: 15 | lib_SOURCES += concat-filename.c 16 | 17 | Include: 18 | "concat-filename.h" 19 | 20 | License: 21 | LGPLv2+ 22 | 23 | Maintainer: 24 | all 25 | -------------------------------------------------------------------------------- /gl/modules/findprog-in: -------------------------------------------------------------------------------- 1 | Description: 2 | Locating a program in a given path. 3 | 4 | Files: 5 | lib/findprog.h 6 | lib/findprog-in.c 7 | m4/findprog-in.m4 8 | m4/eaccess.m4 9 | 10 | Depends-on: 11 | stdbool 12 | filename 13 | concat-filename 14 | 15 | configure.ac: 16 | gl_FINDPROG_IN 17 | 18 | Makefile.am: 19 | lib_SOURCES += findprog.h findprog-in.c 20 | 21 | Include: 22 | "findprog.h" 23 | 24 | License: 25 | LGPLv2+ 26 | 27 | Maintainer: 28 | all 29 | -------------------------------------------------------------------------------- /gl/modules/getloadavg: -------------------------------------------------------------------------------- 1 | Description: 2 | Return the current system load averages. 3 | 4 | Files: 5 | lib/getloadavg.c 6 | m4/getloadavg.m4 7 | 8 | Depends-on: 9 | snippet/warn-on-use 10 | extensions 11 | intprops [test $HAVE_GETLOADAVG = 0] 12 | stdbool [test $HAVE_GETLOADAVG = 0] 13 | 14 | configure.ac: 15 | gl_STDLIB_H 16 | gl_STDLIB_H_REQUIRE_DEFAULTS 17 | AC_REQUIRE([AC_CANONICAL_HOST]) 18 | gl_GETLOADAVG 19 | gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG], [test $HAVE_GETLOADAVG = 0]) 20 | AM_COND_IF([GL_COND_OBJ_GETLOADAVG], [ 21 | gl_PREREQ_GETLOADAVG 22 | ]) 23 | gl_STDLIB_MODULE_INDICATOR([getloadavg]) 24 | 25 | Makefile.am: 26 | if GL_COND_OBJ_GETLOADAVG 27 | lib_SOURCES += getloadavg.c 28 | endif 29 | 30 | Include: 31 | 32 | 33 | Link: 34 | $(GETLOADAVG_LIBS) 35 | 36 | License: 37 | GPL 38 | 39 | Maintainer: 40 | Jim Meyering 41 | -------------------------------------------------------------------------------- /gl/modules/make-macros: -------------------------------------------------------------------------------- 1 | Description: 2 | Install m4 macros for GNU Make. 3 | 4 | Files: 5 | m4/acinclude.m4 6 | m4/dospaths.m4 7 | 8 | configure.ac: 9 | # Check for DOS-style pathnames. 10 | pds_AC_DOS_PATHS 11 | 12 | License: 13 | GPLv3+ 14 | 15 | Maintainer: 16 | gnumake 17 | -------------------------------------------------------------------------------- /mk/Posix.mk.in: -------------------------------------------------------------------------------- 1 | # GNU -*-Makefile-*- to build GNU Make on POSIX systems 2 | # 3 | # POSIX overrides for use with Basic.mk. 4 | # 5 | # Copyright (C) 2017-2024 Free Software Foundation, Inc. 6 | # This file is part of GNU Make. 7 | # 8 | # GNU Make is free software; you can redistribute it and/or modify it under 9 | # the terms of the GNU General Public License as published by the Free Software 10 | # Foundation; either version 3 of the License, or (at your option) any later 11 | # version. 12 | # 13 | # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 14 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 | # details. 17 | # 18 | # You should have received a copy of the GNU General Public License along with 19 | # this program. If not, see . 20 | 21 | # Very little is needed here since the default Basic.mk assumes POSIX 22 | 23 | prog_SOURCES += $(src)/posixos.c 24 | 25 | extra_CPPFLAGS += @GUILE_CFLAGS@ 26 | extra_LDFLAGS += @AM_LDFLAGS@ 27 | LDLIBS += @LIBOBJS@ @gl_LIBOBS@ @ALLOCA@ 28 | LDLIBS += @GUILE_LIBS@ @GETLOADAVG_LIBS@ @LIBINTL@ @LIBS@ 29 | -------------------------------------------------------------------------------- /mk/VMS.mk: -------------------------------------------------------------------------------- 1 | # GNU -*-Makefile-*- to build GNU Make on VMS 2 | # 3 | # VMS overrides for use with Basic.mk. 4 | # 5 | # Copyright (C) 2017-2024 Free Software Foundation, Inc. 6 | # This file is part of GNU Make. 7 | # 8 | # GNU Make is free software; you can redistribute it and/or modify it under 9 | # the terms of the GNU General Public License as published by the Free Software 10 | # Foundation; either version 3 of the License, or (at your option) any later 11 | # version. 12 | # 13 | # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 14 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 | # details. 17 | # 18 | # You should have received a copy of the GNU General Public License along with 19 | # this program. If not, see . 20 | 21 | src = [.src] 22 | lib = [.lib] 23 | SRCDIR = [] 24 | 25 | OBJEXT = .obj 26 | EXEEXT = .exe 27 | 28 | e = 29 | s = $e $e 30 | c = , 31 | 32 | defs = HAVE_CONFIG_H 33 | 34 | ifeq ($(CC),cc) 35 | defs += VMS unlink=remove allocated_variable_expand_for_file=alloc_var_expand_for_file 36 | else 37 | defs += GCC_IS_NATIVE 38 | ifeq ($(ARCH),VAX) 39 | defs += VAX 40 | endif 41 | endif 42 | 43 | extra_CPPFLAGS = /define=($(subst $s,$c,$(patsubst %,"%",$(defs)))) 44 | 45 | cinclude = /nested=none/include=($(src),$(lib)) 46 | ifeq ($(CC),cc) 47 | cprefix = /prefix=(all,except=(glob,globfree)) 48 | cwarn = /standard=relaxed/warn=(disable=questcompare) 49 | endif 50 | 51 | extra_CFLAGS = $(cinclude)$(cprefix)$(cwarn) 52 | 53 | #extra_LDFLAGS = /deb 54 | extra_LDFLAGS = 55 | 56 | # If your system needs extra libraries loaded in, define them here. 57 | # System V probably need -lPW for alloca. 58 | # if on vax, uncomment the following line 59 | #LDLIBS = ,c.opt/opt 60 | ifeq ($(CC),cc) 61 | #LDLIBS =,sys$$library:vaxcrtl.olb/lib 62 | else 63 | LDLIBS =,gnu_cc_library:libgcc.olb/lib 64 | endif 65 | 66 | # If your system doesn't have alloca, or the one provided is bad, 67 | # uncomment this 68 | #ALLOCA = $(alloca_SOURCES) 69 | 70 | # If your system doesn't have alloca.h, or the one provided is bad, 71 | # uncomment this 72 | #BUILT_SOURCES += $(lib)alloca.h 73 | 74 | prog_SOURCES += $(ALLOCA) $(glob_SOURCES) $(vms_SOURCES) 75 | 76 | BUILT_SOURCES += $(lib)fnmatch.h $(lib)glob.h 77 | 78 | COMPILE.cmd = $(CC) $(extra_CFLAGS)$(CFLAGS)/obj=$@ $(extra_CPPFLAGS)$(CPPFLAGS) $1 79 | 80 | LINK.cmd = $(LD)$(extra_LDFLAGS)$(LDFLAGS)/exe=$@ $(subst $s,$c,$1)$(LDLIBS) 81 | 82 | # Don't know how to do this 83 | CHECK.cmd = 84 | 85 | MKDIR.cmd = create/dir $1 86 | RM.cmd = delete $1 87 | CP.cmd = copy $1 $2 88 | 89 | define CLEANSPACE 90 | -purge [...] 91 | -delete $(PROG); 92 | -delete $(src)*.$(OBJEXT); 93 | endef 94 | 95 | 96 | $(OUTDIR)$(src)config.h: $(SRCDIR)$(src)config.h-vms 97 | $(call CP.cmd,$<,$@) 98 | -------------------------------------------------------------------------------- /mk/msdosdjgpp.mk: -------------------------------------------------------------------------------- 1 | # GNU -*-Makefile-*- to build GNU Make on MS-DOS with DJGPP 2 | # 3 | # MS-DOS overrides for use with Basic.mk. 4 | # 5 | # Copyright (C) 2017-2024 Free Software Foundation, Inc. 6 | # This file is part of GNU Make. 7 | # 8 | # GNU Make is free software; you can redistribute it and/or modify it under 9 | # the terms of the GNU General Public License as published by the Free Software 10 | # Foundation; either version 3 of the License, or (at your option) any later 11 | # version. 12 | # 13 | # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 14 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 | # details. 17 | # 18 | # You should have received a copy of the GNU General Public License along with 19 | # this program. If not, see . 20 | 21 | OBJEXT = o 22 | EXEEXT = .exe 23 | 24 | CC = gcc 25 | 26 | # Translate a POSIX path into a Windows path. Don't bother with drives. 27 | # Used only inside recipes, with DOS/CMD tools that require it. 28 | P2W = $(subst /,\,$1) 29 | 30 | prog_SOURCES += $(loadavg_SOURCES) $(glob_SOURCES) 31 | 32 | BUILT_SOURCES += $(lib)alloca.h $(lib)fnmatch.h $(lib)glob.h 33 | 34 | INCLUDEDIR = c:/djgpp/include 35 | LIBDIR = c:/djgpp/lib 36 | LOCALEDIR = c:/djgpp/share 37 | 38 | MKDIR.cmd = command.com /c mkdir $(call P2W,$1) 39 | RM.cmd = command.com /c del /F /Q $(call P2W,$1) 40 | CP.cmd = command.com /c copy /Y $(call P2W,$1 $2) 41 | 42 | $(OUTDIR)src/config.h: $(SRCDIR)/src/configh.dos 43 | $(call CP.cmd,$<,$@) 44 | -------------------------------------------------------------------------------- /po/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !LINGUAS 4 | !POTFILES.in 5 | -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- 1 | be 2 | bg 3 | cs 4 | da 5 | de 6 | es 7 | fi 8 | fr 9 | ga 10 | gl 11 | he 12 | hr 13 | id 14 | it 15 | ja 16 | ka 17 | ko 18 | lt 19 | nl 20 | pl 21 | pt 22 | pt_BR 23 | ro 24 | ru 25 | sr 26 | sv 27 | tr 28 | uk 29 | vi 30 | zh_CN 31 | zh_TW 32 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | # List of source files containing translatable strings. 2 | # Copyright (C) 2000-2024 Free Software Foundation, Inc. 3 | # This file is part of GNU Make. 4 | # 5 | # GNU Make is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free Software 7 | # Foundation; either version 3 of the License, or (at your option) any later 8 | # version. 9 | # 10 | # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | # details. 14 | # 15 | # You should have received a copy of the GNU General Public License along with 16 | # this program. If not, see . 17 | 18 | src/ar.c 19 | src/arscan.c 20 | src/commands.c 21 | src/dir.c 22 | src/expand.c 23 | src/file.c 24 | src/function.c 25 | src/getopt.c 26 | src/guile.c 27 | src/hash.c 28 | src/implicit.c 29 | src/job.c 30 | src/load.c 31 | src/main.c 32 | src/misc.c 33 | src/output.c 34 | src/posixos.c 35 | src/read.c 36 | src/remake.c 37 | src/remote-cstms.c 38 | src/rule.c 39 | src/shuffle.c 40 | src/signame.c 41 | src/strcache.c 42 | src/variable.c 43 | src/vmsfunctions.c 44 | src/vmsjobs.c 45 | src/vpath.c 46 | src/warning.c 47 | src/warning.h 48 | src/w32/w32os.c 49 | -------------------------------------------------------------------------------- /prepare_vms.com: -------------------------------------------------------------------------------- 1 | $! 2 | $! prepare_vms.com - Build config.h-vms from master on VMS. 3 | $! 4 | $! This is used for building off the master instead of a release tarball. 5 | $! 6 | $! 7 | $! First try ODS-5, Pathworks V6 or UNZIP name. 8 | $! 9 | $ config_template = f$search("sys$disk:[.src]mkconfig*h.in") 10 | $ if config_template .eqs. "" 11 | $ then 12 | $! 13 | $! Try NFS, VMStar, or Pathworks V5 ODS-2 encoded name. 14 | $! 15 | $ config_template = f$search("sys$disk:[.src]mkconfig.h*in") 16 | $ if config_template .eqs. "" 17 | $ then 18 | $ write sys$output "Could not find mkconfig.h.in!" 19 | $ exit 44 20 | $ endif 21 | $ endif 22 | $ config_template_file = f$parse(config_template,,,"name") 23 | $ config_template_type = f$parse(config_template,,,"type") 24 | $ config_template = "sys$disk:[.src]" + config_template_file + config_template_type 25 | $! 26 | $! 27 | $! Pull the version from configure.ac 28 | $! 29 | $ open/read ac_file sys$disk:[]configure.ac 30 | $ac_read_loop: 31 | $ read ac_file/end=ac_read_loop_end line_in 32 | $ key = f$extract(0, 7, line_in) 33 | $ if key .nes. "AC_INIT" then goto ac_read_loop 34 | $ package = f$element (1,"[",line_in) 35 | $ package = f$element (0,"]",package) 36 | $ version = f$element (2,"[",line_in) 37 | $ version = f$element (0,"]",version) 38 | $ac_read_loop_end: 39 | $ close ac_file 40 | $! 41 | $ if (version .eqs. "") 42 | $ then 43 | $ write sys$output "Unable to determine version!" 44 | $ exit 44 45 | $ endif 46 | $! 47 | $! 48 | $ outfile = "sys$disk:[.src]mkconfig.h" 49 | $! 50 | $! Note the pipe command is close to the length of 255, which is the 51 | $! maximum token length prior to VMS V8.2: 52 | $! %DCL-W-TKNOVF, command element is too long - shorten 53 | $! PDS: Blown out; someone else will have to figure this out 54 | $ pipe (write sys$output "sub,@PACKAGE@,make,WHOLE/NOTYPE" ;- 55 | write sys$output "sub,@PACKAGE_BUGREPORT@,bug-make@gnu.org,WHOLE/NOTYPE" ;- 56 | write sys$output "sub,@PACKAGE_NAME@,GNU Make,WHOLE/NOTYPE" ;- 57 | write sys$output "sub,@PACKAGE_TARNAME@,make,WHOLE/NOTYPE" ;- 58 | write sys$output "sub,@PACKAGE_URL@,https://www.gnu.org/software/make/,WHOLE/NOTYPE" ;- 59 | write sys$output "sub,@PACKAGE_VERSION@,''version',WHOLE/NOTYPE" ;- 60 | write sys$output "exit") |- 61 | edit/edt 'config_template'/out='outfile'/command=sys$pipe >nla0: 62 | $! 63 | $ write sys$output "GNU Make version: ", version, " prepared for VMS" 64 | -------------------------------------------------------------------------------- /scripts/copyright-update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (C) 2014-2024 Free Software Foundation, Inc. 4 | # This file is part of GNU Make. 5 | # 6 | # Update GNU Make copyrights using gnulib update-copyright 7 | 8 | EXCLUDE='^\(\.[a-z].*\|.*/\.[a-z].*\|.*COPYING\|src/hash\.[ch]\|ChangeLog.*\|.*/ChangeLog.*\|INSTALL\|doc/make\.texi\|bootstrap\)$' 9 | 10 | update=${UPDATE_COPYRIGHT:-${GNULIB_SRCDIR:-../../gnulib}/build-aux/update-copyright} 11 | 12 | die () { echo "$*"; exit 1; } 13 | 14 | getfiles () { 15 | git ls-files | grep -v "$EXCLUDE" 16 | } 17 | 18 | run () { 19 | cmd=$(command -v "$update") || die "Cannot locate update-copyright ($update)" 20 | test -x "$cmd" || die "Cannot locate update-copyright ($update)" 21 | 22 | force=false 23 | 24 | case $1 in 25 | (-v) getfiles | sort; exit 0 ;; 26 | (-f) force=true ;; 27 | (--) : ;; 28 | (-*) echo "usage: $0 [-v]"; exit 1 ;; 29 | esac 30 | 31 | if $force; then 32 | : just do it 33 | elif test ! -f src/makeint.h; then 34 | die "Run in the root of the GNU Make workspace" 35 | elif test -f configure; then 36 | die "Run in a clean workspace (git clean -fdX)" 37 | fi 38 | 39 | # We use intervals 40 | export UPDATE_COPYRIGHT_USE_INTERVALS=1 41 | 42 | "$cmd" $(getfiles) 43 | 44 | echo "*** Update doc/make.texi copyright by hand!" 45 | echo "*** Update src/main.c:print_version() copyright by hand!" 46 | 47 | exit 0 48 | } 49 | 50 | run "$@" 51 | 52 | # GNU Make is free software; you can redistribute it and/or modify it under 53 | # the terms of the GNU General Public License as published by the Free Software 54 | # Foundation; either version 3 of the License, or (at your option) any later 55 | # version. 56 | # 57 | # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 58 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 59 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 60 | # details. 61 | # 62 | # You should have received a copy of the GNU General Public License along with 63 | # this program. If not, see . 64 | -------------------------------------------------------------------------------- /src/commands.h: -------------------------------------------------------------------------------- 1 | /* Definition of data structures describing shell commands for GNU Make. 2 | Copyright (C) 1988-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | /* Structure that gives the commands to make a file 18 | and information about where these commands came from. */ 19 | 20 | struct commands 21 | { 22 | floc fileinfo; /* Where commands were defined. */ 23 | char *commands; /* Commands text. */ 24 | char **command_lines; /* Commands chopped up into lines. */ 25 | unsigned char *lines_flags; /* One set of flag bits for each line. */ 26 | unsigned short ncommand_lines;/* Number of command lines. */ 27 | char recipe_prefix; /* Recipe prefix for this command set. */ 28 | unsigned int any_recurse:1; /* Nonzero if any 'lines_flags' elt has */ 29 | /* the COMMANDS_RECURSE bit set. */ 30 | }; 31 | 32 | /* Bits in 'lines_flags'. */ 33 | #define COMMANDS_RECURSE 1 /* Recurses: + or $(MAKE). */ 34 | #define COMMANDS_SILENT 2 /* Silent: @. */ 35 | #define COMMANDS_NOERROR 4 /* No errors: -. */ 36 | 37 | struct file; 38 | struct child; 39 | 40 | void fatal_error_signal (int sig); 41 | void execute_file_commands (struct file *file); 42 | void print_commands (const struct commands *cmds); 43 | void delete_child_targets (struct child *child); 44 | void chop_commands (struct commands *cmds); 45 | void set_file_variables (struct file *file, const char *stem); 46 | -------------------------------------------------------------------------------- /src/config.h-vms: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mirror/make/c63a5bc6a2881d515bb3020ed477fcba08fb2f3d/src/config.h-vms -------------------------------------------------------------------------------- /src/debug.h: -------------------------------------------------------------------------------- 1 | /* Debugging macros and interface. 2 | Copyright (C) 1999-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #define DB_NONE (0x000) 18 | #define DB_BASIC (0x001) 19 | #define DB_VERBOSE (0x002) 20 | #define DB_JOBS (0x004) 21 | #define DB_IMPLICIT (0x008) 22 | #define DB_PRINT (0x010) 23 | #define DB_WHY (0x020) 24 | #define DB_MAKEFILES (0x100) 25 | 26 | #define DB_ALL (0xfff) 27 | 28 | extern int db_level; 29 | 30 | #define ISDB(_l) ((_l)&db_level) 31 | 32 | /* When adding macros to this list be sure to update the value of 33 | XGETTEXT_OPTIONS in the po/Makevars file. */ 34 | #define DBS(_l,_x) do{ if(ISDB(_l)) {print_spaces (depth); \ 35 | printf _x; fflush (stdout);} }while(0) 36 | 37 | #define DBF(_l,_x) do{ if(ISDB(_l)) {print_spaces (depth); \ 38 | printf (_x, file->name); \ 39 | fflush (stdout);} }while(0) 40 | 41 | #define DB(_l,_x) do{ if(ISDB(_l)) {printf _x; fflush (stdout);} }while(0) 42 | -------------------------------------------------------------------------------- /src/gettext.h: -------------------------------------------------------------------------------- 1 | /* Convenience header for conditional use of GNU . 2 | Copyright (C) 1995-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #ifndef _LIBGETTEXT_H 18 | #define _LIBGETTEXT_H 1 19 | 20 | /* NLS can be disabled through the configure --disable-nls option. */ 21 | #if ENABLE_NLS 22 | 23 | /* Get declarations of GNU message catalog functions. */ 24 | # include 25 | 26 | #else 27 | 28 | /* Disabled NLS. 29 | The casts to 'const char *' serve the purpose of producing warnings 30 | for invalid uses of the value returned from these functions. 31 | On pre-ANSI systems without 'const', the config.h file is supposed to 32 | contain "#define const". */ 33 | # define gettext(Msgid) ((const char *) (Msgid)) 34 | # define dgettext(Domainname, Msgid) ((const char *) (Msgid)) 35 | # define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) 36 | # define ngettext(Msgid1, Msgid2, N) \ 37 | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) 38 | # define dngettext(Domainname, Msgid1, Msgid2, N) \ 39 | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) 40 | # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ 41 | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) 42 | # define textdomain(Domainname) ((const char *) (Domainname)) 43 | # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) 44 | # define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) 45 | 46 | #endif 47 | 48 | /* A pseudo function call that serves as a marker for the automated 49 | extraction of messages, but does not call gettext(). The run-time 50 | translation is done at a different place in the code. 51 | The argument, String, should be a literal string. Concatenated strings 52 | and other string expressions won't work. 53 | The macro's expansion is not parenthesized, so that it is suitable as 54 | initializer for static 'char[]' or 'const char[]' variables. */ 55 | #define gettext_noop(String) String 56 | 57 | #endif /* _LIBGETTEXT_H */ 58 | -------------------------------------------------------------------------------- /src/gmk-default.scm: -------------------------------------------------------------------------------- 1 | ;; Contents of the (GNU Make) Guile module 2 | ;; Copyright (C) 2011-2024 Free Software Foundation, Inc. 3 | ;; This file is part of GNU Make. 4 | ;; 5 | ;; GNU Make is free software; you can redistribute it and/or modify it under 6 | ;; the terms of the GNU General Public License as published by the Free 7 | ;; Software Foundation; either version 3 of the License, or (at your option) 8 | ;; any later version. 9 | ;; 10 | ;; GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | ;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | ;; details. 14 | ;; 15 | ;; You should have received a copy of the GNU General Public License along 16 | ;; with this program. If not, see . 17 | 18 | (define (to-string-maybe x) 19 | (cond 20 | ;; In GNU Make, "false" is the empty string 21 | ((or (not x) 22 | (unspecified? x) 23 | (variable? x) 24 | (null? x) 25 | (and (string? x) (string-null? x))) 26 | #f) 27 | ;; We want something not false... not sure about this 28 | ((eq? x #t) "#t") 29 | ;; Basics 30 | ((or (symbol? x) (number? x)) 31 | (object->string x)) 32 | ((char? x) 33 | (string x)) 34 | ;; Printable string (no special characters) 35 | ((and (string? x) (string-every char-set:printing x)) 36 | x) 37 | ;; No idea: fail 38 | (else (error "Unknown object:" x)))) 39 | 40 | (define (obj-to-str x) 41 | (let ((acc '())) 42 | (define (walk x) 43 | (cond ((pair? x) (walk (car x)) (walk (cdr x))) 44 | ((to-string-maybe x) => (lambda (s) (set! acc (cons s acc)))))) 45 | (walk x) 46 | (string-join (reverse! acc)))) 47 | 48 | ;; Return the value of the GNU Make variable V 49 | (define (gmk-var v) 50 | (gmk-expand (format #f "$(~a)" (obj-to-str v)))) 51 | 52 | ;; Export the public interfaces 53 | (export gmk-expand gmk-eval gmk-var) 54 | -------------------------------------------------------------------------------- /src/loadapi.c: -------------------------------------------------------------------------------- 1 | /* API for GNU Make dynamic objects. 2 | Copyright (C) 2013-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #include "makeint.h" 18 | 19 | #include "filedef.h" 20 | #include "variable.h" 21 | #include "dep.h" 22 | 23 | /* Allocate a buffer in our context, so we can free it. */ 24 | char * 25 | gmk_alloc (unsigned int len) 26 | { 27 | return xmalloc (len); 28 | } 29 | 30 | /* Free a buffer returned by gmk_expand(). */ 31 | void 32 | gmk_free (char *s) 33 | { 34 | free (s); 35 | } 36 | 37 | /* Evaluate a buffer as make syntax. 38 | Ideally eval_buffer() will take const char *, but not yet. */ 39 | void 40 | gmk_eval (const char *buffer, const gmk_floc *gfloc) 41 | { 42 | /* Preserve existing variable buffer context. */ 43 | char *pbuf; 44 | size_t plen; 45 | char *s; 46 | floc fl; 47 | floc *flp; 48 | 49 | if (gfloc) 50 | { 51 | fl.filenm = gfloc->filenm; 52 | fl.lineno = gfloc->lineno; 53 | fl.offset = 0; 54 | flp = &fl; 55 | } 56 | else 57 | flp = NULL; 58 | 59 | install_variable_buffer (&pbuf, &plen); 60 | 61 | s = xstrdup (buffer); 62 | eval_buffer (s, flp); 63 | free (s); 64 | 65 | restore_variable_buffer (pbuf, plen); 66 | } 67 | 68 | /* Expand a string and return an allocated buffer. 69 | Caller must call gmk_free() with this buffer. */ 70 | char * 71 | gmk_expand (const char *ref) 72 | { 73 | return allocated_expand_string (ref); 74 | } 75 | 76 | /* Register a function to be called from makefiles. */ 77 | void 78 | gmk_add_function (const char *name, gmk_func_ptr func, 79 | unsigned int min, unsigned int max, unsigned int flags) 80 | { 81 | define_new_function (reading_file, name, min, max, flags, func); 82 | } 83 | -------------------------------------------------------------------------------- /src/mkconfig.h.in: -------------------------------------------------------------------------------- 1 | /* Autoconf values for use on non-POSIX systems. 2 | Copyright (C) 2022-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | /* Name of package */ 18 | #define PACKAGE "@PACKAGE@" 19 | 20 | /* Define to the address where bug reports for this package should be sent. */ 21 | #define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" 22 | 23 | /* Define to the full name of this package. */ 24 | #define PACKAGE_NAME "@PACKAGE_NAME@" 25 | 26 | /* Define to the full name and version of this package. */ 27 | #define PACKAGE_STRING "@PACKAGE_NAME@ @PACKAGE_VERSION@" 28 | 29 | /* Define to the one symbol short name of this package. */ 30 | #define PACKAGE_TARNAME "@PACKAGE_TARNAME@" 31 | 32 | /* Define to the home page for this package. */ 33 | #define PACKAGE_URL "@PACKAGE_URL@" 34 | 35 | /* Define to the version of this package. */ 36 | #define PACKAGE_VERSION "@PACKAGE_VERSION@" 37 | -------------------------------------------------------------------------------- /src/mkcustom.h: -------------------------------------------------------------------------------- 1 | /* Miscellaneous global declarations and portability cruft for GNU Make. 2 | Copyright (C) 2023-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | /* 18 | This file is included at the end of config.h 19 | 20 | That means it's included _everywhere_ as the first thing, 21 | INCLUDING content imported from gnulib. BE AWARE!! 22 | */ 23 | 24 | #undef HAVE_CONFIG_H 25 | #define HAVE_CONFIG_H 1 26 | 27 | /* Specify we want GNU source code. This must be defined before any 28 | system headers are included. */ 29 | 30 | #define _GNU_SOURCE 1 31 | 32 | /* AIX requires this to be the first thing in the file. */ 33 | #if HAVE_ALLOCA_H 34 | # include 35 | #else 36 | # ifdef _AIX 37 | #pragma alloca 38 | # else 39 | # if !defined(__GNUC__) && !MK_OS_W32 40 | # ifndef alloca /* predefined by HP cc +Olibcalls */ 41 | char *alloca (); 42 | # endif 43 | # endif 44 | # endif 45 | #endif 46 | 47 | /* Declare function prototypes for src/misc.c functions if needed. */ 48 | 49 | #include 50 | 51 | #if !HAVE_STRCASECMP && !HAVE_STRICMP && !HAVE_STRCMPI 52 | int strcasecmp (const char *s1, const char *s2); 53 | #endif 54 | 55 | #if !HAVE_STRNCASECMP && !HAVE_STRNICMP && !HAVE_STRNCMPI 56 | int strncasecmp (const char *s1, const char *s2, size_t n); 57 | #endif 58 | 59 | #if !HAVE_MEMPCPY 60 | void *mempcpy (void *dest, const void *src, size_t n); 61 | #endif 62 | 63 | #if !HAVE_STPCPY 64 | char *stpcpy (char *dest, const char *src); 65 | #endif 66 | -------------------------------------------------------------------------------- /src/output.h: -------------------------------------------------------------------------------- 1 | /* Output to stdout / stderr for GNU Make 2 | Copyright (C) 2013-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | struct output 18 | { 19 | int out; 20 | int err; 21 | unsigned int syncout:1; /* True if we want to synchronize output. */ 22 | }; 23 | 24 | extern struct output *output_context; 25 | extern unsigned int stdio_traced; 26 | 27 | #define FD_STDIN (fileno (stdin)) 28 | #define FD_STDOUT (fileno (stdout)) 29 | #define FD_STDERR (fileno (stderr)) 30 | 31 | #define OUTPUT_SET(_new) do{ output_context = (_new)->syncout ? (_new) : NULL; }while(0) 32 | #define OUTPUT_UNSET() do{ output_context = NULL; }while(0) 33 | 34 | #define OUTPUT_TRACED() do{ stdio_traced = 1; }while(0) 35 | #define OUTPUT_IS_TRACED() (!!stdio_traced) 36 | 37 | /* Write a buffer directly to the given file descriptor. 38 | This handles errors etc. */ 39 | int output_write (int fd, const void *buffer, size_t len); 40 | 41 | /* Initialize and close a child output structure: if NULL do this program's 42 | output (this should only be done once). */ 43 | void output_init (struct output *out); 44 | void output_close (struct output *out); 45 | 46 | /* In situations where output may be about to be displayed but we're not 47 | sure if we've set it up yet, call this. */ 48 | void output_start (void); 49 | 50 | /* Show a message on stdout or stderr. Will start the output if needed. */ 51 | void outputs (int is_err, const char *msg); 52 | 53 | #if defined(NO_OUTPUT_SYNC) 54 | # define output_dump(_o) (void)(0) 55 | #else 56 | /* Dump any child output content to stdout, and reset it. */ 57 | void output_dump (struct output *out); 58 | #endif 59 | -------------------------------------------------------------------------------- /src/rule.h: -------------------------------------------------------------------------------- 1 | /* Definitions for using pattern rules in GNU Make. 2 | Copyright (C) 1988-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | 18 | /* Structure used for pattern (implicit) rules. */ 19 | 20 | struct rule 21 | { 22 | struct rule *next; 23 | const char **targets; /* Targets of the rule. */ 24 | unsigned int *lens; /* Lengths of each target. */ 25 | const char **suffixes; /* Suffixes (after '%') of each target. */ 26 | struct dep *deps; /* Dependencies of the rule. */ 27 | struct commands *cmds; /* Commands to execute. */ 28 | char *_defn; /* Definition of the rule. */ 29 | unsigned short num; /* Number of targets. */ 30 | char terminal; /* If terminal (double-colon). */ 31 | char in_use; /* If in use by a parent pattern_search. */ 32 | }; 33 | 34 | /* For calling install_pattern_rule. */ 35 | struct pspec 36 | { 37 | const char *target, *dep, *commands; 38 | }; 39 | 40 | 41 | extern struct rule *pattern_rules; 42 | extern struct rule *last_pattern_rule; 43 | extern unsigned int num_pattern_rules; 44 | 45 | extern unsigned int max_pattern_deps; 46 | extern unsigned int max_pattern_targets; 47 | extern size_t max_pattern_dep_length; 48 | 49 | extern struct file *suffix_file; 50 | 51 | 52 | void snap_implicit_rules (void); 53 | void convert_to_pattern (void); 54 | void install_pattern_rule (struct pspec *p, int terminal); 55 | void create_pattern_rule (const char **targets, const char **target_percents, 56 | unsigned short num, int terminal, struct dep *deps, 57 | struct commands *commands, int override); 58 | const char *get_rule_defn (struct rule *rule); 59 | void print_rule_data_base (void); 60 | -------------------------------------------------------------------------------- /src/shuffle.h: -------------------------------------------------------------------------------- 1 | /* Declarations for target shuffling support. 2 | Copyright (C) 2022, 2024-2022 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | struct dep; 18 | struct goaldep; 19 | 20 | void shuffle_set_mode (const char *cmdarg); 21 | const char *shuffle_get_mode (void); 22 | void shuffle_deps_recursive (struct dep* g); 23 | 24 | #define shuffle_goaldeps_recursive(_g) do{ \ 25 | shuffle_deps_recursive ((struct dep *)_g); \ 26 | } while(0) 27 | -------------------------------------------------------------------------------- /src/version.c: -------------------------------------------------------------------------------- 1 | /* Record version and build host architecture for GNU Make. 2 | Copyright (C) 1988-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | /* We use instead of "config.h" so that a compilation 18 | using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h 19 | (which it would do because makeint.h was found in $srcdir). */ 20 | #include 21 | 22 | #ifndef MAKE_HOST 23 | # define MAKE_HOST "unknown" 24 | #endif 25 | 26 | const char *version_string = PACKAGE_VERSION; 27 | const char *make_host = MAKE_HOST; 28 | 29 | /* 30 | Local variables: 31 | version-control: never 32 | End: 33 | */ 34 | -------------------------------------------------------------------------------- /src/vmsdir.h: -------------------------------------------------------------------------------- 1 | /* dirent.h for vms 2 | Copyright (C) 1996-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #ifndef VMSDIR_H 18 | #define VMSDIR_H 19 | 20 | #include 21 | 22 | #define MAXNAMLEN 255 23 | 24 | #ifndef __DECC 25 | #if !defined (__GNUC__) && !defined (__ALPHA) 26 | typedef unsigned long u_long; 27 | typedef unsigned short u_short; 28 | #endif 29 | #endif 30 | 31 | struct direct 32 | { 33 | off_t d_off; 34 | u_long d_fileno; 35 | u_short d_reclen; 36 | u_short d_namlen; 37 | char d_name[MAXNAMLEN + 1]; 38 | }; 39 | 40 | #undef DIRSIZ 41 | #define DIRSIZ(dp) \ 42 | (((sizeof (struct direct) \ 43 | - (MAXNAMLEN+1) \ 44 | + ((dp)->d_namlen+1)) \ 45 | + 3) & ~3) 46 | 47 | #define d_ino d_fileno /* compatibility */ 48 | 49 | 50 | /* 51 | * Definitions for library routines operating on directories. 52 | */ 53 | 54 | typedef struct DIR 55 | { 56 | struct direct dir; 57 | char d_result[MAXNAMLEN + 1]; 58 | #if defined (__ALPHA) || defined (__DECC) 59 | struct FAB fab; 60 | #else 61 | struct fabdef fab; 62 | #endif 63 | } DIR; 64 | 65 | #ifndef NULL 66 | #define NULL 0 67 | #endif 68 | 69 | #define rewinddir(dirp) seekdir((dirp), (long)0) 70 | 71 | DIR *opendir (); 72 | struct direct *readdir (DIR *dfd); 73 | int closedir (DIR *dfd); 74 | const char *vmsify (const char *name, int type); 75 | 76 | #endif /* VMSDIR_H */ 77 | -------------------------------------------------------------------------------- /src/vmsify.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mirror/make/c63a5bc6a2881d515bb3020ed477fcba08fb2f3d/src/vmsify.c -------------------------------------------------------------------------------- /src/w32/include/dirent.h: -------------------------------------------------------------------------------- 1 | /* Windows version of dirent.h 2 | Copyright (C) 1996-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #ifndef _DIRENT_H 18 | #define _DIRENT_H 19 | 20 | #ifdef __MINGW32__ 21 | # include 22 | # include_next 23 | #else 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #ifndef NAME_MAX 31 | #define NAME_MAX 255 32 | #endif 33 | 34 | #define __DIRENT_COOKIE 0xfefeabab 35 | 36 | /* File types for `d_type'. 37 | Windows only supports DT_CHR, DT_DIR, and DT_REG. */ 38 | enum 39 | { 40 | DT_UNKNOWN = 0, 41 | # define DT_UNKNOWN DT_UNKNOWN 42 | DT_FIFO = 1, 43 | # define DT_FIFO DT_FIFO 44 | DT_CHR = 2, 45 | # define DT_CHR DT_CHR 46 | DT_DIR = 4, 47 | # define DT_DIR DT_DIR 48 | DT_BLK = 6, 49 | # define DT_BLK DT_BLK 50 | DT_REG = 8, 51 | # define DT_REG DT_REG 52 | DT_LNK = 10, 53 | # define DT_LNK DT_LNK 54 | DT_SOCK = 12, 55 | # define DT_SOCK DT_SOCK 56 | DT_WHT = 14 57 | # define DT_WHT DT_WHT 58 | }; 59 | 60 | 61 | struct dirent 62 | { 63 | ino_t d_ino; /* unused - no equivalent on Windows32. */ 64 | unsigned char d_type; 65 | char d_name[NAME_MAX+1]; /* must come last due to dir.c assumptions. */ 66 | }; 67 | 68 | typedef struct dir_struct 69 | { 70 | ULONG dir_ulCookie; 71 | HANDLE dir_hDirHandle; 72 | DWORD dir_nNumFiles; 73 | char dir_pDirectoryName[NAME_MAX+1]; 74 | struct dirent dir_sdReturn; 75 | } DIR; 76 | 77 | DIR *opendir(const char *); 78 | struct dirent *readdir(DIR *); 79 | void rewinddir(DIR *); 80 | void closedir(DIR *); 81 | void seekdir(DIR *, long); 82 | 83 | #endif /* !__MINGW32__ */ 84 | #endif 85 | -------------------------------------------------------------------------------- /src/w32/include/dlfcn.h: -------------------------------------------------------------------------------- 1 | /* dlfcn.h replacement for MS-Windows build. 2 | Copyright (C) 2013-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #ifndef DLFCN_H 18 | #define DLFCN_H 19 | 20 | #define RTLD_LAZY 1 21 | #define RTLD_NOW 2 22 | #define RTLD_GLOBAL 4 23 | 24 | extern void *dlopen (const char *, int); 25 | extern void *dlsym (void *, const char *); 26 | extern char *dlerror (void); 27 | extern int dlclose (void *); 28 | 29 | #endif /* DLFCN_H */ 30 | -------------------------------------------------------------------------------- /src/w32/include/pathstuff.h: -------------------------------------------------------------------------------- 1 | /* Definitions for Windows path manipulation. 2 | Copyright (C) 1996-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #ifndef _PATHSTUFF_H 18 | #define _PATHSTUFF_H 19 | 20 | char *convert_Path_to_windows32(char *Path, char to_delim); 21 | char *convert_vpath_to_windows32(char *Path, char to_delim); 22 | char *w32ify(const char *file, int resolve); 23 | char *getcwd_fs(char *buf, int len); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/w32/include/sub_proc.h: -------------------------------------------------------------------------------- 1 | /* Definitions for Windows process invocation. 2 | Copyright (C) 1996-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #ifndef SUB_PROC_H 18 | #define SUB_PROC_H 19 | 20 | /* 21 | * Component Name: 22 | * 23 | * $Date$ 24 | * 25 | * $Source$ 26 | * 27 | * $Id$ 28 | */ 29 | 30 | #define EXTERN_DECL(entry, args) extern entry args 31 | #define VOID_DECL void 32 | 33 | EXTERN_DECL(HANDLE process_init, (VOID_DECL)); 34 | EXTERN_DECL(HANDLE process_init_fd, (HANDLE stdinh, HANDLE stdouth, 35 | HANDLE stderrh)); 36 | EXTERN_DECL(long process_begin, (HANDLE proc, char **argv, char **envp, 37 | char *exec_path, char *as_user)); 38 | EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data, 39 | int stdin_data_len)); 40 | EXTERN_DECL(long process_file_io, (HANDLE proc)); 41 | EXTERN_DECL(void process_cleanup, (HANDLE proc)); 42 | EXTERN_DECL(HANDLE process_wait_for_any, (int block, DWORD* pdwWaitStatus)); 43 | EXTERN_DECL(void process_register, (HANDLE proc)); 44 | EXTERN_DECL(HANDLE process_easy, (char** argv, char** env, 45 | int outfd, int errfd)); 46 | EXTERN_DECL(BOOL process_kill, (HANDLE proc, int signal)); 47 | EXTERN_DECL(BOOL process_table_full, (VOID_DECL)); 48 | EXTERN_DECL(int process_table_usable_size, (VOID_DECL)); 49 | EXTERN_DECL(int process_table_actual_size, (VOID_DECL)); 50 | EXTERN_DECL(DWORD process_set_handles, (HANDLE *handles)); 51 | EXTERN_DECL(DWORD process_wait_for_multiple_objects, (DWORD, const HANDLE*, BOOL, DWORD)); 52 | 53 | /* support routines */ 54 | EXTERN_DECL(long process_errno, (HANDLE proc)); 55 | EXTERN_DECL(long process_last_err, (HANDLE proc)); 56 | EXTERN_DECL(long process_exit_code, (HANDLE proc)); 57 | EXTERN_DECL(long process_signal, (HANDLE proc)); 58 | EXTERN_DECL(char * process_outbuf, (HANDLE proc)); 59 | EXTERN_DECL(char * process_errbuf, (HANDLE proc)); 60 | EXTERN_DECL(int process_outcnt, (HANDLE proc)); 61 | EXTERN_DECL(int process_errcnt, (HANDLE proc)); 62 | EXTERN_DECL(void process_pipes, (HANDLE proc, int pipes[3])); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/w32/include/w32err.h: -------------------------------------------------------------------------------- 1 | /* Definitions for Windows error handling. 2 | Copyright (C) 1996-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #ifndef _W32ERR_H_ 18 | #define _W32ERR_H_ 19 | 20 | #ifndef EXTERN_DECL 21 | #define EXTERN_DECL(entry, args) entry args 22 | #endif 23 | 24 | EXTERN_DECL(const char * map_windows32_error_to_string, (DWORD error)); 25 | 26 | #endif /* !_W32ERR_H */ 27 | -------------------------------------------------------------------------------- /src/w32/subproc/misc.c: -------------------------------------------------------------------------------- 1 | /* Process handling for Windows 2 | Copyright (C) 1996-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include "proc.h" 23 | 24 | 25 | /* 26 | * Description: Convert a NULL string terminated UNIX environment block to 27 | * an environment block suitable for a windows32 system call 28 | * 29 | * Returns: TRUE= success, FALSE=fail 30 | * 31 | * Notes/Dependencies: the environment block is sorted in case-insensitive 32 | * order, is double-null terminated, and is a char *, not a char ** 33 | */ 34 | int _cdecl compare(const void *a1, const void *a2) 35 | { 36 | return _stricoll(*((char**)a1),*((char**)a2)); 37 | } 38 | bool_t 39 | arr2envblk(char **arr, char **envblk_out, size_t *envsize_needed) 40 | { 41 | char **tmp; 42 | size_t size_needed; 43 | int arrcnt; 44 | char *ptr; 45 | 46 | arrcnt = 0; 47 | while (arr[arrcnt]) { 48 | arrcnt++; 49 | } 50 | 51 | tmp = (char**) calloc(arrcnt + 1, sizeof(char *)); 52 | if (!tmp) { 53 | return FALSE; 54 | } 55 | 56 | arrcnt = 0; 57 | size_needed = *envsize_needed = 0; 58 | while (arr[arrcnt]) { 59 | tmp[arrcnt] = arr[arrcnt]; 60 | size_needed += strlen(arr[arrcnt]) + 1; 61 | arrcnt++; 62 | } 63 | size_needed++; 64 | *envsize_needed = size_needed; 65 | 66 | qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare); 67 | 68 | ptr = *envblk_out = calloc(size_needed, 1); 69 | if (!ptr) { 70 | free(tmp); 71 | return FALSE; 72 | } 73 | 74 | arrcnt = 0; 75 | while (tmp[arrcnt]) { 76 | strcpy(ptr, tmp[arrcnt]); 77 | ptr += strlen(tmp[arrcnt]) + 1; 78 | arrcnt++; 79 | } 80 | 81 | free(tmp); 82 | return TRUE; 83 | } 84 | -------------------------------------------------------------------------------- /src/w32/subproc/proc.h: -------------------------------------------------------------------------------- 1 | /* Definitions for Windows 2 | Copyright (C) 1996-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #ifndef _PROC_H 18 | #define _PROC_H 19 | 20 | typedef int bool_t; 21 | 22 | #define E_SCALL 101 23 | #define E_IO 102 24 | #define E_NO_MEM 103 25 | #define E_FORK 104 26 | 27 | extern bool_t arr2envblk(char **arr, char **envblk_out, size_t *envsize_needed); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/w32/subproc/w32err.c: -------------------------------------------------------------------------------- 1 | /* Error handling for Windows 2 | Copyright (C) 1996-2024 Free Software Foundation, Inc. 3 | This file is part of GNU Make. 4 | 5 | GNU Make is free software; you can redistribute it and/or modify it under the 6 | terms of the GNU General Public License as published by the Free Software 7 | Foundation; either version 3 of the License, or (at your option) any later 8 | version. 9 | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along with 15 | this program. If not, see . */ 16 | 17 | #include 18 | #include 19 | #include "makeint.h" 20 | #include "w32err.h" 21 | 22 | /* 23 | * Description: the windows32 version of perror() 24 | * 25 | * Returns: a pointer to a static error 26 | * 27 | * Notes/Dependencies: I got this from 28 | * comp.os.ms-windows.programmer.win32 29 | */ 30 | const char * 31 | map_windows32_error_to_string (DWORD ercode) { 32 | /* 33 | * We used to have an MSVC-specific '__declspec (thread)' qualifier 34 | * here, with the following comment: 35 | * 36 | * __declspec (thread) necessary if you will use multiple threads on MSVC 37 | * 38 | * However, Make was never multithreaded on Windows (except when 39 | * Ctrl-C is hit, in which case the main thread is stopped 40 | * immediately, so it doesn't matter in this context). The functions 41 | * on sub_proc.c that started and stopped additional threads were 42 | * never used, and are now #ifdef'ed away. Until we need more than 43 | * one thread, we have no problems with the following buffer being 44 | * static. (If and when we do need it to be in thread-local storage, 45 | * the corresponding GCC qualifier is '__thread'.) 46 | */ 47 | static char szMessageBuffer[128]; 48 | DWORD ret; 49 | 50 | /* Fill message buffer with a default message in 51 | * case FormatMessage fails 52 | */ 53 | wsprintf (szMessageBuffer, "Error %ld", ercode); 54 | 55 | /* 56 | * Special code for winsock error handling. 57 | */ 58 | if (ercode > WSABASEERR) { 59 | OS (fatal, NILF, "%s", szMessageBuffer); 60 | } 61 | 62 | /* 63 | * Default system message handling 64 | */ 65 | ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 66 | NULL, 67 | ercode, 68 | LANG_NEUTRAL, 69 | szMessageBuffer, 70 | sizeof(szMessageBuffer), 71 | NULL); 72 | 73 | if (ret) 74 | { 75 | char *cp; 76 | for (cp = szMessageBuffer + ret - 1; cp >= szMessageBuffer; --cp) 77 | { 78 | if (*cp != '\r' && *cp != '\n') 79 | break; 80 | *cp = '\0'; 81 | } 82 | } 83 | 84 | return szMessageBuffer; 85 | } 86 | -------------------------------------------------------------------------------- /src/w32/utf8.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UTF-8 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/w32/utf8.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "utf8.manifest" 4 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | .test-result 2 | config-flags.pm 3 | work 4 | -------------------------------------------------------------------------------- /tests/config-flags.pm.W32: -------------------------------------------------------------------------------- 1 | # This is a -*-perl-*- script 2 | # 3 | # Set variables for Windows systems. 4 | 5 | %CONFIG_FLAGS = ( 6 | USE_SYSTEM_GLOB => 'no' 7 | ); 8 | 9 | 1; 10 | -------------------------------------------------------------------------------- /tests/config-flags.pm.in: -------------------------------------------------------------------------------- 1 | # This is a -*-perl-*- script 2 | # 3 | # Set variables that were defined by configure, in case we need them 4 | # during the tests. 5 | 6 | %CONFIG_FLAGS = ( 7 | AM_LDFLAGS => '@AM_LDFLAGS@', 8 | AR => '@AR@', 9 | CC => '@CC@', 10 | CFLAGS => '@CFLAGS@', 11 | CPP => '@CPP@', 12 | CPPFLAGS => '@CPPFLAGS@', 13 | GUILE_CFLAGS => '@GUILE_CFLAGS@', 14 | GUILE_LIBS => '@GUILE_LIBS@', 15 | LDFLAGS => '@LDFLAGS@', 16 | LIBS => '@LIBS@', 17 | USE_SYSTEM_GLOB => '@USE_SYSTEM_GLOB@' 18 | ); 19 | 20 | 1; 21 | -------------------------------------------------------------------------------- /tests/config_flags_pm.com: -------------------------------------------------------------------------------- 1 | $! 2 | $! config_flags_pm.com - Build config-flags.pm on VMS. 3 | $! 4 | $! Just good enough to run the self tests for now. 5 | $! 6 | $! Copyright (C) 2014-2024 Free Software Foundation, Inc. 7 | $! This file is part of GNU Make. 8 | $! 9 | $! GNU Make is free software; you can redistribute it and/or modify it under 10 | $! the terms of the GNU General Public License as published by the Free Software 11 | $! Foundation; either version 3 of the License, or (at your option) any later 12 | $! version. 13 | $! 14 | $! GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 15 | $! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 16 | $! FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 | $! details. 18 | $! 19 | $! You should have received a copy of the GNU General Public License along with 20 | $! this program. If not, see . 21 | $! 22 | $! 23 | $ open/read cfpm_in config-flags.pm.in 24 | $! 25 | $ outfile = "sys$disk:[]config-flags.pm" 26 | $! 27 | $ cflags = "/include=([],[.lib]" 28 | $! 29 | $ create 'outfile' 30 | $ open/append cfpm 'outfile' 31 | $! 32 | $cfpm_read_loop: 33 | $ read cfpm_in/end=cfpm_read_loop_end line_in 34 | $ line_in_len = f$length(line_in) 35 | $ if f$locate("@", line_in) .lt. line_in_len 36 | $ then 37 | $ part1 = f$element(0, "@", line_in) 38 | $ key = f$element(1, "@", line_in) 39 | $ part2 = f$element(2, "@", line_in) 40 | $ value = "" 41 | $ if key .eqs. "CC" then value = "CC" 42 | $ if key .eqs. "CPP" then value = "CPP" 43 | $ if key .eqs. "CFLAGS" then value = cflags 44 | $ if key .eqs. "GUILE_CFLAGS" then value = cflags 45 | $ if key .eqs. "USE_SYSTEM_GLOB" then value = "no" 46 | $ write cfpm part1, value, part2 47 | $ goto cfpm_read_loop 48 | $ endif 49 | $ write cfpm line_in 50 | $ goto cfpm_read_loop 51 | $cfpm_read_loop_end: 52 | $ close cfpm_in 53 | $ close cfpm 54 | $! 55 | -------------------------------------------------------------------------------- /tests/guile.supp: -------------------------------------------------------------------------------- 1 | # Guile valgrind suppression file 2 | # Created with Guile 1.8.7 3 | 4 | # --- Garbage collection 5 | { 6 | guilegc 7 | Memcheck:Cond 8 | ... 9 | fun:scm_gc_for_newcell 10 | } 11 | { 12 | guilegc 13 | Memcheck:Value4 14 | ... 15 | fun:scm_gc_for_newcell 16 | } 17 | { 18 | guilegc 19 | Memcheck:Value8 20 | ... 21 | fun:scm_gc_for_newcell 22 | } 23 | 24 | 25 | # -- scm_alloc_struct 26 | { 27 | guileheap 28 | Memcheck:Leak 29 | ... 30 | fun:scm_alloc_struct 31 | } 32 | -------------------------------------------------------------------------------- /tests/mkshadow: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Simple script to make a "shadow" test directory, using symbolic links. 4 | # Typically you'd put the shadow in /tmp or another local disk 5 | # 6 | # Copyright (C) 1992-2024 Free Software Foundation, Inc. 7 | # This file is part of GNU Make. 8 | # 9 | # GNU Make is free software; you can redistribute it and/or modify it under 10 | # the terms of the GNU General Public License as published by the Free Software 11 | # Foundation; either version 3 of the License, or (at your option) any later 12 | # version. 13 | # 14 | # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 15 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 16 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 | # details. 18 | # 19 | # You should have received a copy of the GNU General Public License along with 20 | # this program. If not, see . 21 | 22 | case "$1" in 23 | "") echo 'Usage: mkshadow '; exit 1 ;; 24 | esac 25 | 26 | dest="$1" 27 | 28 | if [ ! -d "$dest" ]; then 29 | echo "Destination directory '$dest' must exist!" 30 | exit 1 31 | fi 32 | 33 | if [ ! -f run_make_tests ]; then 34 | echo "The current directory doesn't appear to contain the test suite!" 35 | exit 1 36 | fi 37 | 38 | suite=`pwd | sed 's%^/tmp_mnt%%'` 39 | name=`basename "$suite"` 40 | 41 | files=`echo *` 42 | 43 | set -e 44 | 45 | mkdir "$dest/$name" 46 | cd "$dest/$name" 47 | 48 | ln -s "$suite" .testdir 49 | 50 | for f in $files; do 51 | ln -s .testdir/$f . 52 | done 53 | 54 | rm -rf work 55 | 56 | echo "Shadow test suite created in '$dest/$name'." 57 | exit 0 58 | -------------------------------------------------------------------------------- /tests/run_make_tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec perl $0.pl ${1+"$@"} 3 | -------------------------------------------------------------------------------- /tests/run_make_tests.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Copyright (C) 2017-2024 Free Software Foundation, Inc. 3 | rem This file is part of GNU Make. 4 | rem 5 | rem GNU Make is free software; you can redistribute it and/or modify it under 6 | rem the terms of the GNU General Public License as published by the Free 7 | rem Software Foundation; either version 3 of the License, or (at your option) 8 | rem any later version. 9 | rem 10 | rem GNU Make is distributed in the hope that it will be useful, but WITHOUT 11 | rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | rem FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for. 13 | rem more details. 14 | rem 15 | rem You should have received a copy of the GNU General Public License along 16 | rem with this program. If not, see . 17 | 18 | setlocal 19 | cd "%~dp0" 20 | 21 | perl -I. .\run_make_tests.pl %* 22 | -------------------------------------------------------------------------------- /tests/scripts/features/comments: -------------------------------------------------------------------------------- 1 | $description = "The following test creates a makefile to test comments\n" 2 | ."and comment continuation to the next line using a \n" 3 | ."backslash within makefiles."; 4 | 5 | $details = "To test comments within a makefile, a semi-colon was placed \n" 6 | ."after a comment was started. This should not be reported as\n" 7 | ."an error since it is within a comment. We then continue the \n" 8 | ."comment to the next line using a backslash. To test whether\n" 9 | ."the comment really continued, we place an echo command with some\n" 10 | ."text on the line which should never execute since it should be \n" 11 | ."within a comment\n"; 12 | 13 | open(MAKEFILE,"> $makefile"); 14 | 15 | # The Contents of the MAKEFILE ... 16 | 17 | print MAKEFILE <<\EOF; 18 | # Test comment vs semicolon parsing and line continuation 19 | target: # this ; is just a comment \ 20 | @echo This is within a comment. 21 | @echo There should be no errors for this makefile. 22 | EOF 23 | 24 | # END of Contents of MAKEFILE 25 | 26 | close(MAKEFILE); 27 | 28 | &run_make_with_options($makefile,"",&get_logfile); 29 | 30 | # Create the answer to what should be produced by this Makefile 31 | $answer = "There should be no errors for this makefile.\n"; 32 | 33 | # COMPARE RESULTS 34 | 35 | &compare_output($answer,&get_logfile(1)); 36 | 37 | 1; 38 | -------------------------------------------------------------------------------- /tests/scripts/features/default_names: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "This script tests to make sure that Make looks for 4 | default makefiles in the correct order (GNUmakefile,makefile,Makefile)"; 5 | 6 | # Create a makefile called "GNUmakefile" 7 | $makefile = "GNUmakefile"; 8 | 9 | open(MAKEFILE,"> $makefile"); 10 | print MAKEFILE "FIRST: ; \@echo It chose GNUmakefile\n"; 11 | close(MAKEFILE); 12 | 13 | # Create another makefile called "makefile" 14 | open(MAKEFILE,"> makefile"); 15 | print MAKEFILE "SECOND: ; \@echo It chose makefile\n"; 16 | close(MAKEFILE); 17 | 18 | # DOS/W32/MacOSX platforms are case-insensitive / case-preserving, so 19 | # Makefile is the same file as makefile. Just test what we can here. 20 | 21 | my $case_sensitive = 0; 22 | if (! -f 'Makefile') { 23 | # Create another makefile called "Makefile" 24 | $case_sensitive = 1; 25 | open(MAKEFILE,"> Makefile"); 26 | print MAKEFILE "THIRD: ; \@echo It chose Makefile\n"; 27 | close(MAKEFILE); 28 | } 29 | 30 | run_make_with_options("","",&get_logfile); 31 | compare_output("It chose GNUmakefile\n",&get_logfile(1)); 32 | unlink($makefile); 33 | 34 | run_make_with_options("","",&get_logfile); 35 | compare_output("It chose makefile\n",&get_logfile(1)); 36 | unlink("makefile"); 37 | 38 | if ($case_sensitive) { 39 | run_make_with_options("","",&get_logfile); 40 | compare_output("It chose Makefile\n",&get_logfile(1)); 41 | unlink("Makefile"); 42 | } 43 | 44 | 1; 45 | -------------------------------------------------------------------------------- /tests/scripts/features/dircache: -------------------------------------------------------------------------------- 1 | # -*-mode: perl-*- 2 | 3 | $description = "Test the directory cache behavior."; 4 | 5 | # The first wildcard should bring the entire directory into the cache Then we 6 | # create a new file "behind make's back" then see if the next wildcard detects 7 | # it. 8 | 9 | run_make_test(q! 10 | _orig := $(wildcard ./*) 11 | $(shell echo > anewfile) 12 | _new := $(wildcard ./*) 13 | $(info diff=$(filter-out $(_orig),$(_new))) 14 | all:;@: 15 | !, 16 | '', "diff=./anewfile\n"); 17 | 18 | rmfiles('anewfile'); 19 | 20 | run_make_test(q! 21 | _orig := $(wildcard ./*) 22 | $(file >anewfile) 23 | _new := $(wildcard ./*) 24 | $(info diff=$(filter-out $(_orig),$(_new))) 25 | all:;@: 26 | !, 27 | '', "diff=./anewfile\n"); 28 | 29 | rmfiles('anewfile'); 30 | 31 | 1; 32 | -------------------------------------------------------------------------------- /tests/scripts/features/echoing: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "The following test creates a makefile to test command 3 | echoing. It tests that when a command line starts with 4 | a '\@', the echoing of that line is suppressed. It also 5 | tests the -n option which tells make to ONLY echo the 6 | commands and no execution happens. In this case, even 7 | the commands with '\@' are printed. Lastly, it tests the 8 | -s flag which tells make to prevent all echoing, as if 9 | all commands started with a '\@'."; 10 | 11 | $details = "This test is similar to the 'clean' test except that a '\@' has 12 | been placed in front of the delete command line. Four tests 13 | are run here. First, make is run normally and the first echo 14 | command should be executed. In this case there is no '\@' so 15 | we should expect make to display the command AND display the 16 | echoed message. Secondly, make is run with the clean target, 17 | but since there is a '\@' at the beginning of the command, we 18 | expect no output; just the deletion of a file which we check 19 | for. Third, we give the clean target again except this time 20 | we give make the -n option. We now expect the command to be 21 | displayed but not to be executed. In this case we need only 22 | to check the output since an error message would be displayed 23 | if it actually tried to run the delete command again and the 24 | file didn't exist. Lastly, we run the first test again with 25 | the -s option and check that make did not echo the echo 26 | command before printing the message.\n"; 27 | 28 | $example = "EXAMPLE_FILE"; 29 | 30 | touch($example); 31 | 32 | # TEST #1 33 | # ------- 34 | 35 | run_make_test(" 36 | all: 37 | \techo This makefile did not clean the dir... good 38 | clean: 39 | \t\@$CMD_rmfile $example\n", 40 | '', 'echo This makefile did not clean the dir... good 41 | This makefile did not clean the dir... good'); 42 | 43 | # TEST #2 44 | # ------- 45 | 46 | run_make_test(undef, 'clean', ''); 47 | if (-f $example) { 48 | $test_passed = 0; 49 | unlink($example); 50 | } 51 | 52 | # TEST #3 53 | # ------- 54 | 55 | run_make_test(undef, '-n clean', "$CMD_rmfile $example\n"); 56 | 57 | 58 | # TEST #4 59 | # ------- 60 | 61 | run_make_test(undef, '-s', "This makefile did not clean the dir... good\n"); 62 | 63 | 64 | 1; 65 | -------------------------------------------------------------------------------- /tests/scripts/features/exec: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | use warnings; 4 | 5 | my $description = "Test that make can execute binaries as well as scripts with" 6 | ." various shabangs and without a shbang"; 7 | my $details = "The various shells that this test uses are the default" 8 | ." /bin/sh, \$SHELL and the perl interpreter that is" 9 | ." executing this test program. The shells are used for the value" 10 | ." of SHELL inside the test makefile and also as a shbang in the" 11 | ." executed script. There is also a test which executes a script" 12 | ." that has no shbang."; 13 | 14 | # Only bother with this on UNIX systems 15 | $port_type eq 'UNIX' or return -1; 16 | $^O =~ /cygwin/ and return -1; 17 | 18 | my @shbangs = ('#!/bin/sh', "#!$perl_name"); 19 | 20 | # The exec in Valgrind's VM doesn't allow starting commands without any shbang 21 | $valgrind or push @shbangs, ''; 22 | 23 | my @shells = ('', 'SHELL=/bin/sh'); 24 | 25 | # Try whatever shell the user has, as long as it's not a C shell. 26 | # The C shell is not usable with make, due to not correctly handling 27 | # file descriptors and possibly other issues. 28 | my $usersh = $origENV{SHELL}; 29 | if ($usersh !~ /csh/) { 30 | push @shbangs, ("#!$usersh"); 31 | push @shells, ("SHELL=$usersh"); 32 | } 33 | 34 | my $answer = 'hello, world'; 35 | 36 | # tests [0-11] 37 | # Have a makefile with various SHELL= exec a shell program with varios 38 | # shbangs or without a shbang at all. 39 | my $stem = './exec.cmd'; 40 | my $k = 0; 41 | for my $shbang (@shbangs) { 42 | for my $shell (@shells) { 43 | my $cmd = $k ? "$stem.$k" : $stem; 44 | ++$k; 45 | unlink $cmd; 46 | open(CMD,"> $cmd"); 47 | print CMD "$shbang\n"; 48 | print CMD "printf \"$answer\\n\";\n"; 49 | close(CMD); 50 | chmod 0700, $cmd; 51 | 52 | run_make_test("# shbang=$shbang\n# shell=$shell" . q! 53 | all:; @$(CMD) 54 | !, "$shell CMD=$cmd", "$answer\n"); 55 | 56 | rmfiles($cmd); 57 | } 58 | } 59 | 60 | # tests [12-14] 61 | # Exec a binary from a makefile that has SHELL=. 62 | for my $shell (@shells) { 63 | run_make_test(q! 64 | all:; @#PERL# -e 'printf "$(ANSWER)\n"'; 65 | !, "$shell ANSWER='$answer'", "$answer\n"); 66 | } 67 | 68 | # test 15 69 | # Use perl as a shell. 70 | run_make_test(q! 71 | SHELL = #PERL# 72 | .SHELLFLAGS = -e 73 | all:; @printf "$(ANSWER)\n"; 74 | !, "ANSWER='$answer'", "$answer\n"); 75 | 76 | 1; 77 | -------------------------------------------------------------------------------- /tests/scripts/features/expand: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test variable expansion."; 4 | 5 | # sv 64124. 6 | # Expand a variable whose value exceeds 200 bytes. 7 | # 200 is the initial size of variable_buffer. 8 | # Value bigger than 200 bytes causes a realloc of variable_buffer. 9 | # In this test the variable being expanded is MAKEFLAGS and its value occupies 10 | # 12, 600 and 120000 bytes. 11 | 12 | my $s = "hello_world\n"; 13 | my @mult = (1, 50, 10000); 14 | 15 | for my $m (@mult) { 16 | my $answer = $s x $m; 17 | $ENV{'MAKEFLAGS'} = " -- hello=$answer"; 18 | run_make_test(q! 19 | $(info x$(hello)y) 20 | all: 21 | !, 22 | '', "x${answer}y\n#MAKE#: Nothing to be done for 'all'.\n"); 23 | } 24 | 25 | # This tells the test driver that the perl test script executed properly. 26 | 1; 27 | -------------------------------------------------------------------------------- /tests/scripts/features/mult_rules: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "\ 4 | The following test creates a makefile to test the presence 5 | of multiple rules for one target. One file can be the 6 | target of several rules if at most one rule has commands; 7 | the other rules can only have dependencies."; 8 | 9 | $details = "\ 10 | The makefile created in this test contains two hardcoded rules 11 | for foo.o and bar.o. It then gives another multiple target rule 12 | with the same names as above but adding more dependencies. 13 | Additionally, another variable extradeps is listed as a 14 | dependency but is defined to be null. It can however be defined 15 | on the make command line as extradeps=extra.h which adds yet 16 | another dependency to the targets."; 17 | 18 | open(MAKEFILE,"> $makefile"); 19 | 20 | # The Contents of the MAKEFILE ... 21 | 22 | print MAKEFILE < $makefile"); 14 | 15 | # The Contents of the MAKEFILE ... 16 | 17 | print MAKEFILE "bigoutput littleoutput: test.h\n"; 18 | print MAKEFILE "\t\@echo I am \$(subst output,,\$@)\n"; 19 | 20 | # END of Contents of MAKEFILE 21 | 22 | close(MAKEFILE); 23 | 24 | &touch("test.h"); 25 | 26 | &run_make_with_options($makefile,"bigoutput",&get_logfile); 27 | 28 | 29 | # Create the answer to what should be produced by this Makefile 30 | $answer = "I am big\n"; 31 | 32 | &compare_output($answer,&get_logfile(1)); 33 | 34 | &run_make_with_options($makefile,"littleoutput",&get_logfile); 35 | $answer = "I am little\n"; 36 | &compare_output($answer,&get_logfile(1)); 37 | 38 | unlink "test.h"; 39 | 40 | 1; 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /tests/scripts/features/order_only: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test order-only prerequisites."; 3 | 4 | $details = "\ 5 | Create makefiles with various combinations of normal and order-only 6 | prerequisites and ensure they behave properly. Test the \$| variable."; 7 | 8 | # TEST #0 -- Basics 9 | 10 | run_make_test(' 11 | %r: | baz ; @echo $< $^ $| 12 | bar: foo 13 | foo:;@: 14 | baz:;@:', 15 | '', "foo foo baz\n"); 16 | 17 | # TEST #1 -- First try: the order-only prereqs need to be built. 18 | 19 | run_make_test(q! 20 | foo: bar | baz 21 | @echo '$$^ = $^' 22 | @echo '$$| = $|' 23 | touch $@ 24 | 25 | .PHONY: baz 26 | 27 | bar baz: 28 | touch $@!, 29 | '', "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n"); 30 | 31 | 32 | # TEST #2 -- now we do it again: baz is PHONY but foo should _NOT_ be updated 33 | 34 | run_make_test(undef, '', "touch baz\n"); 35 | 36 | unlink(qw(foo bar baz)); 37 | 38 | # TEST #3 -- Make sure the order-only prereq was promoted to normal. 39 | 40 | run_make_test(q! 41 | foo: bar | baz 42 | @echo '$$^ = $^' 43 | @echo '$$| = $|' 44 | touch $@ 45 | 46 | foo: baz 47 | 48 | .PHONY: baz 49 | 50 | bar baz: 51 | touch $@!, 52 | '', "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"); 53 | 54 | 55 | # TEST #4 -- now we do it again 56 | 57 | run_make_test(undef, '', "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"); 58 | 59 | unlink(qw(foo bar baz)); 60 | 61 | # Test empty normal prereqs 62 | 63 | # TEST #5 -- make sure the parser was correct. 64 | 65 | run_make_test(q! 66 | foo:| baz 67 | @echo '$$^ = $^' 68 | @echo '$$| = $|' 69 | touch $@ 70 | 71 | .PHONY: baz 72 | 73 | baz: 74 | touch $@!, 75 | '', "touch baz\n\$^ = \n\$| = baz\ntouch foo\n"); 76 | 77 | # TEST #6 -- now we do it again: this time foo won't be built 78 | 79 | run_make_test(undef, '', "touch baz\n"); 80 | 81 | unlink(qw(foo baz)); 82 | 83 | # Test order-only in pattern rules 84 | 85 | # TEST #7 -- make sure the parser was correct. 86 | 87 | run_make_test(q! 88 | %.w : %.x | baz 89 | @echo '$$^ = $^' 90 | @echo '$$| = $|' 91 | touch $@ 92 | 93 | all: foo.w 94 | 95 | .PHONY: baz 96 | foo.x baz: 97 | touch $@!, 98 | '', 99 | "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n"); 100 | 101 | # TEST #8 -- now we do it again: this time foo.w won't be built 102 | 103 | run_make_test(undef, '', "touch baz\n"); 104 | 105 | unlink(qw(foo.w foo.x baz)); 106 | 107 | # TEST #9 -- make sure that $< is set correctly in the face of order-only 108 | # prerequisites in pattern rules. 109 | 110 | run_make_test(' 111 | %r: | baz ; @echo $< $^ $| 112 | bar: foo 113 | foo:;@: 114 | baz:;@:', 115 | '', "foo foo baz\n"); 116 | 117 | 118 | 1; 119 | -------------------------------------------------------------------------------- /tests/scripts/features/override: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the override directive on variable assignments."; 4 | 5 | $details = ""; 6 | 7 | # TEST 0: Basic override 8 | 9 | run_make_test(' 10 | X = start 11 | override recur = $(X) 12 | override simple := $(X) 13 | X = end 14 | all: ; @echo "$(recur) $(simple)" 15 | ', 16 | 'recur=I simple=J', "end start\n"); 17 | 18 | # TEST 1: Override with append 19 | 20 | run_make_test(' 21 | X += X1 22 | override X += X2 23 | override Y += Y1 24 | Y += Y2 25 | all: ; @echo "$(X) $(Y)" 26 | ', 27 | '', "X1 X2 Y1\n"); 28 | 29 | # TEST 2: Override with append to the command line 30 | 31 | run_make_test(undef, 'X=C Y=C', "C X2 C Y1\n"); 32 | 33 | # Test override of define/endef 34 | 35 | run_make_test(' 36 | override define foo 37 | @echo First comes the definition. 38 | @echo Then comes the override. 39 | endef 40 | all: ; $(foo) 41 | ', 42 | 'foo=Hello', "First comes the definition.\nThen comes the override.\n"); 43 | 44 | 45 | 1; 46 | -------------------------------------------------------------------------------- /tests/scripts/features/quoting: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "The following test creates a makefile to test using \n" . 4 | "quotes within makefiles."; 5 | 6 | open(MAKEFILE,"> $makefile"); 7 | 8 | # The Contents of the MAKEFILE ... 9 | 10 | print MAKEFILE <<'EOM'; 11 | TEXFONTS = NICEFONT 12 | DEFINES = -DDEFAULT_TFM_PATH=\".:$(TEXFONTS)\" 13 | test: ; @"echo" 'DEFINES = $(DEFINES)' 14 | EOM 15 | 16 | # END of Contents of MAKEFILE 17 | 18 | close(MAKEFILE); 19 | 20 | 21 | &run_make_with_options($makefile,"",&get_logfile); 22 | 23 | 24 | # Create the answer to what should be produced by this Makefile 25 | $answer = 'DEFINES = -DDEFAULT_TFM_PATH=\".:NICEFONT\"' . "\n"; 26 | 27 | # COMPARE RESULTS 28 | 29 | &compare_output($answer,&get_logfile(1)); 30 | 31 | 1; 32 | -------------------------------------------------------------------------------- /tests/scripts/features/recursion: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test recursion."; 3 | 4 | $details = "DETAILS"; 5 | 6 | # Test some basic recursion. 7 | run_make_test(' 8 | .RECIPEPREFIX := | 9 | all: 10 | | $(MAKE) -f #MAKEFILE# foo 11 | foo: 12 | | @echo $(MAKE) 13 | | @echo MAKELEVEL = $(MAKELEVEL) 14 | | $(MAKE) -f #MAKEFILE# last 15 | last: 16 | | @echo $(MAKE) 17 | | @echo MAKELEVEL = $(MAKELEVEL) 18 | | @echo THE END 19 | ', 20 | ('CFLAGS=-O -w' . ($parallel_jobs ? ' -j 2' : '')), 21 | ($vos 22 | ? "#MAKE#: Entering directory '#PWD#' 23 | make 'CFLAGS=-O' -f #MAKEFILE# foo 24 | make CFLAGS=-O 25 | MAKELEVEL = 0 26 | make 'CFLAGS=-O' -f #MAKEFILE# last 27 | make CFLAGS=-O 28 | MAKELEVEL = 0 29 | THE END 30 | #MAKE#: Leaving directory '#PWD#'" 31 | : "#MAKE#: Entering directory '#PWD#' 32 | #MAKEPATH# -f #MAKEFILE# foo 33 | #MAKE#[1]: Entering directory '#PWD#' 34 | #MAKEPATH# 35 | MAKELEVEL = 1 36 | #MAKEPATH# -f #MAKEFILE# last 37 | #MAKE#[2]: Entering directory '#PWD#' 38 | #MAKEPATH# 39 | MAKELEVEL = 2 40 | THE END 41 | #MAKE#[2]: Leaving directory '#PWD#' 42 | #MAKE#[1]: Leaving directory '#PWD#' 43 | #MAKE#: Leaving directory '#PWD#'")); 44 | 45 | 46 | # Test command line overrides. 47 | run_make_test(' 48 | recur: all ; @$(MAKE) --no-print-directory -f #MAKEFILE# a=AA all 49 | all: ; @echo "MAKEOVERRIDES = $(MAKEOVERRIDES)" 50 | ', 51 | 'a=ZZ', 52 | 'MAKEOVERRIDES = a=ZZ 53 | MAKEOVERRIDES = a=AA 54 | '); 55 | 56 | # SV 46013: Ensure that MAKEOVERRIDES is passed even if set in the makefile 57 | run_make_test(q! 58 | ifeq ($(MAKELEVEL),0) 59 | MAKEOVERRIDES += FOO+=bar 60 | endif 61 | .PHONY: M R 62 | M: ; @$(MAKE) --no-print-directory -f #MAKEFILE# R 63 | R: ; @echo '$(FOO)' 64 | !, 65 | '', 'bar'); 66 | 67 | 1; 68 | -------------------------------------------------------------------------------- /tests/scripts/features/rule_glob: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test globbing in targets and prerequisites."; 4 | 5 | $details = ""; 6 | 7 | touch(qw(a.one a.two a.three)); 8 | 9 | # Test wildcards in regular targets and prerequisites 10 | run_make_test(q{ 11 | .PHONY: all a.one a.two a.three 12 | all: a.one* a.t[a-z0-9]o a.th[!q]ee 13 | a.o[Nn][Ee] a.t*: ; @echo $@ 14 | }, 15 | '', "a.one\na.two\na.three"); 16 | 17 | # Test wildcards in pattern targets and prerequisites 18 | run_make_test(q{ 19 | .PHONY: all 20 | all: a.four 21 | %.four : %.t* ; @echo $@: $(sort $^) 22 | }, 23 | '', "a.four: a.three a.two"); 24 | 25 | # Test wildcards in second expansion targets and prerequisites 26 | run_make_test(q{ 27 | .PHONY: all 28 | all: a.four 29 | .SECONDEXPANSION: 30 | %.four : $$(sort %.t*) ; @echo $@: $(sort $^) 31 | }, 32 | '', "a.four: a.three a.two"); 33 | 34 | unlink(qw(a.one a.two a.three)); 35 | 36 | # This tells the test driver that the perl test script executed properly. 37 | 1; 38 | -------------------------------------------------------------------------------- /tests/scripts/features/shell_assignment: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test BSD-style shell assignments (VAR != VAL) for variables."; 4 | 5 | $details = ""; 6 | 7 | # TEST 0: Basic shell assignment (!=). 8 | 9 | run_make_test(' 10 | .POSIX: 11 | 12 | demo1!=printf \' 1 2 3\n4\n\n5 \n \n 6\n\n\n\n\' 13 | demo2 != printf \'7 8\n \' 14 | demo3 != printf \'$$(demo2)\' 15 | demo4 != printf \' 2 3 \n\' 16 | demo5 != printf \' 2 3 \n\n\' 17 | all: ; @echo "<$(demo1)> <$(demo2)> <$(demo3)> <$(demo4)> <${demo5}>" 18 | ', 19 | '', "< 1 2 3 4 5 6 > <7 8 > <7 8 > < 2 3 > < 2 3 >\n"); 20 | 21 | # TEST 1: Handle '#' the same way as BSD make 22 | $hashOctal = "\\043"; 23 | if ($osname eq 'os390') { 24 | $hashOctal = "\\173"; 25 | } 26 | 27 | run_make_test(' 28 | foo1!=echo bar#baz 29 | hash != printf \'' . $hashOctal . '\' 30 | foo2!= echo "bar$(hash)baz" 31 | 32 | all: ; @echo "<$(foo1)> <$(hash)> <$(foo2)>" 33 | ', 34 | '', " <#> \n"); 35 | 36 | # TEST 2: shell assignment variables (from !=) should be recursive. 37 | # Note that variables are re-evaluated later, so the shell can output 38 | # a value like $(XYZZY) as part of !=. The $(XYZZY) will be EVALUATED 39 | # when the value containing it is evaluated. On the negative side, this 40 | # means if you don't want this, you need to escape dollar signs as $$. 41 | # On the positive side, it means that shell programs can output macros 42 | # that are then evaluated as they are traditionally evaluated.. and that 43 | # you can use traditional macro evaluation semantics to implement !=. 44 | 45 | run_make_test(' 46 | XYZZY = fiddle-dee-dee 47 | dollar = $$ 48 | VAR3 != printf \'%s\' \'$(dollar)(XYZZY)\' 49 | 50 | all: ; @echo "<$(VAR3)>" 51 | ', 52 | '', "\n"); 53 | 54 | 55 | # TEST 3: Overrides invoke shell anyway; they just don't store the result 56 | # in a way that is visible. 57 | 58 | run_make_test(' 59 | 60 | override != echo abc > ,abc ; cat ,abc 61 | 62 | all: ; @echo "<$(override)>" ; cat ,abc 63 | ', 64 | 'override=xyz', "\nabc\n"); 65 | 66 | unlink(',abc'); 67 | 68 | 69 | 1; 70 | -------------------------------------------------------------------------------- /tests/scripts/features/utf8: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test support for UTF-8."; 4 | 5 | $details = ""; 6 | 7 | # Verify that the UTF-8 BOM is ignored. 8 | run_make_test("\xEF\xBB\xBFall: ; \@echo \$\@\n", '', "all"); 9 | 10 | # This tells the test driver that the perl test script executed properly. 11 | 1; 12 | -------------------------------------------------------------------------------- /tests/scripts/features/varnesting: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test recursive variables"; 3 | 4 | $details = ""; 5 | 6 | run_make_test(' 7 | x = variable1 8 | variable2 := Hello 9 | y = $(subst 1,2,$(x)) 10 | z = y 11 | a := $($($(z))) 12 | all: ; @echo $(a) 13 | ', 14 | '', "Hello\n"); 15 | 16 | # This tests resetting the value of a variable while expanding it. 17 | # You may only see problems with this if you're using valgrind or 18 | # some other memory checker that poisons freed memory. 19 | # See Savannah patch #7534 20 | 21 | run_make_test(' 22 | VARIABLE = $(eval VARIABLE := echo hi)$(VARIABLE) 23 | wololo: ; @$(VARIABLE) 24 | ', 25 | '', "hi\n"); 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /tests/scripts/features/vpathgpath: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Tests VPATH+/GPATH functionality."; 3 | 4 | $details = ""; 5 | 6 | mkdir('work'); 7 | 8 | $VP = "work$pathsep"; 9 | 10 | open(MAKEFILE,"> $makefile"); 11 | 12 | # The Contents of the MAKEFILE ... 13 | 14 | print MAKEFILE "VPATH = $VP\n"; 15 | 16 | print MAKEFILE <<'EOMAKE'; 17 | 18 | GPATH = $(VPATH) 19 | 20 | .SUFFIXES: .a .b .c .d 21 | .PHONY: general rename notarget intermediate 22 | 23 | %.a: 24 | %.b: 25 | %.c: 26 | %.d: 27 | 28 | %.a : %.b ; cat $^ > $@ 29 | %.b : %.c ; cat $^ > $@ 30 | %.c :: %.d ; cat $^ > $@ 31 | 32 | # General testing info: 33 | 34 | general: foo.b 35 | foo.b: foo.c bar.c 36 | 37 | EOMAKE 38 | 39 | close(MAKEFILE); 40 | 41 | @touchedfiles = (); 42 | 43 | $off = -500; 44 | 45 | sub gtouchfiles { 46 | foreach (@_) { 47 | ($f = $_) =~ s,VP/,$VP,g; 48 | &utouch($off, $f); 49 | $off += 10; 50 | push(@touchedfiles, $f); 51 | } 52 | } 53 | 54 | # Run the general-case test 55 | 56 | >ouchfiles("VP/foo.d", "VP/bar.d", "VP/foo.c", "VP/bar.c", "foo.b", "bar.d"); 57 | 58 | &run_make_with_options($makefile,"general",&get_logfile()); 59 | 60 | push(@touchedfiles, "bar.c"); 61 | 62 | $answer = "$make_name: Nothing to be done for 'general'.\n"; 63 | 64 | &compare_output($answer,&get_logfile(1)); 65 | 66 | unlink(@touchedfiles) unless $keep; 67 | 68 | 1; 69 | -------------------------------------------------------------------------------- /tests/scripts/features/vpathplus: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Tests the new VPATH+ functionality added in 3.76."; 3 | 4 | $details = ""; 5 | 6 | mkdir('work'); 7 | 8 | $VP = "work$pathsep"; 9 | 10 | @touchedfiles = (); 11 | 12 | $off = -500; 13 | 14 | sub touchfiles { 15 | foreach (@_) { 16 | &utouch($off, $_); 17 | $off += 10; 18 | push(@touchedfiles, $_); 19 | } 20 | } 21 | 22 | &touchfiles("$VP/foo.d", "$VP/bar.d", "$VP/foo.c", "$VP/bar.c", "foo.b", "bar.d"); 23 | 24 | # Run the general-case test 25 | 26 | run_make_test(qq!VPATH = $VP! . q! 27 | .SUFFIXES: .a .b .c .d 28 | .PHONY: general rename notarget intermediate 29 | 30 | %.a: 31 | %.b: 32 | %.c: 33 | %.d: 34 | 35 | %.a : %.b ; cat $^ > $@ 36 | %.b : %.c ; cat $^ > $@ 2>/dev/null || exit 1 37 | %.c :: %.d ; cat $^ > $@ 38 | 39 | # General testing info: 40 | 41 | general: foo.b 42 | foo.b: foo.c bar.c 43 | 44 | # Rename testing info: 45 | 46 | rename: $(VPATH)/foo.c foo.d 47 | 48 | # Target not made testing info: 49 | 50 | notarget: notarget.b 51 | notarget.c: notarget.d ; -@echo "not creating $@ from $^" 52 | 53 | # Intermediate files: 54 | 55 | intermediate: inter.a 56 | !, 57 | 'general', "cat bar.d > bar.c\ncat ${VP}foo.c bar.c > foo.b 2>/dev/null || exit 1\n"); 58 | 59 | push(@touchedfiles, "bar.c"); 60 | 61 | # Test rules that don't make the target correctly 62 | 63 | &touchfiles("$VP/notarget.c", "notarget.b", "notarget.d"); 64 | 65 | run_make_test(undef, 'notarget', "not creating notarget.c from notarget.d\ncat notarget.c > notarget.b 2>/dev/null || exit 1\n#MAKE#: *** [#MAKEFILE#:11: notarget.b] Error 1\n", 512); 66 | 67 | # Test intermediate file handling (part 1) 68 | 69 | &touchfiles("$VP/inter.d"); 70 | 71 | my $be = pack("L", 1) eq pack("N", 1); 72 | my $intfiles = $be ? "inter.c inter.b" : "inter.b inter.c"; 73 | 74 | run_make_test(undef, 'intermediate', "cat ${VP}inter.d > inter.c\ncat inter.c > inter.b 2>/dev/null || exit 1\ncat inter.b > inter.a\nrm $intfiles\n"); 75 | 76 | push(@touchedfiles, "inter.a", "inter.b"); 77 | 78 | # Test intermediate file handling (part 2) 79 | 80 | &utouch(-20, "inter.a"); 81 | &utouch(-10, "$VP/inter.b"); 82 | &touch("$VP/inter.d"); 83 | 84 | run_make_test(undef, 'intermediate', "cat ${VP}inter.d > inter.c\ncat inter.c > inter.b 2>/dev/null || exit 1\ncat inter.b > inter.a\nrm inter.c\n"); 85 | 86 | push(@touchedfiles, "$VP/inter.b", "$VP/inter.d"); 87 | 88 | unlink @touchedfiles unless $keep; 89 | 90 | 1; 91 | -------------------------------------------------------------------------------- /tests/scripts/functions/abspath: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test the abspath functions."; 3 | 4 | $details = ""; 5 | 6 | # Someone needs to rewrite this to be portable for Windows 7 | $port_type eq 'W32' and return -1; 8 | 9 | run_make_test(' 10 | ifneq ($(realpath $(abspath .)),$(CURDIR)) 11 | $(warning .: abs="$(abspath .)" real="$(realpath $(abspath .))" curdir="$(CURDIR)") 12 | endif 13 | 14 | ifneq ($(realpath $(abspath ./)),$(CURDIR)) 15 | $(warning ./: abs="$(abspath ./)" real="$(realpath $(abspath ./))" curdir="$(CURDIR)") 16 | endif 17 | 18 | ifneq ($(realpath $(abspath .///)),$(CURDIR)) 19 | $(warning .///: abs="$(abspath .///)" real="$(realpath $(abspath .///))" curdir="$(CURDIR)") 20 | endif 21 | 22 | ifneq ($(abspath /),/) 23 | $(warning /: abspath="$(abspath /)") 24 | endif 25 | 26 | ifneq ($(abspath ///),/) 27 | $(warning ///: abspath="$(abspath ///)") 28 | endif 29 | 30 | ifneq ($(abspath /.),/) 31 | $(warning /.: abspath="$(abspath /.)") 32 | endif 33 | 34 | ifneq ($(abspath ///.),/) 35 | $(warning ///.: abspath="$(abspath ///.)") 36 | endif 37 | 38 | ifneq ($(abspath /./),/) 39 | $(warning /./: abspath="$(abspath /./)") 40 | endif 41 | 42 | ifneq ($(abspath /.///),/) 43 | $(warning /.///: abspath="$(abspath /.///)") 44 | endif 45 | 46 | ifneq ($(abspath /..),/) 47 | $(warning /..: abspath="$(abspath /..)") 48 | endif 49 | 50 | ifneq ($(abspath ///..),/) 51 | $(warning ///..: abspath="$(abspath ///..)") 52 | endif 53 | 54 | ifneq ($(abspath /../),/) 55 | $(warning /../: abspath="$(abspath /../)") 56 | endif 57 | 58 | ifneq ($(abspath /..///),/) 59 | $(warning /..///: abspath="$(abspath /..///)") 60 | endif 61 | 62 | 63 | ifneq ($(abspath /foo/bar/..),/foo) 64 | $(warning /foo/bar/..: abspath="$(abspath /foo/bar/..)") 65 | endif 66 | 67 | ifneq ($(abspath /foo/bar/../../../baz),/baz) 68 | $(warning /foo/bar/../../../baz: abspath="$(abspath /foo/bar/../../../baz)") 69 | endif 70 | 71 | ifneq ($(abspath /foo/bar/../ /..),/foo /) 72 | $(warning /foo/bar/../ /..: abspath="$(abspath /foo/bar/../ /..)") 73 | endif 74 | 75 | 76 | .PHONY: all 77 | all: ; @: 78 | ', 79 | '', 80 | ''); 81 | 82 | 83 | # This tells the test driver that the perl test script executed properly. 84 | 1; 85 | -------------------------------------------------------------------------------- /tests/scripts/functions/addprefix: -------------------------------------------------------------------------------- 1 | $description = "The following test creates a makefile to test the addprefix " 2 | ."function."; 3 | 4 | $details = ""; 5 | 6 | # IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET 7 | # THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF 8 | # HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END. 9 | # EXAMPLE: $makefile2 = &get_tmpfile; 10 | 11 | 12 | open(MAKEFILE,"> $makefile"); 13 | 14 | # The Contents of the MAKEFILE ... 15 | 16 | print MAKEFILE "string := \$(addprefix src${pathsep},a.b.z.foo hacks) \n" 17 | ."all: \n" 18 | ."\t\@echo \$(string) \n"; 19 | 20 | # END of Contents of MAKEFILE 21 | 22 | close(MAKEFILE); 23 | 24 | &run_make_with_options($makefile,"",&get_logfile,0); 25 | 26 | # Create the answer to what should be produced by this Makefile 27 | $answer = "src${pathsep}a.b.z.foo src${pathsep}hacks\n"; 28 | 29 | # COMPARE RESULTS 30 | 31 | # In this call to compare output, you should use the call &get_logfile(1) 32 | # to send the name of the last logfile created. You may also use 33 | # the special call &get_logfile(1) which returns the same as &get_logfile(1). 34 | 35 | &compare_output($answer,&get_logfile(1)); 36 | 37 | # This tells the test driver that the perl test script executed properly. 38 | 1; 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /tests/scripts/functions/addsuffix: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test the addsuffix function."; 3 | 4 | $details = ""; 5 | 6 | 7 | open(MAKEFILE,"> $makefile"); 8 | 9 | # The Contents of the MAKEFILE ... 10 | 11 | print MAKEFILE <1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET 7 | # THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF 8 | # HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END. 9 | # EXAMPLE: $makefile2 = &get_tmpfile; 10 | 11 | 12 | open(MAKEFILE,"> $makefile"); 13 | 14 | # The Contents of the MAKEFILE ... 15 | 16 | print MAKEFILE "string := \$(basename src${pathsep}a.b.z.foo.c src${pathsep}hacks src.bar${pathsep}a.b.z.foo.c src.bar${pathsep}hacks hacks) \n" 17 | ."all: \n" 18 | ."\t\@echo \$(string) \n"; 19 | 20 | # END of Contents of MAKEFILE 21 | 22 | close(MAKEFILE); 23 | 24 | &run_make_with_options($makefile,"",&get_logfile,0); 25 | 26 | # Create the answer to what should be produced by this Makefile 27 | $answer = "src${pathsep}a.b.z.foo src${pathsep}hacks src.bar${pathsep}a.b.z.foo src.bar${pathsep}hacks hacks\n"; 28 | 29 | # COMPARE RESULTS 30 | 31 | # In this call to compare output, you should use the call &get_logfile(1) 32 | # to send the name of the last logfile created. You may also use 33 | # the special call &get_logfile(1) which returns the same as &get_logfile(1). 34 | 35 | &compare_output($answer,&get_logfile(1)); 36 | 37 | # This tells the test driver that the perl test script executed properly. 38 | 1; 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /tests/scripts/functions/call: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test the call function.\n"; 3 | 4 | $details = "Try various uses of call and ensure they all give the correct 5 | results.\n"; 6 | 7 | run_make_test(q! 8 | # Simple, just reverse two things 9 | # 10 | reverse = $2 $1 11 | 12 | # A complex 'map' function, using recursive 'call'. 13 | # 14 | map = $(foreach a,$2,$(call $1,$a)) 15 | 16 | # Test using a builtin; this is silly as it's simpler to do without call 17 | # 18 | my-notdir = $(call notdir,$(1)) 19 | 20 | # Test using non-expanded builtins 21 | # 22 | my-foreach = $(foreach $(1),$(2),$(3)) 23 | my-if = $(if $(1),$(2),$(3)) 24 | 25 | # Test recursive invocations of call with different arguments 26 | # 27 | one = $(1) $(2) $(3) 28 | two = $(call one,$(1),foo,$(2)) 29 | 30 | # Test recursion on the user-defined function. As a special case make 31 | # won't error due to this. 32 | # Implement transitive closure using $(call ...) 33 | # 34 | DEP_foo = bar baz quux 35 | DEP_baz = quux blarp 36 | rest = $(wordlist 2,$(words ${1}),${1}) 37 | tclose = $(if $1,$(firstword $1)\ 38 | $(call tclose,$(sort ${DEP_$(firstword $1)} $(call rest,$1)))) 39 | 40 | all: ; @echo '$(call reverse,bar,foo)'; \ 41 | echo '$(call map,origin,MAKE reverse map)'; \ 42 | echo '$(call my-notdir,a/b c/d e/f)'; \ 43 | echo '$(call my-foreach)'; \ 44 | echo '$(call my-foreach,a,,,)'; \ 45 | echo '$(call my-if,a,b,c)'; \ 46 | echo '$(call two,bar,baz)'; \ 47 | echo '$(call tclose,foo)'; 48 | !, 49 | "", "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n"); 50 | 51 | # These won't work because call expands all its arguments first, before 52 | # passing them on, then marks them as resolved/simple, so they're not 53 | # expanded again by the function. 54 | # 55 | # echo '$(call my-foreach,a,x y z,$$(a)$$(a))'; \ 56 | # echo '$(call my-if,,$$(info don't print this),$$(info do print this))' 57 | # 58 | # $answer = "xx yy zz\ndo print this\n"; 59 | 60 | # TEST eclipsing of arguments when invoking sub-calls 61 | 62 | run_make_test(q! 63 | all = $1 $2 $3 $4 $5 $6 $7 $8 $9 64 | 65 | level1 = $(call all,$1,$2,$3,$4,$5) 66 | level2 = $(call level1,$1,$2,$3) 67 | level3 = $(call level2,$1,$2,$3,$4,$5) 68 | 69 | all: 70 | @echo $(call all,1,2,3,4,5,6,7,8,9,10,11) 71 | @echo $(call level1,1,2,3,4,5,6,7,8) 72 | @echo $(call level2,1,2,3,4,5,6,7,8) 73 | @echo $(call level3,1,2,3,4,5,6,7,8) 74 | !, 75 | "", "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n"); 76 | 77 | # Ensure that variables are defined in global scope even in a $(call ...) 78 | 79 | delete $ENV{X123}; 80 | 81 | run_make_test(' 82 | tst = $(eval export X123) 83 | $(call tst) 84 | all: ; @echo "$${X123-not set}" 85 | ', 86 | '', "\n"); 87 | 88 | 1; 89 | 90 | ### Local Variables: 91 | ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 92 | ### End: 93 | -------------------------------------------------------------------------------- /tests/scripts/functions/dir: -------------------------------------------------------------------------------- 1 | $description = "The following test creates a makefile to test the dir " 2 | ."function."; 3 | 4 | $details = ""; 5 | 6 | # IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET 7 | # THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF 8 | # HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END. 9 | # EXAMPLE: $makefile2 = &get_tmpfile; 10 | 11 | 12 | open(MAKEFILE,"> $makefile"); 13 | 14 | # The Contents of the MAKEFILE ... 15 | 16 | print MAKEFILE "string := \$(dir src${pathsep}foo.c hacks) \n" 17 | ."all: \n" 18 | ."\t\@echo \$(string) \n"; 19 | 20 | # END of Contents of MAKEFILE 21 | 22 | close(MAKEFILE); 23 | 24 | &run_make_with_options($makefile,"",&get_logfile,0); 25 | 26 | # Create the answer to what should be produced by this Makefile 27 | $answer = "src${pathsep} .${pathsep}\n"; 28 | 29 | # COMPARE RESULTS 30 | 31 | # In this call to compare output, you should use the call &get_logfile(1) 32 | # to send the name of the last logfile created. You may also use 33 | # the special call &get_logfile(1) which returns the same as &get_logfile(1). 34 | 35 | &compare_output($answer,&get_logfile(1)); 36 | 37 | # This tells the test driver that the perl test script executed properly. 38 | 1; 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /tests/scripts/functions/error: -------------------------------------------------------------------------------- 1 | # -*-Perl-*- 2 | 3 | $description = "\ 4 | The following test creates a makefile to test the error function."; 5 | 6 | $details = ""; 7 | 8 | open(MAKEFILE,"> $makefile"); 9 | 10 | print MAKEFILE 'err = $(error Error found!) 11 | 12 | ifdef ERROR1 13 | $(error error is $(ERROR1)) 14 | endif 15 | 16 | ifdef ERROR2 17 | $(error error is $(ERROR2)) 18 | endif 19 | 20 | ifdef ERROR3 21 | all: some; @echo $(error error is $(ERROR3)) 22 | endif 23 | 24 | ifdef ERROR4 25 | all: some; @echo error is $(ERROR4) 26 | @echo $(error error is $(ERROR4)) 27 | endif 28 | 29 | some: ; @echo Some stuff 30 | 31 | testvar: ; @: $(err) 32 | '; 33 | 34 | close(MAKEFILE); 35 | 36 | # Test #1 37 | 38 | &run_make_with_options($makefile, "ERROR1=yes", &get_logfile, 512); 39 | $answer = "$makefile:4: *** error is yes. Stop.\n"; 40 | &compare_output($answer,&get_logfile(1)); 41 | 42 | # Test #2 43 | 44 | &run_make_with_options($makefile, "ERROR2=no", &get_logfile, 512); 45 | $answer = "$makefile:8: *** error is no. Stop.\n"; 46 | &compare_output($answer,&get_logfile(1)); 47 | 48 | # Test #3 49 | 50 | &run_make_with_options($makefile, "ERROR3=maybe", &get_logfile, 512); 51 | $answer = "Some stuff\n$makefile:12: *** error is maybe. Stop.\n"; 52 | &compare_output($answer,&get_logfile(1)); 53 | 54 | # Test #4 55 | 56 | &run_make_with_options($makefile, "ERROR4=definitely", &get_logfile, 512); 57 | $answer = "Some stuff\n$makefile:17: *** error is definitely. Stop.\n"; 58 | &compare_output($answer,&get_logfile(1)); 59 | 60 | # Test #5 61 | 62 | &run_make_with_options($makefile, "testvar", &get_logfile, 512); 63 | $answer = "$makefile:22: *** Error found!. Stop.\n"; 64 | &compare_output($answer,&get_logfile(1)); 65 | 66 | # This tells the test driver that the perl test script executed properly. 67 | 1; 68 | 69 | ### Local Variables: 70 | ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 71 | ### End: 72 | -------------------------------------------------------------------------------- /tests/scripts/functions/filter-out: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the filter and filter-out functions."; 4 | 5 | $details = "The makefile created in this test has two variables. The 6 | filter-out function is first used to discard names ending in 7 | .o with a single simple pattern. The second filter-out function 8 | augments the simple pattern with three literal names, which are 9 | also added to the text argument. This tests an internal hash table 10 | which is only used if there are multiple literals present in both 11 | the pattern and text arguments. The result of both filter-out 12 | functions is the same single .elc name.\n"; 13 | 14 | # Basic test -- filter 15 | run_make_test(q! 16 | files1 := $(filter %.o, foo.elc bar.o lose.o) 17 | files2 := $(filter %.o foo.i, foo.i bar.i lose.i foo.elc bar.o lose.o) 18 | all: ; @echo '$(files1) $(files2)' 19 | !, 20 | '', "bar.o lose.o foo.i bar.o lose.o\n"); 21 | 22 | # Basic test -- filter-out 23 | run_make_test(q! 24 | files1 := $(filter-out %.o, foo.elc bar.o lose.o) 25 | files2 := $(filter-out foo.i bar.i lose.i %.o, foo.i bar.i lose.i foo.elc bar.o lose.o) 26 | all: ; @echo '$(files1) $(files2)' 27 | !, 28 | '', "foo.elc foo.elc\n"); 29 | 30 | # Force use of hash (see function.c:func_filter_filterout for params) 31 | 32 | my $base = 'foo.1 foo.2 foo.3 foo.4 foo.5 foo.6 foo.7 foo.8 foo.9 foo.10'; 33 | 34 | my $base10 = join(' ', ($base) x 10); 35 | my $out3 = join(' ', ('foo.3') x 10); 36 | my $out456 = join(' ', ('foo.4 foo.5 foo.6') x 10); 37 | 38 | run_make_test("words := $base10" . q! 39 | files1 := $(filter %.3, $(words)) 40 | files2 := $(filter %.4 foo.5 foo.6, $(words)) 41 | all: ; @echo '$(files1) $(files2)' 42 | !, 43 | '', "$out3 $out456\n"); 44 | 45 | 46 | # Escaped patterns 47 | run_make_test(q!all:;@echo '$(filter foo\%bar,foo%bar fooXbar)'!, 48 | '', "foo%bar\n"); 49 | 50 | run_make_test(q!all:;@echo '$(filter foo\%\%\\\\\%\%bar,foo%%\\%%bar fooX\\Ybar)'!, 51 | '', "foo%%\\%%bar\n"); 52 | 53 | run_make_test(q! 54 | X = $(filter foo\\\\\%bar,foo\%bar foo\Xbar) 55 | all:;@echo '$(X)'!, 56 | '', "foo\\%bar\n"); 57 | 58 | 1; 59 | -------------------------------------------------------------------------------- /tests/scripts/functions/findstring: -------------------------------------------------------------------------------- 1 | $description = "The following test creates a makefile to test the findstring " 2 | ."function."; 3 | 4 | $details = ""; 5 | 6 | # IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET 7 | # THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF 8 | # HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END. 9 | # EXAMPLE: $makefile2 = &get_tmpfile; 10 | 11 | 12 | open(MAKEFILE,"> $makefile"); 13 | 14 | # The Contents of the MAKEFILE ... 15 | 16 | print MAKEFILE "string := \$(findstring port, reporter)\n" 17 | ."all: \n" 18 | ."\t\@echo \$(string) \n"; 19 | 20 | # END of Contents of MAKEFILE 21 | 22 | close(MAKEFILE); 23 | 24 | &run_make_with_options($makefile, 25 | "", 26 | &get_logfile, 27 | 0); 28 | 29 | # Create the answer to what should be produced by this Makefile 30 | $answer = "port\n"; 31 | 32 | # COMPARE RESULTS 33 | 34 | # In this call to compare output, you should use the call &get_logfile(1) 35 | # to send the name of the last logfile created. You may also use 36 | # the special call &get_logfile(1) which returns the same as &get_logfile(1). 37 | 38 | &compare_output($answer,&get_logfile(1)); 39 | 40 | # This tells the test driver that the perl test script executed properly. 41 | 1; 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /tests/scripts/functions/flavor: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test the flavor function."; 3 | 4 | $details = ""; 5 | 6 | 7 | # Test #1: Test general logic. 8 | # 9 | run_make_test(' 10 | s := s 11 | r = r 12 | 13 | $(info u $(flavor u)) 14 | $(info s $(flavor s)) 15 | $(info r $(flavor r)) 16 | 17 | ra += ra 18 | rc ?= rc 19 | 20 | $(info ra $(flavor ra)) 21 | $(info rc $(flavor rc)) 22 | 23 | s += s 24 | r += r 25 | 26 | $(info s $(flavor s)) 27 | $(info r $(flavor r)) 28 | 29 | 30 | .PHONY: all 31 | all:;@: 32 | ', 33 | '', 34 | 'u undefined 35 | s simple 36 | r recursive 37 | ra recursive 38 | rc recursive 39 | s simple 40 | r recursive'); 41 | 42 | 43 | # This tells the test driver that the perl test script executed properly. 44 | 1; 45 | -------------------------------------------------------------------------------- /tests/scripts/functions/foreach: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | # $Id$ 3 | 4 | $description = "Test the foreach function."; 5 | 6 | $details = "This is a test of the foreach function in gnu make. 7 | This function starts with a space separated list of 8 | names and a variable. Each name in the list is substituted 9 | into the variable and the given text evaluated. The general 10 | form of the command is $(foreach var,\$list,\$text). Several 11 | types of foreach loops are tested\n"; 12 | 13 | 14 | # TEST 0 15 | 16 | # Set an environment variable that we can test in the makefile. 17 | $ENV{FOOFOO} = 'foo foo'; 18 | 19 | run_make_test("space = ' '".' 20 | null := 21 | auto_var = udef space CC null FOOFOO MAKE foo CFLAGS WHITE @ < 22 | foo = bletch null @ garf 23 | av = $(foreach var, $(auto_var), $(origin $(var)) ) 24 | override WHITE := BLACK 25 | for_var = $(addsuffix .c,foo $(null) $(foo) $(space) $(av) ) 26 | fe = $(foreach var2, $(for_var),$(subst .c,.o, $(var2) ) ) 27 | all: auto for2 28 | auto : ; @echo $(av) 29 | for2: ; @echo $(fe)', 30 | '-e WHITE=WHITE CFLAGS=', 31 | "undefined file default file environment override default file command line override automatic automatic 32 | foo.o bletch.o null.o @.o garf.o .o .o undefined.o file.o default.o file.o environment.o override.o default.o file.o command.o line.o override.o automatic.o automatic.o"); 33 | 34 | # TEST 1: Test that foreach variables take precedence over global 35 | # variables in a global scope (like inside an eval). Tests bug #11913 36 | 37 | run_make_test(' 38 | .PHONY: all target 39 | all: target 40 | 41 | x := BAD 42 | 43 | define mktarget 44 | target: x := $(x) 45 | target: ; @echo "$(x)" 46 | endef 47 | 48 | x := GLOBAL 49 | 50 | $(foreach x,FOREACH,$(eval $(value mktarget)))', 51 | '', 52 | 'FOREACH'); 53 | 54 | # Allow variable names with trailing space 55 | run_make_test(q! 56 | $(foreach \ 57 | a \ 58 | , b c d \ 59 | , $(info $a)) 60 | all:;@: 61 | !, 62 | "", "b\nc\nd\n"); 63 | 64 | # Allow empty variable names. We still expand the body. 65 | 66 | run_make_test(' 67 | x = $(foreach ,1 2 3,a) 68 | y := $x 69 | 70 | all: ; @echo $y', 71 | '', "a a a\n"); 72 | 73 | # Check some error conditions. 74 | 75 | run_make_test(' 76 | x = $(foreach ) 77 | y = $x 78 | 79 | all: ; @echo $y', 80 | '', 81 | "#MAKEFILE#:2: *** insufficient number of arguments (1) to function 'foreach'. Stop.", 82 | 512); 83 | 84 | run_make_test(' 85 | x = $(foreach x,y) 86 | y := $x 87 | 88 | all: ; @echo $y', 89 | '', 90 | "#MAKEFILE#:2: *** insufficient number of arguments (2) to function 'foreach'. Stop.", 91 | 512); 92 | 93 | 1; 94 | -------------------------------------------------------------------------------- /tests/scripts/functions/if: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test the if function.\n"; 3 | 4 | $details = "Try various uses of if and ensure they all give the correct 5 | results.\n"; 6 | 7 | open(MAKEFILE, "> $makefile"); 8 | 9 | print MAKEFILE < 16 | all: 17 | > @echo 0_1 $(intcmp $n,$n) 18 | > @echo 0_2 $(intcmp $z,$z) 19 | > @echo 0_3 $(intcmp -$z,$z) 20 | > @echo 0_4 $(intcmp $p,$p) 21 | > @echo 0_5 $(intcmp $n,$z) 22 | > @echo 0_6 $(intcmp $z,$n) 23 | > @echo 1_1 $(intcmp $n,$n,$(shell echo lt)) 24 | > @echo 1_2 $(intcmp $n,$z,$(shell echo lt)) 25 | > @echo 1_3 $(intcmp $z,$n,$(shell echo lt)) 26 | > @echo 2_1 $(intcmp $n,$p,lt,ge) 27 | > @echo 2_2 $(intcmp $z,$z,lt,ge) 28 | > @echo 2_3 $(intcmp $p,$n,lt,ge) 29 | > @echo 3_0 $(intcmp $p,$n,lt,eq,) 30 | > @echo 3_1 $(intcmp $z,$p,lt,eq,gt) 31 | > @echo 3_2 $(intcmp $p,$z,lt,eq,gt) 32 | > @echo 3_3 $(intcmp $p,$p,lt,eq,gt) 33 | > @echo 3_4 $(intcmp $p,$q,lt,eq,gt) 34 | > @echo 3_5 $(intcmp $q,$p,lt,eq,gt) 35 | > @echo 3_6 $(intcmp -$p,-$q,lt,eq,gt) 36 | > @echo 3_7 $(intcmp -$q,-$p,lt,eq,gt) 37 | > @echo 4_1 $(intcmp -$(huge),$(huge),lt,eq,gt) 38 | > @echo 4_2 $(intcmp $(huge),-$(huge),lt,eq,gt) 39 | > @echo 4_3 $(intcmp -$(huge),-$(huge),lt,eq,gt) 40 | > @echo 4_4 $(intcmp +$(huge),$(huge),lt,eq,gt) 41 | ', '', '0_1 -10 42 | 0_2 0 43 | 0_3 0 44 | 0_4 888 45 | 0_5 46 | 0_6 47 | 1_1 48 | 1_2 lt 49 | 1_3 50 | 2_1 lt 51 | 2_2 ge 52 | 2_3 ge 53 | 3_0 54 | 3_1 lt 55 | 3_2 gt 56 | 3_3 eq 57 | 3_4 lt 58 | 3_5 gt 59 | 3_6 gt 60 | 3_7 lt 61 | 4_1 lt 62 | 4_2 gt 63 | 4_3 eq 64 | 4_4 eq 65 | '); 66 | 67 | # Test error conditions 68 | 69 | run_make_test(' 70 | intcmp-e1: ; @echo $(intcmp 12a,1,foo) 71 | intcmp-e2: ; @echo $(intcmp 0,,foo) 72 | intcmp-e3: ; @echo $(intcmp -1,) 73 | intcmp-e4: ; @echo $(intcmp ,55)', 74 | 'intcmp-e1', 75 | "#MAKEFILE#:2: *** non-numeric first argument to 'intcmp' function: '12a'. Stop.", 76 | 512); 77 | 78 | run_make_test(undef, 79 | 'intcmp-e2', 80 | "#MAKEFILE#:3: *** non-numeric second argument to 'intcmp' function: empty value. Stop.", 81 | 512); 82 | 83 | run_make_test(undef, 84 | 'intcmp-e3', 85 | "#MAKEFILE#:4: *** non-numeric second argument to 'intcmp' function: empty value. Stop.", 86 | 512); 87 | 88 | run_make_test(undef, 89 | 'intcmp-e4', 90 | "#MAKEFILE#:5: *** non-numeric first argument to 'intcmp' function: empty value. Stop.", 91 | 512); 92 | 93 | 94 | # This tells the test driver that the perl test script executed properly. 95 | 1; 96 | -------------------------------------------------------------------------------- /tests/scripts/functions/join: -------------------------------------------------------------------------------- 1 | $description = "The following test creates a makefile to test the join " 2 | ."function."; 3 | 4 | $details = ""; 5 | 6 | # IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET 7 | # THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF 8 | # HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END. 9 | # EXAMPLE: $makefile2 = &get_tmpfile; 10 | 11 | 12 | open(MAKEFILE,"> $makefile"); 13 | 14 | # The Contents of the MAKEFILE ... 15 | 16 | print MAKEFILE "string := \$(join a b c,foo hacks .pl1) \n" 17 | ."all: \n" 18 | ."\t\@echo \$(string) \n"; 19 | 20 | # END of Contents of MAKEFILE 21 | 22 | close(MAKEFILE); 23 | 24 | &run_make_with_options($makefile,"",&get_logfile,0); 25 | 26 | # Create the answer to what should be produced by this Makefile 27 | $answer = "afoo bhacks c.pl1\n"; 28 | 29 | # COMPARE RESULTS 30 | 31 | # In this call to compare output, you should use the call &get_logfile(1) 32 | # to send the name of the last logfile created. You may also use 33 | # the special call &get_logfile(1) which returns the same as &get_logfile(1). 34 | 35 | &compare_output($answer,&get_logfile(1)); 36 | 37 | # This tells the test driver that the perl test script executed properly. 38 | 1; 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /tests/scripts/functions/notdir: -------------------------------------------------------------------------------- 1 | $description = "The following test creates a makefile to test the notdir " 2 | ."function."; 3 | 4 | $details = ""; 5 | 6 | # IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET 7 | # THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF 8 | # HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END. 9 | # EXAMPLE: $makefile2 = &get_tmpfile; 10 | 11 | 12 | open(MAKEFILE,"> $makefile"); 13 | 14 | # The Contents of the MAKEFILE ... 15 | 16 | print MAKEFILE "string := \$(notdir ${pathsep}src${pathsep}foo.c hacks) \n" 17 | ."all: \n" 18 | ."\t\@echo \$(string) \n"; 19 | 20 | # END of Contents of MAKEFILE 21 | 22 | close(MAKEFILE); 23 | 24 | &run_make_with_options($makefile,"",&get_logfile,0); 25 | 26 | # Create the answer to what should be produced by this Makefile 27 | $answer = "foo.c hacks\n"; 28 | 29 | # COMPARE RESULTS 30 | 31 | # In this call to compare output, you should use the call &get_logfile(1) 32 | # to send the name of the last logfile created. You may also use 33 | # the special call &get_logfile(1) which returns the same as &get_logfile(1). 34 | 35 | &compare_output($answer,&get_logfile(1)); 36 | 37 | # This tells the test driver that the perl test script executed properly. 38 | 1; 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /tests/scripts/functions/origin: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the origin function."; 4 | 5 | $details = "This is a test of the origin function in gnu make. 6 | This function will report on where a variable was 7 | defined per the following list: 8 | 9 | 'undefined' never defined 10 | 'default' default definition 11 | 'environment' environment var without -e 12 | 'environment override' environment var with -e 13 | 'file' defined in makefile 14 | 'command line' defined on the command line 15 | 'override' defined by override in makefile 16 | 'automatic' Automatic variable\n"; 17 | 18 | # Set an environment variable 19 | $ENV{MAKETEST} = 1; 20 | 21 | run_make_test(' 22 | foo := bletch garf 23 | auto_var = undefined CC MAKETEST MAKE foo CFLAGS WHITE @ 24 | av = $(foreach var, $(auto_var), $(origin $(var)) ) 25 | override WHITE := BLACK 26 | .RECIPEPREFIX = > 27 | all: auto 28 | > @echo $(origin undefined) 29 | > @echo $(origin CC) 30 | > @echo $(origin MAKETEST) 31 | > @echo $(origin MAKE) 32 | > @echo $(origin foo) 33 | > @echo $(origin CFLAGS) 34 | > @echo $(origin WHITE) 35 | > @echo $(origin @) 36 | auto : 37 | > @echo $(av)', 38 | '-e WHITE=WHITE CFLAGS=', 39 | 'undefined default environment override default file command line override automatic 40 | undefined 41 | default 42 | environment override 43 | default 44 | file 45 | command line 46 | override 47 | automatic'); 48 | 49 | 1; 50 | -------------------------------------------------------------------------------- /tests/scripts/functions/realpath: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test the realpath functions."; 3 | 4 | $details = ""; 5 | 6 | # Check the local directory's realpath 7 | run_make_test(' 8 | ifneq ($(realpath .),$(CURDIR)) 9 | $(warning $(realpath .) != $(CURDIR)) 10 | endif 11 | 12 | ifneq ($(realpath ./),$(CURDIR)) 13 | $(warning $(realpath ./) != $(CURDIR)) 14 | endif 15 | 16 | ifneq ($(realpath .///),$(CURDIR)) 17 | $(warning $(realpath .///) != $(CURDIR)) 18 | endif 19 | 20 | .PHONY: all 21 | all: ; @: 22 | ', 23 | '', ''); 24 | 25 | # Find the realpath to the root of the partition 26 | create_file('root.mk', 'all:;$(info $(realpath /))'); 27 | my $root = `$make_path -sf root.mk`; 28 | unlink('root.mk'); 29 | $root =~ s/\r?\n//g; 30 | 31 | my $tst = ' 32 | ifneq ($(realpath /.),#ROOT#) 33 | $(warning $(realpath /.) != #ROOT#) 34 | endif 35 | 36 | ifneq ($(realpath /./),#ROOT#) 37 | $(warning $(realpath /./) != #ROOT#) 38 | endif 39 | 40 | ifneq ($(realpath /.///),#ROOT#) 41 | $(warning $(realpath /.///) != #ROOT#) 42 | endif 43 | 44 | ifneq ($(realpath /..),#ROOT#) 45 | $(warning $(realpath /..) != #ROOT#) 46 | endif 47 | 48 | ifneq ($(realpath /../),#ROOT#) 49 | $(warning $(realpath /../) != #ROOT#) 50 | endif 51 | 52 | ifneq ($(realpath /..///),#ROOT#) 53 | $(warning $(realpath /..///) != #ROOT#) 54 | endif 55 | 56 | ifneq ($(realpath . /..),$(CURDIR) #ROOT#) 57 | $(warning $(realpath . /..) != $(CURDIR) #ROOT#) 58 | endif 59 | 60 | .PHONY: all 61 | all: ; @: 62 | '; 63 | $tst =~ s/#ROOT#/$root/g; 64 | run_make_test($tst, '', ''); 65 | 66 | # On Windows platforms "//" means something special. So, don't do these tests 67 | # there. 68 | 69 | if ($port_type ne 'W32') { 70 | $tst = ' 71 | ifneq ($(realpath ///),#ROOT#) 72 | $(warning $(realpath ///) != #ROOT#) 73 | endif 74 | 75 | ifneq ($(realpath ///.),#ROOT#) 76 | $(warning $(realpath ///.) != #ROOT#) 77 | endif 78 | 79 | ifneq ($(realpath ///..),#ROOT#) 80 | $(warning $(realpath ///..) != #ROOT#) 81 | endif 82 | 83 | .PHONY: all 84 | all: ; @:'; 85 | $tst =~ s/#ROOT#/$root/g; 86 | 87 | run_make_test($tst, '', ''); 88 | } 89 | 90 | 91 | # This tells the test driver that the perl test script executed properly. 92 | 1; 93 | -------------------------------------------------------------------------------- /tests/scripts/functions/sort: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "The following test creates a makefile to verify 4 | the ability of make to sort lists of object. Sort 5 | will also remove any duplicate entries. This will also 6 | be tested."; 7 | 8 | $details = "The make file is built with a list of object in a random order 9 | and includes some duplicates. Make should sort all of the elements 10 | remove all duplicates\n"; 11 | 12 | run_make_test(' 13 | foo := moon_light days 14 | foo1:= jazz 15 | bar := captured 16 | bar2 = boy end, has rise A midnight 17 | bar3:= $(foo) 18 | s1 := _by 19 | s2 := _and_a 20 | t1 := $(addsuffix $(s1), $(bar) ) 21 | t2 := $(addsuffix $(s2), $(foo1) ) 22 | t3 := $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) 23 | t4 := $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) 24 | t5 := $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) 25 | t6 := $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) 26 | t7 := $(t6) $(t6) $(t6) 27 | p1 := $(addprefix $(foo1), $(s2) ) 28 | blank:= 29 | all: 30 | @echo $(sort $(bar2) $(foo) $(addsuffix $(s1), $(bar) ) $(t2) $(bar2) $(bar3)) 31 | @echo $(sort $(blank) $(foo) $(bar2) $(t1) $(p1) ) 32 | @echo $(sort $(foo) $(bar2) $(t1) $(t4) $(t5) $(t7) $(t6) ) 33 | ', 34 | '', 'A boy captured_by days end, has jazz_and_a midnight moon_light rise 35 | A boy captured_by days end, has jazz_and_a midnight moon_light rise 36 | A boy captured_by days end, has jazz_and_a midnight moon_light rise 37 | '); 38 | 39 | 40 | # Test with non-space/tab whitespace. Note that you can't see the 41 | # original bug except using valgrind. 42 | 43 | run_make_test("FOO = a b\tc\rd\fe \f \f \f \f \ff 44 | all: ; \@echo \$(words \$(sort \$(FOO)))\n", 45 | '', "6\n"); 46 | 47 | 1; 48 | 49 | ### Local Variables: 50 | ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 51 | ### End: 52 | -------------------------------------------------------------------------------- /tests/scripts/functions/strip: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "The following test creates a makefile to verify 3 | the ability of make to strip white space from lists of object.\n"; 4 | 5 | 6 | $details = "The make file is built with a list of objects that contain white space 7 | These are then run through the strip command to remove it. This is then 8 | verified by echoing the result.\n"; 9 | 10 | open(MAKEFILE,"> $makefile"); 11 | 12 | # The Contents of the MAKEFILE ... 13 | 14 | print MAKEFILE <<'EOMAKE'; 15 | TEST1 := "Is this TERMINAL fun? What makes you believe is this terminal fun? JAPAN is a WONDERFUL planet -- I wonder if we will ever reach their level of COMPARATIVE SHOPPING..." 16 | E := 17 | TEST2 := $E try this and this $E 18 | 19 | define TEST3 20 | 21 | and these test out 22 | 23 | 24 | some 25 | blank lines 26 | 27 | 28 | 29 | endef 30 | 31 | .PHONY: all 32 | all: 33 | @echo '$(strip $(TEST1) )' 34 | @echo '$(strip $(TEST2) )' 35 | @echo '$(strip $(TEST3) )' 36 | 37 | space: ; @echo '$(strip ) $(strip )' 38 | 39 | EOMAKE 40 | 41 | # END of Contents of MAKEFILE 42 | 43 | close(MAKEFILE); 44 | 45 | &run_make_with_options($makefile,"",&get_logfile); 46 | $answer = "\"Is this TERMINAL fun? What makes you believe is this terminal fun? JAPAN is a WONDERFUL planet -- I wonder if we will ever reach their level of COMPARATIVE SHOPPING...\" 47 | try this and this 48 | and these test out some blank lines 49 | "; 50 | &compare_output($answer,&get_logfile(1)); 51 | 52 | 53 | &run_make_with_options($makefile,"space",&get_logfile); 54 | $answer = " \n"; 55 | &compare_output($answer,&get_logfile(1)); 56 | 57 | 1; 58 | -------------------------------------------------------------------------------- /tests/scripts/functions/substitution: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the subst and patsubst functions"; 4 | 5 | $details = ""; 6 | 7 | # Generic patsubst test: test both the function and variable form. 8 | 9 | run_make_test(' 10 | foo := a.o b.o c.o 11 | bar := $(foo:.o=.c) 12 | bar2:= $(foo:%.o=%.c) 13 | bar3:= $(patsubst %.c,%.o,x.c.c bar.c) 14 | all:;@echo $(bar); echo $(bar2); echo $(bar3)', 15 | '', 16 | 'a.c b.c c.c 17 | a.c b.c c.c 18 | x.c.o bar.o'); 19 | 20 | # Patsubst without '%'--shouldn't match because the whole word has to match 21 | # in patsubst. Based on a bug report by Markus Mauhart 22 | 23 | run_make_test('all:;@echo $(patsubst Foo,Repl,FooFoo)', '', 'FooFoo'); 24 | 25 | # Variable subst where a pattern matches multiple times in a single word. 26 | # Based on a bug report by Markus Mauhart 27 | 28 | run_make_test(' 29 | A := fooBARfooBARfoo 30 | all:;@echo $(A:fooBARfoo=REPL)', '', 'fooBARREPL'); 31 | 32 | 1; 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /tests/scripts/functions/suffix: -------------------------------------------------------------------------------- 1 | $description = "The following test creates a makefile to test the suffix\n" 2 | ."function. \n"; 3 | 4 | $details = "The suffix function will return the string following the last _._\n" 5 | ."the list provided. It will provide all of the unique suffixes found\n" 6 | ."in the list. The long strings are sorted to remove duplicates.\n"; 7 | 8 | # IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET 9 | # THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF 10 | # HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END. 11 | # EXAMPLE: $makefile2 = &get_tmpfile; 12 | 13 | 14 | open(MAKEFILE,"> $makefile"); 15 | 16 | # The Contents of the MAKEFILE ... 17 | 18 | print MAKEFILE "string := word.pl general_test2.pl1 FORCE.pl word.pl3 generic_test.perl /tmp.c/bar foo.baz/bar.c MAKEFILES_variable.c\n" 19 | ."string2 := \$(string) \$(string) \$(string) \$(string) \$(string) \$(string) \$(string)\n" 20 | ."string3 := \$(string2) \$(string2) \$(string2) \$(string2) \$(string2) \$(string2) \$(string2)\n" 21 | ."string4 := \$(string3) \$(string3) \$(string3) \$(string3) \$(string3) \$(string3) \$(string3)\n" 22 | ."all: \n" 23 | ."\t\@echo \$(suffix \$(string)) \n" 24 | ."\t\@echo \$(sort \$(suffix \$(string4))) \n" 25 | ."\t\@echo \$(suffix \$(string) a.out) \n" 26 | ."\t\@echo \$(sort \$(suffix \$(string3))) \n"; 27 | 28 | 29 | 30 | # END of Contents of MAKEFILE 31 | 32 | close(MAKEFILE); 33 | 34 | &run_make_with_options($makefile,"",&get_logfile,0); 35 | 36 | # Create the answer to what should be produced by this Makefile 37 | 38 | # COMPARE RESULTS 39 | $answer = ".pl .pl1 .pl .pl3 .perl .c .c\n" 40 | .".c .perl .pl .pl1 .pl3\n" 41 | .".pl .pl1 .pl .pl3 .perl .c .c .out\n" 42 | .".c .perl .pl .pl1 .pl3\n"; 43 | 44 | # In this call to compare output, you should use the call &get_logfile(1) 45 | # to send the name of the last logfile created. You may also use 46 | # the special call &get_logfile(1) which returns the same as &get_logfile(1). 47 | 48 | &compare_output($answer,&get_logfile(1)); 49 | 50 | # This tells the test driver that the perl test script executed properly. 51 | 1; 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /tests/scripts/functions/value: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the value function."; 4 | 5 | $details = "This is a test of the value function in GNU Make. 6 | This function will evaluate to the value of the named variable with no 7 | further expansion performed on it.\n"; 8 | 9 | open(MAKEFILE,"> $makefile"); 10 | 11 | print MAKEFILE <<'EOF'; 12 | export FOO = foo 13 | 14 | recurse = FOO = $FOO 15 | static := FOO = $(value FOO) 16 | 17 | all: ; @echo $(recurse) $(value recurse) $(static) $(value static) 18 | EOF 19 | 20 | close(MAKEFILE); 21 | 22 | &run_make_with_options($makefile, "", &get_logfile); 23 | 24 | # Create the answer to what should be produced by this Makefile 25 | $answer = "FOO = OO FOO = foo FOO = foo FOO = foo\n"; 26 | 27 | 28 | &compare_output($answer,&get_logfile(1)); 29 | 30 | 1; 31 | -------------------------------------------------------------------------------- /tests/scripts/functions/warning: -------------------------------------------------------------------------------- 1 | # -*-Perl-*- 2 | 3 | $description = "\ 4 | The following test creates a makefile to test the warning function."; 5 | 6 | $details = ""; 7 | 8 | open(MAKEFILE,"> $makefile"); 9 | 10 | print MAKEFILE <<'EOF'; 11 | ifdef WARNING1 12 | $(warning warning is $(WARNING1)) 13 | endif 14 | 15 | ifdef WARNING2 16 | $(warning warning is $(WARNING2)) 17 | endif 18 | 19 | ifdef WARNING3 20 | all: some; @echo hi $(warning warning is $(WARNING3)) 21 | endif 22 | 23 | ifdef WARNING4 24 | all: some; @echo hi 25 | @echo there $(warning warning is $(WARNING4)) 26 | endif 27 | 28 | some: ; @echo Some stuff 29 | 30 | EOF 31 | 32 | close(MAKEFILE); 33 | 34 | # Test #1 35 | 36 | &run_make_with_options($makefile, "WARNING1=yes", &get_logfile, 0); 37 | $answer = "$makefile:2: warning is yes\nSome stuff\n"; 38 | &compare_output($answer,&get_logfile(1)); 39 | 40 | # Test #2 41 | 42 | &run_make_with_options($makefile, "WARNING2=no", &get_logfile, 0); 43 | $answer = "$makefile:6: warning is no\nSome stuff\n"; 44 | &compare_output($answer,&get_logfile(1)); 45 | 46 | # Test #3 47 | 48 | &run_make_with_options($makefile, "WARNING3=maybe", &get_logfile, 0); 49 | $answer = "Some stuff\n$makefile:10: warning is maybe\nhi\n"; 50 | &compare_output($answer,&get_logfile(1)); 51 | 52 | # Test #4 53 | 54 | &run_make_with_options($makefile, "WARNING4=definitely", &get_logfile, 0); 55 | $answer = "Some stuff\n$makefile:15: warning is definitely\nhi\nthere\n"; 56 | &compare_output($answer,&get_logfile(1)); 57 | 58 | # Test linenumber offset 59 | 60 | run_make_test(q! 61 | all: one two 62 | $(warning in $@ line 3) 63 | @true 64 | $(warning in $@ line 5) 65 | 66 | one two: 67 | $(warning in $@ line 8) 68 | @true 69 | $(warning in $@ line 10) 70 | !, 71 | '', "#MAKEFILE#:8: in one line 8 72 | #MAKEFILE#:10: in one line 10 73 | #MAKEFILE#:8: in two line 8 74 | #MAKEFILE#:10: in two line 10 75 | #MAKEFILE#:3: in all line 3 76 | #MAKEFILE#:5: in all line 5\n"); 77 | 78 | # This tells the test driver that the perl test script executed properly. 79 | 1; 80 | 81 | ### Local Variables: 82 | ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 83 | ### End: 84 | -------------------------------------------------------------------------------- /tests/scripts/misc/close_stdout: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Make sure make exits with an error if stdout is full."; 4 | 5 | -e '/dev/full' or return -1; 6 | 7 | # In Strawberry Perl, /dev/full "exists" but does nothing :-/ 8 | $port_type eq 'W32' and return -1; 9 | 10 | run_make_test("\n", '-v > /dev/full', '/^#MAKE#: write error/', 256); 11 | 12 | 1; 13 | -------------------------------------------------------------------------------- /tests/scripts/misc/failure: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test miscellaneous failures."; 4 | 5 | 6 | # Test that the "did you mean TAB" message is printed properly 7 | 8 | run_make_test(q! 9 | $x. 10 | !, 11 | '', '#MAKEFILE#:2: *** missing separator. Stop.', 512); 12 | 13 | run_make_test(q! 14 | foo: 15 | bar 16 | !, 17 | '', '#MAKEFILE#:3: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.', 512); 18 | 19 | run_make_test(q! 20 | .RECIPEPREFIX = : 21 | foo: 22 | bar 23 | !, 24 | '', '#MAKEFILE#:4: *** missing separator. Stop.', 512); 25 | 26 | for my $kw ('eq', 'neq') { 27 | run_make_test(qq! 28 | if$kw(foo,bar) 29 | \$(error ouch) 30 | endif 31 | !, 32 | '', '#MAKEFILE#:2: *** missing separator (ifeq/ifneq must be followed by whitespace). Stop.', 512); 33 | 34 | run_make_test(qq! 35 | if$kw 36 | \$(error ouch) 37 | endif 38 | !, 39 | '', '#MAKEFILE#:2: *** invalid syntax in conditional. Stop.', 512); 40 | 41 | run_make_test(qq! 42 | if$kw blah 43 | \$(error ouch) 44 | endif 45 | !, 46 | '', '#MAKEFILE#:2: *** invalid syntax in conditional. Stop.', 512); 47 | } 48 | 49 | 1; 50 | -------------------------------------------------------------------------------- /tests/scripts/misc/fopen-fail: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Make sure make exits with an error if fopen fails."; 4 | 5 | # For some reason on Cygwin, make exits with no error message after 6 | # it recurses for a while. 7 | $^O =~ /cygwin/ and return -1; 8 | 9 | # Recurse infinitely until we run out of open files, and ensure we 10 | # fail with a non-zero exit code. Don't bother to test the output 11 | # since it's hard to know what it will be, exactly. 12 | # See Savannah bug #27374. 13 | 14 | # Use a longer-than-normal timeout: some systems have more FDs available? 15 | # We also set ulimit -n 512 in check-regression in Makefile.am, which see. 16 | # See Savannah bug #42390. 17 | run_make_test(q! 18 | include $(lastword $(MAKEFILE_LIST)) 19 | !, 20 | '', undef, 512, 300); 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /tests/scripts/misc/general1: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "The following test creates a makefile to test the 4 | simple functionality of make. It mimics the 5 | rebuilding of a product with dependencies. 6 | It also tests the simple definition of VPATH."; 7 | 8 | open(MAKEFILE,"> $makefile"); 9 | 10 | print MAKEFILE < $makefile"); 9 | 10 | # The contents of the Makefile ... 11 | 12 | print MAKEFILE < $@ 22 | ', 23 | '', 'cp bar.x foo'); 24 | 25 | run_make_test(undef, '', "#MAKE#: Nothing to be done for 'all'."); 26 | run_make_test(undef, '-B', 'cp bar.x foo'); 27 | 28 | # Put the timestamp for foo into the future; it should still be remade. 29 | # There are clock skew errors printed here but they will be cleared by 30 | # the comparison code. 31 | utouch(1000, 'foo'); 32 | run_make_test(undef, '', "#MAKE#: Nothing to be done for 'all'."); 33 | run_make_test(undef, '-B', 'cp bar.x foo'); 34 | 35 | # Clean up 36 | 37 | rmfiles('bar.x', 'foo'); 38 | 39 | # Test -B with the re-exec feature: we don't want to re-exec forever 40 | # Savannah bug # 7566 41 | 42 | run_make_test(' 43 | all: ; @: 44 | $(info MAKE_RESTARTS=$(MAKE_RESTARTS)) 45 | include foo.x 46 | foo.x: ; @touch $@ 47 | ', 48 | '-B', 'MAKE_RESTARTS= 49 | MAKE_RESTARTS=1'); 50 | 51 | rmfiles('foo.x'); 52 | 53 | # Test -B with the re-exec feature: we DO want -B in the "normal" part of the 54 | # makefile. 55 | 56 | &touch('blah.x'); 57 | 58 | run_make_test(' 59 | all: blah.x ; @echo $@ 60 | $(info MAKE_RESTARTS=$(MAKE_RESTARTS)) 61 | include foo.x 62 | foo.x: ; @touch $@ 63 | blah.x: ; @echo $@ 64 | ', 65 | '-B', 'MAKE_RESTARTS= 66 | MAKE_RESTARTS=1 67 | blah.x 68 | all'); 69 | 70 | rmfiles('foo.x', 'blah.x'); 71 | 72 | # Test that $? is set properly with -B; all prerequisites will be newer! 73 | 74 | utouch(-10, 'x.b'); 75 | touch('x.a'); 76 | 77 | run_make_test(q! 78 | x.a: x.b ; @echo $? 79 | !, 80 | '-B', "x.b\n"); 81 | 82 | unlink(qw(x.a x.b)); 83 | 84 | 1; 85 | 86 | ### Local Variables: 87 | ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 88 | ### End: 89 | -------------------------------------------------------------------------------- /tests/scripts/options/dash-C: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the -C option to GNU Make."; 4 | 5 | use File::Spec; 6 | 7 | # Pre-set $makefile to be in a subdirectory 8 | $makefile = 'Makefile'; 9 | 10 | my $_srcdir = 'src'; 11 | mkdir($_srcdir, 0775); 12 | 13 | my $_incdir = 'inc'; 14 | mkdir($_incdir, 0775); 15 | 16 | my $_mkpath = File::Spec->catfile($_srcdir, $makefile); 17 | create_file($_mkpath, "include \$(file)\nall: ;\n"); 18 | 19 | # TEST #1 20 | # ------- 21 | run_make_test('', "-C $_srcdir --no-print-directory", 22 | "#MAKE#: 'all' is up to date."); 23 | 24 | # TEST #2 25 | # ------- 26 | # Do it again with trailing "/"; this should work the same 27 | 28 | run_make_test(undef, "-C $_srcdir/ --no-print-directory", 29 | "#MAKE#: 'all' is up to date."); 30 | 31 | # Test stringing together multiple -C options 32 | 33 | run_make_test(undef, "-C $_incdir -C .. -C $_srcdir --no-print-directory", 34 | "#MAKE#: 'all' is up to date."); 35 | 36 | # SV 63552 - Ensure -I is considered after -C 37 | 38 | my $_incfile = 'test'; 39 | my $_incpath = File::Spec->catfile($_incdir, $_incfile); 40 | create_file($_incpath, '$(info included)'); 41 | 42 | my $_incopt = File::Spec->catfile('..', $_incdir); 43 | 44 | run_make_test(undef, "-C src -I $_incopt --no-print-directory file=$_incfile", 45 | "included\n#MAKE#: 'all' is up to date."); 46 | 47 | unlink($_incpath); 48 | rmdir($_incdir); 49 | 50 | unlink($_mkpath); 51 | rmdir($_srcdir); 52 | 1; 53 | -------------------------------------------------------------------------------- /tests/scripts/options/dash-W: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test make -W (what if) option.\n"; 4 | 5 | # Basic build 6 | 7 | run_make_test(' 8 | a.x: b.x 9 | a.x b.x: ; echo >> $@ 10 | ', 11 | '', "echo >> b.x\necho >> a.x"); 12 | 13 | # Run it again: nothing should happen 14 | 15 | run_make_test(undef, '', "#MAKE#: 'a.x' is up to date."); 16 | 17 | # Now run it with -W b.x: should rebuild a.x 18 | 19 | run_make_test(undef, '-W b.x', 'echo >> a.x'); 20 | 21 | # Put the timestamp for a.x into the future; it should still be remade. 22 | # There are clock skew errors printed here but they will be cleared by 23 | # the comparison code. 24 | utouch(1000, 'a.x'); 25 | run_make_test(undef, '', "#MAKE#: 'a.x' is up to date."); 26 | run_make_test(undef, '-W b.x', 'echo >> a.x'); 27 | 28 | # Clean up 29 | 30 | rmfiles('a.x', 'b.x'); 31 | 32 | # Test -W with the re-exec feature: we don't want to re-exec forever 33 | # Savannah bug # 7566 34 | 35 | # First set it up with a normal build 36 | 37 | run_make_test(' 38 | all: baz.x ; @: 39 | include foo.x 40 | foo.x: bar.x 41 | @echo "\$$(info restarts=\$$(MAKE_RESTARTS))" > $@ 42 | @echo "touch $@" 43 | bar.x: ; echo >> $@ 44 | baz.x: bar.x ; @echo "touch $@" 45 | ', 46 | '', 'echo >> bar.x 47 | touch foo.x 48 | restarts=1 49 | touch baz.x'); 50 | 51 | # Now run with -W bar.x 52 | 53 | # Tweak foo.x's timestamp so the update will change it. 54 | # There are clock skew errors printed here but they will be cleared by 55 | # the comparison code. 56 | &utouch(1000, 'foo.x'); 57 | 58 | run_make_test(undef, '-W bar.x', "restarts=\ntouch foo.x\nrestarts=1\ntouch baz.x"); 59 | 60 | rmfiles('foo.x', 'bar.x'); 61 | 62 | # Test -W on vpath-found files: it should take effect. 63 | # Savannah bug # 15341 64 | 65 | mkdir('x-dir', 0777); 66 | utouch(-20, 'x-dir/x'); 67 | touch('y'); 68 | 69 | run_make_test(' 70 | y: x ; @echo cp $< $@ 71 | ', 72 | '-W x-dir/x VPATH=x-dir', 73 | 'cp x-dir/x y'); 74 | 75 | # Make sure ./ stripping doesn't interfere with the match. 76 | 77 | run_make_test(' 78 | y: x ; @echo cp $< $@ 79 | ', 80 | '-W ./x-dir/x VPATH=x-dir', 81 | 'cp x-dir/x y'); 82 | 83 | run_make_test(undef, 84 | '-W x-dir/x VPATH=./x-dir', 85 | 'cp ./x-dir/x y'); 86 | 87 | unlink(qw(y x-dir/x)); 88 | rmdir('x-dir'); 89 | 90 | 1; 91 | 92 | ### Local Variables: 93 | ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 94 | ### End: 95 | -------------------------------------------------------------------------------- /tests/scripts/options/dash-d: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test make -d option.\n"; 4 | 5 | # sv 60777. 6 | # Test that debug output is printed when both -d and --trace are specified. 7 | run_make_test('all: ; :', '-d --trace', "/GNU Make/"); 8 | 9 | 1; 10 | -------------------------------------------------------------------------------- /tests/scripts/options/dash-l: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | # Date: Tue, 11 Aug 1992 09:34:26 -0400 3 | # From: pds@lemming.webo.dg.com (Paul D. Smith) 4 | 5 | $description = "Test load balancing (-l) option."; 6 | 7 | $details = "\ 8 | This test creates a makefile where all depends on three rules 9 | which contain the same body. Each rule checks for the existence 10 | of a temporary file; if it exists an error is generated. If it 11 | doesn't exist then it is created, the rule sleeps, then deletes 12 | the temp file again. Thus if any of the rules are run in 13 | parallel the test will fail. When make is called in this test, 14 | it is given the -l option with a value of 0.0001. This ensures 15 | that the load will be above this number and make will therefore 16 | decide that it cannot run more than one job even though -j 4 was 17 | also specified on the command line."; 18 | 19 | # On Windows a very different algorithm is used. 20 | $port_type eq 'W32' and return -1; 21 | 22 | open(MAKEFILE,"> $makefile"); 23 | printf MAKEFILE subst_make_string(q! 24 | test = #HELPER# noexist test-file file test-file sleep 2 rm test-file 25 | 26 | all : ONE TWO THREE 27 | ONE : ; @$(test) 28 | TWO : ; @$(test) 29 | THREE : ; @$(test) 30 | !); 31 | close(MAKEFILE); 32 | my $ans = "noexist test-file\nfile test-file\nsleep 2\nrm test-file\n"; 33 | 34 | $mkoptions = "-l 0.0001"; 35 | $mkoptions .= " -j 4" if ($parallel_jobs); 36 | 37 | # We have to wait longer than the default (5s). 38 | &run_make_with_options($makefile, $mkoptions, &get_logfile, 0, 10); 39 | 40 | $slurp = &read_file_into_string(&get_logfile(1)); 41 | if ($slurp =~ /cannot enforce load limit/) { 42 | return -1; 43 | } 44 | &compare_output("$ans$ans$ans", &get_logfile(1)); 45 | 46 | 1; 47 | -------------------------------------------------------------------------------- /tests/scripts/options/dash-q: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test the -q option.\n"; 3 | 4 | $details = "Try various uses of -q and ensure they all give the correct results.\n"; 5 | 6 | # TEST 0 7 | 8 | run_make_test(qq! 9 | one: 10 | two: ; 11 | three: ; : 12 | four: ; \$(.XY) 13 | five: ; \\ 14 | \$(.XY) 15 | six: ; \\ 16 | \$(.XY) 17 | \t\$(.XY) 18 | seven: ; \\ 19 | \$(.XY) 20 | \t: foo 21 | \t\$(.XY) 22 | !, 23 | '-q one', ''); 24 | 25 | # TEST 1 26 | 27 | run_make_test(undef, '-q two', ''); 28 | 29 | # TEST 2 30 | 31 | run_make_test(undef, '-q three', '', 256); 32 | 33 | # TEST 3 34 | 35 | run_make_test(undef, '-q four', ''); 36 | 37 | # TEST 4 38 | 39 | run_make_test(undef, '-q five', ''); 40 | 41 | # TEST 5 42 | 43 | run_make_test(undef, '-q six', ''); 44 | 45 | # TEST 6 46 | 47 | run_make_test(undef, '-q seven', '', 256); 48 | 49 | # TEST 7 : Savannah bug # 7144 50 | 51 | run_make_test(' 52 | one:: ; @echo one 53 | one:: ; @echo two 54 | ', 55 | '-q', '', 256); 56 | 57 | # TEST 7 : Savannah bug # 42249 58 | # Make sure we exit with 1 even for prerequisite updates 59 | run_make_test(' 60 | build-stamp: ; echo $@ 61 | build-arch: build-stamp 62 | build-x: build-arch 63 | build-y: build-x 64 | ', 65 | '-q build-y', '', 256); 66 | 67 | # TEST 8 68 | # Make sure we exit with 2 on error even with -q 69 | run_make_test(' 70 | build-stamp: ; echo $@ 71 | build-arch: build-stamp-2 72 | build-x: build-arch 73 | build-y: build-x 74 | ', 75 | '-q build-y', "#MAKE#: *** No rule to make target 'build-stamp-2', needed by 'build-arch'. Stop.\n", 512); 76 | 77 | # TEST 9 : Savannah bug # 47151 78 | # Make sure we exit with 1 when invoking a recursive make 79 | run_make_test(' 80 | foo: bar ; echo foo 81 | bar: ; @$(MAKE) -f #MAKEFILE# baz 82 | baz: ; echo baz 83 | ', 84 | '-q foo', '', 256); 85 | 86 | 1; 87 | -------------------------------------------------------------------------------- /tests/scripts/options/dash-r: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test removing default rules and variables"; 4 | 5 | touch('xxx.c'); 6 | 7 | # Simple check 8 | run_make_test("\n", '-r COMPILE.c=echo xxx.o', 9 | "#MAKE#: *** No rule to make target 'xxx.o'. Stop.", 512); 10 | 11 | # Make sure we can set it from within the makefile too 12 | run_make_test(q! 13 | COMPILE.c = echo 14 | MAKEFLAGS += -r 15 | !, 16 | 'xxx.o', 17 | "#MAKE#: *** No rule to make target 'xxx.o'. Stop.", 512); 18 | 19 | unlink('xxx.c'); 20 | 21 | # Simple check for -R 22 | run_make_test(q! 23 | all:;$(info CC='$(CC)') 24 | !, 25 | '-sR', "CC=''"); 26 | 27 | # Make sure we can set -R from within the makefile too 28 | run_make_test(q! 29 | MAKEFLAGS += -R 30 | all:;$(info CC='$(CC)') 31 | !, 32 | '-s', "CC=''"); 33 | 34 | # sv 62356. 35 | # Setting -R in MAKEFLAGS sets -r. 36 | run_make_test(q! 37 | MAKEFLAGS := -R 38 | .PHONY: hello.c 39 | all: hello.o 40 | !, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.", 512); 41 | 42 | my @flavors = ('=', ':=', ':::=', '+='); 43 | 44 | # sv 64107. 45 | 46 | # Use $answer to test that -R in the makefile has the same effect as -R on the 47 | # command line. 48 | 49 | my $answer = "at parse time TEX=\nat build time TEX=\n#MAKE#: 'all' is up to date.\n"; 50 | 51 | # Subtest 1. 52 | # First run with -R command line switch. 53 | 54 | for my $fl (@flavors) { 55 | run_make_test(" 56 | \$(info at parse time TEX=\$(TEX)) 57 | all:; \$(info at build time TEX=\$(TEX)) 58 | ", '-R', "$answer"); 59 | } 60 | 61 | # Subtest 2. 62 | # Set -R in the makefile. 63 | # Also, test that setting -R in MAKEFLAGS takes effect immediately. 64 | 65 | for my $fl (@flavors) { 66 | run_make_test(" 67 | \$(info at start time TEX=\$(TEX)) 68 | MAKEFLAGS ${fl} -R 69 | \$(info at parse time TEX=\$(TEX)) 70 | all:; \$(info at build time TEX=\$(TEX)) 71 | ", '', "at start time TEX=tex\n$answer"); 72 | } 73 | 74 | # Same as above, but also set TEX conditionally. 75 | 76 | $answer = "at parse time TEX=hello\nat build time TEX=hello\n#MAKE#: 'all' is up to date.\n"; 77 | 78 | # Subtest 3. 79 | # -R on the command line. 80 | 81 | for my $fl (@flavors) { 82 | run_make_test(" 83 | TEX ?= hello 84 | \$(info at parse time TEX=\$(TEX)) 85 | all:; \$(info at build time TEX=\$(TEX)) 86 | ", '-R', "$answer"); 87 | } 88 | 89 | # Subtest 4. 90 | # -R in the makefile. 91 | 92 | for my $fl (@flavors) { 93 | run_make_test(" 94 | \$(info at start time TEX=\$(TEX)) 95 | MAKEFLAGS ${fl} -R 96 | TEX ?= hello 97 | \$(info at parse time TEX=\$(TEX)) 98 | all:; \$(info at build time TEX=\$(TEX)) 99 | ", '', "at start time TEX=tex\n$answer"); 100 | } 101 | 102 | 103 | 1; 104 | -------------------------------------------------------------------------------- /tests/scripts/options/dash-s: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the -s (silent) and --no-silent options.\n"; 4 | 5 | run_make_test(q! 6 | all: one two 7 | one: ; @echo MAKEFLAGS=$$MAKEFLAGS 8 | two: ; echo two 9 | !, 10 | '', "MAKEFLAGS=\necho two\ntwo"); 11 | 12 | run_make_test(undef, '-s', "MAKEFLAGS=s\ntwo"); 13 | run_make_test(undef, '--silent', "MAKEFLAGS=s\ntwo"); 14 | run_make_test(undef, '--quiet', "MAKEFLAGS=s\ntwo"); 15 | 16 | run_make_test(undef, '--no-silent', "MAKEFLAGS= --no-silent\necho two\ntwo"); 17 | 18 | run_make_test(undef, '-s --no-silent', "MAKEFLAGS= --no-silent\necho two\ntwo"); 19 | run_make_test(undef, '--silent --no-silent', "MAKEFLAGS= --no-silent\necho two\ntwo"); 20 | run_make_test(undef, '--quiet --no-silent', "MAKEFLAGS= --no-silent\necho two\ntwo"); 21 | 22 | run_make_test(undef, '--no-silent -s', "MAKEFLAGS=s\ntwo"); 23 | run_make_test(undef, '--no-silent --silent', "MAKEFLAGS=s\ntwo"); 24 | run_make_test(undef, '--no-silent --quiet', "MAKEFLAGS=s\ntwo"); 25 | 26 | 1; 27 | -------------------------------------------------------------------------------- /tests/scripts/options/dash-t: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the -t option.\n"; 4 | 5 | $details = "Look out for regressions of prior bugs related to -t.\n"; 6 | # That means, nobody has even tried to make the tests below comprehensive 7 | 8 | # TEST 0 9 | # bug reported by Henning Makholm on 2001-11-03: 10 | # make 3.79.1 touches only interm-[ab] but reports final-[a] as 11 | # 'up to date' without touching them. 12 | # The 'obvious' fix didn't work for double-colon rules, so pay special 13 | # attention to them. 14 | 15 | open(MAKEFILE, "> $makefile"); 16 | print MAKEFILE <<'EOMAKE'; 17 | final-a: interm-a ; echo >> $@ 18 | final-b: interm-b ; echo >> $@ 19 | interm-a:: orig1-a ; echo >> $@ 20 | interm-a:: orig2-a ; echo >> $@ 21 | interm-b:: orig1-b ; echo >> $@ 22 | interm-b:: orig2-b ; echo >> $@ 23 | EOMAKE 24 | close(MAKEFILE); 25 | 26 | &utouch(-30, 'orig1-a','orig2-b'); 27 | &utouch(-20, 'interm-a','interm-b'); 28 | &utouch(-10, 'final-a','final-b'); 29 | &touch('orig2-a','orig1-b'); 30 | 31 | &run_make_with_options($makefile, "-t final-a final-b", &get_logfile); 32 | $answer = "touch interm-a\ntouch final-a\ntouch interm-b\ntouch final-b\n"; 33 | &compare_output($answer, &get_logfile(1)); 34 | 35 | unlink('orig1-a', 'orig2-a', 'interm-a', 'final-a'); 36 | unlink('orig1-b', 'orig2-b', 'interm-b', 'final-b'); 37 | 38 | # TEST 1 39 | # -t should not touch files with no commands. 40 | 41 | $makefile2 = &get_tmpfile; 42 | 43 | open(MAKEFILE, "> $makefile2"); 44 | print MAKEFILE <<'EOMAKE'; 45 | 46 | PHOOEY: xxx 47 | xxx: ; @: 48 | 49 | EOMAKE 50 | close(MAKEFILE); 51 | 52 | &run_make_with_options($makefile2, "-t", &get_logfile); 53 | $answer = "touch xxx\n"; 54 | &compare_output($answer, &get_logfile(1)); 55 | 56 | unlink('xxx'); 57 | 58 | 1; 59 | -------------------------------------------------------------------------------- /tests/scripts/options/eval: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the --eval option."; 4 | 5 | $details = "Verify that --eval options take effect, 6 | and are passed to sub-makes."; 7 | 8 | # Verify that --eval is evaluated first 9 | run_make_test(q! 10 | $(info infile) 11 | BAR = bar 12 | all: ; @echo all 13 | recurse: ; @$(MAKE) -f #MAKEFILE# && echo recurse!, 14 | ['--eval=$(info eval)', 'FOO=$(BAR)'], "eval\ninfile\nall"); 15 | 16 | # Make sure that --eval is handled correctly during recursion 17 | run_make_test(undef, ['--no-print-directory', '--eval=$(info eval)', 'recurse'], 18 | "eval\ninfile\neval\ninfile\nall\nrecurse"); 19 | 20 | # Make sure that --eval is not passed in MAKEFLAGS 21 | run_make_test(q! 22 | all: ; @echo "MAKEFLAGS=$$MAKEFLAGS" 23 | !, 24 | ['--eval=$(info eval)'], 25 | "eval\n".'MAKEFLAGS= --eval=$$(info\ eval)'); 26 | 27 | # Make sure that --eval is handled correctly during restarting 28 | run_make_test(q! 29 | all: ; @echo $@ 30 | -include gen.mk 31 | gen.mk: ; @echo > $@ 32 | !, 33 | ['--eval=$(info eval)'], "eval\neval\nall"); 34 | 35 | unlink('gen.mk'); 36 | 37 | # Check -E 38 | run_make_test(q! 39 | BAR = bar 40 | all: ; @echo all 41 | recurse: ; @$(MAKE) -f #MAKEFILE# && echo recurse!, 42 | ['-E', '$(info eval)', 'FOO=$(BAR)'], "eval\nall"); 43 | 44 | 1; 45 | -------------------------------------------------------------------------------- /tests/scripts/options/general: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test generic option processing.\n"; 3 | 4 | # TEST 0 5 | 6 | if (!$parallel_jobs) { 7 | $answer = "#MAKE#: Parallel jobs (-j) are not supported on this platform.\n#MAKE#: Resetting to single job (-j1) mode.\n1foo\n"; 8 | } 9 | else { 10 | $answer = "1foo\n"; 11 | } 12 | 13 | run_make_test(q! 14 | foo 1foo: ; @echo $@ 15 | !, 16 | "-j 1foo", $answer); 17 | 18 | # TEST 1 19 | 20 | # This test prints the usage string; I don't really know a good way to 21 | # test it. I guess I could invoke make with a known-bad option to see 22 | # what the usage looks like, then compare it to what I get here... :( 23 | 24 | # On UNIX I can invoke it with 2>/dev/null, then just check the error code. 25 | 26 | if ($port_type ne 'W32') { 27 | run_make_test(undef, "-j1foo 2>/dev/null", '', 512); 28 | } 29 | 30 | 1; 31 | -------------------------------------------------------------------------------- /tests/scripts/options/print-directory: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the -w option to GNU Make."; 4 | 5 | my $enter = "#MAKE#: Entering directory '#PWD#'"; 6 | my $leave = "#MAKE#: Leaving directory '#PWD#'"; 7 | 8 | # Simple test without -w 9 | run_make_test(q! 10 | all: ; @echo hi 11 | !, 12 | "", "hi\n"); 13 | 14 | my $ans = "$enter\nhi\n$leave\n"; 15 | 16 | # Simple test with -w 17 | run_make_test(undef, "-w", $ans); 18 | 19 | # Simple test with overriding -w 20 | run_make_test(undef, "-w --no-print-directory", "hi\n"); 21 | 22 | # Simple test with overriding --no-print-directory 23 | run_make_test(undef, "--no-print-directory --print-directory", $ans); 24 | 25 | # Test makefile rebuild to ensure no enter/leave 26 | run_make_test(q! 27 | include foo 28 | all: ;@: 29 | foo: ; touch foo 30 | !, 31 | "", "touch foo\n"); 32 | unlink('foo'); 33 | 34 | $ans = "$enter\ntouch foo\n$leave\n"; 35 | 36 | # Test makefile rebuild with -w 37 | run_make_test(undef, "-w", $ans); 38 | unlink('foo'); 39 | 40 | # Test makefile rebuild with -w overridden 41 | run_make_test(undef, "-w --no-print-directory", "touch foo\n"); 42 | unlink('foo'); 43 | 44 | # Test makefile rebuild with --no-print-directory overridden 45 | run_make_test(undef, "--no-print-directory --print-directory", $ans); 46 | unlink('foo'); 47 | 48 | my $enter1 = "#MAKE#[1]: Entering directory '#PWD#'"; 49 | my $leave1 = "#MAKE#[1]: Leaving directory '#PWD#'"; 50 | 51 | $ans = "$enter1\nhi\n$leave1\n"; 52 | 53 | # Test makefile recursion with default enter/leave 54 | run_make_test(q! 55 | all: ;@$(MAKE) -f #MAKEFILE# recurse 56 | recurse: ; @echo hi 57 | !, 58 | "", $ans); 59 | 60 | # Disable enter/leave 61 | run_make_test(undef, "--no-print-directory", "hi\n"); 62 | 63 | # Re-enable enter/leave 64 | $ans = "$enter\n$ans$leave\n"; 65 | run_make_test(undef, "--no-print-directory -w", $ans); 66 | 67 | # Override enter/leave 68 | run_make_test(undef, "-w --no-print-directory", "hi\n"); 69 | 70 | 1; 71 | -------------------------------------------------------------------------------- /tests/scripts/options/print-targets: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the --print-targets option to GNU Make."; 4 | 5 | # Define various things and verify the output 6 | run_make_test(q! 7 | .PHONY: all 8 | all: ;@: 9 | 10 | # "special" target 11 | .BOGUS: ;@: 12 | 13 | # Check various forms of suffix rule 14 | .SUFFIXES: .q 15 | .q: ;@: 16 | .c.o: ;@: 17 | 18 | # Not a suffix rule 19 | .x.z: ;@: 20 | 21 | # Verify included files aren't built / don't fail 22 | 23 | include badfile 24 | include goodfile 25 | 26 | submake: ; $(MAKE) all 27 | always: ; +echo always 28 | goodfile: ; touch goodfile 29 | !, 30 | "--print-targets", "submake\n.x.z\nalways\nall\ngoodfile\n"); 31 | 32 | 1; 33 | -------------------------------------------------------------------------------- /tests/scripts/options/symlinks: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the -L option."; 4 | 5 | $details = "Verify that symlink handling with and without -L works properly."; 6 | 7 | # Only run these tests if the system sypports symlinks 8 | 9 | exists $FEATURES{'check-symlink'} or return -1; 10 | 11 | use File::Spec; 12 | 13 | # Set up a symlink sym -> dep 14 | # We'll make both dep and targ older than sym 15 | &utouch(-10, 'dep'); 16 | &utouch(-5, 'targ'); 17 | 18 | my $dirnm = (File::Spec->splitdir($testpath))[-1]; 19 | my $dep = File::Spec->catfile(File::Spec->updir(), $dirnm, 'dep'); 20 | symlink($dep, 'sym') or die "Cannot create symlink sym -> $dep\n"; 21 | 22 | # Without -L, nothing should happen 23 | # With -L, it should update targ 24 | run_make_test('targ: sym ; @echo make $@ from $<', '', 25 | "#MAKE#: 'targ' is up to date."); 26 | run_make_test(undef, '-L', "make targ from sym"); 27 | 28 | # Now update dep; in all cases targ should be out of date. 29 | &touch('dep'); 30 | run_make_test(undef, '', "make targ from sym"); 31 | run_make_test(undef, '-L', "make targ from sym"); 32 | 33 | # Now update targ; in all cases targ should be up to date. 34 | &touch('targ'); 35 | run_make_test(undef, '', "#MAKE#: 'targ' is up to date."); 36 | run_make_test(undef, '-L', "#MAKE#: 'targ' is up to date."); 37 | 38 | # Add in a new link between sym and dep. Be sure it's newer than targ. 39 | sleep(1); 40 | rename('dep', 'dep1'); 41 | symlink('dep1', 'dep'); 42 | 43 | # Without -L, nothing should happen 44 | # With -L, it should update targ 45 | run_make_test(undef, '', "#MAKE#: 'targ' is up to date."); 46 | run_make_test(undef, '-L', "make targ from sym"); 47 | 48 | rmfiles('targ', 'dep', 'sym', 'dep1'); 49 | 50 | # Check handling when symlinks point to non-existent files. Without -L we 51 | # should get an error: with -L we should use the timestamp of the symlink. 52 | 53 | symlink("../$dirnm/dep", 'sym'); 54 | run_make_test('targ: sym ; @echo make $@ from $<', '', 55 | "#MAKE#: *** No rule to make target 'sym', needed by 'targ'. Stop.", 512); 56 | 57 | run_make_test('targ: sym ; @echo make $@ from $<', '-L', 58 | 'make targ from sym'); 59 | 60 | 61 | rmfiles('targ', 'sym'); 62 | 63 | 1; 64 | -------------------------------------------------------------------------------- /tests/scripts/targets/DEFAULT: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "The following test creates a makefile to override part\n" 4 | ."of one Makefile with Another Makefile with the .DEFAULT\n" 5 | ."rule."; 6 | 7 | $details = "This tests the use of the .DEFAULT special target to say that \n" 8 | ."to remake any target that cannot be made fram the information\n" 9 | ."in the containing makefile, make should look in another makefile\n" 10 | ."This test gives this makefile the target bar which is not \n" 11 | ."defined here but passes the target bar on to another makefile\n" 12 | ."which does have the target bar defined.\n"; 13 | 14 | create_file('defsub.mk', q! 15 | bar: ; @echo Executing rule BAR 16 | !); 17 | 18 | run_make_test(q! 19 | foo:; @echo Executing rule FOO 20 | 21 | .DEFAULT: ; @$(MAKE) -f defsub.mk $@ 22 | !, 23 | 'bar',"#MAKE#[1]: Entering directory '#PWD#'\n" 24 | . "Executing rule BAR\n" 25 | . "#MAKE#[1]: Leaving directory '#PWD#'\n"); 26 | 27 | unlink('defsub.mk'); 28 | 29 | 1; 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /tests/scripts/targets/DELETE_ON_ERROR: -------------------------------------------------------------------------------- 1 | #! -*-perl-*- 2 | 3 | $description = "Test the behaviour of the .DELETE_ON_ERROR target."; 4 | 5 | $details = ""; 6 | 7 | run_make_test(' 8 | .DELETE_ON_ERROR: 9 | all: ; exit 1 > $@ 10 | ', 11 | '', "exit 1 > all\n#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n#MAKE#: *** deleting file 'all'", 512); 12 | 13 | run_make_test(' 14 | .DELETE_ON_ERROR: 15 | all: foo.x ; 16 | %.x : %.q ; echo > $@ 17 | %.q : ; exit 1 > $@ 18 | ', 19 | '', "exit 1 > foo.q\n#MAKE#: *** [#MAKEFILE#:5: foo.q] Error 1\n#MAKE#: *** deleting file 'foo.q'", 512); 20 | 21 | # This tells the test driver that the perl test script executed properly. 22 | 1; 23 | -------------------------------------------------------------------------------- /tests/scripts/targets/FORCE: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "The following tests rules without Commands or Dependencies."; 4 | 5 | # Create a file named "clean". This is the same name as the target clean 6 | # and tricks the target into thinking that it is up to date. (Unless you 7 | # use the .PHONY target. 8 | touch('clean'); 9 | 10 | run_make_test(qq! 11 | .IGNORE : 12 | clean: FORCE ; $CMD_rmfile clean 13 | FORCE: 14 | !, 15 | '', "$CMD_rmfile clean"); 16 | 17 | rmfiles('clean'); 18 | 19 | 1; 20 | -------------------------------------------------------------------------------- /tests/scripts/targets/IGNORE: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the behaviour of the .IGNORE target."; 4 | 5 | $details = ""; 6 | 7 | # Without any ignore 8 | run_make_test(q! 9 | all: ; @#HELPER# -q fail 1 10 | !, 11 | '', "#MAKE#: *** [#MAKEFILE#:2: all] Error 1", 512); 12 | 13 | # Global .IGNORE 14 | run_make_test(q! 15 | .IGNORE: 16 | all: ; @#HELPER# -q fail 1 17 | !, 18 | '', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)"); 19 | 20 | # Specific .IGNORE 21 | 22 | run_make_test(q! 23 | .IGNORE: all 24 | all: ; @#HELPER# -q fail 1 25 | !, 26 | '', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)"); 27 | 28 | 1; 29 | -------------------------------------------------------------------------------- /tests/scripts/targets/PHONY: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "The following tests the use of a PHONY target. It makes\n" 4 | ."sure that the rules under a target get executed even if\n" 5 | ."a filename of the same name of the target exists in the\n" 6 | ."directory.\n"; 7 | 8 | $details = "This makefile in this test declares the target clean to be a \n" 9 | ."PHONY target. We then create a file named \"clean\" in the \n" 10 | ."directory. Although this file exists, the rule under the target\n" 11 | ."clean should still execute because of it's phony status."; 12 | 13 | $example = "EXAMPLE_FILE"; 14 | 15 | touch($example); 16 | 17 | # Create a file named "clean". This is the same name as the target clean 18 | # and tricks the target into thinking that it is up to date. (Unless you 19 | # use the .PHONY target. 20 | touch('clean'); 21 | 22 | open(MAKEFILE, "> $makefile"); 23 | print MAKEFILE qq! 24 | .PHONY : clean 25 | all: ; \@echo This makefile did not clean the dir ... good 26 | clean: ; $CMD_rmfile $example clean 27 | !; 28 | close(MAKEFILE); 29 | 30 | $answer = "$CMD_rmfile $example clean\n"; 31 | &run_make_with_options($makefile,"clean",&get_logfile); 32 | 33 | if (-f $example) { 34 | $test_passed = 0; 35 | } 36 | 37 | &compare_output($answer,&get_logfile(1)); 38 | 39 | # Just in case 40 | unlink($example, 'clean'); 41 | 42 | 1; 43 | -------------------------------------------------------------------------------- /tests/scripts/targets/SILENT: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the special target .SILENT."; 4 | 5 | run_make_test(q! 6 | .PHONY: M a b 7 | M: a b 8 | .SILENT : b 9 | a b: ; echo $@ 10 | !, 11 | '', "echo a\na\nb"); 12 | 13 | run_make_test(q! 14 | .PHONY: M a b 15 | M: a b 16 | .SILENT: 17 | a b: ; echo $@ 18 | !, 19 | '', "a\nb"); 20 | 21 | # SV 54740 : don't inherit .SILENT settings in sub-makes 22 | run_make_test(q! 23 | .PHONY: M r a b 24 | r: a b ; @$(MAKE) -f #MAKEFILE# M V=x 25 | a b: ; echo $@ 26 | 27 | V = 28 | $V.SILENT: 29 | M: a b 30 | !, 31 | '--no-print-directory', "a\nb\necho a\na\necho b\nb"); 32 | 33 | 1; 34 | -------------------------------------------------------------------------------- /tests/scripts/targets/clean: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "The following test creates a makefile to delete a \n" 4 | ."file in the directory. It tests to see if make will \n" 5 | ."NOT execute the command unless the rule is given in \n" 6 | ."the make command line."; 7 | 8 | $example = "EXAMPLE_FILE"; 9 | 10 | open(MAKEFILE,"> $makefile"); 11 | print MAKEFILE qq! 12 | all: ; \@echo This makefile did not clean the dir... good 13 | clean: ; $CMD_rmfile $example 14 | !; 15 | close(MAKEFILE); 16 | 17 | touch($example); 18 | run_make_with_options($makefile,"",&get_logfile,0); 19 | 20 | $answer = "This makefile did not clean the dir... good\n"; 21 | compare_output($answer,&get_logfile(1)) || error("abort"); 22 | 23 | 24 | $answer = "$CMD_rmfile $example\n"; 25 | run_make_with_options($makefile,"clean",&get_logfile,0); 26 | if (-f $example) { 27 | $test_passed = 0; 28 | } 29 | compare_output($answer,&get_logfile(1)) || error("abort"); 30 | 31 | 1; 32 | -------------------------------------------------------------------------------- /tests/scripts/test_template: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = ""; 4 | $details = ""; 5 | 6 | # Run a make test. See the documentation of run_make_test() in 7 | # run_make_tests.pl, but briefly the first argument is a string with the 8 | # contents of a makefile to be tested, the second is a string containing the 9 | # arguments to be passed to the make invocation, the third is a string 10 | # containing the expected output. The fourth is the expected exit code for 11 | # make. If not specified, it's assumed that the make program should succeed 12 | # (exit with 0). 13 | 14 | run_make_test('Your test makefile goes here', 15 | 'Arguments to pass to make go here', 16 | 'Expected output from the invocation goes here'); 17 | 18 | # There are various special tokens, options, etc. See the full documentation 19 | # in run_make_tests.pl. 20 | 21 | 22 | # This tells the test driver that the perl test script executed properly. 23 | 1; 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /tests/scripts/variables/CURDIR: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "This tests the CURDIR variable."; 4 | 5 | $details = "Echo CURDIR both with and without -C. Also ensure overrides work."; 6 | 7 | 8 | # TEST #1 9 | # ------- 10 | 11 | run_make_test(q! 12 | all: ; @echo $(CURDIR) 13 | !, 14 | '', "#PWD#\n"); 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /tests/scripts/variables/DEFAULT_GOAL: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test the .DEFAULT_GOAL special variable."; 3 | 4 | $details = ""; 5 | 6 | 7 | # Test #1: basic logic. 8 | # 9 | run_make_test(' 10 | # Basics. 11 | # 12 | foo: ; @: 13 | 14 | ifneq ($(.DEFAULT_GOAL),foo) 15 | $(error ) 16 | endif 17 | 18 | # Reset to empty. 19 | # 20 | .DEFAULT_GOAL := 21 | 22 | bar: ; @: 23 | 24 | ifneq ($(.DEFAULT_GOAL),bar) 25 | $(error ) 26 | endif 27 | 28 | # Change to a different goal. 29 | # 30 | 31 | .DEFAULT_GOAL := baz 32 | 33 | baz: ; @echo $@ 34 | ', 35 | '', 36 | 'baz'); 37 | 38 | 39 | # Test #2: unknown goal. 40 | # 41 | run_make_test(' 42 | .DEFAULT_GOAL = foo 43 | ', 44 | '', 45 | "#MAKE#: *** No rule to make target 'foo'. Stop.", 46 | 512); 47 | 48 | 49 | # Test #3: more than one goal. 50 | # 51 | run_make_test(' 52 | .DEFAULT_GOAL := foo bar 53 | ', 54 | '', 55 | '#MAKE#: *** .DEFAULT_GOAL contains more than one target. Stop.', 56 | 512); 57 | 58 | 59 | # Test #4: Savannah bug #12226. 60 | # 61 | run_make_test(' 62 | define rule 63 | foo: ; @echo $$@ 64 | endef 65 | 66 | define make-rule 67 | $(eval $(rule)) 68 | endef 69 | 70 | $(call make-rule) 71 | 72 | ', 73 | '', 74 | 'foo'); 75 | 76 | # TEST #5: .DEFAULT_GOAL containing just whitespace (Savannah bug #25697) 77 | 78 | run_make_test(' 79 | N = 80 | .DEFAULT_GOAL = $N $N # Just whitespace 81 | 82 | foo: ; @echo "boo" 83 | ', 84 | '', "#MAKE#: *** No targets. Stop.\n", 512); 85 | 86 | # This tells the test driver that the perl test script executed properly. 87 | 1; 88 | -------------------------------------------------------------------------------- /tests/scripts/variables/GNUMAKEFLAGS: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test proper behavior of GNUMAKEFLAGS"; 4 | 5 | # Accept flags from GNUMAKEFLAGS as well as MAKEFLAGS 6 | # Results always go in MAKEFLAGS 7 | 8 | $ENV{'GNUMAKEFLAGS'} = '-e -r -R'; 9 | 10 | run_make_test(q! 11 | all: ; @echo $(MAKEFLAGS) 12 | !, 13 | '', 'erR'); 14 | 15 | # Long arguments mean everything is prefixed with "-" 16 | 17 | $ENV{'GNUMAKEFLAGS'} = '--no-print-directory -e -r -R --trace'; 18 | 19 | run_make_test(q! 20 | all: ; @echo $(MAKEFLAGS) 21 | !, 22 | '', "#MAKEFILE#:2: update target 'all' due to: target does not exist 23 | echo erR --trace --no-print-directory 24 | erR --trace --no-print-directory"); 25 | 26 | # Verify that re-exec / recursion doesn't duplicate flags from GNUMAKEFLAGS 27 | 28 | unlink('x.mk'); 29 | 30 | $ENV{GNUMAKEFLAGS} = '-Itst/bad'; 31 | 32 | run_make_test(q! 33 | recurse: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS; #MAKEPATH# -f #MAKEFILE# all 34 | all: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS 35 | -include x.mk 36 | x.mk: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS; echo > $@ 37 | !, 38 | "", "x.mk\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\nrecurse\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\n#MAKE#[1]: Entering directory '#PWD#'\nall\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\n#MAKE#[1]: Leaving directory '#PWD#'\n"); 39 | 40 | unlink('x.mk'); 41 | 42 | # Ensure that we don't add GNUMAKEFLAGS to the environment if it's not there 43 | run_make_test(q! 44 | all: ; @#HELPER# env GNUMAKEFLAGS 45 | !, 46 | '', 'GNUMAKEFLAGS='); 47 | 48 | $ENV{GNUMAKEFLAGS} = '-Itst/bad'; 49 | run_make_test(q! 50 | all: ; @#HELPER# env GNUMAKEFLAGS 51 | !, 52 | '', 'GNUMAKEFLAGS='); 53 | 54 | 1; 55 | -------------------------------------------------------------------------------- /tests/scripts/variables/INCLUDE_DIRS: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | $description = "Test the .INCLUDE_DIRS special variable."; 3 | 4 | $details = ""; 5 | 6 | use Cwd; 7 | 8 | $dir = cwd; 9 | $dir =~ s,.*/([^/]+)$,../$1,; 10 | 11 | if (-d '/usr/include') { 12 | # Test #1: The content of .INCLUDE_DIRS depends on the platform for which 13 | # make was built. What we know for sure is that it shouldn't be 14 | # empty. 15 | # 16 | run_make_test(' 17 | ifeq ($(.INCLUDE_DIRS),) 18 | $(warning .INCLUDE_DIRS is empty) 19 | endif 20 | 21 | .PHONY: all 22 | all:;@: 23 | ', 24 | '', ''); 25 | } 26 | 27 | # Test #2: Make sure -I paths end up in .INCLUDE_DIRS. 28 | # 29 | run_make_test(' 30 | ifeq ($(dir),) 31 | $(warning dir is empty) 32 | endif 33 | 34 | ifeq ($(filter $(dir),$(.INCLUDE_DIRS)),) 35 | $(warning .INCLUDE_DIRS does not contain $(dir): $(.INCLUDE_DIRS)) 36 | endif 37 | 38 | .PHONY: all 39 | all:;@: 40 | ', 41 | "-I$dir dir=$dir", ''); 42 | 43 | # Find the default .INCLUDE_DIRS 44 | create_file('defaultdirs.mk', "\$(info \$(.INCLUDE_DIRS))\nall:;\@:\n"); 45 | my $cmd = subst_make_string("#MAKEPATH# -f defaultdirs.mk"); 46 | my @dirs = `$cmd`; 47 | my $dirs = $dirs[0]; 48 | $dirs =~ s/\r?\n//g; 49 | unlink('defaultdirs.mk'); 50 | 51 | run_make_test(" 52 | ifneq (\$(.INCLUDE_DIRS),$dirs) 53 | \$(warning Mismatched \$(.INCLUDE_DIRS) != $dirs) 54 | endif 55 | all:;\@: 56 | ", 57 | '', ''); 58 | 59 | # Verify that -I- disables content from .INCLUDE_DIRS 60 | 61 | run_make_test(q/ 62 | ifneq ($(.INCLUDE_DIRS),) 63 | $(warning Mismatched $(.INCLUDE_DIRS) != ) 64 | endif 65 | all:;@: 66 | /, 67 | '-I-', ''); 68 | 69 | # Prefix -I dirs to the front 70 | mkdir('somedir', 0777); 71 | 72 | my $xdirs = $dirs ? " $dirs" : ''; 73 | run_make_test(" 74 | ifneq (\$(.INCLUDE_DIRS),somedir$xdirs) 75 | \$(warning Mismatched '\$(.INCLUDE_DIRS)' != 'somedir$xdirs') 76 | endif 77 | all:;\@: 78 | ", 79 | '-I somedir', ''); 80 | 81 | # Verify .INCLUDE_DIRS contains files after -I- 82 | 83 | run_make_test(q/ 84 | ifneq ($(.INCLUDE_DIRS),somedir) 85 | $(warning Mismatched $(.INCLUDE_DIRS) != somedir) 86 | endif 87 | all:;@: 88 | /, 89 | '-I - -I somedir', ''); 90 | 91 | rmdir('somedir'); 92 | 93 | # This tells the test driver that the perl test script executed properly. 94 | 1; 95 | -------------------------------------------------------------------------------- /tests/scripts/variables/LIBPATTERNS: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test .LIBPATTERNS special variable."; 4 | 5 | $details = ""; 6 | 7 | # TEST 0: basics 8 | 9 | touch('mtest_foo.a'); 10 | 11 | run_make_test(' 12 | .LIBPATTERNS = mtest_%.a 13 | all: -lfoo ; @echo "build $@ from $<" 14 | ', 15 | '', "build all from mtest_foo.a\n"); 16 | 17 | # TEST 1: Handle elements that are not patterns. 18 | 19 | run_make_test(' 20 | .LIBPATTERNS = mtest_foo.a mtest_%.a 21 | all: -lfoo ; @echo "build $@ from $<" 22 | ', 23 | '', "#MAKE#: .LIBPATTERNS element 'mtest_foo.a' is not a pattern 24 | build all from mtest_foo.a\n"); 25 | 26 | # TEST 2: target-specific override 27 | 28 | # Uncomment this when we add support, see Savannah bug #25703 29 | # run_make_test(' 30 | # .LIBPATTERNS = mbad_%.a 31 | # all: .LIBPATTERNS += mtest_%.a 32 | # all: -lfoo ; @echo "build $@ from $<" 33 | # ', 34 | # '', "build all from mtest_foo.a\n"); 35 | 36 | unlink('mtest_foo.a'); 37 | 38 | 1; 39 | -------------------------------------------------------------------------------- /tests/scripts/variables/MAKE: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test proper behavior of the MAKE variable"; 4 | 5 | $details = "DETAILS"; 6 | 7 | run_make_test(q! 8 | TMP := $(MAKE) 9 | MAKE := $(subst X=$(X),,$(MAKE)) 10 | all: 11 | @echo $(TMP) 12 | $(MAKE) -f #MAKEFILE# foo 13 | 14 | foo: 15 | @echo $(MAKE) 16 | !, 17 | '', 18 | "#MAKEPATH#\n#MAKEPATH# -f #MAKEFILE# foo\n" 19 | . "#MAKE#[1]: Entering directory '#PWD#'\n" 20 | . "#MAKEPATH#\n#MAKE#[1]: Leaving directory '#PWD#'\n"); 21 | 22 | rmfiles("foo"); 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /tests/scripts/variables/MAKECMDGOALS: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the MAKECMDGOALS variable."; 4 | 5 | $details = "\ 6 | We construct a makefile with various targets, all of which print out 7 | \$(MAKECMDGOALS), then call it different ways."; 8 | 9 | open(MAKEFILE,"> $makefile"); 10 | print MAKEFILE "\ 11 | .DEFAULT all: 12 | \@echo \$(MAKECMDGOALS) 13 | "; 14 | close(MAKEFILE); 15 | 16 | # TEST #1 17 | 18 | &run_make_with_options($makefile, 19 | "", 20 | &get_logfile, 21 | 0); 22 | $answer = "\n"; 23 | &compare_output($answer,&get_logfile(1)); 24 | 25 | # TEST #2 26 | 27 | &run_make_with_options($makefile, 28 | "all", 29 | &get_logfile, 30 | 0); 31 | $answer = "all\n"; 32 | &compare_output($answer,&get_logfile(1)); 33 | 34 | 35 | # TEST #3 36 | 37 | &run_make_with_options($makefile, 38 | "foo bar baz yaz", 39 | &get_logfile, 40 | 0); 41 | $answer = "foo bar baz yaz\nfoo bar baz yaz\nfoo bar baz yaz\nfoo bar baz yaz\n"; 42 | &compare_output($answer,&get_logfile(1)); 43 | 44 | 45 | # This tells the test driver that the perl test script executed properly. 46 | 1; 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /tests/scripts/variables/MAKEFILES: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the MAKEFILES variable."; 4 | 5 | $makefile2 = &get_tmpfile; 6 | $makefile3 = &get_tmpfile; 7 | 8 | open(MAKEFILE,"> $makefile2"); 9 | print MAKEFILE < $makefile3"); 17 | print MAKEFILE < $makefile"); 8 | 9 | # The Contents of the MAKEFILE ... 10 | 11 | print MAKEFILE < $@ 25 | bar.x: ; @touch $@ 26 | ', 27 | '', 'MAKE_RESTARTS= 28 | MAKE_RESTARTS=1 29 | MAKE_RESTARTS=2'); 30 | 31 | rmfiles('foo.x', 'bar.x'); 32 | 33 | # Test multiple restarts and make sure the variable is cleaned up 34 | 35 | run_make_test(' 36 | .RECIPEPREFIX = > 37 | recurse: 38 | > @echo recurse MAKE_RESTARTS=$$MAKE_RESTARTS 39 | > @$(MAKE) -f #MAKEFILE# all 40 | all: ; @echo all MAKE_RESTARTS=$$MAKE_RESTARTS 41 | $(info MAKE_RESTARTS=$(MAKE_RESTARTS)) 42 | include foo.x 43 | foo.x: ; @echo "include bar.x" > $@ 44 | bar.x: ; @touch $@ 45 | ', 46 | '', "MAKE_RESTARTS= 47 | MAKE_RESTARTS=1 48 | MAKE_RESTARTS=2 49 | recurse MAKE_RESTARTS= 50 | #MAKE#[1]: Entering directory '#PWD#' 51 | MAKE_RESTARTS= 52 | all MAKE_RESTARTS= 53 | #MAKE#[1]: Leaving directory '#PWD#'"); 54 | 55 | rmfiles('foo.x', 'bar.x'); 56 | 57 | 1; 58 | -------------------------------------------------------------------------------- /tests/scripts/variables/MFILE_LIST: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test the MAKEFILE_LIST variable."; 4 | 5 | create_file('incl2', "m2 := \$(MAKEFILE_LIST)\n"); 6 | 7 | run_make_test(qq! 8 | m1 := \$(MAKEFILE_LIST) 9 | include incl2 10 | m3 := \$(MAKEFILE_LIST) 11 | 12 | all: 13 | \t\@echo \$(m1) 14 | \t\@echo \$(m2) 15 | \t\@echo \$(m3) 16 | !, 17 | '', "#MAKEFILE#\n#MAKEFILE# incl2\n#MAKEFILE# incl2\n"); 18 | 19 | unlink('incl2'); 20 | 21 | # SV 50823 -- makefiles containing '$' chars 22 | 23 | create_file('foo$bar', "m2 := \$(MAKEFILE_LIST)\n"); 24 | 25 | run_make_test(qq! 26 | m1 := \$(MAKEFILE_LIST) 27 | include foo\$\$bar 28 | m3 := \$(MAKEFILE_LIST) 29 | 30 | all: 31 | \t\@echo '\$(m1)' 32 | \t\@echo '\$(m2)' 33 | \t\@echo '\$(m3)' 34 | \t\@echo '\$(value MAKEFILE_LIST)' 35 | !, 36 | '', "#MAKEFILE#\n#MAKEFILE# foo\$bar\n#MAKEFILE# foo\$bar\n#MAKEFILE# foo\$bar\n"); 37 | 38 | unlink('foo$bar'); 39 | 40 | 1; 41 | -------------------------------------------------------------------------------- /tests/scripts/variables/conditional: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test various flavors of conditional variable setting."; 4 | 5 | $details = ""; 6 | 7 | # Test ?= 8 | 9 | run_make_test(q! 10 | x = bar 11 | y = baz 12 | foo ?= $(x) 13 | biz?=$(y) 14 | x = 10 15 | y = 20 16 | all:;@: $(info foo=$(foo) biz=$(biz)) 17 | !, 18 | '', "foo=10 biz=20"); 19 | 20 | run_make_test(q! 21 | foo=1 22 | biz=2 23 | x = bar 24 | y = baz 25 | foo ?= $(x) 26 | biz?=$(y) 27 | x = 10 28 | y = 20 29 | all:;@: $(info foo=$(foo) biz=$(biz)) 30 | !, 31 | '', "foo=1 biz=2"); 32 | 33 | # Test ?:= 34 | 35 | run_make_test(q! 36 | x = bar 37 | y = baz 38 | foo ?:= $(x) 39 | biz?:=$(y) 40 | x = 10 41 | y = 20 42 | all:;@: $(info foo=$(foo) biz=$(biz)) 43 | !, 44 | '', "foo=bar biz=baz"); 45 | 46 | run_make_test(q! 47 | foo=1 48 | biz=2 49 | x = bar 50 | y = baz 51 | foo ?:= $(x)$(info expanded) 52 | biz?:=$(y)$(info expanded) 53 | x = 10 54 | y = 20 55 | all:;@: $(info foo=$(foo) biz=$(biz)) 56 | !, 57 | '', "foo=1 biz=2"); 58 | 59 | # Test ?::= 60 | 61 | run_make_test(q! 62 | x = bar 63 | y = baz 64 | foo ?::= $(x) 65 | biz?::=$(y) 66 | x = 10 67 | y = 20 68 | all:;@: $(info foo=$(foo) biz=$(biz)) 69 | !, 70 | '', "foo=bar biz=baz"); 71 | 72 | run_make_test(q! 73 | foo=1 74 | biz=2 75 | x = bar 76 | y = baz 77 | foo ?::= $(x)$(info expanded) 78 | biz?::=$(y)$(info expanded) 79 | x = 10 80 | y = 20 81 | all:;@: $(info foo=$(foo) biz=$(biz)) 82 | !, 83 | '', "foo=1 biz=2"); 84 | 85 | # Test ?:::= 86 | 87 | run_make_test(q! 88 | x = bar 89 | y = baz 90 | foo ?:::= $(x) 91 | biz?:::=$(y) 92 | x = 10 93 | y = 20 94 | all:;@: $(info foo=$(foo) biz=$(biz)) 95 | !, 96 | '', "foo=bar biz=baz"); 97 | 98 | run_make_test(q! 99 | foo=1 100 | biz=2 101 | x = bar 102 | y = baz 103 | foo ?:::= $(x)$(info expanded) 104 | biz?:::=$(y)$(info expanded) 105 | x = 10 106 | y = 20 107 | all:;@: $(info foo=$(foo) biz=$(biz)) 108 | !, 109 | '', "foo=1 biz=2"); 110 | 111 | # Test ?!= 112 | 113 | run_make_test(q/ 114 | x = bar 115 | y = baz 116 | foo ?!= echo $(x) 117 | biz?!=echo $(y) 118 | x = 10 119 | y = 20 120 | all:;@: $(info foo=$(foo) biz=$(biz)) 121 | /, 122 | '', "foo=bar biz=baz"); 123 | 124 | run_make_test(q/ 125 | foo=1 126 | biz=2 127 | x = bar 128 | y = baz 129 | foo ?!= echo $(x)$(info expanded) 130 | biz?!=echo $(y)$(info expanded) 131 | x = 10 132 | y = 20 133 | all:;@: $(info foo=$(foo) biz=$(biz)) 134 | /, 135 | '', "foo=1 biz=2"); 136 | 137 | 1; 138 | -------------------------------------------------------------------------------- /tests/scripts/variables/negative: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Run some negative tests (things that should fail)."; 4 | 5 | my $unterm = '*** unterminated variable reference. Stop.'; 6 | 7 | # TEST #0 8 | # Check that non-terminated variable references are detected (and 9 | # reported using the best filename/lineno info 10 | run_make_test(' 11 | foo = bar 12 | x = $(foo 13 | y = $x 14 | 15 | all: ; @echo $y 16 | ', 17 | '', "#MAKEFILE#:3: $unterm", 18 | 512); 19 | 20 | # TEST #1 21 | # Bogus variable value passed on the command line. 22 | run_make_test(undef, ['x=$(other'], "#MAKEFILE#:4: $unterm", 512); 23 | 24 | # TEST #2 25 | # Again, but this time while reading the makefile. 26 | run_make_test(' 27 | foo = bar 28 | x = $(foo 29 | y = $x 30 | 31 | z := $y 32 | 33 | all: ; @echo $y 34 | ', 35 | '', "#MAKEFILE#:3: $unterm", 512); 36 | 37 | # TEST #3 38 | # Bogus variable value passed on the command line. 39 | run_make_test(undef, ['x=$(other'], "#MAKEFILE#:4: $unterm", 512); 40 | 41 | my $nosep = '*** missing separator. Stop.'; 42 | 43 | # Whitespace not allowed in variable names 44 | run_make_test('x y =', '', "#MAKEFILE#:1: $nosep", 512); 45 | 46 | run_make_test('x y=', '', "#MAKEFILE#:1: $nosep", 512); 47 | 48 | # In theory an empty variable should be ignored, but during parsing it's a 49 | # real token and so this fails. I'm not 100% sure if this is right or not. 50 | 51 | run_make_test('x $X=', '', "#MAKEFILE#:1: $nosep", 512); 52 | 53 | 54 | 1; 55 | -------------------------------------------------------------------------------- /tests/scripts/variables/special: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test special GNU Make variables."; 4 | 5 | $details = ""; 6 | 7 | &run_make_test(' 8 | 9 | X1 := $(sort $(filter FOO BAR,$(.VARIABLES))) 10 | 11 | FOO := foo 12 | 13 | X2 := $(sort $(filter FOO BAR,$(.VARIABLES))) 14 | 15 | BAR := bar 16 | 17 | all: ; @echo X1 = $(X1); echo X2 = $(X2); echo LAST = $(sort $(filter FOO BAR,$(.VARIABLES))) 18 | ', 19 | '', "X1 =\nX2 = FOO\nLAST = BAR FOO\n"); 20 | 21 | # SV 45728: Test that undefining a variable is reflected properly 22 | 23 | &run_make_test(' 24 | FOO := foo 25 | BAR := bar 26 | $(info one: $(sort $(filter FOO BAR BAZ,$(.VARIABLES)))) 27 | undefine BAR 28 | BAZ := baz 29 | $(info two: $(sort $(filter FOO BAR BAZ,$(.VARIABLES)))) 30 | all:;@: 31 | ', 32 | '', "one: BAR FOO\ntwo: BAZ FOO\n"); 33 | 34 | # $makefile2 = &get_tmpfile; 35 | # open(MAKEFILE, "> $makefile2"); 36 | 37 | # print MAKEFILE <<'EOF'; 38 | 39 | # X1 := $(sort $(.TARGETS)) 40 | 41 | # all: foo 42 | # @echo X1 = $(X1) 43 | # @echo X2 = $(X2) 44 | # @echo LAST = $(sort $(.TARGETS)) 45 | 46 | # X2 := $(sort $(.TARGETS)) 47 | 48 | # foo: 49 | 50 | # EOF 51 | 52 | # close(MAKEFILE); 53 | 54 | # # TEST #2 55 | # # ------- 56 | 57 | # &run_make_with_options($makefile2, "", &get_logfile); 58 | # $answer = "X1 =\nX2 = all\nLAST = all foo\n"; 59 | # &compare_output($answer, &get_logfile(1)); 60 | 61 | # Test the .RECIPEPREFIX variable 62 | &run_make_test(' 63 | define foo 64 | : foo-one\ 65 | foo-two 66 | : foo-three 67 | : foo-four 68 | endef 69 | 70 | orig: ; : orig-one 71 | : orig-two \ 72 | orig-three \ 73 | orig-four \ 74 | orig-five \\\\ 75 | : orig-six 76 | $(foo) 77 | 78 | .RECIPEPREFIX = > 79 | test: ; : test-one 80 | >: test-two \ 81 | test-three \ 82 | >test-four \ 83 | > test-five \\\\ 84 | >: test-six 85 | >$(foo) 86 | 87 | .RECIPEPREFIX = 88 | reset: ; : reset-one 89 | : reset-two \ 90 | reset-three \ 91 | reset-four \ 92 | reset-five \\\\ 93 | : reset-six 94 | $(foo) 95 | ', 96 | 'orig test reset', 97 | ': orig-one 98 | : orig-two \ 99 | orig-three \ 100 | orig-four \ 101 | orig-five \\\\ 102 | : orig-six 103 | : foo-one foo-two 104 | : foo-three 105 | : foo-four 106 | : test-one 107 | : test-two \ 108 | test-three \ 109 | test-four \ 110 | test-five \\\\ 111 | : test-six 112 | : foo-one foo-two 113 | : foo-three 114 | : foo-four 115 | : reset-one 116 | : reset-two \ 117 | reset-three \ 118 | reset-four \ 119 | reset-five \\\\ 120 | : reset-six 121 | : foo-one foo-two 122 | : foo-three 123 | : foo-four'); 124 | 125 | 1; 126 | 127 | ### Local Variables: 128 | ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 129 | ### End: 130 | -------------------------------------------------------------------------------- /tests/scripts/variables/undefine: -------------------------------------------------------------------------------- 1 | # -*-perl-*- 2 | 3 | $description = "Test variable undefine."; 4 | 5 | $details = ""; 6 | 7 | # TEST 0: basic undefine functionality 8 | 9 | run_make_test(' 10 | a = a 11 | b := b 12 | define c 13 | c 14 | endef 15 | 16 | $(info $(flavor a) $(flavor b) $(flavor c)) 17 | 18 | n := b 19 | 20 | undefine a 21 | undefine $n 22 | undefine c 23 | 24 | $(info $(flavor a) $(flavor b) $(flavor c)) 25 | 26 | 27 | all: ;@: 28 | ', 29 | '', "recursive simple recursive\nundefined undefined undefined"); 30 | 31 | 32 | # TEST 1: override 33 | 34 | run_make_test(' 35 | undefine a 36 | override undefine b 37 | 38 | $(info $(flavor a) $(flavor b)) 39 | 40 | 41 | all: ;@: 42 | ', 43 | 'a=a b=b', "recursive undefined"); 44 | 45 | 1; 46 | 47 | # TEST 2: undefine in eval (make sure we undefine from the global var set) 48 | 49 | run_make_test(' 50 | define undef 51 | $(eval undefine $$1) 52 | endef 53 | 54 | a := a 55 | $(call undef,a) 56 | $(info $(flavor a)) 57 | 58 | 59 | all: ;@: 60 | ', 61 | '', "undefined"); 62 | 63 | 64 | # TEST 3: Missing variable name 65 | 66 | run_make_test(' 67 | a = 68 | undefine $a 69 | all: ;@echo ouch 70 | ', 71 | '', "#MAKEFILE#:3: *** empty variable name. Stop.\n", 512); 72 | 73 | # Ensure that define can be a target when not appearing in a variable 74 | # definition context. See SV 59870 75 | 76 | run_make_test(q! 77 | undefine = undefine 78 | 79 | $(undefine) : ;@echo $@ 80 | 81 | %:undefine 82 | 83 | all: undefine foo 84 | 85 | %.x : undefine 86 | 87 | foo:; 88 | !, 89 | '', "undefine\n"); 90 | 91 | 1; 92 | -------------------------------------------------------------------------------- /tests/scripts/vms/library: -------------------------------------------------------------------------------- 1 | # -*-mode: perl-*- 2 | 3 | $description = "Test GNU Make's VMS Library management features."; 4 | 5 | $details = "\ 6 | This only works on VMS systems."; 7 | 8 | return -1 if $osname ne 'VMS'; 9 | 10 | # Help library 11 | $mk_string = "help : help.hlb(file1.hlp)\n\n" . 12 | "file1.hlp :\n" . 13 | "\t\@pipe open/write xxx file1.hlp ; write xxx \"1 help\" ; close xxx\n"; 14 | 15 | my $answer = "library /replace help.hlb file1.hlp"; 16 | 17 | run_make_test($mk_string, 18 | '', $answer); 19 | 20 | unlink('help.hlb'); 21 | unlink('file1.hlp'); 22 | 23 | #Text library 24 | $mk_string = "text : text.tlb(file1.txt)\n\n" . 25 | "file1.txt :\n" . 26 | "\t\@pipe open/write xxx file1.txt ; write xxx \"text file\" ; close xxx\n"; 27 | 28 | $answer = "library /replace text.tlb file1.txt"; 29 | 30 | run_make_test($mk_string, 31 | '', $answer); 32 | 33 | unlink('text.tlb'); 34 | unlink('file1.txt'); 35 | 36 | 37 | #Macro library 38 | $mk_string = "macro : macro.mlb(file1.mar)\n\n" . 39 | "file1.mar :\n" . 40 | "\tpipe open/write xxx file1.mar ; " . 41 | "write xxx \".macro a b\" ; write xxx \".endm\" ; close xxx\n"; 42 | 43 | $answer = "library /replace macro.mlb file1.mar"; 44 | 45 | run_make_test($mk_string, 46 | '', $answer); 47 | 48 | unlink('macro.mlb'); 49 | unlink('file1.mar'); 50 | 51 | $mk_string = 52 | "all:imagelib.olb(file2.exe)\n" . 53 | "file2.exe : file2.obj file2.opt\n" . 54 | "\t\@link /share=\$\@ \$\*,\$\*/opt\n\n" . 55 | "file2.opt :\n" . 56 | "\t\@pipe open/write xxx file2.opt ; " . 57 | "write xxx \"CASE_SENSITIVE=YES\" ; close xxx\n" . 58 | "file2.c :\n" . 59 | "\t\@pipe open/write xxx file2.c ; write xxx \"file2(){}\" ; close xxx\n"; 60 | 61 | $answer = "library /replace imagelib.olb file2.exe"; 62 | 63 | run_make_test($mk_string, 64 | '', $answer); 65 | 66 | unlink('imagelib.olb'); 67 | unlink('file2.c'); 68 | unlink('file2.obj'); 69 | unlink('file2.exe'); 70 | unlink('file2.opt'); 71 | 72 | # This tells the test driver that the perl test script executed properly. 73 | 1; 74 | -------------------------------------------------------------------------------- /vms_export_symbol_test.com: -------------------------------------------------------------------------------- 1 | $! VMS_EXPORT_SYMBOL_TEST.COM 2 | $! 3 | $! Verify the VMS_EXPORT_SYMBOL.C module 4 | $! 5 | $! 22-May-2014 J. Malmberg 6 | $! 7 | $!========================================================================= 8 | $! 9 | $ cc/names=(as_is)/define=(DEBUG=1,_POSIX_EXIT=1) vms_export_symbol.c 10 | $! 11 | $ link vms_export_symbol 12 | $! 13 | $ delete vms_export_symbol.obj;* 14 | $! 15 | $! Need a foreign command to test. 16 | $ vms_export_symbol := $sys$disk:[]vms_export_symbol.exe 17 | $ save_export_symbol = vms_export_symbol 18 | $! 19 | $ vms_export_symbol 20 | $ if $severity .ne. 1 21 | $ then 22 | $ write sys$output "Test program failed!"; 23 | $ endif 24 | $! 25 | $ if vms_export_symbol .nes. save_export_symbol 26 | $ then 27 | $ write sys$output "Test failed to restore foreign command!" 28 | $ endif 29 | $ if f$type(test_export_symbol) .nes. "" 30 | $ then 31 | $ write sys$output "Test failed to clear exported symbol!" 32 | $ endif 33 | $ if f$type(test_putenv_symbol) .nes. "" 34 | $ then 35 | $ write sys$output "Test failed to clear putenv exported symbol!" 36 | $ endif 37 | $! 38 | --------------------------------------------------------------------------------