Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 1 | # |
| 2 | # Makefile for musl (requires GNU make) |
| 3 | # |
| 4 | # This is how simple every makefile should be... |
| 5 | # No, I take that back - actually most should be less than half this size. |
| 6 | # |
| 7 | # Use config.mak to override any of the following variables. |
| 8 | # Do not make changes here. |
| 9 | # |
| 10 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 11 | srcdir = . |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 12 | exec_prefix = /usr/local |
| 13 | bindir = $(exec_prefix)/bin |
| 14 | |
| 15 | prefix = /usr/local/musl |
| 16 | includedir = $(prefix)/include |
| 17 | libdir = $(prefix)/lib |
Rich Felker | 207c45d | 2011-06-27 21:38:11 -0400 | [diff] [blame] | 18 | syslibdir = /lib |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 19 | |
Rich Felker | 63bcda4 | 2016-02-17 13:56:27 -0500 | [diff] [blame] | 20 | SRC_DIRS = $(addprefix $(srcdir)/,src/* crt ldso) |
| 21 | BASE_GLOBS = $(addsuffix /*.c,$(SRC_DIRS)) |
| 22 | ARCH_GLOBS = $(addsuffix /$(ARCH)/*.[csS],$(SRC_DIRS)) |
| 23 | BASE_SRCS = $(sort $(wildcard $(BASE_GLOBS))) |
| 24 | ARCH_SRCS = $(sort $(wildcard $(ARCH_GLOBS))) |
Rich Felker | 9f5eb77 | 2016-01-19 18:19:01 -0500 | [diff] [blame] | 25 | BASE_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(BASE_SRCS))) |
Rich Felker | 9f5eb77 | 2016-01-19 18:19:01 -0500 | [diff] [blame] | 26 | ARCH_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(ARCH_SRCS))) |
Rich Felker | 0f814a4 | 2016-01-20 02:49:32 +0000 | [diff] [blame] | 27 | REPLACED_OBJS = $(sort $(subst /$(ARCH)/,/,$(ARCH_OBJS))) |
Rich Felker | 63bcda4 | 2016-02-17 13:56:27 -0500 | [diff] [blame] | 28 | ALL_OBJS = $(addprefix obj/, $(filter-out $(REPLACED_OBJS), $(sort $(BASE_OBJS) $(ARCH_OBJS)))) |
| 29 | |
| 30 | LIBC_OBJS = $(filter obj/src/%,$(ALL_OBJS)) |
| 31 | LDSO_OBJS = $(filter obj/ldso/%,$(ALL_OBJS:%.o=%.lo)) |
| 32 | CRT_OBJS = $(filter obj/crt/%,$(ALL_OBJS)) |
| 33 | |
| 34 | AOBJS = $(LIBC_OBJS) |
| 35 | LOBJS = $(LIBC_OBJS:.o=.lo) |
Bobby Bingham | 63e3a16 | 2016-05-12 00:34:05 -0500 | [diff] [blame] | 36 | GENH = obj/include/bits/alltypes.h obj/include/bits/syscall.h |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 37 | GENH_INT = obj/src/internal/version.h |
Rich Felker | e6917ec | 2017-03-21 12:13:59 -0400 | [diff] [blame] | 38 | IMPH = $(addprefix $(srcdir)/, src/internal/stdio_impl.h src/internal/pthread_impl.h src/internal/locale_impl.h src/internal/libc.h) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 39 | |
Rich Felker | 4cd8b47 | 2015-11-02 16:58:14 -0500 | [diff] [blame] | 40 | LDFLAGS = |
| 41 | LDFLAGS_AUTO = |
Rich Felker | 1b23145 | 2012-08-02 21:05:43 -0400 | [diff] [blame] | 42 | LIBCC = -lgcc |
Rich Felker | d76eafc | 2012-05-01 19:30:03 -0400 | [diff] [blame] | 43 | CPPFLAGS = |
Rich Felker | 4cd8b47 | 2015-11-02 16:58:14 -0500 | [diff] [blame] | 44 | CFLAGS = |
| 45 | CFLAGS_AUTO = -Os -pipe |
Rich Felker | d76eafc | 2012-05-01 19:30:03 -0400 | [diff] [blame] | 46 | CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc |
| 47 | |
| 48 | CFLAGS_ALL = $(CFLAGS_C99FSE) |
Rich Felker | efdf04c | 2016-01-27 19:31:15 -0500 | [diff] [blame] | 49 | CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include |
Rich Felker | 4cd8b47 | 2015-11-02 16:58:14 -0500 | [diff] [blame] | 50 | CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS) |
Rich Felker | d76eafc | 2012-05-01 19:30:03 -0400 | [diff] [blame] | 51 | |
Rich Felker | 4cd8b47 | 2015-11-02 16:58:14 -0500 | [diff] [blame] | 52 | LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS) |
| 53 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 54 | AR = $(CROSS_COMPILE)ar |
| 55 | RANLIB = $(CROSS_COMPILE)ranlib |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 56 | INSTALL = $(srcdir)/tools/install.sh |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 57 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 58 | ARCH_INCLUDES = $(wildcard $(srcdir)/arch/$(ARCH)/bits/*.h) |
Rich Felker | efdf04c | 2016-01-27 19:31:15 -0500 | [diff] [blame] | 59 | GENERIC_INCLUDES = $(wildcard $(srcdir)/arch/generic/bits/*.h) |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 60 | INCLUDES = $(wildcard $(srcdir)/include/*.h $(srcdir)/include/*/*.h) |
Rich Felker | efdf04c | 2016-01-27 19:31:15 -0500 | [diff] [blame] | 61 | ALL_INCLUDES = $(sort $(INCLUDES:$(srcdir)/%=%) $(GENH:obj/%=%) $(ARCH_INCLUDES:$(srcdir)/arch/$(ARCH)/%=include/%) $(GENERIC_INCLUDES:$(srcdir)/arch/generic/%=include/%)) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 62 | |
Rich Felker | 41d5183 | 2011-02-24 16:37:21 -0500 | [diff] [blame] | 63 | EMPTY_LIB_NAMES = m rt pthread crypt util xnet resolv dl |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 64 | EMPTY_LIBS = $(EMPTY_LIB_NAMES:%=lib/lib%.a) |
Rich Felker | 8b084f0 | 2016-02-19 14:16:33 -0500 | [diff] [blame] | 65 | CRT_LIBS = $(addprefix lib/,$(notdir $(CRT_OBJS))) |
Rich Felker | d76eafc | 2012-05-01 19:30:03 -0400 | [diff] [blame] | 66 | STATIC_LIBS = lib/libc.a |
Rich Felker | 207c45d | 2011-06-27 21:38:11 -0400 | [diff] [blame] | 67 | SHARED_LIBS = lib/libc.so |
Rich Felker | 58f430c | 2012-04-22 14:32:49 -0400 | [diff] [blame] | 68 | TOOL_LIBS = lib/musl-gcc.specs |
Rich Felker | d76eafc | 2012-05-01 19:30:03 -0400 | [diff] [blame] | 69 | ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS) |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 70 | ALL_TOOLS = obj/musl-gcc |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 71 | |
Shiz | b3cd7d1 | 2015-06-28 23:08:19 +0200 | [diff] [blame] | 72 | WRAPCC_GCC = gcc |
Shiz | fb58545 | 2015-06-28 23:08:21 +0200 | [diff] [blame] | 73 | WRAPCC_CLANG = clang |
Shiz | b3cd7d1 | 2015-06-28 23:08:19 +0200 | [diff] [blame] | 74 | |
Rich Felker | 3e7f186 | 2013-07-18 20:30:58 -0400 | [diff] [blame] | 75 | LDSO_PATHNAME = $(syslibdir)/ld-musl-$(ARCH)$(SUBARCH).so.1 |
Rich Felker | 207c45d | 2011-06-27 21:38:11 -0400 | [diff] [blame] | 76 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 77 | -include config.mak |
| 78 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 79 | ifeq ($(ARCH),) |
Rich Felker | 157e284 | 2016-02-17 16:11:45 -0500 | [diff] [blame] | 80 | |
| 81 | all: |
| 82 | @echo "Please set ARCH in config.mak before running make." |
| 83 | @exit 1 |
| 84 | |
| 85 | else |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 86 | |
Rich Felker | 8d54681 | 2011-06-28 08:27:38 -0400 | [diff] [blame] | 87 | all: $(ALL_LIBS) $(ALL_TOOLS) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 88 | |
Rich Felker | 63bcda4 | 2016-02-17 13:56:27 -0500 | [diff] [blame] | 89 | OBJ_DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(GENH) $(GENH_INT))) obj/include) |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 90 | |
Rich Felker | 63bcda4 | 2016-02-17 13:56:27 -0500 | [diff] [blame] | 91 | $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(ALL_OBJS:%.o=%.lo) $(GENH) $(GENH_INT): | $(OBJ_DIRS) |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 92 | |
| 93 | $(OBJ_DIRS): |
| 94 | mkdir -p $@ |
| 95 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 96 | obj/include/bits/alltypes.h: $(srcdir)/arch/$(ARCH)/bits/alltypes.h.in $(srcdir)/include/alltypes.h.in $(srcdir)/tools/mkalltypes.sed |
| 97 | sed -f $(srcdir)/tools/mkalltypes.sed $(srcdir)/arch/$(ARCH)/bits/alltypes.h.in $(srcdir)/include/alltypes.h.in > $@ |
Rich Felker | 1355fdc | 2011-02-15 00:33:23 -0500 | [diff] [blame] | 98 | |
Bobby Bingham | 63e3a16 | 2016-05-12 00:34:05 -0500 | [diff] [blame] | 99 | obj/include/bits/syscall.h: $(srcdir)/arch/$(ARCH)/bits/syscall.h.in |
| 100 | cp $< $@ |
| 101 | sed -n -e s/__NR_/SYS_/p < $< >> $@ |
| 102 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 103 | obj/src/internal/version.h: $(wildcard $(srcdir)/VERSION $(srcdir)/.git) |
| 104 | printf '#define VERSION "%s"\n' "$$(cd $(srcdir); sh tools/version.sh)" > $@ |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 105 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 106 | obj/src/internal/version.o obj/src/internal/version.lo: obj/src/internal/version.h |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 107 | |
Rich Felker | 5552ce5 | 2016-01-25 19:29:55 -0500 | [diff] [blame] | 108 | obj/crt/rcrt1.o obj/ldso/dlstart.lo obj/ldso/dynlink.lo: $(srcdir)/src/internal/dynlink.h $(srcdir)/arch/$(ARCH)/reloc.h |
Rich Felker | 179ab5a | 2013-12-01 17:27:25 -0500 | [diff] [blame] | 109 | |
Rich Felker | 5552ce5 | 2016-01-25 19:29:55 -0500 | [diff] [blame] | 110 | obj/crt/crt1.o obj/crt/scrt1.o obj/crt/rcrt1.o obj/ldso/dlstart.lo: $(srcdir)/arch/$(ARCH)/crt_arch.h |
Rich Felker | 179ab5a | 2013-12-01 17:27:25 -0500 | [diff] [blame] | 111 | |
Rich Felker | 5552ce5 | 2016-01-25 19:29:55 -0500 | [diff] [blame] | 112 | obj/crt/rcrt1.o: $(srcdir)/ldso/dlstart.c |
Rich Felker | d043780 | 2012-08-05 12:32:20 -0400 | [diff] [blame] | 113 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 114 | obj/crt/Scrt1.o obj/crt/rcrt1.o: CFLAGS_ALL += -fPIC |
Rich Felker | 585ba14 | 2015-06-03 02:00:44 -0400 | [diff] [blame] | 115 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 116 | obj/crt/$(ARCH)/crti.o: $(srcdir)/crt/$(ARCH)/crti.s |
Rich Felker | c5e34da | 2013-07-26 01:49:14 -0400 | [diff] [blame] | 117 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 118 | obj/crt/$(ARCH)/crtn.o: $(srcdir)/crt/$(ARCH)/crtn.s |
Rich Felker | c5e34da | 2013-07-26 01:49:14 -0400 | [diff] [blame] | 119 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 120 | OPTIMIZE_SRCS = $(wildcard $(OPTIMIZE_GLOBS:%=$(srcdir)/src/%)) |
| 121 | $(OPTIMIZE_SRCS:$(srcdir)/%.c=obj/%.o) $(OPTIMIZE_SRCS:$(srcdir)/%.c=obj/%.lo): CFLAGS += -O3 |
Rich Felker | a80847d | 2013-07-22 21:22:04 -0400 | [diff] [blame] | 122 | |
Rich Felker | 4a1f55e | 2013-08-01 17:12:23 -0400 | [diff] [blame] | 123 | MEMOPS_SRCS = src/string/memcpy.c src/string/memmove.c src/string/memcmp.c src/string/memset.c |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 124 | $(MEMOPS_SRCS:%.c=obj/%.o) $(MEMOPS_SRCS:%.c=obj/%.lo): CFLAGS_ALL += $(CFLAGS_MEMOPS) |
Rich Felker | 4a1f55e | 2013-08-01 17:12:23 -0400 | [diff] [blame] | 125 | |
Rich Felker | 1ef849c | 2015-04-13 20:13:10 -0400 | [diff] [blame] | 126 | NOSSP_SRCS = $(wildcard crt/*.c) \ |
| 127 | src/env/__libc_start_main.c src/env/__init_tls.c \ |
Rich Felker | f9b8df4 | 2016-01-25 20:06:31 -0500 | [diff] [blame] | 128 | src/env/__stack_chk_fail.c \ |
| 129 | src/thread/__set_thread_area.c src/thread/$(ARCH)/__set_thread_area.c \ |
| 130 | src/string/memset.c src/string/$(ARCH)/memset.c \ |
| 131 | src/string/memcpy.c src/string/$(ARCH)/memcpy.c \ |
Rich Felker | 5552ce5 | 2016-01-25 19:29:55 -0500 | [diff] [blame] | 132 | ldso/dlstart.c ldso/dynlink.c |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 133 | $(NOSSP_SRCS:%.c=obj/%.o) $(NOSSP_SRCS:%.c=obj/%.lo): CFLAGS_ALL += $(CFLAGS_NOSSP) |
Rich Felker | 1ef849c | 2015-04-13 20:13:10 -0400 | [diff] [blame] | 134 | |
Rich Felker | 63bcda4 | 2016-02-17 13:56:27 -0500 | [diff] [blame] | 135 | $(CRT_OBJS): CFLAGS_ALL += -DCRT |
Rich Felker | de2b67f | 2015-04-19 22:05:29 -0400 | [diff] [blame] | 136 | |
Rich Felker | 5552ce5 | 2016-01-25 19:29:55 -0500 | [diff] [blame] | 137 | $(LOBJS) $(LDSO_OBJS): CFLAGS_ALL += -fPIC |
Rich Felker | 9514e70 | 2016-01-19 19:08:52 -0500 | [diff] [blame] | 138 | |
Rich Felker | ada4798 | 2016-01-20 02:58:29 +0000 | [diff] [blame] | 139 | CC_CMD = $(CC) $(CFLAGS_ALL) -c -o $@ $< |
| 140 | |
Alex Dowad | 35b3312 | 2015-07-10 15:03:24 +0200 | [diff] [blame] | 141 | # Choose invocation of assembler to be used |
Alex Dowad | 35b3312 | 2015-07-10 15:03:24 +0200 | [diff] [blame] | 142 | ifeq ($(ADD_CFI),yes) |
Rich Felker | 9514e70 | 2016-01-19 19:08:52 -0500 | [diff] [blame] | 143 | AS_CMD = LC_ALL=C awk -f $(srcdir)/tools/add-cfi.common.awk -f $(srcdir)/tools/add-cfi.$(ARCH).awk $< | $(CC) $(CFLAGS_ALL) -x assembler -c -o $@ - |
Alex Dowad | 35b3312 | 2015-07-10 15:03:24 +0200 | [diff] [blame] | 144 | else |
Rich Felker | ada4798 | 2016-01-20 02:58:29 +0000 | [diff] [blame] | 145 | AS_CMD = $(CC_CMD) |
Alex Dowad | 35b3312 | 2015-07-10 15:03:24 +0200 | [diff] [blame] | 146 | endif |
| 147 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 148 | obj/%.o: $(srcdir)/%.s |
Rich Felker | ada4798 | 2016-01-20 02:58:29 +0000 | [diff] [blame] | 149 | $(AS_CMD) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 150 | |
Rich Felker | 9f5eb77 | 2016-01-19 18:19:01 -0500 | [diff] [blame] | 151 | obj/%.o: $(srcdir)/%.S |
Rich Felker | ada4798 | 2016-01-20 02:58:29 +0000 | [diff] [blame] | 152 | $(CC_CMD) |
Rich Felker | 9f5eb77 | 2016-01-19 18:19:01 -0500 | [diff] [blame] | 153 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 154 | obj/%.o: $(srcdir)/%.c $(GENH) $(IMPH) |
Rich Felker | ada4798 | 2016-01-20 02:58:29 +0000 | [diff] [blame] | 155 | $(CC_CMD) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 156 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 157 | obj/%.lo: $(srcdir)/%.s |
Rich Felker | ada4798 | 2016-01-20 02:58:29 +0000 | [diff] [blame] | 158 | $(AS_CMD) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 159 | |
Rich Felker | 9f5eb77 | 2016-01-19 18:19:01 -0500 | [diff] [blame] | 160 | obj/%.lo: $(srcdir)/%.S |
Rich Felker | ada4798 | 2016-01-20 02:58:29 +0000 | [diff] [blame] | 161 | $(CC_CMD) |
Rich Felker | 9f5eb77 | 2016-01-19 18:19:01 -0500 | [diff] [blame] | 162 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 163 | obj/%.lo: $(srcdir)/%.c $(GENH) $(IMPH) |
Rich Felker | ada4798 | 2016-01-20 02:58:29 +0000 | [diff] [blame] | 164 | $(CC_CMD) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 165 | |
Rich Felker | 5552ce5 | 2016-01-25 19:29:55 -0500 | [diff] [blame] | 166 | lib/libc.so: $(LOBJS) $(LDSO_OBJS) |
Rich Felker | 9514e70 | 2016-01-19 19:08:52 -0500 | [diff] [blame] | 167 | $(CC) $(CFLAGS_ALL) $(LDFLAGS_ALL) -nostdlib -shared \ |
Rich Felker | 65498f2 | 2016-01-31 00:40:33 -0500 | [diff] [blame] | 168 | -Wl,-e,_dlstart -o $@ $(LOBJS) $(LDSO_OBJS) $(LIBCC) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 169 | |
Rich Felker | 1619127 | 2016-01-25 19:57:38 -0500 | [diff] [blame] | 170 | lib/libc.a: $(AOBJS) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 171 | rm -f $@ |
Rich Felker | 1619127 | 2016-01-25 19:57:38 -0500 | [diff] [blame] | 172 | $(AR) rc $@ $(AOBJS) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 173 | $(RANLIB) $@ |
| 174 | |
Rich Felker | 4fd1595 | 2011-02-17 17:12:52 -0500 | [diff] [blame] | 175 | $(EMPTY_LIBS): |
| 176 | rm -f $@ |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 177 | $(AR) rc $@ |
| 178 | |
Rich Felker | 63bcda4 | 2016-02-17 13:56:27 -0500 | [diff] [blame] | 179 | lib/%.o: obj/crt/$(ARCH)/%.o |
| 180 | cp $< $@ |
| 181 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 182 | lib/%.o: obj/crt/%.o |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 183 | cp $< $@ |
| 184 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 185 | lib/musl-gcc.specs: $(srcdir)/tools/musl-gcc.specs.sh config.mak |
Rich Felker | 58f430c | 2012-04-22 14:32:49 -0400 | [diff] [blame] | 186 | sh $< "$(includedir)" "$(libdir)" "$(LDSO_PATHNAME)" > $@ |
| 187 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 188 | obj/musl-gcc: config.mak |
Shiz | b3cd7d1 | 2015-06-28 23:08:19 +0200 | [diff] [blame] | 189 | printf '#!/bin/sh\nexec "$${REALGCC:-$(WRAPCC_GCC)}" "$$@" -specs "%s/musl-gcc.specs"\n' "$(libdir)" > $@ |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 190 | chmod +x $@ |
| 191 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 192 | obj/%-clang: $(srcdir)/tools/%-clang.in config.mak |
Shiz | fb58545 | 2015-06-28 23:08:21 +0200 | [diff] [blame] | 193 | sed -e 's!@CC@!$(WRAPCC_CLANG)!g' -e 's!@PREFIX@!$(prefix)!g' -e 's!@INCDIR@!$(includedir)!g' -e 's!@LIBDIR@!$(libdir)!g' -e 's!@LDSO@!$(LDSO_PATHNAME)!g' $< > $@ |
| 194 | chmod +x $@ |
| 195 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 196 | $(DESTDIR)$(bindir)/%: obj/% |
Rich Felker | e678fc6 | 2013-08-17 22:21:11 -0400 | [diff] [blame] | 197 | $(INSTALL) -D $< $@ |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 198 | |
Rich Felker | 207c45d | 2011-06-27 21:38:11 -0400 | [diff] [blame] | 199 | $(DESTDIR)$(libdir)/%.so: lib/%.so |
Rich Felker | e678fc6 | 2013-08-17 22:21:11 -0400 | [diff] [blame] | 200 | $(INSTALL) -D -m 755 $< $@ |
Rich Felker | 207c45d | 2011-06-27 21:38:11 -0400 | [diff] [blame] | 201 | |
Rich Felker | ec05a0b | 2011-06-23 22:13:47 -0400 | [diff] [blame] | 202 | $(DESTDIR)$(libdir)/%: lib/% |
Rich Felker | e678fc6 | 2013-08-17 22:21:11 -0400 | [diff] [blame] | 203 | $(INSTALL) -D -m 644 $< $@ |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 204 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 205 | $(DESTDIR)$(includedir)/bits/%: $(srcdir)/arch/$(ARCH)/bits/% |
Rich Felker | e678fc6 | 2013-08-17 22:21:11 -0400 | [diff] [blame] | 206 | $(INSTALL) -D -m 644 $< $@ |
Rich Felker | d66ab4f | 2013-07-01 13:43:43 -0400 | [diff] [blame] | 207 | |
Rich Felker | efdf04c | 2016-01-27 19:31:15 -0500 | [diff] [blame] | 208 | $(DESTDIR)$(includedir)/bits/%: $(srcdir)/arch/generic/bits/% |
| 209 | $(INSTALL) -D -m 644 $< $@ |
| 210 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 211 | $(DESTDIR)$(includedir)/bits/%: obj/include/bits/% |
| 212 | $(INSTALL) -D -m 644 $< $@ |
| 213 | |
| 214 | $(DESTDIR)$(includedir)/%: $(srcdir)/include/% |
Rich Felker | e678fc6 | 2013-08-17 22:21:11 -0400 | [diff] [blame] | 215 | $(INSTALL) -D -m 644 $< $@ |
Rich Felker | ec05a0b | 2011-06-23 22:13:47 -0400 | [diff] [blame] | 216 | |
Rich Felker | 82fa6b4 | 2013-08-16 17:51:38 -0400 | [diff] [blame] | 217 | $(DESTDIR)$(LDSO_PATHNAME): $(DESTDIR)$(libdir)/libc.so |
Rich Felker | 9ff8ed4 | 2013-08-31 11:36:56 -0400 | [diff] [blame] | 218 | $(INSTALL) -D -l $(libdir)/libc.so $@ || true |
Rich Felker | f8e054f | 2012-05-04 21:54:57 -0400 | [diff] [blame] | 219 | |
Rich Felker | 0780936 | 2012-08-17 19:32:24 -0400 | [diff] [blame] | 220 | install-libs: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(if $(SHARED_LIBS),$(DESTDIR)$(LDSO_PATHNAME),) |
| 221 | |
| 222 | install-headers: $(ALL_INCLUDES:include/%=$(DESTDIR)$(includedir)/%) |
| 223 | |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 224 | install-tools: $(ALL_TOOLS:obj/%=$(DESTDIR)$(bindir)/%) |
Rich Felker | 0780936 | 2012-08-17 19:32:24 -0400 | [diff] [blame] | 225 | |
Rich Felker | 157e284 | 2016-02-17 16:11:45 -0500 | [diff] [blame] | 226 | install: install-libs install-headers install-tools |
| 227 | |
Rich Felker | f807107 | 2014-06-25 16:14:37 -0400 | [diff] [blame] | 228 | musl-git-%.tar.gz: .git |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 229 | git --git-dir=$(srcdir)/.git archive --format=tar.gz --prefix=$(patsubst %.tar.gz,%,$@)/ -o $@ $(patsubst musl-git-%.tar.gz,%,$@) |
Rich Felker | 0780936 | 2012-08-17 19:32:24 -0400 | [diff] [blame] | 230 | |
Rich Felker | f807107 | 2014-06-25 16:14:37 -0400 | [diff] [blame] | 231 | musl-%.tar.gz: .git |
Petr Hosek | 2f853dd | 2015-11-18 12:07:32 -0800 | [diff] [blame] | 232 | git --git-dir=$(srcdir)/.git archive --format=tar.gz --prefix=$(patsubst %.tar.gz,%,$@)/ -o $@ v$(patsubst musl-%.tar.gz,%,$@) |
Rich Felker | 0780936 | 2012-08-17 19:32:24 -0400 | [diff] [blame] | 233 | |
Rich Felker | 157e284 | 2016-02-17 16:11:45 -0500 | [diff] [blame] | 234 | endif |
| 235 | |
| 236 | clean: |
| 237 | rm -rf obj lib |
| 238 | |
| 239 | distclean: clean |
| 240 | rm -f config.mak |
| 241 | |
Rich Felker | 0780936 | 2012-08-17 19:32:24 -0400 | [diff] [blame] | 242 | .PHONY: all clean install install-libs install-headers install-tools |