aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLAN-TW <lantw44@gmail.com>2013-01-27 20:24:07 +0800
committerLAN-TW <lantw44@gmail.com>2013-01-27 20:24:07 +0800
commit6b44a76e69005b971a9bcf5427eb4b93f20f28c1 (patch)
tree687941a286eff80840edae0dfa1addfcd32fe1f9
parent7ca893e145cb1d6e73127c4dfbf1a51281c0882a (diff)
downloadsctjudge-6b44a76e69005b971a9bcf5427eb4b93f20f28c1.tar.gz
sctjudge-6b44a76e69005b971a9bcf5427eb4b93f20f28c1.tar.zst
sctjudge-6b44a76e69005b971a9bcf5427eb4b93f20f28c1.zip
重新規劃 configure.ac,加入自動猜測的功能 (版本號進入 1.0)
現在可以偵測 Linux 和 FreeBSD,並提供不同的預設選項了! 預設的東西失敗了不會結束 configure,但使用者自己指定的就會。 待解決問題: (1) 程序監視器目前只實做了 Linux 版本,FreeBSD 尚未實作。 (但已進行相關準備工作) (2) 0.000 秒 訊息可能不會被洗掉的問題,這大概要下一版才能解決。
-rw-r--r--.gitignore23
-rw-r--r--configure.ac312
-rw-r--r--l4basic/l4arg/Makefile.in (renamed from l4basic/l4arg/Makefile)4
-rw-r--r--l4basic/l4bds/Makefile.in (renamed from l4basic/l4bds/Makefile)4
-rw-r--r--l4basic/l4darr/Makefile.in (renamed from l4basic/l4darr/Makefile)4
-rw-r--r--src/checktle.c1
-rw-r--r--src/disptime.c16
-rw-r--r--src/main.c57
-rw-r--r--src/mkchild.c2
-rw-r--r--src/version.h.in75
10 files changed, 334 insertions, 164 deletions
diff --git a/.gitignore b/.gitignore
index d3e9709..6bff056 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,18 +10,25 @@
*.swp
aclocal.m4
autom4te.cache
+autoscan.log
compile
config.log
config.msg
config.status
+config.guess
+config.sub
configure
+configure.scan
depcomp
-install-sh
-Makefile.in
missing
-sctjudge.spec
-src/Makefile
-src/config.h
-src/config.h.in
-src/version.h
-src/stamp-h1
+install-sh
+/Makefile
+/Makefile.in
+/sctjudge.spec
+/src/Makefile
+/src/Makefile.in
+/src/config.h
+/src/config.h.in
+/src/version.h
+/src/stamp-h1
+/src/sctjudge
diff --git a/configure.ac b/configure.ac
index 65f58e6..3309e70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,19 +1,27 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
-AC_INIT([sctjudge], [1.0-rc3], [lantw44@gmail.com])
+AC_INIT([sctjudge], [1.0], [lantw44@gmail.com])
AM_INIT_AUTOMAKE([foreign -Wall])
AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([src/config.h])
-AC_CONFIG_FILES([Makefile sctjudge.spec src/Makefile src/version.h])
-
-releasedate="2012-11-15"
+AC_CONFIG_FILES([
+ Makefile
+ sctjudge.spec
+ l4basic/l4arg/Makefile
+ l4basic/l4bds/Makefile
+ l4basic/l4darr/Makefile
+ src/Makefile
+ src/version.h
+ ])
+
+releasedate="2013-01-27"
rpmversion="1.0"
-# Checks for programs.
-AC_PROG_CC
-AM_PROG_CC_C_O
+
+
+
# 寫入版本資訊
AC_SUBST([PROGRAM_NAME], [AC_PACKAGE_NAME])
@@ -21,10 +29,12 @@ AC_SUBST([PROGRAM_VERSION], [AC_PACKAGE_VERSION])
AC_SUBST([PROGRAM_RPMVERSION], $rpmversion)
AC_SUBST([PROGRAM_DATE], $releasedate)
+
+
+
# 提早離開 configure 的途徑
AC_ARG_ENABLE([check],
- [AS_HELP_STRING([--disable-check],
- [skip all checks])],
+ [AS_HELP_STRING([--disable-check], [skip all checks])],
[opt_check=$enableval], [opt_check=yes])
if test x"${opt_check}" = xno; then \
@@ -34,75 +44,93 @@ if test x"${opt_check}" = xno; then \
exit 0
fi
-# 和預設的 CFLAGS 說再見
-test -n "${CFLAGS}" && CFLAGS="-g"
+
+
+
+# 偵測作業系統類型
+AC_CANONICAL_HOST
+AC_CANONICAL_BUILD
+
+
+
+
+# 根據作業系統修改預設選項
+case "$build_os" in
+ *linux*)
+ opt_procmon=guess
+ opt_cap=guess
+ ;;
+ *freebsd*)
+ opt_procmon=no
+ opt_cap=no
+ ;;
+ *)
+ opt_procmon=no
+ opt_cap=no
+ ;;
+esac
+
+
+
# 偵錯很重要,但使用者應該不需要
-AC_ARG_ENABLE([debug],
- [AS_HELP_STRING([--enable-debug],
- [produce debugging information and disable
- optimization in binary files])],
- [opt_debug=$enableval], [opt_debug=no])
-
-if test -n "${CFLAGS}"; then
- if test x"${opt_debug}" = xyes; then
- CFLAGS="-g"
- else
- CFLAGS="-O2"
- fi
+AC_ARG_ENABLE([optimized],
+ [AS_HELP_STRING([--disable-optimized], [disable compiler optimization])],
+ [opt_optimized=$enableval], [opt_optimized=yes])
+
+if test x"${opt_optimized}" = xno; then
+ if test -z "${CFLAGS}"; then
+ CFLAGS="-g"
+ else
+ CFLAGS="${CFLAGS//-O2/}"
+ fi
fi
+
+
+# 偵測必要的程式
+AC_PROG_CC
+AC_PROG_INSTALL
+AM_PROG_CC_C_O
+
+
+
+
+# 寫入編譯參數
+AC_SUBST([AUTOTOOL_CC], ["$CC"])
+AC_SUBST([AUTOTOOL_CFLAGS], ["$CFLAGS"])
+
+
+
# 靜態連結,如果想做 portable 版本的話
AC_ARG_ENABLE([static],
- [AC_HELP_STRING([--enable-static],
+ [AS_HELP_STRING([--enable-static],
[statically link all executables])],
[opt_static=$enableval], [opt_static=no])
AM_CONDITIONAL([STATIC_EXEC], [test x"${opt_static}" = xyes])
-# 有些功能是選用的......
-AC_ARG_ENABLE([procmon],
- [AS_HELP_STRING([--enable-procmon],
- [enable process monitor using Linux proc filesystem])],
- [opt_procmon=$enableval], [opt_procmon=no])
-test x"${opt_procmon}" = xyes && \
- AC_DEFINE([HAVE_CONF_PROCMON], [1], [Process Monitor])
-AC_ARG_ENABLE([cap],
- [AS_HELP_STRING([--enable-cap],
- [using Linux capabilities instead of standard UNIX permission])],
- [opt_cap=$enableval], [opt_cap=no])
-test x"${opt_cap}" = xyes && \
- AC_DEFINE([HAVE_CONF_CAP], [1], [Linux Capabilities])
+# 選用的功能
+AC_ARG_ENABLE([procmon],
+ [AS_HELP_STRING([--enable-procmon=METHOD],
+ [enable process monitor (METHOD=linux/freebsd)
+ (LINUX=Linux /proc filesystem)
+ (FREEBSD=FreeBSD sysctl(3))])],
+ [opt_procmon=$enableval], [true])
-# 可以設定 /dev/null 名稱
-AC_ARG_WITH([null],
- AS_HELP_STRING([--with-null=NULL],
- [set the path of the data sink (default: /dev/null)]),
- [with_null=$withval], [with_null=/dev/null])
+AC_ARG_ENABLE([cap],
+ [AS_HELP_STRING([--enable-cap],
+ [use Linux capabilities instead of standard UNIX permission
+ (default: YES if building for Linux)])],
+ [opt_cap=$enableval], [true])
-AC_CHECK_FILE([${with_null}],
- [AC_DEFINE_UNQUOTED([NULL_DEVICE], ["${with_null}"],
- [Path of the data sink])],
- [AC_MSG_ERROR([${with_null} does not exist])])
-# 可以設定 proc filesystem 在哪裡
-AC_ARG_WITH([proc],
- AS_HELP_STRING([--with-proc=PROC],
- [set the location of your Linux proc file system]),
- [with_proc=$withval], [with_proc=/proc])
-
-if test x"${opt_procmon}" = xyes; then \
- AC_CHECK_FILES([${with_proc}/stat ${with_proc}/$$/stat ${with_proc}/$$/statm ${with_proc}/$$/status],
- [AC_DEFINE_UNQUOTED([PROC_PATH], ["${with_proc}"],
- [Location of Linux proc file system])],
- [AC_MSG_ERROR([Linux proc file system support is incomplete])])
-fi
-# Checks for libraries.
+# 檢查必要的函式庫
AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread -lrt"],
[test_nort=yes], [-lrt])
@@ -115,29 +143,9 @@ AC_CHECK_LIB([c], [sem_timedwait], [true],
[AC_MSG_ERROR([Semaphore support is required])], ["$LIBS"])
-if test x"${opt_cap}" = xyes; then
- checkliblist="cap_init cap_clear_flag cap_set_proc"
- for i in $checkliblist; do
- AC_CHECK_LIB([cap], $i, [true],
- AC_MSG_ERROR(You must install libcap-devel or use --disable-cap))
- done
-# Checks for programs
- AC_CHECK_PROG([have_prog_setcap],[setcap],[yes],[no])
- test x"${have_prog_setcap}" = xno &&
- AC_MSG_ERROR(setcap does not exist in your PATH)
- LIBS="$LIBS -lcap"
-fi
-
-AM_CONDITIONAL([USING_SETCAP], [test x"${opt_cap}" = xyes])
-
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h locale.h stdlib.h string.h sys/time.h unistd.h])
-if test x"${opt_cap}" = xyes; then
- AC_CHECK_HEADERS([sys/prctl.h sys/capability.h], [],
- [AC_MSG_ERROR(You must install these files or use --disable-cap)])
-fi
-
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UID_T
AC_TYPE_MODE_T
@@ -146,17 +154,145 @@ AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_FORK
-AC_FUNC_MALLOC
-AC_CHECK_FUNCS([clock_gettime dup2 memset setlocale strchr strerror strrchr getuid getpid setpgid wait4 fcntl fchown open close setrlimit chmod unlink],
- [], AC_MSG_ERROR(This program requires all these functions!))
-AC_CHECK_FUNCS([getpwnam getgrnam getpwuid getgrgid],
- opt_ugidname=yes, opt_ugidname=no)
+test x"${ac_cv_func_fork_works}" = xyes || \
+ AC_MSG_ERROR(This program requires a working fork function.)
+
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+
+for f in \
+ clock_gettime dup2 memset setlocale strchr strerror strrchr getuid \
+ getpid setpgid wait4 fcntl fchown open close setrlimit chmod unlink
+do
+ AC_CHECK_FUNC([$f],
+ [true], AC_MSG_ERROR(This program requires all these functions!))
+done
+
+for f in getpwnam getgrnam getpwuid getgrgid
+do
+ AC_CHECK_FUNC([$f], [opt_ugidname=yes], [opt_ugidname=no])
+ test x"${opt_ugidname}" = xno && break
+done
test x"${opt_ugidname}" = xyes && \
AC_DEFINE([HAVE_CONF_UGIDNAME], [1],
[Conversion between user or group ID and name])
+
+
+
+
+# 可以設定 /dev/null 名稱
+AC_ARG_WITH([null],
+ AS_HELP_STRING([--with-null=NULL],
+ [set the path of the data sink (default: /dev/null)]),
+ [with_null=$withval], [with_null=/dev/null])
+
+if test "$build" = "$host"; then \
+ AC_CHECK_FILE([${with_null}], [true],
+ [AC_MSG_ERROR([${with_null} does not exist])])
+else
+ echo "Cross compiling: Data sink existence check is SKIPPED!"
+fi
+
+AC_DEFINE_UNQUOTED([WITH_NULL], ["${with_null}"], [Path of the data sink])
+
+
+
+
+
+
+# 判斷是否可用 procmon
+# 可以設定 proc filesystem 在哪裡
+AC_ARG_WITH([linuxproc],
+ AS_HELP_STRING([--with-linuxproc=PROC],
+ [set the location of your Linux proc file system (default: /proc)]),
+ [with_linuxproc=$withval], [with_linuxproc=/proc])
+
+if test x"${opt_procmon}" = xyes; then
+ case "$build_os" in
+ *linux*)
+ opt_procmon=linux
+ ;;
+ *freebsd*)
+ opt_procmon=freebsd
+ ;;
+ *)
+ ;;
+ esac
+fi
+
+
+if test x"${opt_procmon}" = xlinux || test x"${opt_procmon}" = xguess; then
+ if test "$build" = "$host"; then
+ for f in \
+ "${with_linuxproc}/stat" \
+ "${with_linuxproc}/$$/stat" \
+ "${with_linuxproc}/$$/statm" \
+ "${with_linuxproc}/$$/status"
+ do
+ AC_CHECK_FILE([$f], [procmon_found=yes], [procmon_found=no])
+ test x"${procmon_found}" = xno && break
+ done
+ if test x"${procmon_found}" = xyes; then
+ opt_procmon=linux
+ else
+ if test x"${opt_procmon}" = xlinux; then
+ AC_MSG_ERROR([Linux proc file system support is incomplete])
+ fi
+ opt_procmon=no
+ fi
+ else
+ echo "Cross compiling: Linux proc file system support check is SKIPPED!"
+ opt_procmon=linux
+ fi
+fi
+
+
+if test x"${opt_procmon}" = xfreebsd || test x"${opt_procmon}" = xguess; then
+ if test x"${opt_procmon}" = xfreebsd; then
+ AC_MSG_ERROR([FreeBSD process monitor is not implemented])
+ fi
+fi
+
+
+
+if test x"${opt_procmon}" = xlinux; then
+ AC_DEFINE([HAVE_CONF_PROCMON_LINUX], [1], [Process Monitor (Linux)])
+ AC_DEFINE_UNQUOTED([WITH_LINUXPROC], ["${with_linuxproc}"],
+ [Location of Linux proc file system])
+fi
+
+
+
+if test x"${opt_cap}" = xyes || test x"${opt_cap}" = xguess; then
+ AC_CHECK_LIB([cap], [cap_set_proc], [cap_found_1=yes], [cap_found_1=no])
+ AC_CHECK_PROG([cap_found_2], [setcap], [yes], [no])
+ AC_CHECK_HEADERS([sys/prctl.h sys/capability.h], [cap_found_3=yes],
+ [cap_found_3=no])
+
+ if test x"${cap_found_1}" = xyes && test x"${cap_found_2}" = xyes && \
+ test x"${cap_found_3}" = xyes; then
+ opt_cap=yes
+ else
+ if test x"${opt_cap}" = xyes; then
+ AC_MSG_ERROR([You must install Linux capabilities library (libcap)
+ or use --disable-cap])
+ fi
+ opt_cap=no
+ fi
+fi
+
+if test x"${opt_cap}" = xyes; then
+ LIBS="$LIBS -lcap"
+ AC_DEFINE([HAVE_CONF_CAP], [1], [Linux Capabilities])
+fi
+AM_CONDITIONAL([USING_SETCAP], [test x"${opt_cap}" = xyes])
+
+
+
+
AC_OUTPUT
confmsgsave="config.msg"
@@ -164,14 +300,14 @@ confmsgsave="config.msg"
echo "" | tee "$confmsgsave"
echo "Optional Features:" | tee -a "$confmsgsave"
echo "(1) Conversion between user or group ID and name .... $opt_ugidname" | tee -a "$confmsgsave"
-echo "(2) Process monitor using Linux proc filesystem ..... $opt_procmon" | tee -a "$confmsgsave"
-echo "(3) Linux capabilities support ...................... $opt_cap" | tee -a "$confmsgsave"
+echo "(2) Linux capabilities support ...................... $opt_cap" | tee -a "$confmsgsave"
+echo "(3) Process monitor ................................. $opt_procmon" | tee -a "$confmsgsave"
echo "-------------------------------------------------------------" | tee -a "$confmsgsave"
echo "Compiling and Linking Options:" | tee -a "$confmsgsave"
-echo "(1) Debugging information ........................... $opt_debug" | tee -a "$confmsgsave"
+echo "(1) Compiler optimization ........................... $opt_optimized" | tee -a "$confmsgsave"
echo "(2) Statically linked executable .................... $opt_static" | tee -a "$confmsgsave"
echo "-------------------------------------------------------------" | tee -a "$confmsgsave"
echo "Strings:" | tee -a "$confmsgsave"
-echo "(1) Linux proc filesystem path ...................... $with_proc" | tee -a "$confmsgsave"
+echo "(1) Linux proc filesystem path ...................... $with_linuxproc" | tee -a "$confmsgsave"
echo "(2) Data sink path .................................. $with_null" | tee -a "$confmsgsave"
echo "The above messages has been written to $confmsgsave"
diff --git a/l4basic/l4arg/Makefile b/l4basic/l4arg/Makefile.in
index 0f2ffe3..fafe44b 100644
--- a/l4basic/l4arg/Makefile
+++ b/l4basic/l4arg/Makefile.in
@@ -1,8 +1,8 @@
-CC=cc
+CC=@AUTOTOOL_CC@
AR=ar
RM=rm -f
INSTALL=install -m 644
-LOCAL_CFLAGS=-g
+LOCAL_CFLAGS=@AUTOTOOL_CFLAGS@
CFLAGS=-Wall -I. -I../l4darr $(LOCAL_CFLAGS)
OBJ=toargv.o qarg.o
LIBFILE=libl4arg.a
diff --git a/l4basic/l4bds/Makefile b/l4basic/l4bds/Makefile.in
index c4c2caa..b51dfee 100644
--- a/l4basic/l4bds/Makefile
+++ b/l4basic/l4bds/Makefile.in
@@ -1,8 +1,8 @@
-CC=cc
+CC=@AUTOTOOL_CC@
AR=ar
RM=rm -f
INSTALL=install -m 644
-LOCAL_CFLAGS=-g
+LOCAL_CFLAGS=@AUTOTOOL_CFLAGS@
CFLAGS=-Wall -I. $(LOCAL_CFLAGS)
OBJ=list.o
LIBFILE=libl4bds.a
diff --git a/l4basic/l4darr/Makefile b/l4basic/l4darr/Makefile.in
index 4593ccf..8d68314 100644
--- a/l4basic/l4darr/Makefile
+++ b/l4basic/l4darr/Makefile.in
@@ -1,8 +1,8 @@
-CC=cc
+CC=@AUTOTOOL_CC@
AR=ar
RM=rm -f
INSTALL=install -m 644
-LOCAL_CFLAGS=-g
+LOCAL_CFLAGS=@AUTOTOOL_CFLAGS@
CFLAGS=-Wall -I. $(LOCAL_CFLAGS)
OBJ=d1array.o d1arrstr.o d2array.o
LIBFILE=libl4darr.a
diff --git a/src/checktle.c b/src/checktle.c
index e70fe8b..126a5e3 100644
--- a/src/checktle.c
+++ b/src/checktle.c
@@ -25,7 +25,6 @@ void* sctjudge_checktle(void* arg){
long long sleeptime = (long long)(*(int*)arg) * 1000000;
struct sigaction break_catch;
struct timespec timelimit, timeinit, timecur, timeexpire;
- const struct timespec nanslparg = {0, SCT_CHECKTLE_INTERVAL};
pthread_mutex_lock(&tkill_mx);
tkill_yes = 1;
diff --git a/src/disptime.c b/src/disptime.c
index deeee68..4f64cd7 100644
--- a/src/disptime.c
+++ b/src/disptime.c
@@ -20,12 +20,12 @@ void* sctjudge_displaytime(void* arg){
timesleep.tv_sec = 0;
timesleep.tv_nsec = (*(long*)arg);
-#ifdef HAVE_CONF_PROCMON
+#ifdef HAVE_CONF_PROCMON_LINUX
int i;
pid_t pidcopy;
- const char* sysstatfile = PROC_PATH"/stat";
+ const char* sysstatfile = WITH_LINUXPROC"/stat";
char statfile[25], statusfile[25];
FILE *statp, *statusp, *sysstatp;
@@ -51,15 +51,15 @@ void* sctjudge_displaytime(void* arg){
clock_gettime(CLOCK_REALTIME, &timeinit);
-#ifdef HAVE_CONF_PROCMON
+#ifdef HAVE_CONF_PROCMON_LINUX
pthread_mutex_lock(&pidmutex);
pidcopy = pidchild;
pthread_mutex_unlock(&pidmutex);
#endif
-#ifdef HAVE_CONF_PROCMON
- sprintf(statfile, PROC_PATH"/%d/stat", pidcopy);
- sprintf(statusfile, PROC_PATH"/%d/status", pidcopy);
+#ifdef HAVE_CONF_PROCMON_LINUX
+ sprintf(statfile, WITH_LINUXPROC"/%d/stat", pidcopy);
+ sprintf(statusfile, WITH_LINUXPROC"/%d/status", pidcopy);
#endif
do{
@@ -67,7 +67,7 @@ void* sctjudge_displaytime(void* arg){
difftimespec(&timeinit, &timecur, &timepast);
printf("\r%4ld.%03ld 秒", timepast.tv_sec,
timepast.tv_nsec / 1000000);
-#ifdef HAVE_CONF_PROCMON
+#ifdef HAVE_CONF_PROCMON_LINUX
statp = fopen(statfile, "r");
statusp = fopen(statusfile, "r");
sysstatp = fopen(sysstatfile, "r");
@@ -106,7 +106,7 @@ void* sctjudge_displaytime(void* arg){
diffsyscpuall;
res_cpusystem = 1000 * (cpusystem - precpusystem) /
diffsyscpuall;
- printf(" user%%: %2hd.%hd sys%%: %2hd.%hd",
+ printf(" user%%: %2d.%d sys%%: %2d.%d",
res_cpuuser / 10, res_cpuuser % 10,
res_cpusystem / 10, res_cpusystem % 10);
}else{
diff --git a/src/main.c b/src/main.c
index eabf764..3b48b18 100644
--- a/src/main.c
+++ b/src/main.c
@@ -121,10 +121,10 @@ int main(int argc, char* argv[]){
" 指定受測程式可執行檔名稱(務必靜態連結!)\n\n"
" -i/-input <檔案>\n"
" 指定要導向至受測程式標準輸入的檔案,若未指定則為 "
- NULL_DEVICE"\n\n"
+ WITH_NULL"\n\n"
" -o/-output <檔案>\n"
" 指定要導向至受測程式標準輸出的檔案,若未指定則為 "
- NULL_DEVICE"\n\n"
+ WITH_NULL"\n\n"
" -r/-root <目錄>\n"
" 受測程式將以<目錄>為根目錄執行,若無此選項則關"
"閉 chroot 功能\n\n"
@@ -140,7 +140,7 @@ int main(int argc, char* argv[]){
" 將受測程式的標準錯誤也導向至輸出檔。若未指定,"
"則只有標準輸\n"
" 出會寫入輸出檔案,標準錯誤則被導向至 "
- NULL_DEVICE"\n\n"
+ WITH_NULL"\n\n"
" nocopy\n"
" 如果啟用了 chroot 功能,預設情況下本程式會自動"
"將檔案複製\n"
@@ -162,54 +162,7 @@ int main(int argc, char* argv[]){
}else if(!strcmp(&argv[i][1], "V") ||
!strcmp(&argv[i][1], "version") ||
!strcmp(&argv[i][1], "-version")){
- puts(SCTJUDGE_TITLEBAR);
- putchar('\n');
- printf("目前可用(+)和不可用(-)的功能列表:\n"
-#ifdef HAVE_CONF_PROCMON
- " + "
-#else
- " - "
-#endif
- "使用 Linux 的 proc 檔案系統來增強程序監視器的功能 (--"
-#ifdef HAVE_CONF_PROCMON
- "enable"
-#else
- "disable"
-#endif
- "-procmon)\n"
-#ifdef HAVE_CONF_CAP
- " + "
-#else
- " - "
-#endif
- "支援 Linux capabilities (--"
-#ifdef HAVE_CONF_CAP
- "enable"
-#else
- "disable"
-#endif
- "-cap)\n"
-#ifdef HAVE_CONF_UGIDNAME
- " + "
-#else
- " - "
-#endif
- "自動轉換使用者或群組名稱成 UID 或 GID "
- "(自動偵測)\n"
- );
- putchar('\n');
- printf("編譯時指定的參數列表:\n"
-#ifdef NULL_DEVICE
- " * 用於捨棄資料的裝置檔案:"
- NULL_DEVICE
- " (--with-null)\n"
-#endif
-#ifdef PROC_PATH
- " * Linux 的 proc 檔案系統路徑:"
- PROC_PATH
- " (--with-proc)\n"
-#endif
- );
+ fputs(SCTJUDGE_ABOUT_STRING, stdout);
exit(SCTEXIT_SUCCESS);
}else if(!strcmp(&argv[i][1], "v") ||
!strcmp(&argv[i][1], "verbose")){
@@ -366,7 +319,7 @@ int main(int argc, char* argv[]){
exit(SCTEXIT_TOOFEW);
}
if(mcopt.inputfile == NULL){
- mcopt.inputfile = NULL_DEVICE;
+ mcopt.inputfile = WITH_NULL;
}
if(mcopt.outputfile == NULL){
fputs("輸出檔案名稱必要參數,不可為空白\n", stderr);
diff --git a/src/mkchild.c b/src/mkchild.c
index 3f754a7..805105f 100644
--- a/src/mkchild.c
+++ b/src/mkchild.c
@@ -549,7 +549,7 @@ void* sctjudge_makechild(void* arg){
SCTCHILD_WRITE_SUCCMSG(SCTCHILD_DUP2_STDERR);
}
}else{
- fderr = open(NULL_DEVICE, O_RDONLY);
+ fderr = open(WITH_NULL, O_RDONLY);
if(fderr < 0){
SCTCHILD_WRITE_FAILMSG(SCTCHILD_OPEN_STDERR);
exit(1);
diff --git a/src/version.h.in b/src/version.h.in
index ad2713b..7fae827 100644
--- a/src/version.h.in
+++ b/src/version.h.in
@@ -2,3 +2,78 @@
#define SCTJUDGE_VERSION "@PROGRAM_VERSION@"
#define SCTJUDGE_DATE "@PROGRAM_DATE@"
#define SCTJUDGE_TITLEBAR SCTJUDGE_NAME" "SCTJUDGE_VERSION" ("SCTJUDGE_DATE")"
+
+#if (defined(HAVE_CONF_PROCMON_LINUX) || defined(HAVE_CONF_PROCMON_FREEBSD))
+# define HAVE_CONF_PROCMON_SYMBOL " + "
+# define HAVE_CONF_PROCMON_STRING "enable"
+# if defined(HAVE_CONF_PROCMON_LINUX)
+# define HAVE_CONF_PROCMON_METHOD "linux"
+# elif defined(HAVE_CONF_PROCMON_FREEBSD)
+# define HAVE_CONF_PROCMON_METHOD "freebsd"
+# else
+# define HAVE_CONF_PROCMON_METHOD "unknown"
+# endif
+#else
+# define HAVE_CONF_PROCMON_SYMBOL " - "
+# define HAVE_CONF_PROCMON_STRING "disable"
+#endif
+
+#ifdef HAVE_CONF_CAP
+# define HAVE_CONF_CAP_SYMBOL " + "
+# define HAVE_CONF_CAP_STRING "enable"
+#else
+# define HAVE_CONF_CAP_SYMBOL " - "
+# define HAVE_CONF_CAP_STRING "disable"
+#endif
+
+#ifdef HAVE_CONF_UGIDNAME
+# define HAVE_CONF_UGIDNAME_SYMBOL " + "
+# define HAVE_CONF_UGIDNAME_STRING "enable"
+#else
+# define HAVE_CONF_UGIDNAME_SYMBOL " - "
+# define HAVE_CONF_UGIDNAME_STRING "disable"
+#endif
+
+#ifdef WITH_NULL
+# define WITH_NULL_STRING \
+ " * 用於捨棄資料的裝置檔案:" \
+ WITH_NULL \
+ " (--with-null)\n"
+#else
+# define WITH_NULL_STRING ""
+#endif
+
+#ifdef WITH_LINUXPROC
+# define WITH_LINUXPROC_STRING \
+ " * Linux 的 proc 檔案系統路徑:" \
+ WITH_LINUXPROC \
+ " (--with-linuxproc)\n"
+#else
+# define WITH_LINUXPROC_STRING ""
+#endif
+
+#define SCTJUDGE_ABOUT_STRING \
+ SCTJUDGE_TITLEBAR"\n" \
+ "\n" \
+ SCTJUDGE_NAME" 是自由軟體,您可以依據 New BSD License 的規範" \
+ "自由修改與散布這個程式。\n" \
+ "本程式沒有任何擔保,作者也不會對任何正確或" \
+ "錯誤使用本程式造成的損失負責。\n" \
+ "\n" \
+ "目前可用(+)和不可用(-)的功能列表:\n" \
+ HAVE_CONF_PROCMON_SYMBOL \
+ "增強的程序監視器的功能 (--" \
+ HAVE_CONF_PROCMON_STRING \
+ "-procmon=" \
+ HAVE_CONF_PROCMON_METHOD \
+ ")\n" \
+ HAVE_CONF_CAP_SYMBOL \
+ "支援 Linux capabilities (--" \
+ HAVE_CONF_CAP_STRING \
+ "-cap)\n" \
+ HAVE_CONF_UGIDNAME_SYMBOL \
+ "自動轉換使用者或群組名稱成 UID 或 GID (自動偵測)\n" \
+ "\n" \
+ "編譯時指定的參數列表:\n" \
+ WITH_NULL_STRING \
+ WITH_LINUXPROC_STRING