logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

main.mk (2580B)


  1. # SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
  2. # SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
  3. #
  4. # SPDX-License-Identifier: GPL-3.0-or-later
  5. include common.mk
  6. CFLAGS = \
  7. -I. \
  8. -Iinclude \
  9. -Ilib \
  10. -Ilib/sh \
  11. -Ibuiltins \
  12. $(COMMON_CFLAGS)
  13. LDFLAGS = -L. -Lbuiltins -static
  14. LIBRARIES = libsh.a builtins/libbuiltins.a libglob.a libtilde.a
  15. SHLIB_FILES = clktck getcwd getenv oslib setlinebuf strcasecmp strerror strtod \
  16. vprint itos rename zread zwrite shtty inet_aton netopen \
  17. strpbrk timeval clock makepath pathcanon pathphys stringlist stringvec \
  18. tmpfile spell strtrans strindex shquote snprintf mailstat fmtulong \
  19. fmtullong strtoll strtoull strtoimax strtoumax fmtumax netconn mktime \
  20. strftime xstrchr zcatfd
  21. # FIXME: for some reason these don't get picked up correctly in the
  22. # final linking cmd
  23. SHLIB_ODD_FILES = zcatfd strtoumax spell pathphys
  24. SHLIB_OBJS = $(addprefix lib/sh/, $(addsuffix .o, $(SHLIB_FILES)))
  25. SHLIB_ODD_OBJS = $(addprefix lib/sh/, $(addsuffix .o, $(SHLIB_ODD_FILES)))
  26. MKBUILTINS_OBJS = builtins/mkbuiltins.o
  27. BUILTINS_DEFS = $(addprefix builtins/, $(addsuffix .def, $(BUILTINS_DEF_FILES)))
  28. GLOB_FILES = glob strmatch smatch xmbsrtowcs
  29. GLOB_OBJS = $(addprefix lib/glob/, $(addsuffix .o, $(GLOB_FILES)))
  30. TILDE_OBJS = lib/tilde/tilde.o
  31. MKSYNTAX_OBJS = mksyntax.o
  32. MKSIGNAMES_OBJS = support/mksignames.o
  33. FILES = shell eval y.tab general make_cmd print_cmd dispose_cmd execute_cmd \
  34. variables copy_cmd error expr flags nojobs subst hashcmd hashlib mailcheck \
  35. trap input unwind_prot pathexp sig test version alias array arrayfunc \
  36. braces bracecomp bashhist bashline list stringlib locale findcmd redir \
  37. pcomplete pcomplib syntax xmalloc siglist
  38. OBJS = $(addsuffix .o, $(FILES))
  39. all: bash
  40. # Builtins
  41. mkbuiltins: $(MKBUILTINS_OBJS)
  42. $(CC) $(CFLAGS) $(MKBUILTINS_OBJS) $(LDFLAGS) -o $@
  43. ./mkbuiltins -externfile builtins/builtext.h -structfile builtins/builtins.c -noproduction $(BUILTINS_DEFS)
  44. # libsh
  45. libsh.a: $(SHLIB_OBJS)
  46. $(AR) cr $@ $^
  47. # libglob
  48. libglob.a: $(GLOB_OBJS)
  49. $(AR) cr $@ $^
  50. # libtilde
  51. libtilde.a: $(TILDE_OBJS)
  52. $(AR) cr $@ $^
  53. # The actual program
  54. mksyntax: $(MKSYNTAX_OBJS)
  55. $(CC) $^ $(LDFLAGS) -o $@ -lgetopt
  56. syntax.c: mksyntax
  57. ./mksyntax -o $@
  58. mksignames: $(MKSIGNAMES_OBJS)
  59. $(CC) $^ $(LDFLAGS) -o $@ -lgetopt
  60. signames.h: mksignames
  61. ./mksignames $@
  62. y.tab.c: parse.y
  63. yacc -d $^
  64. trap.c: signames.h
  65. bash: libsh.a libglob.a libtilde.a $(OBJS)
  66. $(CC) -o bash $(LIBRARIES) $(OBJS) $(SHLIB_ODD_OBJS) $(LDFLAGS) -lsh -lbuiltins -lglob -ltilde