]> git.eshelyaron.com Git - emacs.git/commitdiff
Move native C code into shared library
authorAndrea Corallo <andrea_corallo@yahoo.it>
Fri, 10 May 2019 14:26:18 +0000 (16:26 +0200)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:33:36 +0000 (11:33 +0100)
lib/Makefile.in
src/Makefile.in
src/emacs.c
src/main.c [new file with mode: 0644]

index 06d8e56421bffa8f14c4fb780616658d441bfd08..ed3123885d270d39964829d4d67b0bc569cc5cba 100644 (file)
@@ -26,6 +26,8 @@ abs_top_srcdir = @abs_top_srcdir@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 
+CFLAGS = -fPIC @CFLAGS@
+
 all:
 .PHONY: all
 
@@ -50,7 +52,7 @@ am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
 am__v_at_0 = @
 am__v_at_1 =
 
-ALL_CFLAGS= \
+ALL_CFLAGS= -fPIC \
   $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) $(DEPFLAGS) \
   $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) $(PROFILING_CFLAGS) $(CFLAGS) \
   -I. -I../src -I$(srcdir) -I$(srcdir)/../src \
index ab63b92627224dda558b5b1044a713db43fa69a4..423c5a3f92967ce42823e74a5b1d2d58e58c9f84 100644 (file)
@@ -33,7 +33,7 @@ top_srcdir = @top_srcdir@
 abs_top_srcdir=@abs_top_srcdir@
 VPATH = $(srcdir)
 CC = @CC@
-CFLAGS = @CFLAGS@
+CFLAGS = @CFLAGS@ -fPIC
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@
 EXEEXT = @EXEEXT@
@@ -463,7 +463,7 @@ FIRSTFILE_OBJ=@FIRSTFILE_OBJ@
 ALLOBJS = $(FIRSTFILE_OBJ) $(VMLIMIT_OBJ) $(obj) $(otherobj)
 
 # Must be first, before dep inclusion!
-all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES)
+all: $(pdmp) $(OTHER_FILES)
 .PHONY: all
 
 dmpstruct_headers=$(srcdir)/lisp.h $(srcdir)/buffer.h \
@@ -642,25 +642,33 @@ else
   MAKE_PDUMPER_FINGERPRINT =
 endif
 
-## We have to create $(etc) here because init_cmdargs tests its
-## existence when setting Vinstallation_directory (FIXME?).
-## This goes on to affect various things, and the emacs binary fails
-## to start if Vinstallation_directory has the wrong value.
-temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \
-  $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT)
-       $(AM_V_CCLD)$(CC) -o $@.tmp \
-         $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
-         $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES)
-ifeq ($(HAVE_PDUMPER),yes)
-       $(AM_V_at)$(MAKE_PDUMPER_FINGERPRINT) $@.tmp
-endif
-       $(AM_V_at)mv $@.tmp $@
-       $(MKDIR_P) $(etc)
-ifeq ($(DUMPING),unexec)
-  ifneq ($(PAXCTL_notdumped),)
-       $(PAXCTL_notdumped) $@
-  endif
-endif
+## FIXME: dumper support totally missing here
+libemacs.so: $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \
+  $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT) main.o
+       $(CC) --shared -o $@ $(ALLOBJS) -Wl,-Bstatic $(LIBEGNU_ARCHIVE) -Wl,-Bdynamic $(LIBES)
+
+temacs$(EXEEXT): libemacs.so main.o
+       $(CC) -L. main.o -o $@ $(TEMACS_LDFLAGS) $(LDFLAGS) \
+               $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES) -lemacs -Wl,-rpath -Wl,$(shell pwd)
+
+# ## We have to create $(etc) here because init_cmdargs tests its
+# ## existence when setting Vinstallation_directory (FIXME?).
+# ## This goes on to affect various things, and the emacs binary fails
+# ## to start if Vinstallation_directory has the wrong value.
+# temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \
+#   $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT)
+#      $(AM_V_CCLD)$(CC) -o $@.tmp \
+#        $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
+#        $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES)
+# ifeq ($(HAVE_PDUMPER),yes)
+#      $(AM_V_at)$(MAKE_PDUMPER_FINGERPRINT) $@.tmp
+# endif
+#      $(AM_V_at)mv $@.tmp $@
+#      $(MKDIR_P) $(etc)
+# ifeq ($(DUMPING),unexec)
+#   ifneq ($(PAXCTL_notdumped),)
+#      $(PAXCTL_notdumped) $@
+#   endif
 
 ## The following oldxmenu-related rules are only (possibly) used if
 ## HAVE_X11 && !USE_GTK, but there is no harm in always defining them.
index c5a760d29f642e0f419fcad6b2e766dd22bf2c2d..81703b4660a71e256aace453458c8cad92f64422 100644 (file)
@@ -924,7 +924,7 @@ load_pdump (int argc, char **argv)
 #endif /* HAVE_PDUMPER */
 
 int
-main (int argc, char **argv)
+main1 (int argc, char **argv)
 {
   /* Variable near the bottom of the stack, and aligned appropriately
      for pointers.  */
diff --git a/src/main.c b/src/main.c
new file mode 100644 (file)
index 0000000..41e3553
--- /dev/null
@@ -0,0 +1,26 @@
+/* Trampoline for GNU Emacs.
+   Copyright (C) 2019 Free Software
+   Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
+
+extern int main1 (int argc, char **argv);
+
+int
+main (int argc, char **argv)
+{
+  return main1(argc, argv);
+}