01-Makefile.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. 01-Makefile.patch, changes:
  2. * on x86_64 systems, install libraries in /usr/lib64
  3. * added shared library target
  4. * added CFLAGS_EXTRA to pass $SLKCFLAGS (can be improved)
  5. * avoid building examples
  6. * disabled debug information
  7. --- quickjs-2021-03-27/Makefile 2021-03-27 07:00:32.000000000 -0300
  8. +++ quickjs-2021-03-27-modified/Makefile 2022-08-02 21:52:01.476250120 -0300
  9. @@ -36,12 +36,14 @@
  10. ifdef CONFIG_DARWIN
  11. # use clang instead of gcc
  12. -CONFIG_CLANG=y
  13. +#CONFIG_CLANG=y
  14. CONFIG_DEFAULT_AR=y
  15. endif
  16. # installation directory
  17. prefix=/usr/local
  18. +libdir=$(prefix)/lib
  19. +CFLAGS_EXTRA=
  20. # use the gprof profiler
  21. #CONFIG_PROFILE=y
  22. @@ -66,7 +68,7 @@
  23. ifdef CONFIG_CLANG
  24. HOST_CC=clang
  25. CC=$(CROSS_PREFIX)clang
  26. - CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
  27. + CFLAGS= -Wall -MMD -MF $(OBJDIR)/$(@F).d
  28. CFLAGS += -Wextra
  29. CFLAGS += -Wno-sign-compare
  30. CFLAGS += -Wno-missing-field-initializers
  31. @@ -87,7 +89,7 @@
  32. else
  33. HOST_CC=gcc
  34. CC=$(CROSS_PREFIX)gcc
  35. - CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
  36. + CFLAGS= -Wall -MMD -MF $(OBJDIR)/$(@F).d
  37. CFLAGS += -Wno-array-bounds -Wno-format-truncation
  38. ifdef CONFIG_LTO
  39. AR=$(CROSS_PREFIX)gcc-ar
  40. @@ -107,12 +109,15 @@
  41. DEFINES+=-D__USE_MINGW_ANSI_STDIO # for standard snprintf behavior
  42. endif
  43. +DEFINES += -DCONFIG_LIBDIR=\"$(libdir)\"
  44. +
  45. +CFLAGS+=$(CFLAGS_EXTRA)
  46. CFLAGS+=$(DEFINES)
  47. CFLAGS_DEBUG=$(CFLAGS) -O0
  48. CFLAGS_SMALL=$(CFLAGS) -Os
  49. CFLAGS_OPT=$(CFLAGS) -O2
  50. CFLAGS_NOLTO:=$(CFLAGS_OPT)
  51. -LDFLAGS=-g
  52. +#LDFLAGS=-g
  53. ifdef CONFIG_LTO
  54. CFLAGS_SMALL+=-flto
  55. CFLAGS_OPT+=-flto
  56. @@ -157,14 +162,14 @@
  57. ifdef CONFIG_ASAN
  58. PROGS+=
  59. else
  60. -PROGS+=examples/hello examples/hello_module examples/test_fib
  61. +#PROGS+=examples/hello examples/hello_module examples/test_fib
  62. ifndef CONFIG_DARWIN
  63. -PROGS+=examples/fib.so examples/point.so
  64. +#PROGS+=examples/fib.so examples/point.so
  65. endif
  66. endif
  67. endif
  68. -all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS)
  69. +all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS) libquickjs.so
  70. QJS_LIB_OBJS=$(OBJDIR)/quickjs.o $(OBJDIR)/libregexp.o $(OBJDIR)/libunicode.o $(OBJDIR)/cutils.o $(OBJDIR)/quickjs-libc.o
  71. @@ -187,6 +192,9 @@
  72. qjs$(EXE): $(QJS_OBJS)
  73. $(CC) $(LDFLAGS) $(LDEXPORT) -o $@ $^ $(LIBS)
  74. +libquickjs.so: $(QJS_LIB_OBJS)
  75. + $(CC) -shared $(LDFLAGS) -fPIC $(LDEXPORT) -o $@ $^ $(LIBS)
  76. +
  77. qjs-debug$(EXE): $(patsubst %.o, %.debug.o, $(QJS_OBJS))
  78. $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
  79. @@ -299,13 +307,15 @@
  80. install: all
  81. mkdir -p "$(DESTDIR)$(prefix)/bin"
  82. - $(STRIP) qjs qjsc
  83. + $(STRIP) qjs qjsc libquickjs.so
  84. install -m755 qjs qjsc "$(DESTDIR)$(prefix)/bin"
  85. ln -sf qjs "$(DESTDIR)$(prefix)/bin/qjscalc"
  86. - mkdir -p "$(DESTDIR)$(prefix)/lib/quickjs"
  87. - install -m644 libquickjs.a "$(DESTDIR)$(prefix)/lib/quickjs"
  88. + mkdir -p "$(DESTDIR)/$(libdir)/quickjs"
  89. + install -m644 libquickjs.a "$(DESTDIR)/$(libdir)/quickjs"
  90. + install -m644 libquickjs.so "$(DESTDIR)/$(libdir)/quickjs"
  91. + ln -s quickjs/libquickjs.so "$(DESTDIR)/$(libdir)/libquickjs.so"
  92. ifdef CONFIG_LTO
  93. - install -m644 libquickjs.lto.a "$(DESTDIR)$(prefix)/lib/quickjs"
  94. + install -m644 libquickjs.lto.a "$(DESTDIR)/$(libdir)/quickjs"
  95. endif
  96. mkdir -p "$(DESTDIR)$(prefix)/include/quickjs"
  97. install -m644 quickjs.h quickjs-libc.h "$(DESTDIR)$(prefix)/include/quickjs"