Skip to content

builds and install libs dependent to the output of gcc -print-multi-lib #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion CONFIGVARS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#
WITH_020_LIB = yes
WITH_V4E_LIB = yes
WITH_FASTCALL_LIB = yes

#
# target and host compiler
Expand Down Expand Up @@ -73,7 +74,7 @@ TAR = tar
#
# optimizations
#
OPTS = -O2 -fomit-frame-pointer
OPTS = -O2 -fomit-frame-pointer $(EXTRA_OPTS)


#
Expand All @@ -98,3 +99,28 @@ DEFINITIONS =
# model type
#
MODEL =

# Multilib

MULTILIBDIRS :=
MULTILIBFLAGS =

ifneq (,$(strip $(shell $(CC) -print-multi-lib | sed -e 's/\.;//')))
# gcc supports multilibs
# get multi-lib-dirs
MULTILIBDIRS := $(shell $(CC) -print-multi-lib | sed -e "s:;.*::")
ifneq ($(WITH_FASTCALL_LIB),yes)
# filter out fastcall
MULTILIBDIRS := $(shell echo $(MULTILIBDIRS) | sed -e 's/\S*mfastcall\S*/ /g')
endif
ifneq ($(WITH_V4E_LIB),yes)
# filter-out coldfire libs
MULTILIBDIRS := $(shell echo $(MULTILIBDIRS) | sed -e 's/\S*m5475\S*/ /g')
endif
ifneq ($(WITH_020_LIB),yes)
# filter-out 68020 libs
MULTILIBDIRS := $(shell echo $(MULTILIBDIRS) | sed -e 's/\S*m68020\S*/ /g')
endif
MULTILIBFLAGS = $(shell $(CC) -print-multi-lib | grep '^$(1);' | sed -e 's/^.*;//' -e 's/@/ -/g')

endif
30 changes: 30 additions & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ COMPILE = $(filter-out $(NOCFLAGS-$(<F)), $(filter-out $(nocflags),\
$(CC) $(cflags) $(CFLAGS) $(CFLAGS-$(<F)) $(CFLAGS-$(DIRSTEM))) \
$(DEFS-$(<F)) $(DEFS-$(DIRSTEM)))

ifeq ($(MULTILIBDIRS),)
#
# compile rule
#
Expand All @@ -21,6 +22,35 @@ $(DEFS-$(<F)) $(DEFS-$(DIRSTEM)))
#
DEP_FILES = $(addprefix ./.deps/, $(patsubst %.o,%.P,$(OBJS)))

else

DEP_FILES :=

define CC_MULTI_TEMPLATE

#
# compile rule
#

.mlibs/$(1)/%.o : %.c
$$(AM_V_CC)$$(COMPILE) -Wp,-MD,$$(@:.o=.d) -c $$< -o $$@
.mlibs/$(1)/%.o : %.S
$$(AM_V_CPPAS)$$(COMPILE) -Wp,-MD,$$(@:.o=.d) -c $$< -o $$@
.mlibs/$(1)/%.o : %.s
$$(AM_V_AS)$$(COMPILE) -Wp,-MD,$$(@:.o=.d) -c $$< -o $$@

#
# dependencies
#
DEP_FILES += $(addprefix ./.mlibs/$(1)/, $(patsubst %.o,%.d,$(OBJS)))


endef
$(foreach DIR,$(MULTILIBDIRS),$(eval $(call CC_MULTI_TEMPLATE,$(DIR))))

endif


# These are automatically remade, no need for make to worry about
# them.
.PHONY : $(DEP_FILES)
Expand Down
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ GENFILES = .lib* libgem*.a
GENFILES += mt_gem.h Doxyfile gemlib.spec
GENFILES += html

ifeq ($(MULTILIBDIRS),)
# gcc don't supports multilibs --> old stuff

ALL_LIBS = normal mshort

ifeq ($(WITH_020_LIB),yes)
Expand All @@ -43,6 +46,13 @@ ifeq ($(WITH_V4E_LIB),yes)
ALL_LIBS += m5475 m5475mshort
endif

else
ALL_LIBS = $(patsubst %,.mlibs/%/libgem.a, $(MULTILIBDIRS))
endif




libs: $(ALL_LIBS)

normal:
Expand Down Expand Up @@ -131,6 +141,18 @@ all-compilers:
make -f vbcc.mak;
make -f zip.mak

define MULTI_TEMPLATE
.mlibs/$(1) :
$$(AM_V_at)$$(MKDIR) -p $$@
.mlibs/$(1)/libgem.a : GENERAL += $(call MULTILIBFLAGS,$(1))
.mlibs/$(1)/libgem.a : mt_gem.h .mlibs/$(1) $(addprefix .mlibs/$(1)/, $(COBJS:.c=.o) $(SOBJS:.S=.o))
$$(AM_V_at)$$(RM) $$@
$$(AM_V_AR)$$(AR) rc $$@ $(addprefix .mlibs/$(1)/, $(COBJS:.c=.o) $(SOBJS:.S=.o))
$(AM_V_RANLIB)$(RANLIB) $$@

endef
$(foreach DIR,$(MULTILIBDIRS),$(eval $(call MULTI_TEMPLATE,$(DIR))))

libgem$(TARGET).a: objs
$(AM_V_at)$(RM) $@
$(AM_V_AR)$(AR) rc $@ \
Expand Down Expand Up @@ -176,6 +198,8 @@ mt_gem.h: mt_gem.h.in VERSION
# $(MOVEIFCHANGE) $(srcdir)/mt_gem.tmp $(srcdir)/mt_gem.h

install:
ifeq ($(MULTILIBDIRS),)
# gcc don't supports multilibs --> old stuff
install -m 755 -d $(PREFIX)/lib
install -m 644 libgem.a $(PREFIX)/lib/libgem.a
install -m 755 -d $(PREFIX)/lib/mshort
Expand All @@ -192,6 +216,12 @@ ifeq ($(WITH_V4E_LIB),yes)
install -m 644 libgemv4e.a $(PREFIX)/lib/m5475/libgem.a
install -m 755 -d $(PREFIX)/lib/m5475/mshort
install -m 644 libgemv4e16.a $(PREFIX)/lib/m5475/mshort/libgem.a
endif
else
for lib in $(MULTILIBDIRS); do \
install -m 755 -d $(PREFIX)/lib/$$lib; \
install -m 644 ./.mlibs/$$lib/libgem.a $(PREFIX)/lib/$$lib/libgem.a; \
done
endif
install -m 755 -d $(PREFIX)/include
install -m 644 gem.h $(PREFIX)/include
Expand All @@ -200,6 +230,7 @@ endif
install -m 644 mt_gemx.h $(PREFIX)/include

uninstall:
ifeq ($(MULTILIBDIRS),)
rm -f $(PREFIX)/lib/libgem.a
rm -f $(PREFIX)/lib/libgem16.a
rm -f $(PREFIX)/lib/mshort/libgem.a
Expand All @@ -210,8 +241,17 @@ endif
ifeq ($(WITH_V4E_LIB),yes)
rm -f $(PREFIX)/lib/m5475/libgem.a
rm -f $(PREFIX)/lib/m5475/mshort/libgem.a
endif
else
for lib in $(MULTILIBDIRS); do \
rm -f $(PREFIX)/lib/$$lib; \
done
endif
rm -f $(PREFIX)/include/gem.h
rm -f $(PREFIX)/include/gemx.h
rm -f $(PREFIX)/include/mt_gem.h
rm -f $(PREFIX)/include/mt_gemx.h

ifneq ($(MULTILIBDIRS),)
include $(top_srcdir)/DEPENDENCIES
endif