mirror of
https://github.com/giantpune/mailboxbomb.git
synced 2024-11-04 20:05:04 +01:00
160 lines
6.1 KiB
Makefile
160 lines
6.1 KiB
Makefile
# makefile used for building a windows binary on a linux system
|
|
# using ubuntu mingw package
|
|
#
|
|
#---------------------------------------------------------------------------------
|
|
.SUFFIXES:
|
|
#---------------------------------------------------------------------------------
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# the prefix on the compiler executables
|
|
#---------------------------------------------------------------------------------
|
|
PREFIX := /usr/bin/i586-mingw32msvc-
|
|
|
|
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 $< | sed 's/$(shell echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)/_$(shell echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)/' | $(AS) -o $(@)
|
|
#---------------------------------------------------------------------------------
|
|
# 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.exe
|
|
BUILD := build_win32
|
|
SOURCES := source
|
|
DATA := data
|
|
INCLUDES :=
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# options for code generation
|
|
#---------------------------------------------------------------------------------
|
|
|
|
CFLAGS := -Wall -O3 -g -pipe -funroll-loops -DSEP=\"\\\\\" -DSEPC=\'\\\\\'
|
|
|
|
CFLAGS += $(INCLUDE)
|
|
CXXFLAGS := $(CFLAGS)
|
|
|
|
ASFLAGS := -g
|
|
LDFLAGS = -g -static -static-libgcc
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# any extra libraries we wish to link with the project (order is important)
|
|
#---------------------------------------------------------------------------------
|
|
LIBS := -lwsock32
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# list of directories containing libraries, this must be the top level containing
|
|
# include and lib
|
|
#---------------------------------------------------------------------------------
|
|
LIBDIRS := /usr/i586-mingw32msvc
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# 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 := $(CXX)
|
|
#---------------------------------------------------------------------------------
|
|
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.win
|
|
|
|
#---------------------------------------------------------------------------------
|
|
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
|
|
#---------------------------------------------------------------------------------------
|