1
0
Fork 0
forked from len0rd/rockbox

Don't add LIBSOURCES to SOURCES.

Split source files for library and stand-alone binary and use library as
dependency when building the stand-alone binary. This avoids dependencies
getting added multiple times.

Remove outdated RBARCH handling, we always create fat binaries on OS X these
days.

Change-Id: Ia15a731296edcbe90869a1bf66dda2c3d6c7e317
This commit is contained in:
Dominik Riebeling 2016-12-16 19:39:07 +01:00
parent efe3775145
commit 6f4beaa52c
8 changed files with 17 additions and 24 deletions

View file

@ -11,7 +11,7 @@ CFLAGS += -g -Wall
OUTPUT = chinachippatcher OUTPUT = chinachippatcher
LIBSOURCES = chinachip.c LIBSOURCES = chinachip.c
SOURCES = $(LIBSOURCES) main.c SOURCES = main.c
include ../libtools.make include ../libtools.make

View file

@ -32,7 +32,7 @@ LDOPTS_OSX = -framework CoreFoundation -framework IOKit
LIBSOURCES = ipodpatcher.c fat32format.c arc4.c \ LIBSOURCES = ipodpatcher.c fat32format.c arc4.c \
ipodio-posix.c ipodio-win32-scsi.c ipodio-win32.c ipodio-posix.c ipodio-win32-scsi.c ipodio-win32.c
SOURCES = main.c $(BOOTSRC) $(LIBSOURCES) SOURCES = main.c $(BOOTSRC)
ipodpatcher: SOURCES+= ipodio-posix.c ipodpatcher: SOURCES+= ipodio-posix.c
OUTPUT = ipodpatcher OUTPUT = ipodpatcher

View file

@ -37,8 +37,6 @@ TARGET_DIR ?= $(abspath .)/
NATIVECC ?= gcc NATIVECC ?= gcc
CC ?= gcc CC ?= gcc
CPPDEFINES := $(shell echo foo | $(CROSS)$(CC) -dM -E -) CPPDEFINES := $(shell echo foo | $(CROSS)$(CC) -dM -E -)
# use POSIX/C99 printf on windows
CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
BINARY = $(OUTPUT) BINARY = $(OUTPUT)
# when building a Windows binary add the correct file suffix # when building a Windows binary add the correct file suffix
@ -50,6 +48,8 @@ else
ifeq ($(findstring MINGW,$(CPPDEFINES)),MINGW) ifeq ($(findstring MINGW,$(CPPDEFINES)),MINGW)
BINARY = $(OUTPUT).exe BINARY = $(OUTPUT).exe
COMPILETARGET = mingw COMPILETARGET = mingw
# use POSIX/C99 printf on windows
CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
else else
ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE) ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE)
COMPILETARGET = darwin COMPILETARGET = darwin
@ -79,16 +79,9 @@ CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
NATIVECC = gcc-4.0 NATIVECC = gcc-4.0
endif endif
endif endif
WINDRES = windres
BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET) BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET)
ifdef RBARCH
ARCHFLAGS += -arch $(RBARCH)
OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/
else
OBJDIR = $(abspath $(BUILD_DIR))/ OBJDIR = $(abspath $(BUILD_DIR))/
endif
all: $(BINARY) all: $(BINARY)
@ -103,20 +96,20 @@ DEPS = $(addprefix $(OBJDIR),$(subst .c,.d,$(notdir $(SOURCES) $(LIBSOURCES))))
# additional link dependencies for the standalone executable # additional link dependencies for the standalone executable
# extra dependencies: libucl # extra dependencies: libucl
LIBUCL = libucl$(RBARCH).a LIBUCL = libucl.a
$(LIBUCL): $(OBJDIR)$(LIBUCL) $(LIBUCL): $(OBJDIR)$(LIBUCL)
$(OBJDIR)$(LIBUCL): $(OBJDIR)$(LIBUCL):
$(SILENT)$(MAKE) -C $(TOP)/../tools/ucl/src TARGET_DIR=$(OBJDIR) $@ $(SILENT)$(MAKE) -C $(TOP)/../tools/ucl/src TARGET_DIR=$(OBJDIR) $@
# building the standalone executable # building the standalone executable
$(BINARY): $(OBJS) $(EXTRADEPS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) $(BINARY): $(OBJS) $(EXTRADEPS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) $(TARGET_DIR)lib$(OUTPUT).a
@echo LD $@ @echo LD $@
$(SILENT)$(call mkdir,$(dir $@)) $(SILENT)$(call mkdir,$(dir $@))
# EXTRADEPS need to be built into OBJDIR. # EXTRADEPS need to be built into OBJDIR.
$(SILENT)$(CROSS)$(CC) $(ARCHFLAGS) $(CFLAGS) -o $(BINARY) \ $(SILENT)$(CROSS)$(CC) $(ARCHFLAGS) $(CFLAGS) -o $(BINARY) \
$(OBJS) $(addprefix $(OBJDIR),$(EXTRADEPS)) \ $(OBJS) $(addprefix $(OBJDIR),$(EXTRADEPS)) \
$(addprefix $(OBJDIR),$(EXTRALIBOBJS)) $(LDOPTS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) lib$(OUTPUT).a $(addprefix $(OBJDIR),$(EXTRADEPS)) $(LDOPTS)
# common rules # common rules
$(OBJDIR)%.o: $(OBJDIR)%.o:
@ -125,10 +118,10 @@ $(OBJDIR)%.o:
$(SILENT)$(CROSS)$(CC) $(ARCHFLAGS) $(CFLAGS) -c -o $@ $< $(SILENT)$(CROSS)$(CC) $(ARCHFLAGS) $(CFLAGS) -c -o $@ $<
# lib rules # lib rules
lib$(OUTPUT)$(RBARCH).a: $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a lib$(OUTPUT).a: $(TARGET_DIR)lib$(OUTPUT).a
lib$(OUTPUT)$(RBARCH): $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a lib$(OUTPUT): $(TARGET_DIR)lib$(OUTPUT).a
$(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a: $(LIBOBJS) \ $(TARGET_DIR)lib$(OUTPUT).a: $(LIBOBJS) \
$(addprefix $(OBJDIR),$(EXTRALIBOBJS)) $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
# rules to build a DLL. Only works for W32 as target (i.e. MinGW toolchain) # rules to build a DLL. Only works for W32 as target (i.e. MinGW toolchain)
dll: $(OUTPUT).dll dll: $(OUTPUT).dll
@ -140,7 +133,7 @@ $(TARGET_DIR)$(OUTPUT).dll: $(LIBOBJS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
-Wl,--output-def,$(TARGET_DIR)$(OUTPUT).def -Wl,--output-def,$(TARGET_DIR)$(OUTPUT).def
# create lib file from objects # create lib file from objects
$(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a: $(LIBOBJS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) $(TARGET_DIR)lib$(OUTPUT).a: $(LIBOBJS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
@echo AR $(notdir $@) @echo AR $(notdir $@)
$(SILENT)$(call mkdir,$(dir $@)) $(SILENT)$(call mkdir,$(dir $@))
$(SILENT)$(call rm,$@) $(SILENT)$(call rm,$@)

View file

@ -9,11 +9,11 @@
CFLAGS += -I../../tools/ucl/include -Wall CFLAGS += -I../../tools/ucl/include -Wall
OUTPUT = mkamsboot OUTPUT = mkamsboot
LIBUCL = libucl$(RBARCH).a LIBUCL = libucl.a
# inputs # inputs
LIBSOURCES := dualboot.c md5.c mkamsboot.c LIBSOURCES := dualboot.c md5.c mkamsboot.c
SOURCES := $(LIBSOURCES) main.c SOURCES := main.c
# additional link dependencies for the standalone executable # additional link dependencies for the standalone executable
EXTRADEPS := $(LIBUCL) EXTRADEPS := $(LIBUCL)

View file

@ -13,7 +13,7 @@ OUTPUT = mkmpioboot
# inputs # inputs
LIBSOURCES = mkmpioboot.c LIBSOURCES = mkmpioboot.c
SOURCES = $(LIBSOURCES) main.c SOURCES = main.c
EXTRADEPS = $(LIBUCL) EXTRADEPS = $(LIBUCL)
include ../libtools.make include ../libtools.make

View file

@ -16,7 +16,7 @@ OUTPUT = mktccboot
# inputs # inputs
LIBSOURCES := mktccboot.c $(TOOLSDIR)telechips.c LIBSOURCES := mktccboot.c $(TOOLSDIR)telechips.c
SOURCES := $(LIBSOURCES) main.c SOURCES := main.c
EXTRADEPS := EXTRADEPS :=
include ../libtools.make include ../libtools.make

View file

@ -19,7 +19,7 @@ LIBSOURCES := dualboot.c mkzenboot.c md5.c utils.c \
$(addprefix $(TOOLS_DIR),$(TOOLS_SOURCES)) $(addprefix $(TOOLS_DIR),$(TOOLS_SOURCES))
# inputs for binary only # inputs for binary only
SOURCES := $(LIBSOURCES) main.c SOURCES := main.c
# dependencies for binary # dependencies for binary
EXTRADEPS := EXTRADEPS :=

View file

@ -12,7 +12,7 @@ OUTPUT = sansapatcher
# inputs # inputs
LIBSOURCES := sansapatcher.c sansaio-posix.c sansaio-win32.c LIBSOURCES := sansapatcher.c sansaio-posix.c sansaio-win32.c
SOURCES := $(LIBSOURCES) main.c SOURCES := main.c
# additional link dependencies for the standalone executable # additional link dependencies for the standalone executable
EXTRADEPS := EXTRADEPS :=