mirror of
https://github.com/giantpune/mailboxbomb.git
synced 2024-11-16 17:19:16 +01:00
160 lines
5.9 KiB
Makefile
160 lines
5.9 KiB
Makefile
# makefile used for building a 32bit binary on a x86_64 system
|
|
# using g++-multilib package
|
|
#
|
|
#---------------------------------------------------------------------------------
|
|
.SUFFIXES:
|
|
#---------------------------------------------------------------------------------
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# the prefix on the compiler executables
|
|
#---------------------------------------------------------------------------------
|
|
PREFIX :=
|
|
|
|
export CC := $(PREFIX)gcc
|
|
export CXX := $(PREFIX)g++
|
|
export AS := $(PREFIX)as
|
|
export AR := $(PREFIX)ar
|
|
export OBJCOPY := $(PREFIX)objcopy
|
|
export BIN2S := bin2s
|
|
export STRIP := $(PREFIX)strip
|
|
|
|
#---------------------------------------------------------------------------------
|
|
%.a:
|
|
@echo $(notdir $@)
|
|
@rm -f $@
|
|
@$(AR) -rc $@ $^
|
|
|
|
#---------------------------------------------------------------------------------
|
|
%.o: %.cpp
|
|
@echo $(notdir $<)
|
|
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@
|
|
|
|
#---------------------------------------------------------------------------------
|
|
%.o: %.c
|
|
@echo $(notdir $<)
|
|
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
%.o: %.s
|
|
@echo $(notdir $<)
|
|
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
|
|
|
|
#---------------------------------------------------------------------------------
|
|
%.o: %.S
|
|
@echo $(notdir $<)
|
|
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
|
|
|
|
#---------------------------------------------------------------------------------
|
|
%.bin.o : %.bin
|
|
@echo $(notdir $<)
|
|
@$(BIN2S) -a 32 $< | $(AS) -o $(@) --32
|
|
#---------------------------------------------------------------------------------
|
|
# TARGET is the name of the output
|
|
# BUILD is the directory where object files & intermediate files will be placed
|
|
# SOURCES is a list of directories containing source code
|
|
# INCLUDES is a list of directories containing extra header files
|
|
#---------------------------------------------------------------------------------
|
|
TARGET := Wilbrand.x86
|
|
BUILD := build.32
|
|
SOURCES := source
|
|
DATA := data
|
|
INCLUDES :=
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# options for code generation
|
|
#---------------------------------------------------------------------------------
|
|
|
|
CFLAGS := -Wall -O3 -g -pipe -funroll-loops -m32 -DSEP=\"/\" -DSEPC=\'/\'
|
|
|
|
CFLAGS += $(INCLUDE)
|
|
CXXFLAGS := $(CFLAGS)
|
|
|
|
ASFLAGS := -g
|
|
LDFLAGS = -g -static -static-libgcc -m32
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# any extra libraries we wish to link with the project (order is important)
|
|
#---------------------------------------------------------------------------------
|
|
LIBS :=
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# list of directories containing libraries, this must be the top level containing
|
|
# include and lib
|
|
#---------------------------------------------------------------------------------
|
|
LIBDIRS :=
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# no real need to edit anything past this point unless you need to add additional
|
|
# rules for different file extensions
|
|
#---------------------------------------------------------------------------------
|
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
#---------------------------------------------------------------------------------
|
|
|
|
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
|
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
|
|
|
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
|
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# use CXX for linking C++ projects, CC for standard C
|
|
#---------------------------------------------------------------------------------
|
|
ifeq ($(strip $(CPPFILES)),)
|
|
#---------------------------------------------------------------------------------
|
|
export LD := $(CC)
|
|
#---------------------------------------------------------------------------------
|
|
else
|
|
#---------------------------------------------------------------------------------
|
|
export LD := $(CXX)
|
|
#---------------------------------------------------------------------------------
|
|
endif
|
|
#---------------------------------------------------------------------------------
|
|
|
|
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
|
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
|
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
-I$(CURDIR)/$(BUILD)
|
|
|
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
|
|
.PHONY: $(BUILD) clean
|
|
|
|
#---------------------------------------------------------------------------------
|
|
$(BUILD):
|
|
@[ -d $@ ] || mkdir -p $@
|
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.x86
|
|
|
|
#---------------------------------------------------------------------------------
|
|
clean:
|
|
@echo clean ...
|
|
@rm -fr $(BUILD) $(TARGET) $(TARGET).debug
|
|
|
|
#---------------------------------------------------------------------------------
|
|
else
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# main targets
|
|
#---------------------------------------------------------------------------------
|
|
$(OUTPUT) : $(OFILES)
|
|
@echo linking $(notdir $@).debug
|
|
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@.debug
|
|
@echo strip $(notdir $@).debug "->" $(notdir $@)
|
|
@$(STRIP) -s $@.debug -o $@
|
|
|
|
|
|
-include $(DEPSDIR)/*.d
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
endif
|
|
#---------------------------------------------------------------------------------------
|