1 ######################################################
4 # Desc: Makefile for the Loader library files.
5 # This loader is lightly adapted from the loader in UQBT
6 # Purpose is to load the input binary file into memory, with calls to iterate through sections,
7 # find entry points, symbols, etc.
8 # The main library is BinaryFile, which calls eactly one of ElfBinaryFile etc as needed.
10 # Prerequisite libraries: none
12 ######################################################
15 # Note: gnu make is probably required (for patsubst etc)
16 # This whole makefile is dependent on finding the pattern *BinaryFile.cpp; a lib%.so file is made for each of these
17 # You should be able to add a simple loader without any changes to this Makefile, as long as you follow the naming
18 # convention <type>BinaryFile.*
20 # 24 Nov 08 - Markus Gothe - Automake
21 # 22 Aug 06 - Mike Frysinger: respect values set up by ./configure script
22 # 12 Jul 05 - Mike: All use SymTab.o now
23 # 20 Jul 04 - Mike: Removed BOOMDIR (paths relative now)
24 # 12 Apr 05 - Gerard: Structured
25 # 11 Apr 02 - Mike: Use lib%.so names and -l now; no "make install" any more
27 AUTOMAKE_OPTIONS = foreign
36 ####################################
37 # Detection of OS specific settings
43 WININCLUDE=-Iwin32make/include
44 # RUNPATH is not needed on Windows
46 COPYDLL=$(top_srcdir)/libBinaryFile.$(OBJEXT)
51 # RUNPATH=-Wl,-rpath -Wl,"lib"
55 ######################
65 DOS4GWBinaryFile.cpp \
74 # Until we can resolve the issue of compiling loader/MachOBinaryFile.cpp, don't attempt to make it so at least
75 # the Cygwin hosted Boomerang can compile and use non-MachO loaders
76 LOADERS+=MachOBinaryFile.cpp
78 LOADERDLLS=$(patsubst %,$(top_srcdir)/lib/lib%$(OBJEXT),$(LOADERS))
79 BASEDLL=$(top_srcdir)/lib/libBinaryFile$(OBJEXT)
80 ALLDLLS=$(LOADERDLLS) $(BASEDLL)
81 ALLLIBS=$(patsubst %,-l%,$(LOADERS)) -lBinaryFile
82 ALLOBJS = $(patsubst %, %.o, $(LOADERS))
83 ALLOBJS += BinaryFile.o SymTab.o
85 all: $(ALLDLLS) $(COPYDLL) BinaryFileFactory.$(OBJEXT) BinaryFileStub.$(OBJEXT)
87 microX86dis.$(OBJEXT): microX86dis.c
88 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(FPIC) $<
90 # Extra object files, etc
91 # These are target specific variables.
92 $(top_srcdir)/lib/libWin32BinaryFile.$(OBJEXT): EXTRAS = microX86dis.$(OBJEXT)
93 $(top_srcdir)/lib/libWin32BinaryFile.$(OBJEXT): microX86dis.$(OBJEXT)
94 $(top_srcdir)/lib/libDOS4GWBinaryFile.$(OBJEXT): EXTRAS = microX86dis.$(OBJEXT)
95 $(top_srcdir)/lib/libDOS4GWBinaryFile.$(OBJEXT): microX86dis.$(OBJEXT)
97 $(top_srcdir)/libBinaryFile.$(OBJEXT): $(top_srcdir)/lib/libBinaryFile.$(OBJEXT)
100 BinaryFile.o: CCEXTRAS = -DBUILDING_LIBBINARYFILE
101 MachOBinaryFile.o: CCEXTRAS = -I.
103 $(BASEDLL) : BinaryFile.$(OBJEXT) SymTab.$(OBJEXT)
104 $(CXX) $(CXXFLAGS) -o $@ $(SHARED) BinaryFile.$(OBJEXT) SymTab.$(OBJEXT) $(OUTIMPLIB) $(LDFLAGS)
106 # This pattern generates all the main dependencies
107 $(LOADERDLLS): $(top_srcdir)/lib/lib%.$(OBJEXT) : %.$(OBJEXT) $(BASEDLL)
108 $(CXX) $(CXXFLAGS) -o $@ $(SHARED) $< SymTab.o $(EXTRAS) -lBinaryFile $(RUNPATH) -L$(top_srcdir)/lib $(LDFLAGS)
110 # Compile all objects with -fPIC
111 $(ALLOBJS): %.$(OBJEXT) : %.cpp
112 $(CXX) $(CXXFLAGS) -c $(FPIC) $(CCEXTRAS) -I$(top_srcdir)/include -o $@ $<
118 # Automatic generation of dependencies
120 # automatic is better!
121 depend: $(MAKEDEPEND)
122 $(MAKEDEPEND) -w120 -Y -I$(top_srcdir)/include -I. -I$(top_srcdir)/c -I$(top_srcdir)/codegen \
123 -I$(top_srcdir)/frontend *.cpp *.c > /dev/null 2>&1
125 depend.in: $(MAKEDEPEND)
126 $(MAKEDEPEND) -fMakefile.in -w120 -Y -I$(top_srcdir)/include -I. -I$(top_srcdir)/c -I$(top_srcdir)/codegen \
127 -I$(top_srcdir)/frontend *.cpp *.c > /dev/null 2>&1
130 @echo You need the (X11) makedepend tool to generate dependencies
132 @echo You need the (X11) makedepend tool to generate dependencies
139 testLoader$(EXEEXT): testLoader.$(OBJEXT) LoaderTest.$(OBJEXT) microX86dis.$(OBJEXT) BinaryFileFactory.$(OBJEXT) SymTab.$(OBJEXT)
140 $(CXX) $(CXXFLAGS) -o $@ $^ -lcppunit $(ALLLIBS) $(RUNPATH) $(LDL) -L$(top_srcdir)/lib $(LDFLAGS)
142 testLoader.$(OBJEXT): testLoader.cpp
143 $(CXX) $(CXXFLAGS) -c -o $@ -I$(top_srcdir)/include $<
145 LoaderTest.$(OBJEXT): LoaderTest.cpp LoaderTest.h $(top_srcdir)/include/BinaryFile.h SymTab.$(OBJEXT)
146 $(CXX) $(CXXFLAGS) -c -o $@ -I$(top_srcdir)/include $<
148 # Because of the relative paths, testLoader will only work from the parent
150 test: all testLoader$(EXEEXT)
151 cd $(top_srcdir) && loader/testLoader$(EXEEXT)