Compare commits

...

10 commits

Author SHA1 Message Date
snow flurry cbcffb4717 CMakeLists.txt: set std=gnu++98
Required to fix a few errors where some enum->int->wchar_t* casting
happens.
2023-02-27 22:45:15 -08:00
snow flurry b4596781ea mksh/misc.h: hack for bsd_signal()
For some reason, I wasn't able to get bsd_signal to be exposed by
signal.h, despite using _XOPEN_SOURCE=600 and _GNU_SOURCE/-std=gnu++98.

This hack is close enough. From the man page for bsd_signal(3):

   On modern Linux systems, bsd_signal() and signal(2) are equivalent.
   But on older systems, signal(2) provided unreliable signal semantics;
   see signal(2) for details.
2023-02-27 22:41:28 -08:00
Georg Sauthoff 6312f8bfdb Link to Open Build Service Repository 2017-04-09 17:42:06 +02:00
Georg Sauthoff a9b6d5c596 Resolve RPM conflicts on Fedora > 23
e.g. on Fedora 25:

Error: Transaction check error:
  file /usr/share/man from install of somake-0.6.0-1.x86_64 conflicts with file from package filesystem-3.2-37.fc24.x86_64
  file /usr/share/man/man1 from install of somake-0.6.0-1.x86_64 conflicts with file from package filesystem-3.2-37.fc24.x86_64
2017-03-13 23:52:59 +01:00
Georg Sauthoff 134796a9e5 relax required cmake version
e.g. also compiles on CentOS 6 with cmake 2.8 from EPEL
2016-11-15 21:44:48 +01:00
Georg Sauthoff ee5bee4f2e only include libbsd header if libbsd is installed 2016-11-15 21:43:45 +01:00
Georg Sauthoff 808565e725 add note regarding better include file generation 2016-08-30 10:24:40 +02:00
Georg Sauthoff e52b61f121 add test: KEEP_STATE vs. include generation issue 2016-08-30 09:37:57 +02:00
Georg Sauthoff 77f083298a rename man page to the name of the project 2016-08-29 22:38:23 +02:00
Georg Sauthoff d7687df5f0 remove getwd() declaration because
- it is unused
- LEGACY in POSIX.2001, not available in POSIX.2008
- even available via `unistd.h` on Solaris 10
2016-08-28 23:04:52 +02:00
6 changed files with 135 additions and 17 deletions

View file

@ -1,6 +1,6 @@
# 2016, Georg Sauthoff <mail@georg.so>
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 2.8)
project(somake C CXX)
include(CheckFunctionExists)
@ -56,6 +56,7 @@ set_property(TARGET ${PROJECT_NAME} mksh vroot PROPERTY INCLUDE_DIRECTORIES
${CMAKE_CURRENT_BINARY_DIR}
${BSD_INCLUDE_DIRS}
)
set_property(TARGET ${PROJECT_NAME} mksh vroot PROPERTY CXX_STANDARD 98)
target_link_libraries(${PROJECT_NAME}
mksh vroot pthread ${BSD_LIBRARIES} ${NSL_LIB} ${INTL_LIB}
@ -64,7 +65,8 @@ target_link_libraries(${PROJECT_NAME}
# default install prefix is /usr/local
# change it with e.g. -DCMAKE_INSTALL_PREFIX=/usr
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
install(FILES man/man1/make.1 DESTINATION share/man/man1)
install(FILES man/man1/make.1 DESTINATION share/man/man1
RENAME ${PROJECT_NAME}.1)
install(FILES bin/make.rules.file DESTINATION share/${PROJECT_NAME}
RENAME make.rules)
install(FILES bin/svr4.make.rules.file DESTINATION share/${PROJECT_NAME}
@ -92,6 +94,8 @@ set(CPACK_PACKAGE_VERSION_MINOR "6")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_RPM_PACKAGE_GROUP "Development/Tools")
set(CPACK_RPM_PACKAGE_URL "https://github.com/gsauthof/somake")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
"/usr/share/man" "/usr/share/man/man1")
# CPackDeb default to CPACK_PACKAGE_DESCRIPTION_SUMMARY, although
# the long description makes more sense ...
file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_DEBIAN_PACKAGE_DESCRIPTION)

View file

@ -1,3 +1,5 @@
[![Open Build Service](https://img.shields.io/badge/OBS-.deb%20.rpm-green.svg)][obs]
This repository contains the [Illumos][illumos] make source code (in branch
`illumos`) and based on that a port to Linux (branch `master`).
@ -249,7 +251,8 @@ generation in GNU make prints misleading messages (cf. e.g. bug
102). Sun make's `.make.state` file (that is used for hidden
dependency and command dependency tracking) sometimes causes more
harm than good - e.g. when outdated dependencies aren't removed
(e.g. when one converts a target group into a target list).
(e.g. when one converts a target group into a target list). Or when
include files are regenerated unconditionally (cf. `test/empty_cmd.mf`).
The distributed make that comes with OpenOffice is [also named
DMake][oodmake]. It seems that it was independently developed of Sun's
@ -368,6 +371,10 @@ Or:
$ rpm2cpio somake-0.6.0-Linux.rpm | cpio --list -v
$ rpm -qip somake-0.6.0-Linux.rpm
### Open Build Service
There is also an [Open Build Service Repository][obs] that provides
somake binary packages for several distributions.
## License
@ -388,4 +395,5 @@ also under the [CDDL][cddl].
[smake]: https://sourceforge.net/projects/s-make/
[imake]: https://en.wikipedia.org/wiki/Imake
[dmake]: https://docs.oracle.com/cd/E24457_01/html/E25220/index.html
[obs]: https://build.opensuse.org/package/show/home:gsauthof/somake

View file

@ -353,16 +353,6 @@ extern void gather_recursive_deps(void);
extern char *get_current_path(void);
extern int get_job_msg_id(void);
extern wchar_t *getmem_wc(register int size);
/* On linux getwd(char *) is defined in 'unistd.h' */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __sun
extern char *getwd(char *);
#endif
#ifdef __cplusplus
}
#endif
extern void handle_interrupt(int);
extern Boolean is_running(Name target);
extern void load_cached_names(void);

View file

@ -51,5 +51,6 @@ extern void warning_mksh(char * message, ...);
extern void append_string(register char *from, register String to, register int length);
extern wchar_t *get_wstring(char * from);
#define bsd_signal(x, y) signal(x, y)
#endif

View file

@ -51,15 +51,16 @@
#include <sys/wait.h> /* wait() */
#include <ulimit.h> /* ulimit() */
#include <unistd.h> /* close(), dup2() */
// closefrom only available on Solaris/BSD
// closefrom only available on Solaris/BSD via system header
#include <stdlib.h> /* closefrom() */
#ifdef __linux
#include <bsd/unistd.h>
#endif
#include <libintl.h>
#include <config.h>
#if defined(__linux) && defined(HAVE_CLOSEFROM)
#include <bsd/unistd.h>
#endif
/*
* typedefs & structs
*/

114
test/empty_cmd.mf Normal file
View file

@ -0,0 +1,114 @@
# (A)
.KEEP_STATE:
all: hello
clean:
rm foo.x foo.y
foo.x:
touch foo.x
# <- workaround: disable command dependencies
# ?touch foo.x
foo.y: foo.x
cat foo.x foo.x > foo.y
# <- workaround: disable command dependencies
# ?cat foo.x foo.x > foo.y
# (B)
include foo.y
hello:
echo hello
# The perhaps unintuitive effect of `.KEEP_STATE`
# on the generation of include files.
#
# Effects:
#
# 1) comment out the line after (A)
#
# $ somake -f empty_cmd.mf clean
# rm foo.x foo.y
# $ rm .make.state
# $ somake -f empty_cmd.mf
# touch foo.x
# cat foo.x foo.x > foo.y
# echo hello
# hello
# $ somake -f empty_cmd.mf
# echo hello
# hello
#
# -> meaning that the include file foo.y is only updated
# if it doesn't exist or foo.x is newer. This is
# the expected behavior.
#
# 2) comment in (A) and comment out (B)
#
# $ somake -f empty_cmd.mf clean
# rm foo.x foo.y
# $ rm .make.state
# $ somake -f empty_cmd.mf foo.y
# touch foo.x
# cat foo.x foo.x > foo.y
# $ somake -f empty_cmd.mf foo.y
# `foo.y' is up to date.
#
# -> again, as expected the foo.y action is only executed once.
#
# 3) comment in (A) and (B)
#
# $ somake -f empty_cmd.mf clean
# touch foo.x
# cat foo.x foo.x > foo.y
# rm foo.x foo.y
# $ rm .make.state
# $ somake -f empty_cmd.mf
# touch foo.x
# cat foo.x foo.x > foo.y
# echo hello
# hello
# $ somake -f empty_cmd.mf
# touch foo.x
# cat foo.x foo.x > foo.y
# echo hello
# hello
#
# -> this is unexpected because foo.y is generated each time.
# This is caused by an interaction between KEEP_STATE and
# include. Make reads in the `.make.state` file after
# include directives are being processed. But, as part of the
# dependency checking of the include files the usual KEEP_STATE
# logic is applied such that make assumes that the foo.y action
# command changed from '' (empty) to 'cat foo.x foo.x > foo.y'.
#
# (make basically looks up the 'old' command in an empty database)
#
# When calling make with `-d` the log contains messages like:
#
# different from empty old command
# Building foo.x because new command longer than old
# Building foo.y because new command longer than old
#
# A workaround is to disable command dependencies for the involved
# actions, i.e. `?touch foo` and `?cat foo.x foo.x > foo.y`
#
# This is a bug.
#
# Possible fix:
# i) Just don't use the make.state database before it is loaded.
# This effectively would disable command dependencies for
# generated include files. Similar effect as the described
# workaround.
# ii) or, preferably, load the make.state file before any
# processing of include directives. This would have
# the advantage that an include file is regenerated if a
# variable that is used in the generate action has
# changed (think: `generate.sh $(CC) $(LD) > tool_dependent.mf`