# Acess2 Build Configuration
#
-CC = i686-elf-gcc
-CXX = i686-elf-g++
-#CC = clang -m32
-LD = i686-elf-ld
-#CC = gcc
-#LD = ld
+TRIPLET = i686-pc-acess2
AS = nasm
-#OBJDUMP = i686-elf-objdump
-OBJDUMP = objdump
RM = @rm -f
STRIP = strip
ifeq ($(ARCHDIR),native)
ASFLAGS = -felf
- CPPFLAGS = -Wall
- CFLAGS = $(CPPFLAGS)
- LDFLAGS = -L $(OUTPUTDIR)Libs -lacess-native -lc_acess
+ LDFLAGS = -L $(OUTPUTDIR)Libs
+ LIBS := -lacess-native -lc_acess
#LIBGCC_PATH = $(ACESSDIR)/AcessNative/symbol_renames.ld
else
ASFLAGS = -felf
- CPPFLAGS = -ffreestanding
- CFLAGS = -fno-stack-protector -fno-builtin $(CPPFLAGS) -Wall
- LDFLAGS = -T $(OUTPUTDIR)Libs/acess.ld -L $(OUTPUTDIR)Libs -I /Acess/Libs/ld-acess.so -lld-acess -lc $(OUTPUTDIR)Libs/crtbegin.o $(OUTPUTDIR)Libs/crtend.o -lposix
- LIBGCC_PATH = $(shell $(CC) -print-libgcc-file-name)
+# LDFLAGS = -T $(OUTPUTDIR)Libs/acess.ld
+ LDFLAGS = -L $(OUTPUTDIR)Libs
+ LIBS = -lld-acess
endif
--include $(_appsdir)../common_settings.mk
LDFLAGS += -rpath-link $(OUTPUTDIR)Libs
CXXFLAGS += -std=gnu++11
+CPPFLAGS +=
+CFLAGS += -Wall
+
+-include $(_appsdir)../common_settings.mk
# Extra-verbose errors!
#CFLAGS += -Wall -Wextra -Wwrite-strings -Wshadow -Wswitch-default -Wswitch-enum -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wmissing-declarations -Wlogical-op -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wunsafe-loop-optimizations -Wbad-function-cast -Wc++-compat -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wdisabled-optimization -Woverlength-strings
-CRTBEGIN = $(shell $(CC) $(CFLAGS) -print-file-name=crtbegin.o)
-CRTEND = $(shell $(CC) $(CFLAGS) -print-file-name=crtend.o)
-
DIR = Bin
# - Application Template Makefile
#
-CFLAGS += -g
-LDFLAGS += -g
-
-LDFLAGS += -Map $(_OBJPREFIX)Map.txt
-
-ifneq ($(lastword $(subst -, ,$(basename $(LD)))),ld)
- comma=,
- LDFLAGS := $(subst -rpath-link ,-Wl$(comma)-rpath-link$(comma),$(LDFLAGS))
- LDFLAGS := $(subst -Map ,-Wl$(comma)-Map$(comma),$(LDFLAGS))
-endif
+CFLAGS += -g
+CXXFLAGS += -g
+LDFLAGS += -g
_BIN := $(OUTPUTDIR)$(DIR)/$(BIN)
_OBJPREFIX := obj-$(ARCH)/
-_LIBS := $(filter -l%,$(LDFLAGS))
+LDFLAGS += -Map $(_OBJPREFIX)Map.txt
+
+comma=,
+LDFLAGS := $(subst -rpath-link ,-Wl$(comma)-rpath-link$(comma),$(LDFLAGS))
+LDFLAGS := $(subst -Map ,-Wl$(comma)-Map$(comma),$(LDFLAGS))
+
+_LIBS := $(filter -l%,$(LIBS))
_LIBS := $(patsubst -l%,$(OUTPUTDIR)Libs/lib%.so,$(_LIBS))
ifeq ($(VERBOSE),)
OBJ := $(addprefix $(_OBJPREFIX),$(OBJ))
+#LINK_OBJS := $(CRTI) $(CRTBEGIN) $(CRT0) $(OBJ) $(LIBGCC_PATH) $(CRTEND) $(CRTN)
+LINK_OBJS := $(OBJ)
+
DEPFILES := $(OBJ:%.o=%.dep)
.PHONY : all clean install
@$(xCP) $(_BIN)_ $(DISTROOT)/$(DIR)/$(BIN)
@$(RM) $(_BIN)_
-$(_BIN): $(OUTPUTDIR)Libs/acess.ld $(OUTPUTDIR)Libs/crt0.o $(_LIBS) $(OBJ)
+$(_BIN): $(OUTPUTDIR)Libs/acess.ld $(_LIBS) $(LINK_OBJS)
@mkdir -p $(dir $(_BIN))
@echo [LD] -o $@
- $V$(LD) -g $(LDFLAGS) -o $@ $(CRTBEGIN) $(OBJ) $(LIBGCC_PATH) $(CRTEND)
+ifneq ($(USE_CXX_LINK),)
+ $V$(CXX) -g $(LDFLAGS) -o $(_BIN) $(LINK_OBJS) $(LIBS)
+else
+ $V$(CC) -g $(LDFLAGS) -o $(_BIN) $(LINK_OBJS) $(LIBS)
+endif
$V$(DISASM) $(_BIN) > $(_OBJPREFIX)$(BIN).dsm
$(_OBJPREFIX)%.o: %.c
_libsdir := $(dir $(lastword $(MAKEFILE_LIST)))
-include $(_libsdir)../Makefile.cfg
+USE_CXX_LINK :=
+PRELINK :=
MAKEDEP = $(CC) -M
ifeq ($(ARCHDIR),native)
ASFLAGS += -D ARCHDIR=$(ARCHDIR) -D __ASSEMBLER__=1
- LDFLAGS := -lacess-native
+ LDFLAGS :=
+ LIBS := -lacess-native
#CPPFLAGS := -D SoMain="__attribute__ ((constructor(101))) libacessnative_init"
ifeq ($(PLATFORM),windows)
else
CFLAGS += -fPIC
CXXFLAGS += -fPIC
endif
+ LIBS := -lld-acess
else
- CPPFLAGS := -ffreestanding
CFLAGS := -fno-stack-protector -fPIC
- CXXFLAGS := -fno-stack-protector -fPIC
- LDFLAGS := -I/Acess/Libs/ld-acess.so -lld-acess `$(CC) -print-libgcc-file-name`
+ CXXFLAGS := -fno-stack-protector -fPIC
+ LDFLAGS :=
+ LIBS := -lld-acess
endif
-LDFLAGS += -g -nostdlib -shared -eSoMain -x --no-undefined -L$(OUTPUTDIR)Libs/ --defsym __dso_handle=SoMain
+LDFLAGS += -g -shared -eSoStart -L$(OUTPUTDIR)Libs/ --no-undefined
CXXFLAGS += -std=gnu++11
+#CPPFLAGS += -D 'SoMain(...)=SoMain(__VA_ARGS__) __attribute__ ((visibility ("hidden"))); int SoMain(__VA_ARGS__)'
-include $(_libsdir)../common_settings.mk
LDFLAGS := $(LDFLAGS:-lc=-lc_acess)
endif
-_LD_CMD := $(lastword $(subst -, ,$(firstword $(LD))))
-ifneq ($(_LD_CMD),ld)
- LDFLAGS := $(subst -soname ,-Wl$(comma)-soname$(comma),$(LDFLAGS))
- LDFLAGS := $(subst -Map ,-Wl$(comma)-Map$(comma),$(LDFLAGS))
- LDFLAGS := $(LDFLAGS:-x=-Wl,-x)
- LDFLAGS := $(LDFLAGS:--%=-Wl,--%)
-endif
-
_BIN := $(addprefix $(OUTPUTDIR)Libs/,$(BIN))
_XBIN := $(addprefix $(OUTPUTDIR)Libs/,$(EXTRABIN))
_OBJPREFIX := obj-$(ARCH)/
+LDFLAGS += -Map $(_OBJPREFIX)Map.txt
+
+_LD_CMD := $(lastword $(subst -, ,$(firstword $(LD))))
+LDFLAGS := $(subst -soname ,-Wl$(comma)-soname$(comma),$(LDFLAGS))
+LDFLAGS := $(subst -Map ,-Wl$(comma)-Map$(comma),$(LDFLAGS))
+LDFLAGS := $(LDFLAGS:-x=-Wl,-x)
+LDFLAGS := $(LDFLAGS:--%=-Wl,--%)
_LIBS := $(filter -l%,$(LDFLAGS))
_LIBS := $(patsubst -l%,$(OUTPUTDIR)Libs/lib%.so,$(_LIBS))
# for f in $(INCFILES); do ln -s $f $(ACESSDIR)/include/$f; done
#endif
-$(_BIN): $(OBJ)
+LINK_OBJS = $(PRELINK) $(OBJ)
+$(_BIN): $(LINK_OBJS)
@mkdir -p $(dir $(_BIN))
@echo [LD] -o $(BIN) $(OBJ)
- $V$(LD) $(LDFLAGS) -o $(_BIN) $(OBJ) $(shell $(CC) -print-libgcc-file-name)
- $V$(DISASM) -D -S $(_BIN) > $(_OBJPREFIX)$(BIN).dsm
+ifneq ($(USE_CXX_LINK),)
+ $V$(CXX) $(LDFLAGS) -o $(_BIN) $(LINK_OBJS) $(LIBS)
+else
+ $V$(CC) $(LDFLAGS) -o $(_BIN) $(LINK_OBJS) $(LIBS)
+endif
+ $V$(DISASM) -C $(_BIN) > $(_OBJPREFIX)$(BIN).dsm
-$(_OBJPREFIX)%.o: %.c
+$(_OBJPREFIX)%.o: %.c Makefile
@echo [CC] -o $@
@mkdir -p $(dir $@)
-$(_OBJPREFIX)%.o: %.cc
+$(_OBJPREFIX)%.o: %.cc Makefile
@echo [CXX] -o $@
@mkdir -p $(dir $@)
-$(_OBJPREFIX)%.o: %.cpp
+$(_OBJPREFIX)%.o: %.cpp Makefile
@echo [CXX] -o $@
@mkdir -p $(dir $@)
-$(_OBJPREFIX)%.ao: %.$(ASSUFFIX)
+$(_OBJPREFIX)%.ao: %.$(ASSUFFIX) Makefile
@echo [AS] -o $@
@mkdir -p $(dir $@)
$V$(AS) $(ASFLAGS) -o $@ $<
CPPFLAGS += -I $(ACESSDIR)/Externals/Output/$(ARCHDIR)/include
CFLAGS += -std=gnu99 -g
LDFLAGS += -L $(ACESSDIR)/Externals/Output/$(ARCHDIR)/lib
+
+CRTI := $(OUTPUTDIR)Libs/crti.o
+CRTBEGIN := $(shell $(CC) $(CFLAGS) -print-file-name=crtbegin.o)
+CRT0 := $(OUTPUTDIR)Libs/crt0.o
+CRT0S := $(OUTPUTDIR)Libs/crt0S.o
+CRTEND := $(shell $(CC) $(CFLAGS) -print-file-name=crtend.o)
+CRTN := $(OUTPUTDIR)Libs/crtn.o
+LIBGCC_PATH = $(shell $(CC) -print-libgcc-file-name)