summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wong <markwkm@gmail.com>2023-06-30 15:54:04 -0700
committerMark Wong <markwkm@gmail.com>2023-06-30 15:54:04 -0700
commit0732cca5fd66dd1f26d4024f86b83725b974692f (patch)
treee5d75ac43a0b09cf773f91a7f7e88b2889dd0420
parent33eacc18b77760ffc8ddddb0768f685573676200 (diff)
Fix CMake handling of building getopt.c
* include config.h in getopt.c to get HAVE_GETOPT macro * don't build getopt.c if getopt is found on the system
-rw-r--r--CMakeLists.txt6
-rw-r--r--HISTORY.rst1
-rw-r--r--getopt.c3
3 files changed, 6 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2363b3e..dc13c74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -172,12 +172,15 @@ set_source_files_properties(
PROPERTIES COMPILE_FLAGS "-I${CMAKE_HOME_DIRECTORY} ${PGINCLUDE}"
)
+if (NOT ${HAVE_GETOPT})
+ set (EXTRAFILES "${EXTRAFILES} getopt.c")
+endif (NOT ${HAVE_GETOPT})
+
add_executable(
${PROJECT_NAME}
color.c
commands.c
display.c
- getopt.c
screen.c
sprompt.c
pg.c
@@ -187,6 +190,7 @@ add_executable(
machine/m_remote.c
machine/m_common.c
machine/m_${MACHINE}.c
+ ${EXTRAFILES}
)
# Determine appropriate linker flags.
diff --git a/HISTORY.rst b/HISTORY.rst
index fa3bd43..f249556 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -11,6 +11,7 @@ YYYY-MM-DD v4.0.1
* Replace reallocarray() with POSIX realloc()
* Fix escaping in CMakeLists.txt AppImage target
* Removed building of sigdesc.h, since kill commands was removed in v4.0.0
+* Fix CMake handling of building getopt.c when not found
2020-08-05 v4.0.0
-----------------
diff --git a/getopt.c b/getopt.c
index 2e17e4b..4505488 100644
--- a/getopt.c
+++ b/getopt.c
@@ -11,9 +11,7 @@
* line of the corresponding machine module.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif /* HAVE_CONFIG_H */
#ifndef HAVE_GETOPT
@@ -27,7 +25,6 @@
#define EOF (-1)
#endif
#define ERR(s, c) if(opterr){\
- extern int write();\
char errbuf[2];\
errbuf[0] = c; errbuf[1] = '\n';\
(void) write(2, argv[0], strlen(argv[0]));\