summaryrefslogtreecommitdiff
blob: fd485bd0f07e3ca4024adbf19a6f278dee333201 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
% cm3 config file

readonly TARGET       = "GENTOO_TARGET"
if M3_PROFILING
  readonly BUILD_DIR  = TARGET & "p"
else
  readonly BUILD_DIR  = TARGET
end
readonly OS_TYPE      = "POSIX"
readonly WORD_SIZE    = "32BITS"
readonly GNU_PLATFORM = "GENTOO_GNU_PLATFORM"

readonly NAMING_CONVENTIONS = "0"

proc set_config_options () is
  m3_option ("-why")
  m3_debug (TRUE)
  M3_OPTIONS += "-w1"
end

INITIAL_REACTOR_EDITOR = "GENTOO_INITIAL_REACTOR_EDITOR"

ROOT="GENTOO_ROOT"

INSTALL_ROOT = "GENTOO_INSTALL_ROOT"

BIN_INSTALL     = INSTALL_ROOT & "/bin"
if M3_PROFILING
  LIB_INSTALL   = INSTALL_ROOT & "/libp"
else
  LIB_INSTALL   = INSTALL_ROOT & "/lib"
end
PKG_INSTALL   = INSTALL_ROOT & "/pkg"
DOC_INSTALL   = INSTALL_ROOT & "/doc"
EMACS_INSTALL = INSTALL_ROOT & "/elisp"
MAN_INSTALL   = INSTALL_ROOT & "/man"
HTML_INSTALL  = INSTALL_ROOT & "/www"

USE_ROOT  = INSTALL_ROOT
BIN_USE   = BIN_INSTALL
LIB_USE   = LIB_INSTALL
PKG_USE   = PKG_INSTALL

readonly INSTALL_IMPLS = TRUE

SYSTEM_LIBS = {
  "LIBC"       : [ "-lm" ],
  "FLEX-BISON" : [ "-lfl" ],
  "OPENGL"     : [ "-lGLU", "-lGL", "-lXext" ],
  "MOTIF"      : [ "-lXm" ],
  "X11"        : [ "-lXaw", "-lXmu", "-lXext", "-lXt", "-lSM", "-lICE", "-lX11" ],
%  "POSTGRES95" : [ ]
%  "ODBC"       : [ ]
  "TCP"        : [ ]
}

SYSTEM_LIBORDER = [ "OPENGL", "DECPEX", "MOTIF", "X11", "TCP", "ODBC",
                    "POSTGRES95", "FLEX-BISON", "LEX-YACC", "LIBC" ]

readonly SYSTEM_CC  = "gcc"
readonly SYSTEM_AR  = "ar"
readonly SYSTEM_ASM = "as"

readonly m3back = "@" & BIN_USE & "/cm3cg"

proc m3_backend (source, object, optimize, debug) is
  local args = [ "-quiet", source, "-o", object ]
  if optimize  args += "-O"  end
  if debug     args += "-g"  end
  if M3_PROFILING args += "-p" end
  return try_exec (m3back, args)
end

M3_BACKEND_MODE = "3"

proc compile_c (source, object, options, optimize, debug) is
  local args = [ "-fPIC", options ]
  if optimize  args += "-O"  end
  if debug     args += "-g"  end
  if M3_PROFILING args += "-pg" end
  return try_exec ("@" & SYSTEM_CC, args, "-c", source)
end

proc assemble (source, object) is
  return try_exec ("@" & SYSTEM_ASM, source, "-o", object)
end

GCWRAPFLAGS = "-Wl,--wrap,adjtime,--wrap,getdirentries,--wrap,readv,--wrap,utimes,--wrap,wait3"

proc make_lib (lib, options, objects, imported_libs, shared) is
  local ret_code = 0
  local lib_a    = format ("lib%s.a", lib)
  local lib_so   = format ("lib%s.so", lib)
  local lib_sox  = format ("lib%s.so.5", lib)

  % first, build the non-shared library
  ret_code = try_exec ("@/usr/bin/ar", "crus", lib_a, objects)
  if not equal (ret_code, 0) return ret_code end

  if shared
    % build the shared library
    if M3_PROFILING 
      ret_code = try_exec ("@" & SYSTEM_CC, "-pg -shared " & GCWRAPFLAGS & 
                           "-Wl,-soname," & lib_sox,
                           "-o", lib_sox, objects)
    else
      ret_code = try_exec ("@" & SYSTEM_CC, "-shared " & GCWRAPFLAGS & 
                           "-Wl,-soname," & lib_sox,
                           "-o", lib_sox, objects)
    end
    if not equal (ret_code, 0) return ret_code end

    % create the version aliases
    link_file(lib_sox, lib_so)

    % finally, make sure the shared library stuff gets installed properly
    install_derived (lib_sox)
    install_derived_link (lib_sox, lib_so)
    install_link_to_derived (lib_sox, LIB_INSTALL)
    install_link_to_derived (lib_so, LIB_INSTALL)
  else
    delete_file (lib_so)
    delete_file (lib_sox)
  end

  return 0
end

proc skip_lib (lib, shared) is
  local lib_so   = format ("lib%s.so", lib)
  local lib_sox  = format ("lib%s.so.5", lib)

  if shared
    % make sure the shared library stuff gets installed properly
    install_derived (lib_sox)
    install_derived (lib_so)
    install_link_to_derived (lib_sox, LIB_INSTALL)
    install_link_to_derived (lib_so, LIB_INSTALL)
  else
    delete_file (lib_so)
    delete_file (lib_sox)
  end

  return 0
end

proc m3_link (prog, options, objects, imported_libs, shared) is
  local args = []
  if M3_PROFILING args += "-pg" end
  args += [ "-o", prog, options, objects, imported_libs ]
  if shared
    return try_exec ("@" & SYSTEM_CC, args, GCWRAPFLAGS)
  else
    return try_exec ("@" & SYSTEM_CC, "-static", args, GCWRAPFLAGS)
    %%% -- see M3_NEED_STANDALONE_LINKS  below
    %%%return try_exec ("@" & SYSTEM_CC, args)
  end
end

proc skip_link (prog, shared) is
  return 0
end

M3_FRONT_FLAGS = [ ]
M3_OPTIONS = [ ]
% M3_KEEP_FILES = TRUE
M3_WINDOWS_GUI = FALSE
% M3_COVERAGE = TRUE
M3_COVERAGE_LIB = LIB_USE & "/report_coverage.o"
M3_SPLIT_LIBNAMES = TRUE
M3_SHARED_LIB_ARG = "-Wl,-R"
% M3_BOOTSTRAP = TRUE
% M3_COMPILE_ONCE = TRUE
% SYS_HAS_LOADER = TRUE
% M3_SKIP_LINK = TRUE
% M3_MAIN_IN_C = TRUE
% X11_WITH_SHARED_MEM = TRUE
%M3_NEED_STANDALONE_LINKS = TRUE

GNU_CC     = "GENTOO_GNU_CC"
GNU_CFLAGS = "GENTOO_GNU_CFLAGS"
GNU_MAKE   = "GENTOO_GNU_MAKE"