Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Commit

Permalink
Simplify universal builds by relying on the linker to do the right thing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole André Vadla Ravnås committed Jul 4, 2014
1 parent 6583f06 commit b202b91
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
15 changes: 1 addition & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
endif

CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))

PREFIX ?= /usr
DESTDIR ?=
Expand Down Expand Up @@ -418,23 +419,9 @@ define create-archive
endef


ifeq ($(LIBARCHS),)
define create-library
$(CC) $(LDFLAGS) $($(LIBNAME)_LDFLAGS) $(LIBOBJ) -o $(LIBRARY)
endef
else
ifeq ($(call words,$(LIBARCHS)),1)
define create-library
$(CC) -arch $(LIBARCHS) $(LDFLAGS) $($(LIBNAME)_LDFLAGS) $(LIBOBJ) -o $(LIBRARY)
endef
else
define create-library
$(foreach arch,$(LIBARCHS),$(CC) -arch $(arch) $(LDFLAGS) $($(LIBNAME)_LDFLAGS) $(LIBOBJ) -o $(LIBRARY).$(arch);)
lipo -create $(foreach arch,$(LIBARCHS),$(LIBRARY).$(arch)) -output $(LIBRARY)
rm $(foreach arch,$(LIBARCHS),$(LIBRARY).$(arch))
endef
endif
endif


define generate-pkgcfg
Expand Down
18 changes: 3 additions & 15 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ endif


CFLAGS += -O3 -Wall -I$(INCDIR)
CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
LDFLAGS += -L$(LIBDIR)

CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))

LIBNAME = capstone

BIN_EXT =
Expand Down Expand Up @@ -128,23 +130,9 @@ else
endif


ifeq ($(LIBARCHS),)
define link-dynamic
$(CC) $(LDFLAGS) $< -l$(LIBNAME) -o $@
endef
else
ifeq ($(call words,$(LIBARCHS)),1)
define link-dynamic
$(CC) -arch $(LIBARCHS) $(LDFLAGS) $< -l$(LIBNAME) -o $@
endef
else
define link-dynamic
$(foreach arch,$(LIBARCHS),$(CC) -arch $(arch) $(LDFLAGS) $< -l$(LIBNAME) -o $(@).$(arch);)
lipo -create $(foreach arch,$(LIBARCHS),$(@).$(arch)) -output $@
rm $(foreach arch,$(LIBARCHS),$(@).$(arch))
endef
endif
endif


define link-static
Expand Down

0 comments on commit b202b91

Please sign in to comment.