MC_LIBS=m2/mc-boot-ch/Glibc.o m2/mc-boot-ch/Gmcrts.o
M2LINK=m2/boot-bin/mklink$(exeext)
-GM2_O=
+GM2_O=-O0
GM2_O_S3=-O
GM2_OS=-Os
GM2_G=-g -fm2-g
m2/gm2-gcc/m2misc.o \
m2/gm2-gcc/init.o
GM2_LIBS = m2/gm2-compiler/gm2.a \
- ../$(target_subdir)/libgm2/libm2pim/.libs/libm2pim.a m2/gm2-libs-boot/choosetemp.o
+ m2/gm2-libs/libgm2.a \
GM2_LIBS_BOOT = m2/gm2-compiler-boot/gm2.a \
m2/gm2-libs-boot/libgm2.a \
BUILD-BOOT-H = m2/boot-bin/mc$(exeext) \
$(BUILD-LIBS-BOOT-H) $(BUILD-COMPILER-BOOT-H) $(TARGET_H) $(PLUGIN_HEADERS)
+BUILD-LIBS = $(BUILD-LIBS-BOOT-H) \
+ $(GM2-LIBS-MODS:%.mod=m2/gm2-libs/%.o) \
+ $(GM2-LIBS-CC:%.cc=m2/gm2-libs/%.o) \
+ $(GM2-LIBS-C:%.c=m2/gm2-libs/%.o)
+
# Core library definition modules used by the modula-2 to C++ translator.
MC-LIB-DEFS = \
$(GM2-AUTO-MODS:%.mod=m2/gm2-compiler/%.o)
$(RANLIB) $@
+m2/gm2-libs/libgm2.a: build-compiler gm2$(exeext) $(BUILD-LIBS)
+ -test -d $(@D) || $(mkinstalldirs) $(@D)
+ $(AR) cr $@ $(GM2-LIBS-MODS:%.mod=m2/gm2-libs/%.o) \
+ $(GM2-LIBS-CC:%.cc=m2/gm2-libs/%.o) \
+ $(GM2-LIBS-C:%.c=m2/gm2-libs/%.o)
+ $(RANLIB) $@
+
+m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+ -test -d $(@D) || $(mkinstalldirs) $(@D)
+ $(GM2_1) -c $(GM2_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $< -o $@
+
+m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs-ch/%.c m2/gm2-libs/gm2-libs-host.h
+ -test -d $(@D) || $(mkinstalldirs) $(@D)
+ $(CXX) -DBUILD_GM2_LIBS -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+
+m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs-ch/%.cc m2/gm2-libs/gm2-libs-host.h
+ -test -d $(@D) || $(mkinstalldirs) $(@D)
+ $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+
+m2/gm2-libs/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h
+ -test -d $(@D) || $(mkinstalldirs) $(@D)
+ $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@
+
m2/gm2-libs-boot/libgm2.a: m2/boot-bin/mc$(exeext) $(BUILD-LIBS-BOOT)
-test -d $(@D) || $(mkinstalldirs) $(@D)
$(AR) cr $@ $(GM2-LIBS-BOOT-MODS:%.mod=m2/gm2-libs-boot/%.o) \
Dup, char, Length, Mult ;
FROM StrLib IMPORT StrLen ;
FROM libc IMPORT printf ;
+FROM SYSTEM IMPORT ADR ;
VAR
VAR
c: String ;
BEGIN
- c := InitStringCharStar (colorize_start (EnableColor, name, StrLen (name))) ;
+ c := InitStringCharStar (colorize_start (EnableColor, ADR (name), StrLen (name))) ;
s := ConCat (s, c) ;
c := KillString (c) ;
RETURN s
ELSE
ModuleType := Program
END ;
- IF (Main=Sym) OR NeedToParseImplementation(Sym)
+ IF (Main=Sym) OR NeedToParseImplementation (Sym)
THEN
- (* only need to read implementation module if hidden types are declared or it is the main module *)
+ (* Only need to read implementation module if hidden types are declared or it is the main module *)
LibName := NIL ;
IF Main=Sym
THEN
THEN
FileName := PreprocessModule (FileName, FALSE) ;
PutLibName (Sym, makekey (string (LibName)))
+ ELSE
+ qprintf1 (' Module %-20s : implementation source file not found\n', SymName)
END
END ;
+
IF FileName#NIL
THEN
IF OpenSource (AssociateModule (Dup (FileName), Sym))
THEN
- IF NOT P0SyntaxCheck.CompilationUnit()
+ IF NOT P0SyntaxCheck.CompilationUnit ()
THEN
WriteFormat0 ('compilation failed') ;
CloseSource ;
ELSE
(* It is quite legitimate to implement a module in C (and pretend it was a M2
implementation) providing that it is not the main program module and the
- definition module do not declare a hidden type when -fextended-opaque
+ definition module does not declare a hidden type when -fextended-opaque
is used. *)
- IF (NOT WholeProgram) OR (Sym=Main) OR IsHiddenTypeDeclared(Sym)
+ IF (NOT WholeProgram) OR (Sym=Main) OR IsHiddenTypeDeclared (Sym)
THEN
(* Unrecoverable error. *)
MetaErrorString1 (Sprintf1 (InitString ('file {%%1EUAF%s} containing module {%%1a} cannot be found'),
#include "config.h"
#include "system.h"
-#include "ansi-decl.h"
+#include <getopt.h>
+// #include "ansi-decl.h"
#ifdef __cplusplus
cgetopt_cgetopt_long (int argc, char *argv[], char *optstring, const struct option *longopts,
int *longindex)
{
- int r = cgetopt_long (argc, argv, optstring, longopts, longindex);
+ int r = getopt_long (argc, argv, optstring, longopts, longindex);
cgetopt_optarg = optarg;
cgetopt_optind = optind;
cgetopt_cgetopt_long_only (int argc, char *argv[], char *optstring,
const struct option *longopts, int *longindex)
{
- int r = cgetopt_long_only (argc, argv, optstring, longopts, longindex);
+ int r = getopt_long_only (argc, argv, optstring, longopts, longindex);
cgetopt_optarg = optarg;
cgetopt_optind = optind;
int need_math = (MATH_LIBRARY[0] != '\0');
/* 1 if we should add -lpthread to the command-line.
- FIXME: the default should be a configuration choice. */
+ FIXME: the default should be a configuration choice. */
int need_pthread = 1;
/* True if we saw -static. */
break;
case OPT_fmod_:
module_extension = xstrdup (arg);
- args[i] |= SKIPOPT; /* We will add the option if it is needed. */
#if defined(DEBUG_ARG)
printf ("seen -fmod=%s\n", module_extension);
#endif
printf ("modula-2 source file detected: %s\n", source_file);
#endif
args[i] |= M2SOURCE;
- // args[i] = 0;
}
}
}