[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Multiple Builds From Same Source
From: |
cramerj |
Subject: |
Multiple Builds From Same Source |
Date: |
Tue, 21 May 2013 01:36:26 +0000 |
Hello,
I am trying to build a 32-bit and 64-bit library using the same source with
just one invocation of Make. Unfortunately, I can't seem to figure out how to
tell Make to delete the intermediate files before trying to build the second
library. The object files persist in Make's database so that it performs the
archive of the second target using the first target's object files. Only after
that is done, Make will then delete the object files (as expected). Also, if
you have any "facepalm" moments with this example, feel free to let me know. :)
...
$ cat Makefile
CPPFLAGS += -O3
NATIVE_ARCH := $(shell uname -m)
ifeq "$(NATIVE_ARCH)" "x86_64"
COMPAT_FLAG := -m32
TARGETS := i386 x86_64
else
TARGETS := i386
endif
SOURCES := a.cpp b.cpp c.cpp
MEMBERS := $(SOURCES:.cpp=.o)
ARFLAGS := rcs
all: $(TARGETS)
i386: CXXFLAGS += $(COMPAT_FLAG)
i386: path/to/32b/library.a($(MEMBERS))
x86_64: path/to/64b/library.a($(MEMBERS))
$ make
g++ -m32 -O3 -c -o a.o a.cpp
ar rcs path/to/32b/library.a a.o
g++ -m32 -O3 -c -o b.o b.cpp
ar rcs path/to/32b/library.a b.o
g++ -m32 -O3 -c -o c.o c.cpp
ar rcs path/to/32b/library.a c.o
ar rcs path/to/64b/library.a a.o
ar rcs path/to/64b/library.a b.o
ar rcs path/to/64b/library.a c.o
rm a.o b.o c.o
...
I tried adding i386 and x86_64 to the .PHONY target just as a stab in the dark,
but no luck.
Thanks,
-Jeb
- Multiple Builds From Same Source,
cramerj <=