Changed Makefile to allow cross-architecture compilation.
This commit is contained in:
parent
a5bb1744f4
commit
a4dcbe504e
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
# Ignore binaries
|
# Ignore binaries
|
||||||
bin/
|
bin/
|
||||||
*.o
|
|
||||||
|
27
Makefile
27
Makefile
@ -1,25 +1,24 @@
|
|||||||
CXX=gcc
|
CXX=gcc
|
||||||
CXXFLAGS= -O3 -Wall -std=gnu99
|
CXXFLAGS= -O3 -Wall -std=gnu99
|
||||||
|
|
||||||
INCLUDES=
|
|
||||||
LIBS=
|
|
||||||
|
|
||||||
MV=mv
|
|
||||||
MKDIR=mkdir -p
|
MKDIR=mkdir -p
|
||||||
RM=rm -rf
|
RM=rm -rf
|
||||||
|
|
||||||
SRC_FILES := $(wildcard src/*.c)
|
LBITS := $(shell getconf LONG_BIT)
|
||||||
OBJ_FILES := $(addprefix obj/, $(notdir $(SRC_FILES:.c=.o)))
|
|
||||||
|
|
||||||
all: $(OBJ_FILES)
|
ifeq ($(LBITS),32)
|
||||||
$(MKDIR) bin
|
all: compile32bit
|
||||||
$(CXX) $(CXXFLAGS) $(LIBS) -o bin/cointoss obj/*.o
|
else
|
||||||
|
all: compile64bit
|
||||||
|
endif
|
||||||
|
|
||||||
obj/%.o: src/%.c
|
compile32bit:
|
||||||
$(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $<
|
$(MKDIR) bin/lin32/
|
||||||
|
$(CXX) $(CXXFLAGS) -m32 -o bin/lin32/cointoss src/main.c
|
||||||
|
|
||||||
|
compile64bit:
|
||||||
|
$(MKDIR) bin/lin64/
|
||||||
|
$(CXX) $(CXXFLAGS) -m64 -o bin/lin64/cointoss src/main.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) obj/*.o
|
|
||||||
|
|
||||||
cleanall: clean
|
|
||||||
$(RM) bin
|
$(RM) bin
|
||||||
|
@ -1 +0,0 @@
|
|||||||
This is where the object output files go. This readme file is a simple hack so that git registers it (git doesn't register empty directories).
|
|
Loading…
Reference in New Issue
Block a user