summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2005-10-18 21:12:20 +0000
committerPeter S. Mazinger <ps.m@gmx.net>2005-10-18 21:12:20 +0000
commit768f982ca08845aa8748bd6592ea90fc40fa3aca (patch)
tree61e005951ee0c81c8ddde05a1344a29bc5f5698a
parent8891cd94ce927967b85d88f148e0864f0d502eec (diff)
Update upcoming new infrastructure files
-rw-r--r--Makefile.libs108
-rw-r--r--Makerules241
2 files changed, 127 insertions, 222 deletions
diff --git a/Makefile.libs b/Makefile.libs
new file mode 100644
index 000000000..6a3eb1fec
--- /dev/null
+++ b/Makefile.libs
@@ -0,0 +1,108 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
+#
+
+#LIB_NAME:=libsome
+
+ifneq ($(strip $(LIB_NAME)),)
+ifeq ($(strip $(srcdir)),)
+srcdir=$(top_srcdir)$(LIB_NAME)
+endif
+ifeq ($(strip $($(LIB_NAME)_DIR)),)
+$(LIB_NAME)_DIR:=$(top_builddir)$(LIB_NAME)
+endif
+ifeq ($(strip $($(LIB_NAME)_FULL_NAME)),)
+$(LIB_NAME)_FULL_NAME:=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
+endif
+
+ifeq ($(strip $($(LIB_NAME)_SRC)),)
+ifeq ($(strip $($(LIB_NAME)_MSRC)),)
+$(LIB_NAME)_SRC:=$(wildcard $(srcdir)/*.c)
+endif
+else
+ifeq ($(strip $($(LIB_NAME)_OBJ)),)
+$(LIB_NAME)_OBJ:=$(patsubst $(srcdir)/%.c,$($(LIB_NAME)_DIR)/%.o,$($(LIB_NAME)_SRC))
+endif
+endif
+$(LIB_NAME)_OBJ_PIC:=$(patsubst %.o,%.os,$($(LIB_NAME)_OBJ))
+
+$(LIB_NAME)_MOBJ_PIC:=$(patsubst %.o,%.os,$($(LIB_NAME)_MOBJ))
+
+$(LIB_NAME)_ARCH_OBJ_PIC:=$(patsubst %.o,%.os,$($(LIB_NAME)_ARCH_OBJ))
+
+libso-y+=$(top_builddir)lib/$(LIB_NAME).so
+liba-y+=$(top_builddir)lib/$(LIB_NAME).a
+libclean-y+=$(LIB_NAME)_clean
+
+$($(LIB_NAME)_OBJ): %.o : %.c
+ $(compile.c)
+
+$($(LIB_NAME)_OBJ_PIC): %.os : %.c
+ $(compile.c) $(PICFLAG)
+
+$($(LIB_NAME)_MOBJ): $($(LIB_NAME)_MSRC)
+ $(compile.m)
+
+$($(LIB_NAME)_MOBJ_PIC): $($(LIB_NAME)_MSRC)
+ $(compile.m) $(PICFLAG)
+
+$($(LIB_NAME)_ARCH_OBJ): %.o : %.c
+ $(compile.c)
+
+$($(LIB_NAME)_ARCH_OBJ_PIC): %.os : %.c
+ $(compile.c) $(PICFLAG)
+
+# this should be changed to .os after libc/misc/internals/ is done
+interp:=$(top_builddir)libc/misc/internals/interp.o
+ifeq ($(strip $(EXTRA_LINK_LIBS)),)
+EXTRA_LINK_LIBS=$(interp) -L$(top_builddir)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC)
+endif
+
+$(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_DIR)/$(LIB_NAME)_pic.a $(interp)
+ $(INSTALL) -d $(top_builddir)lib
+ $(RM) $@ $@.$(MAJOR_VERSION) $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME)
+ $(LD) $(LDFLAGS) -soname=$(notdir $@).$(MAJOR_VERSION) -o $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME) \
+ $(EXTRA_LINK_OPTS) $(SHARED_START_FILES) --whole-archive $(firstword $^) \
+ --no-whole-archive $(EXTRA_LINK_LIBS) $(SHARED_END_FILES)
+ $(LN) -sf $($(LIB_NAME)_FULL_NAME) $@.$(MAJOR_VERSION)
+ $(LN) -sf $($(LIB_NAME)_FULL_NAME) $@
+
+$(top_builddir)lib/$(LIB_NAME).so1: $($(LIB_NAME)_OBJ_PIC) $($(LIB_NAME)_MOBJ_PIC) $($(LIB_NAME)_ARCH_OBJ_PIC)
+ $(INSTALL) -d $(top_builddir)lib
+ $(RM) $@ $@.$(MAJOR_VERSION) $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME)
+ $(LD) $(LDFLAGS) -soname=$(notdir $@).$(MAJOR_VERSION) -o $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME) \
+ $(EXTRA_LINK_OPTS) $(SHARED_START_FILES) $^ \
+ $(EXTRA_LINK_LIBS) $(SHARED_END_FILES)
+ $(LN) -sf $($(LIB_NAME)_FULL_NAME) $@.$(MAJOR_VERSION)
+ $(LN) -sf $($(LIB_NAME)_FULL_NAME) $@
+
+$($(LIB_NAME)_DIR)/$(LIB_NAME)_pic.a: $($(LIB_NAME)_OBJ_PIC) $($(LIB_NAME)_MOBJ_PIC) $($(LIB_NAME)_ARCH_OBJ_PIC)
+ifneq ($(strip $(STRIP_FLAGS)),)
+ $(STRIPTOOL) $(STRIP_FLAGS) $^
+else
+ $(STRIPTOOL) -x -R .note -R .comment $^
+endif
+ $(AR) $(ARFLAGS) $@ $^
+ #(AR) $(ARFLAGS) $@ $($(LIB_NAME)_OBJ_PIC) $($(LIB_NAME)_MOBJ_PIC)
+ #(AR) $(ARFLAGS) $@ $($(LIB_NAME)_ARCH_OBJ_PIC)
+
+ifeq ($(DOPIC),y)
+$(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_DIR)/$(LIB_NAME)_pic.a
+ $(RM) $@
+ cp $< $@
+else
+$(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_OBJ) $($(LIB_NAME)_MOBJ) $($(LIB_NAME)_ARCH_OBJ)
+ $(RM) $@
+ $(STRIPTOOL) -x -R .note -R .comment $^
+ $(AR) $(ARFLAGS) $@ $^
+ #(AR) $(ARFLAGS) $@ $($(LIB_NAME)_OBJ) $($(LIB_NAME)_MOBJ)
+ #(AR) $(ARFLAGS) $@ $($(LIB_NAME)_ARCH_OBJ)
+endif
+
+$(LIB_NAME)_clean:
+ rm -f $($(LIB_NAME)_DIR)/*.{o,os,a}
+
+endif
diff --git a/Makerules b/Makerules
index 0bca2789c..29d407040 100644
--- a/Makerules
+++ b/Makerules
@@ -1,237 +1,34 @@
#
# Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
#
-top_srcdir = $(TOPDIR)
-top_builddir = $(TOPDIR)
+.SUFFIXES: .c .S .o .os .so .a .s
-compile.c = $(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$@) $(CFLAGS-$<)
-compile.S = $(compile.c) $(S_CPPFLAGS) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$@) $(ASFLAGS-$<)
-compile.m = $(compile.c) -DL_$(patsubst %.$(suffix $@),%, $@)
-
-#S_CPPFLAGS = -D__ASSEMBLER__ $(asm-CPPFLAGS)
-
-ifeq ($(DOPIC),y)
-DISABLE_PIC := $(PICFLAG)
-else
-DISABLE_PIC := -fno-PIC
-endif
-
-# objects
-ifeq ($(strip $(CSRC)),)
-CSRC = $(wildcard *.c)
+ifndef top_srcdir
+top_srcdir=$(CURDIR)
endif
-COBJ = $(CSRC:.c=.o)
-COBJ_PIC = $(COBJ:.o=.os)
-
-#MSRC = some.c
-#MOBJ = has to be defined if used
-MOBJ_PIC = $(MOBJ:.o=.os)
-MOBJ2_PIC = $(MOBJ2:.o=.os)
-MOBJ3_PIC = $(MOBJ3:.o=.os)
-
-#SSRC = $(wildcard *.S)
-SOBJ = $(SSRC:.S=.o)
-SOBJ_PIC = $(SOBJ:.o=.os)
-
-#ARCH_DIR = $(TARGET_ARCH)
-#ARCH_CSRC = $(wildcard $(ARCH_DIR)/*.c)
-ARCH_COBJ = $(ARCH_CSRC:.c=.o)
-ARCH_COBJ_PIC = $(ARCH_COBJ:.o=.os)
-
-#ARCH_SSRC = $(wildcard $(TARGET_ARCH)/*.S)
-ARCH_SOBJ = $(ARCH_SSRC:.S=.o)
-ARCH_SOBJ_PIC = $(ARCH_SOBJ:.o=.os)
-
-OBJS = $(COBJ) $(SOBJ) $(MOBJ) $(MOBJ2) $(MOBJ3)
-OBJS_PIC = $(COBJ_PIC) $(SOBJ_PIC) $(MOBJ_PIC) $(MOBJ2_PIC) $(MOBJ3_PIC)
-
-ARCH_OBJS = $(ARCH_COBJ) $(ARCH_SOBJ)
-ARCH_OBJS_PIC = $(ARCH_COBJ_PIC) $(ARCH_SOBJ_PIC)
-
-$(COBJ): %.o : %.c
- $(compile.c) $(DISABLE_PIC)
-
-$(MOBJ): $(MSRC)
- $(compile.m) $(DISABLE_PIC)
-
-$(MOBJ2): $(MSRC2)
- $(compile.m) $(DISABLE_PIC)
-
-$(MOBJ3): $(MSRC3)
- $(compile.m) $(DISABLE_PIC)
-
-$(SOBJ): %.o : %.S
- $(compile.S) $(DISABLE_PIC)
-
-$(COBJ_PIC): %.os : %.c
- $(compile.c) $(PICFLAG)
-
-$(MOBJ_PIC): $(MSRC)
- $(compile.m) $(PICFLAG)
-
-$(MOBJ2_PIC): $(MSRC2)
- $(compile.m) $(PICFLAG)
-
-$(MOBJ3_PIC): $(MSRC3)
- $(compile.m) $(PICFLAG)
-
-$(SOBJ_PIC): %.os : %.S
- $(compile.S) $(PICFLAG)
-
-$(ARCH_COBJ): %.o : %.c
- $(compile.c) $(DISABLE_PIC)
-
-$(ARCH_SOBJ): %.o : %.S
- $(compile.S) $(DISABLE_PIC)
-
-$(ARCH_COBJ_PIC): %.os : %.c
- $(compile.c) $(PICFLAG)
-
-$(ARCH_SOBJ_PIC): %.os : %.S
- $(compile.S) $(PICFLAG)
-
-#ifeq ($(strip $(OBJ_DIR)),)
-#OBJ_DIR = $(patsubst %libc/,, $(shell pwd))
-#endif
-OBJ_FILE = $(subst /,., $(OBJ_DIR))
-OBJ_LIST = $(patsubst %,$(TOPDIR)libc/obj.%, $(OBJ_FILE))
-OBJ_LIST_PIC = $(patsubst %,$(TOPDIR)libc/obj_pic.%, $(OBJ_FILE))
-
-ifeq ($(DOPIC),y)
-objs: $(OBJ_LIST_PIC)
-else
-objs: $(OBJ_LIST) $(OBJ_LIST_PIC)
-endif
-
-$(OBJ_LIST): $(OBJS)
- $(STRIPTOOL) -x -R .note -R .comment $^
- echo $(patsubst %,$(OBJ_DIR)/%, $^) > $@
-
-$(OBJ_LIST_PIC): $(OBJS_PIC)
- $(STRIPTOOL) -x -R .note -R .comment $^
- echo $(patsubst %,$(OBJ_DIR)/%, $^) > $@
-# libraries
-#LIB_NAME=libsome
-AR_LIB_NAME = $(TOPDIR)lib/$(LIB_NAME).a
-AR_PIC_LIB_NAME = $(LIB_NAME)_pic.a
-ifeq ($(strip $(SO_LIB_NAME)),)
-SO_LIB_NAME = $(TOPDIR)lib/$(LIB_NAME).so
-endif
-ifeq ($(strip $(SO_FULL_NAME)),)
-SO_FULL_NAME = $(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
-endif
-ifeq ($(strip $(SO_MAJOR_NAME)),)
-SO_MAJOR_NAME = $(LIB_NAME).so.$(MAJOR_VERSION)
+ifndef top_builddir
+top_builddir=$(CURDIR)
endif
-# this should be changed to .os after libc/misc/internals/ is done
-interp := $(TOPDIR)libc/misc/internals/interp.o
-ifeq ($(strip $(EXTRA_LINK_LIBS)),)
-EXTRA_LINK_LIBS = $(interp) -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC)
-endif
+top_srcdir:=$(shell echo "$(top_srcdir)/" | sed -e 's://:/:')
+top_builddir:=$(shell echo "$(top_builddir)/" | sed -e 's://:/:')
-libs: libs_shared $(AR_LIB_NAME)
ifeq ($(HAVE_SHARED),y)
-libs_shared: $(SO_LIB_NAME)
-else
-libs_shared:
-endif
-
-$(AR_PIC_LIB_NAME): $(OBJS_PIC) $(ARCH_OBJS_PIC)
- $(RM) $@
-ifneq ($(strip $(STRIP_FLAGS)),)
- $(STRIPTOOL) $(STRIP_FLAGS) $^
-else
- $(STRIPTOOL) -x -R .note -R .comment $^
-endif
- $(AR) $(ARFLAGS) $@ $(OBJS_PIC)
-ifneq ($(strip $(ARCH_OBJS_PIC)),)
- $(AR) $(ARFLAGS) $@ $(ARCH_OBJS_PIC)
-endif
-
-ifeq ($(DOPIC),y)
-$(AR_LIB_NAME): $(AR_PIC_LIB_NAME)
- $(INSTALL) -d $(TOPDIR)lib
- $(RM) $@
- cp $< $@
+.LIBPATTERNS: "lib%.so"
+libs: libso-y liba-y
else
-$(AR_LIB_NAME): $(OBJS) $(ARCH_OBJS)
- $(INSTALL) -d $(TOPDIR)lib
- $(RM) $@
-ifneq ($(strip $(STRIP_FLAGS)),)
- $(STRIPTOOL) $(STRIP_FLAGS) $^
-else
- $(STRIPTOOL) -x -R .note -R .comment $^
-endif
- $(AR) $(ARFLAGS) $@ $(OBJS)
-ifneq ($(strip $(ARCH_OBJS)),)
- $(AR) $(ARFLAGS) $@ $(ARCH_OBJS)
+.LIBPATTERNS: "lib%.a"
+libs: liba-y
endif
-endif
-
-$(SO_LIB_NAME): $(AR_PIC_LIB_NAME)
- $(INSTALL) -d $(TOPDIR)lib
- $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(TOPDIR)lib/$(SO_MAJOR_NAME) $@
- $(LD) $(LDFLAGS) -soname=$(SO_MAJOR_NAME) -o $(TOPDIR)lib/$(SO_FULL_NAME) \
- $(EXTRA_LINK_OPTS) $(SHARED_START_FILES) --whole-archive $< \
- --no-whole-archive $(EXTRA_LINK_LIBS) $(SHARED_END_FILES)
- $(LN) -sf $(SO_FULL_NAME) $(TOPDIR)lib/$(SO_MAJOR_NAME)
- $(LN) -sf $(SO_FULL_NAME) $@
-# crt stuff
-ifeq ($(HAVE_ELF),y)
-CRT = crt1
-else
-CRT = crt0
-endif
+libso-y: $(libso-y)
+liba-y: $(liba-y)
+libclean-y: $(libclean-y)
-CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
+compile.c=$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$@) $(CFLAGS-$<)
+compile.S=$(compile.c) $(S_CPPFLAGS) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$@) $(ASFLAGS-$<)
+compile.m=$(compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
-crts: $(TOPDIR)lib/$(CRT).o $(TOPDIR)lib/S$(CRT).o $(CTOR_TARGETS)
-
-$(TOPDIR)lib/$(CRT).o: $(CRT).S
- $(compile.S) $(DISABLE_PIC) -DL_$*
- $(STRIPTOOL) -x -R .note -R .comment $@
-
-$(TOPDIR)lib/S$(CRT).o: $(CRT).S
- $(compile.S) $(PIEFLAG) -DL_$*
- $(STRIPTOOL) -x -R .note -R .comment $@
-
-ifeq ($(UCLIBC_CTOR_DTOR),y)
-$(TOPDIR)lib/crti.o: crti.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
-
-$(TOPDIR)lib/crtn.o: crtn.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
-else
-$(CTOR_TARGETS):
- $(INSTALL) -d $(TOPDIR)lib/
- $(AR) $(ARFLAGS) $@
-endif
-
-# addons
-headers:
-
-tags:
- ctags -R
-
-clean:
- $(RM) *.o *.os *.a
-ifneq ($(strip $(ARCH_DIR)),)
- $(RM) $(ARCH_DIR)/*.o $(ARCH_DIR)/*.os
-endif
-
-subdirs: $(patsubst %, _dir_%, $(DIRS))
-subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
-
-$(patsubst %, _dir_%, $(DIRS)) : dummy
- $(MAKE) -C $(patsubst _dir_%, %, $@)
-
-$(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
- $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
-
-.PHONY: dummy
-#
+.PHONY: clean
+clean: libclean-y