OSDN Git Service

Merge branch 'develop' into macos-develop
[hengbandforosx/hengbandosx.git] / src / system / h-config.h
1 /*!
2  * @file h-config.h
3  * @brief OSごとの差異を吸収してコンパイルするためのプリプロ群
4  * The most basic "include" file.
5  * This file simply includes other low level header files.
6  * @date 2021/08/26
7  * @author Hourier
8  * @details
9  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
10  */
11
12 #pragma once
13
14 // @todo このアドレスもそろそろ変えた方が良い気がする.
15 // そもそもこのご時世にメールによる連絡を試みるか?
16 constexpr auto MAINTAINER = "echizen@users.sourceforge.jp";
17
18 // clang-format off
19
20 #if defined(WIN32) && !defined(WINDOWS)
21 #define WINDOWS
22 #endif
23
24 /*
25  * @details
26  * WindowsはShift-JIS (ひらがなや漢字が全て2バイト/文字)で定義されていることとする.
27  * Unix系はEUC (ひらがなや漢字が全て2バイト/文字)で定義されていることとする.
28  * これらは、このゲームがUTF系の可変長文字列に非対応であるためである.
29  * Unix系は、マルチユーザ対応としてSET_UIDを定義する.
30  * フォントやデフォルトのlibパス等も定義する.
31  * HAVE_CONFIG_Hは、autoconfによりコンパイラスイッチ「-DHAVE_CONFIG_H」が付加される.
32  */
33 #ifdef JP
34 #define iseuckanji(x) (((unsigned char)(x) >= 0xa1 && (unsigned char)(x) <= 0xfe) || (unsigned char)(x) == 0x8e)
35 #endif
36 #undef PATH_SEP
37 #ifdef WINDOWS
38   #define PATH_SEP "\\"
39   #ifdef JP
40     #define iskanji(x) ((0x81 <= (unsigned char)(x) && (unsigned char)(x) <= 0x9f) || (0xe0 <= (unsigned char)(x) && (unsigned char)(x) <= 0xfc))
41     #define iskana(x) (((unsigned char)(x) >= 0xA0) && ((unsigned char)(x) <= 0xDF))
42   #endif
43 #else
44   #define PATH_SEP "/"
45   #define SET_UID
46   #define PRIVATE_USER_PATH "~/.angband"
47   #define SAVEFILE_USE_UID
48   
49   #if !defined(HAVE_CONFIG_H)
50     #define HAVE_USLEEP
51   #endif
52   
53   #define SAFE_SETUID
54   /* Pick up system's definition of _POSIX_SAVED_IDS. */
55   #include <unistd.h>
56   #ifdef _POSIX_SAVED_IDS
57     #define SAFE_SETUID_POSIX
58   #endif
59   
60   #ifndef DEFAULT_LIB_PATH
61     #define DEFAULT_LIB_PATH "./lib/"
62   #endif
63   
64   #ifdef USE_XFT
65     #ifdef JP
66       #define DEFAULT_X11_FONT "monospace-24:lang=ja:spacing=90"
67       #define DEFAULT_X11_FONT_SUB "sans-serif-16:lang=ja"
68     #else
69       #define DEFAULT_X11_FONT "monospace-24:lang=en:spacing=90"
70       #define DEFAULT_X11_FONT_SUB "sans-serif-16:lang=en"
71     #endif
72   #else
73     #ifdef JP
74       #define DEFAULT_X11_FONT "-*-*-medium-r-normal--24-*-*-*-*-*-iso8859-1,-*-*-medium-r-normal--24-*-*-*-*-*-jisx0208.1983-0"
75       #define DEFAULT_X11_FONT_SUB "-*-*-medium-r-normal--16-*-*-*-*-*-iso8859-1,-*-*-medium-r-normal--16-*-*-*-*-*-jisx0208.1983-0"
76     #else
77       #define DEFAULT_X11_FONT "-*-*-medium-r-normal--24-*-*-*-*-*-iso8859-1"
78       #define DEFAULT_X11_FONT_SUB "-*-*-medium-r-normal--16-*-*-*-*-*-iso8859-1"
79     #endif
80   #endif
81   
82   #define DEFAULT_X11_FONT_0 DEFAULT_X11_FONT
83   #define DEFAULT_X11_FONT_1 DEFAULT_X11_FONT_SUB
84   #define DEFAULT_X11_FONT_2 DEFAULT_X11_FONT_SUB
85   #define DEFAULT_X11_FONT_3 DEFAULT_X11_FONT_SUB
86   #define DEFAULT_X11_FONT_4 DEFAULT_X11_FONT_SUB
87   #define DEFAULT_X11_FONT_5 DEFAULT_X11_FONT_SUB
88   #define DEFAULT_X11_FONT_6 DEFAULT_X11_FONT_SUB
89   #define DEFAULT_X11_FONT_7 DEFAULT_X11_FONT_SUB
90   
91   /*
92    * Hack -- Mach-O (native binary format of OS X) is basically a Un*x
93    * but has Mac OS/Windows-like user interface.  Disabling the Un*x-like
94    * behavior (PRIVATE_USER_PATH, SAVEFILE_USE_UID) for the modern Mac OS X
95    * interface (MACH_O_COCOA).
96    */
97   #if defined(MACH_O_CARBON) || defined(MACH_O_COCOA)
98   #ifdef PRIVATE_USER_PATH
99   #undef PRIVATE_USER_PATH
100   #endif
101   #ifdef SAVEFILE_USE_UID
102   #undef SAVEFILE_USE_UID
103   #endif
104   #endif
105
106   #ifdef JP
107     #ifdef EUC
108       #define iskanji(x) (iseuckanji(x))
109       #define iskana(x) (0)
110     #else
111       #error Oops! Please define "EUC" for kanji-code of your system.
112     #endif
113   #endif
114   
115   #ifndef HAVE_CONFIG_H
116     #ifdef JP
117     #define USE_XIM
118     #endif
119   
120     #if defined(USE_XIM)
121     #define USE_LOCALE
122     #endif
123   #endif
124 #endif
125
126 // clang-format on
127
128 #if !defined(__GNUC__)
129 #define __attribute__(x)
130 #endif