##
# makefile32
#
# AUTHORS: Robert Fahy <rfahy@ymail.com>
# CREDITS: the internet
# VERSION: 1.01
#
##

##
# TASK:
# - automation, always builds 32-bit executable
#
##

##
# TODO:
# - n/a
#
##

##
# NOTE:
# - the "-D_FILE_OFFSET_BITS=64" option will cause GCC to #define a symbolic constant
#  named "_FILE_OFFSET_BITS" and expanding to "64" in a way visible to all files.
#  this constant has the role to force the file offset type `off_t' to be of
#  8 bytes (64 bits) size. it only matters for 32-bit programs, as 64-bit programs
#  use the large version by default. practically, it will allow a 32-bit program
#  to work with large files of over 4 GB, where the 32-bit limit is at.
#
##

CC=gcc -m32
CFLAGS=-Wall -Wpointer-arith -Wstrict-prototypes -O2 -D_FILE_OFFSET_BITS=64
PRGNAME=xorcorrupt2.elf32
COMPILE=$(CC) $(CFLAGS) -c
OBJFILES:=$(patsubst %.c,%.o, $(wildcard *.c))

the_program: compile copy

compile: $(OBJFILES)
	$(CC) -o $(PRGNAME) $(OBJFILES)

%.o: %.c
	$(COMPILE) -o $@ $<

copy:
	cp -v $(PRGNAME) ../build/

clean:
	rm -v *~ *.elf32 *.o
